File: continuous-integration.sh

package info (click to toggle)
libphonenumber 6.3~svn698-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 26,268 kB
  • ctags: 5,408
  • sloc: cpp: 43,555; xml: 33,687; java: 14,839; ansic: 447; sh: 44; jsp: 39; makefile: 36
file content (96 lines) | stat: -rwxr-xr-x 2,984 bytes parent folder | download | duplicates (20)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
#! /bin/sh

# Copyright (C) 2011 The Libphonenumber Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# Author: Philippe Liard

# Countinuous integration script that tests the different versions and
# configurations of libphonenumber.

# Check geocoding resource files encoding.
(find resources/geocoding -type f | xargs file | egrep -v 'UTF-8|ASCII') && exit 1

# Test the C++ version with the provided CMake parameter.
CXX=g++
INSTALL_PREFIX=/tmp/libphonenumber

test_cpp_version() {
  CC_TEST_FILE=`mktemp`.cc
  CC_TEST_BINARY=`mktemp`
  CMAKE_FLAGS="$1"
  LD_FLAGS="-L${INSTALL_PREFIX}/lib -lphonenumber -lboost_thread $2"

  # Write the program that tests the installation of the library to a temporary
  # source file.
  > $CC_TEST_FILE echo '
    #include <cassert>

    #include <base/memory/scoped_ptr.h>

    // Include all the public headers.
    #include <phonenumbers/asyoutypeformatter.h>
    #include <phonenumbers/phonenumber.pb.h>
    #include <phonenumbers/phonenumbermatch.h>
    #include <phonenumbers/phonenumbermatcher.h>
    #include <phonenumbers/phonenumberutil.h>

    using i18n::phonenumbers::AsYouTypeFormatter;
    using i18n::phonenumbers::PhoneNumberUtil;

    int main() {
      PhoneNumberUtil* const phone_util = PhoneNumberUtil::GetInstance();
      const scoped_ptr<AsYouTypeFormatter> asytf(
          phone_util->GetAsYouTypeFormatter("US"));

      assert(phone_util != NULL);
      assert(asytf != NULL);
    }'

  # Run the build and tests.
  (
    set +e
    rm -rf cpp/build /tmp/libphonenumber
    mkdir cpp/build /tmp/libphonenumber
    cd cpp/build
    cmake "${CMAKE_FLAGS}" -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX ..
    make test
    make install
    $CXX -o $CC_TEST_BINARY $CC_TEST_FILE -I${INSTALL_PREFIX}/include $LD_FLAGS
    LD_LIBRARY_PATH="${INSTALL_PREFIX}/lib" $CC_TEST_BINARY
  )
  STATUS=$?
  # Remove the temporary files.
  rm -f $CC_TEST_FILE
  rm -f $CC_TEST_BINARY

  [ $STATUS -ne 0 ] && exit $STATUS
}

BASE_LIBS='-licuuc -lprotobuf'

test_cpp_version '' "$BASE_LIBS"
test_cpp_version '-DUSE_ICU_REGEXP=ON' "$BASE_LIBS"
test_cpp_version '-DUSE_LITE_METADATA=ON' '-licuuc -lprotobuf-lite'
test_cpp_version '-DUSE_RE2=ON' "$BASE_LIBS -lre2"
test_cpp_version '-DUSE_STD_MAP=ON' "$BASE_LIBS"

# Test Java version using Ant.
(cd java && ant clean jar && ant junit) || exit $?

# Test Java version using Maven.
(cd java && mvn clean package) || exit $?

# Test build tools.
(cd tools/java && mvn clean package) || exit $?