blob: 6b2d04c866c7ffec5e5574a12a2244311dcb3d39 [file] [log] [blame]
Philippe Liardbee8be52011-07-06 12:15:51 +00001#! /bin/sh
2
Philippe Liardb59d9082011-08-18 11:41:24 +00003# Copyright (C) 2011 The Libphonenumber Authors
Philippe Liardbee8be52011-07-06 12:15:51 +00004#
5# Licensed under the Apache License, Version 2.0 (the "License");
6# you may not use this file except in compliance with the License.
7# You may obtain a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS,
13# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14# See the License for the specific language governing permissions and
15# limitations under the License.
16
17# Author: Philippe Liard
18
19# Countinuous integration script that tests the different versions and
20# configurations of libphonenumber.
21
Philippe Liardb8acd0d2011-08-16 13:13:07 +000022# Check geocoding resource files encoding.
23(find resources/geocoding -type f | xargs file | egrep -v 'UTF-8|ASCII') && exit 1
24
Philippe Liardbee8be52011-07-06 12:15:51 +000025# Test the C++ version with the provided CMake parameter.
Philippe Liard33a02e42011-08-17 10:14:24 +000026CXX=g++
27INSTALL_PREFIX=/tmp/libphonenumber
28
Philippe Liardbee8be52011-07-06 12:15:51 +000029test_cpp_version() {
Philippe Liard33a02e42011-08-17 10:14:24 +000030 CC_TEST_FILE=`mktemp`.cc
31 CC_TEST_BINARY=`mktemp`
Philippe Liardbee8be52011-07-06 12:15:51 +000032 CMAKE_FLAGS="$1"
Philippe Liard33a02e42011-08-17 10:14:24 +000033 # Write the program that tests the installation of the library to a temporary
34 # source file.
35 > $CC_TEST_FILE echo '
Philippe Liard4bffe682011-09-14 10:42:59 +000036 #include <base/memory/scoped_ptr.h>
37 #include <phonenumbers/asyoutypeformatter.h>
Philippe Liard33a02e42011-08-17 10:14:24 +000038 #include <phonenumbers/phonenumberutil.h>
Philippe Liard4bffe682011-09-14 10:42:59 +000039
40 using i18n::phonenumbers::AsYouTypeFormatter;
Philippe Liard33a02e42011-08-17 10:14:24 +000041 using i18n::phonenumbers::PhoneNumberUtil;
Philippe Liard4bffe682011-09-14 10:42:59 +000042
Philippe Liard33a02e42011-08-17 10:14:24 +000043 int main() {
44 PhoneNumberUtil* const phone_util = PhoneNumberUtil::GetInstance();
Philippe Liard4bffe682011-09-14 10:42:59 +000045 const scoped_ptr<AsYouTypeFormatter> asytf(
46 phone_util->GetAsYouTypeFormatter("US"));
47 return !(phone_util != NULL && asytf != NULL);
Philippe Liard33a02e42011-08-17 10:14:24 +000048 }'
49 # Run the build and tests.
Philippe Liardbee8be52011-07-06 12:15:51 +000050 (
Philippe Liard33a02e42011-08-17 10:14:24 +000051 rm -rf cpp/build /tmp/libphonenumber &&
52 mkdir cpp/build /tmp/libphonenumber && cd cpp/build &&
53 cmake "${CMAKE_FLAGS}" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX .. &&
54 make && ./libphonenumber_test && make install &&
55 $CXX -o $CC_TEST_BINARY $CC_TEST_FILE -I${INSTALL_PREFIX}/include \
56 -lboost_thread -L${INSTALL_PREFIX}/lib -lphonenumber &&
Philippe Liarde0c92bd2011-08-17 11:25:50 +000057 LD_LIBRARY_PATH=${INSTALL_PREFIX}/lib $CC_TEST_BINARY
Philippe Liard33a02e42011-08-17 10:14:24 +000058 )
59 STATUS=$?
60 # Remove the temporary files.
61 rm -f $CC_TEST_FILE
62 rm -f $CC_TEST_BINARY
63
64 [ $STATUS -ne 0 ] && exit $STATUS
Philippe Liardbee8be52011-07-06 12:15:51 +000065}
66test_cpp_version ''
67test_cpp_version '-DUSE_RE2=ON'
68test_cpp_version '-DUSE_LITE_METADATA=ON'
69test_cpp_version '-DUSE_STD_MAP=ON'
70
71# Test Java version using Ant.
72(cd java && ant clean jar && ant junit) || exit $?
73
74# Test Java version using Maven.
75(cd java && mvn clean package) || exit $?
76
77# Test build tools.
78(cd tools/java && mvn clean package) || exit $?