blob: 9e04bd66e79f9cd0efd0a7e4c200065962b5b637 [file] [log] [blame]
Josh Haberman738393b2016-02-18 20:10:23 -08001#!/bin/bash
Josh Haberman67c727c2016-03-04 14:21:18 -08002#
3# Build and runs tests for the protobuf project. The tests as written here are
4# used by both Jenkins and Travis, though some specialized logic is required to
5# handle the differences between them.
Thomas Van Lentenc4d36382015-06-09 13:35:41 -04006
Josh Haberman0f8c25d2016-02-19 09:11:38 -08007on_travis() {
8 if [ "$TRAVIS" == "true" ]; then
9 "$@"
10 fi
11}
12
Josh Haberman181c7f22015-07-15 11:05:10 -070013# For when some other test needs the C++ main build, including protoc and
14# libprotobuf.
15internal_build_cpp() {
Josh Haberman738393b2016-02-18 20:10:23 -080016 if [ -f src/protoc ]; then
17 # Already built.
18 return
19 fi
20
Josh Habermand33e93b2016-02-18 19:13:07 -080021 if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then
Feng Xiao91258632015-12-21 03:34:28 -080022 # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more
23 # decent C++ 11 support in order to compile conformance tests.
24 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
25 sudo apt-get update -qq
26 sudo apt-get install -qq g++-4.8
27 export CXX="g++-4.8" CC="gcc-4.8"
28 fi
Feng Xiao1e2fece2015-12-18 15:16:07 -080029
Chris Fallin20e94b22015-05-13 16:43:48 -070030 ./autogen.sh
Paul Yangdaba6652016-10-07 16:09:26 -070031 ./configure CXXFLAGS="-fPIC" # -fPIC is needed for python cpp test.
32 # See python/setup.py for more details
Josh Haberman67c727c2016-03-04 14:21:18 -080033 make -j2
Josh Haberman181c7f22015-07-15 11:05:10 -070034}
35
36build_cpp() {
37 internal_build_cpp
Josh Haberman67c727c2016-03-04 14:21:18 -080038 make check -j2
Bo Yangfd332d12016-09-30 00:07:47 +000039 cd conformance && make test_cpp && cd ..
Josh Habermancb36bde2016-04-29 09:52:20 -070040
Thomas Van Lentenbc9d0772016-12-08 16:19:58 -050041 # The benchmark code depends on cmake, so test if it is installed before
42 # trying to do the build.
43 # NOTE: The travis macOS images say they have cmake, but the xcode8.1 image
44 # appears to be missing it: https://github.com/travis-ci/travis-ci/issues/6996
45 if [[ $(type cmake 2>/dev/null) ]]; then
46 # Verify benchmarking code can build successfully.
47 git submodule init
48 git submodule update
49 cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make && cd ../..
50 cd benchmarks && make && ./generate-datasets && cd ..
51 else
52 echo ""
53 echo "WARNING: Skipping validation of the bench marking code, cmake isn't installed."
54 echo ""
55 fi
Chris Fallin20e94b22015-05-13 16:43:48 -070056}
57
58build_cpp_distcheck() {
59 ./autogen.sh
60 ./configure
Feng Xiaoa4f68b12016-07-19 17:20:31 -070061 make dist
62
63 # List all files that should be included in the distribution package.
Feng Xiao599613e2016-11-18 15:36:28 -080064 git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\)" |\
Jie Luoea511492017-01-23 15:11:00 -080065 grep -v ".gitignore" | grep -v "java/compatibility_tests" |\
66 grep -v "python/compatibility_tests" > dist.lst
Feng Xiaoa4f68b12016-07-19 17:20:31 -070067 # Unzip the dist tar file.
68 DIST=`ls *.tar.gz`
69 tar -xf $DIST
70 cd ${DIST//.tar.gz}
71 # Check if every file exists in the dist tar file.
72 FILES_MISSING=""
73 for FILE in $(<../dist.lst); do
74 if ! file $FILE &>/dev/null; then
75 echo "$FILE is not found!"
76 FILES_MISSING="$FILE $FILES_MISSING"
77 fi
78 done
79 cd ..
80 if [ ! -z "$FILES_MISSING" ]; then
81 echo "Missing files in EXTRA_DIST: $FILES_MISSING"
82 exit 1
83 fi
84
85 # Do the regular dist-check for C++.
Josh Haberman67c727c2016-03-04 14:21:18 -080086 make distcheck -j2
Chris Fallin20e94b22015-05-13 16:43:48 -070087}
88
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070089build_csharp() {
Jon Skeetb6defa72015-08-04 10:01:40 +010090 # Just for the conformance tests. We don't currently
91 # need to really build protoc, but it's simplest to keep with the
92 # conventions of the other builds.
93 internal_build_cpp
Josh Habermanffc81182016-02-22 15:39:29 -080094 NUGET=/usr/local/bin/nuget.exe
Jon Skeetb6defa72015-08-04 10:01:40 +010095
Josh Habermanffc81182016-02-22 15:39:29 -080096 if [ "$TRAVIS" == "true" ]; then
97 # Install latest version of Mono
98 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Jon Skeet10a8fb42016-07-14 22:01:47 +010099 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
Josh Habermanffc81182016-02-22 15:39:29 -0800100 echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
Josh Habermanffc81182016-02-22 15:39:29 -0800101 sudo apt-get update -qq
102 sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
Paul Yang46ae90d2016-12-08 11:16:49 -0800103
Jon Skeet10a8fb42016-07-14 22:01:47 +0100104 # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net.
Jon Skeetdeaea212016-07-19 17:57:46 -0700105 sudo sh -c 'echo "deb [arch=amd64] https://apt-mo.trafficmanager.net/repos/dotnet-release/ trusty main" > /etc/apt/sources.list.d/dotnetdev.list'
Jon Skeet10a8fb42016-07-14 22:01:47 +0100106 sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
107 sudo apt-get update -qq
108 sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121
Josh Habermanffc81182016-02-22 15:39:29 -0800109 fi
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700110
Jon Skeet10a8fb42016-07-14 22:01:47 +0100111 # Perform "dotnet new" once to get the setup preprocessing out of the
112 # way. That spews a lot of output (including backspaces) into logs
113 # otherwise, and can cause problems. It doesn't matter if this step
114 # is performed multiple times; it's cheap after the first time anyway.
115 mkdir dotnettmp
116 (cd dotnettmp; dotnet new > /dev/null)
117 rm -rf dotnettmp
118
119 (cd csharp/src; dotnet restore)
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700120 csharp/buildall.sh
Josh Habermane891c292015-12-30 16:03:49 -0800121 cd conformance && make test_csharp && cd ..
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700122}
123
Tim Swast7e31c4d2015-11-20 15:32:53 -0800124build_golang() {
125 # Go build needs `protoc`.
126 internal_build_cpp
127 # Add protoc to the path so that the examples build finds it.
128 export PATH="`pwd`/src:$PATH"
129
130 # Install Go and the Go protobuf compiler plugin.
Feng Xiao20fbb352016-07-21 18:04:56 -0700131 on_travis sudo apt-get update -qq
132 on_travis sudo apt-get install -qq golang
133
Tim Swast7e31c4d2015-11-20 15:32:53 -0800134 export GOPATH="$HOME/gocode"
135 mkdir -p "$GOPATH/src/github.com/google"
Feng Xiao20fbb352016-07-21 18:04:56 -0700136 rm -f "$GOPATH/src/github.com/google/protobuf"
Tim Swast7e31c4d2015-11-20 15:32:53 -0800137 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf"
138 export PATH="$GOPATH/bin:$PATH"
139 go get github.com/golang/protobuf/protoc-gen-go
140
141 cd examples && make gotest && cd ..
142}
143
Chris Fallin20e94b22015-05-13 16:43:48 -0700144use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -0700145 version=$1
146 case "$version" in
Chris Fallin20e94b22015-05-13 16:43:48 -0700147 jdk7)
Josh Haberman0f8c25d2016-02-19 09:11:38 -0800148 on_travis sudo apt-get install openjdk-7-jdk
Chris Fallin20e94b22015-05-13 16:43:48 -0700149 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700150 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700151 ;;
152 oracle7)
Josh Habermanffc81182016-02-22 15:39:29 -0800153 if [ "$TRAVIS" == "true" ]; then
154 sudo apt-get install python-software-properties # for apt-add-repository
155 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
156 sudo debconf-set-selections
157 yes | sudo apt-add-repository ppa:webupd8team/java
158 yes | sudo apt-get install oracle-java7-installer
159 fi;
Chris Fallin20e94b22015-05-13 16:43:48 -0700160 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700161 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700162 ;;
163 esac
164
Josh Haberman1ee0fda2016-03-03 16:02:55 -0800165 if [ "$TRAVIS" != "true" ]; then
166 MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
167 MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
168 fi;
169
Chris Fallin20e94b22015-05-13 16:43:48 -0700170 which java
171 java -version
Feng Xiaoad49ed72016-07-21 11:37:46 -0700172 $MVN -version
Chris Fallin20e94b22015-05-13 16:43:48 -0700173}
174
Josh Habermand08c39c2016-02-20 12:03:39 -0800175# --batch-mode supresses download progress output that spams the logs.
Josh Habermanb28b3f62016-02-20 12:17:10 -0800176MVN="mvn --batch-mode"
Josh Habermand08c39c2016-02-20 12:03:39 -0800177
Chris Fallin20e94b22015-05-13 16:43:48 -0700178build_java() {
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800179 version=$1
180 dir=java_$version
Chris Fallin20e94b22015-05-13 16:43:48 -0700181 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700182 internal_build_cpp
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800183 cp -r java $dir
184 cd $dir && $MVN clean && $MVN test
Feng Xiao9e5fb552015-12-21 11:08:18 -0800185 cd ../..
186}
187
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800188# The conformance tests are hard-coded to work with the $ROOT/java directory.
189# So this can't run in parallel with two different sets of tests.
Feng Xiao9e5fb552015-12-21 11:08:18 -0800190build_java_with_conformance_tests() {
191 # Java build needs `protoc`.
192 internal_build_cpp
Josh Habermand08c39c2016-02-20 12:03:39 -0800193 cd java && $MVN test && $MVN install
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800194 cd util && $MVN package assembly:single
Feng Xiaoaf81dcf2015-12-21 03:25:59 -0800195 cd ../..
Chris Fallin20e94b22015-05-13 16:43:48 -0700196 cd conformance && make test_java && cd ..
197}
198
199build_javanano() {
200 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700201 internal_build_cpp
Josh Habermanb28b3f62016-02-20 12:17:10 -0800202 cd javanano && $MVN test && cd ..
Chris Fallin20e94b22015-05-13 16:43:48 -0700203}
204
Chris Fallin20e94b22015-05-13 16:43:48 -0700205build_java_jdk7() {
206 use_java jdk7
Feng Xiao9e5fb552015-12-21 11:08:18 -0800207 build_java_with_conformance_tests
Chris Fallin20e94b22015-05-13 16:43:48 -0700208}
209build_java_oracle7() {
210 use_java oracle7
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800211 build_java oracle7
Chris Fallin20e94b22015-05-13 16:43:48 -0700212}
Feng Xiaobaa40232016-07-29 14:11:21 -0700213build_java_compatibility() {
214 use_java jdk7
215 internal_build_cpp
216 # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
217 # 3.0.0-beta-4 and the current version.
218 cd java/compatibility_tests/v2.5.0
219 ./test.sh 3.0.0-beta-4
220}
Chris Fallin20e94b22015-05-13 16:43:48 -0700221
Chris Fallin20e94b22015-05-13 16:43:48 -0700222build_javanano_jdk7() {
223 use_java jdk7
224 build_javanano
225}
226build_javanano_oracle7() {
227 use_java oracle7
228 build_javanano
229}
230
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400231internal_install_python_deps() {
Josh Haberman483533d2016-02-19 12:48:33 -0800232 if [ "$TRAVIS" != "true" ]; then
233 return;
234 fi
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400235 # Install tox (OS X doesn't have pip).
236 if [ $(uname -s) == "Darwin" ]; then
237 sudo easy_install tox
238 else
239 sudo pip install tox
240 fi
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400241 # Only install Python2.6/3.x on Linux.
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400242 if [ $(uname -s) == "Linux" ]; then
243 sudo apt-get install -y python-software-properties # for apt-add-repository
244 sudo apt-add-repository -y ppa:fkrull/deadsnakes
245 sudo apt-get update -qq
246 sudo apt-get install -y python2.6 python2.6-dev
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400247 sudo apt-get install -y python3.3 python3.3-dev
248 sudo apt-get install -y python3.4 python3.4-dev
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400249 fi
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400250}
251
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400252build_objectivec_ios() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400253 # Reused the build script that takes care of configuring and ensuring things
254 # are up to date. The OS X test runs the objc conformance test, so skip it
255 # here.
256 # Note: travis has xctool installed, and we've looked at using it in the past
257 # but it has ended up proving unreliable (bugs), an they are removing build
258 # support in favor of xcbuild (or just xcodebuild).
259 objectivec/DevTools/full_mac_build.sh \
260 --core-only --skip-xcode-osx --skip-objc-conformance "$@"
261}
262
263build_objectivec_ios_debug() {
264 build_objectivec_ios --skip-xcode-release
265}
266
267build_objectivec_ios_release() {
268 build_objectivec_ios --skip-xcode-debug
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400269}
270
271build_objectivec_osx() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400272 # Reused the build script that takes care of configuring and ensuring things
273 # are up to date.
274 objectivec/DevTools/full_mac_build.sh \
275 --core-only --skip-xcode-ios
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400276}
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400277
Sergio Campamáf0c14922016-06-14 11:26:01 -0700278build_objectivec_cocoapods_integration() {
Sergio Campamáf0c14922016-06-14 11:26:01 -0700279 # Update pod to the latest version.
280 gem install cocoapods --no-ri --no-rdoc
281 objectivec/Tests/CocoaPods/run_tests.sh
282}
283
Chris Fallin20e94b22015-05-13 16:43:48 -0700284build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700285 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400286 internal_install_python_deps
Chris Fallin20e94b22015-05-13 16:43:48 -0700287 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400288 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400289 if [ $(uname -s) == "Linux" ]; then
Jie Luo2850a982015-10-09 17:07:03 -0700290 envlist=py\{26,27,33,34\}-python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400291 else
292 envlist=py27-python
293 fi
294 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700295 cd ..
296}
297
298build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700299 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400300 internal_install_python_deps
Bo Yangfd332d12016-09-30 00:07:47 +0000301 export LD_LIBRARY_PATH=../src/.libs # for Linux
302 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700303 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400304 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400305 if [ $(uname -s) == "Linux" ]; then
Jisi Liu72bd9c92015-10-06 10:48:57 -0700306 # py26 is currently disabled due to json_format
307 envlist=py\{27,33,34\}-cpp
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400308 else
309 envlist=py27-cpp
310 fi
311 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700312 cd ..
313}
314
Jie Luoea511492017-01-23 15:11:00 -0800315build_python_compatibility() {
316 internal_build_cpp
317 # Use the unit-tests extraced from 2.5.0 to test the compatibilty.
318 cd python/compatibility_tests/v2.5.0
319 # Test between 2.5.0 and the current version.
320 ./test.sh 2.5.0
321 # Test between 3.0.0-beta-1 and the current version.
322 ./test.sh 3.0.0-beta-1
323}
324
Chris Fallin20e94b22015-05-13 16:43:48 -0700325build_ruby21() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700326 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700327 cd ruby && bash travis-test.sh ruby-2.1 && cd ..
328}
329build_ruby22() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700330 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700331 cd ruby && bash travis-test.sh ruby-2.2 && cd ..
332}
333build_jruby() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700334 internal_build_cpp # For conformance tests.
Feng Xiao20fbb352016-07-21 18:04:56 -0700335 # TODO(xiaofeng): Upgrade to jruby-9.x. There are some broken jests to be
336 # fixed.
337 cd ruby && bash travis-test.sh jruby-1.7 && cd ..
338}
339build_ruby_all() {
340 build_ruby21
341 build_ruby22
Paul Yange3e38b82016-12-08 14:39:20 -0800342 # TODO(teboring): Disable jruby test temperarily for it randomly fails.
343 # https://grpc-testing.appspot.com/job/protobuf_pull_request/735/consoleFull.
Paul Yangd8f54c42016-12-08 16:27:56 -0800344 # build_jruby
Chris Fallin20e94b22015-05-13 16:43:48 -0700345}
346
Josh Habermane9cf31e2015-12-21 15:18:17 -0800347build_javascript() {
348 internal_build_cpp
Josh Haberman0d2d8bc2015-12-28 06:43:42 -0800349 cd js && npm install && npm test && cd ..
Josh Habermane9cf31e2015-12-21 15:18:17 -0800350}
351
Paul Yang46ae90d2016-12-08 11:16:49 -0800352generate_php_test_proto() {
353 internal_build_cpp
354 pushd php/tests
355 # Generate test file
356 rm -rf generated
357 mkdir generated
358 ../../src/protoc --php_out=generated proto/test.proto proto/test_include.proto proto/test_no_namespace.proto
359 pushd ../../src
360 ./protoc --php_out=../php/tests/generated google/protobuf/empty.proto
361 popd
362 popd
363}
364
Bo Yangc8bd36e2016-09-30 19:07:33 +0000365use_php() {
366 VERSION=$1
367 PHP=`which php`
368 PHP_CONFIG=`which php-config`
369 PHPIZE=`which phpize`
370 rm $PHP
371 rm $PHP_CONFIG
372 rm $PHPIZE
373 cp "/usr/bin/php$VERSION" $PHP
374 cp "/usr/bin/php-config$VERSION" $PHP_CONFIG
375 cp "/usr/bin/phpize$VERSION" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800376 generate_php_test_proto
Bo Yangc8bd36e2016-09-30 19:07:33 +0000377}
378
Bo Yangc96dd662016-10-04 17:32:08 +0000379use_php_zts() {
380 VERSION=$1
381 PHP=`which php`
382 PHP_CONFIG=`which php-config`
383 PHPIZE=`which phpize`
384 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP
385 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG
386 ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800387 generate_php_test_proto
Bo Yangc96dd662016-10-04 17:32:08 +0000388}
389
Paul Yang51c5ff82016-10-25 17:27:05 -0700390use_php_bc() {
391 VERSION=$1
392 PHP=`which php`
393 PHP_CONFIG=`which php-config`
394 PHPIZE=`which phpize`
395 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP
396 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG
397 ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800398 generate_php_test_proto
Paul Yang51c5ff82016-10-25 17:27:05 -0700399}
400
Bo Yangfd332d12016-09-30 00:07:47 +0000401build_php5.5() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000402 use_php 5.5
Paul Yange3e38b82016-12-08 14:39:20 -0800403 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000404 rm -rf vendor
405 cp -r /usr/local/vendor-5.5 vendor
406 ./vendor/bin/phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800407 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000408}
409
Bo Yang34cdaf42016-10-03 21:59:58 +0000410build_php5.5_c() {
411 use_php 5.5
412 cd php/tests && /bin/bash ./test.sh && cd ../..
413}
Bo Yang34cdaf42016-10-03 21:59:58 +0000414
Bo Yangc96dd662016-10-04 17:32:08 +0000415build_php5.5_zts_c() {
416 use_php_zts 5.5
Bo Yang4f3d20a2016-10-05 10:54:39 -0700417 wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
Bo Yangc96dd662016-10-04 17:32:08 +0000418 cd php/tests && /bin/bash ./test.sh && cd ../..
419}
420
Paul Yang51c5ff82016-10-25 17:27:05 -0700421build_php5.5_32() {
422 use_php_bc 5.5
Paul Yange3e38b82016-12-08 14:39:20 -0800423 pushd php
Paul Yang51c5ff82016-10-25 17:27:05 -0700424 rm -rf vendor
425 cp -r /usr/local/vendor-5.5 vendor
426 ./vendor/bin/phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800427 popd
Paul Yang51c5ff82016-10-25 17:27:05 -0700428}
429
Paul Yangdf839072016-11-10 11:20:50 -0800430build_php5.5_c_32() {
431 use_php_bc 5.5
432 wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
433 cd php/tests && /bin/bash ./test.sh && cd ../..
434}
435
Bo Yangfd332d12016-09-30 00:07:47 +0000436build_php5.6() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000437 use_php 5.6
Paul Yange3e38b82016-12-08 14:39:20 -0800438 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000439 rm -rf vendor
440 cp -r /usr/local/vendor-5.6 vendor
441 ./vendor/bin/phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800442 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000443}
444
Bo Yang34cdaf42016-10-03 21:59:58 +0000445build_php5.6_c() {
446 use_php 5.6
Bo Yangfd332d12016-09-30 00:07:47 +0000447 cd php/tests && /bin/bash ./test.sh && cd ../..
448}
449
Bo Yang63448e62016-10-05 18:28:13 -0700450build_php5.6_mac() {
Paul Yang46ae90d2016-12-08 11:16:49 -0800451 generate_php_test_proto
Bo Yang63448e62016-10-05 18:28:13 -0700452 # Install PHP
453 curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
Paul Yang1f2dbc82016-11-08 11:38:34 -0800454 PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
455 export PATH="$PHP_FOLDER/bin:$PATH"
Bo Yang63448e62016-10-05 18:28:13 -0700456
457 # Install phpunit
458 curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar
459 chmod +x phpunit.phar
460 sudo mv phpunit.phar /usr/local/bin/phpunit
461
462 # Install valgrind
463 echo "#! /bin/bash" > valgrind
464 chmod ug+x valgrind
465 sudo mv valgrind /usr/local/bin/valgrind
466
467 # Test
468 cd php/tests && /bin/bash ./test.sh && cd ../..
469}
470
Bo Yangfd332d12016-09-30 00:07:47 +0000471build_php7.0() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000472 use_php 7.0
Paul Yange3e38b82016-12-08 14:39:20 -0800473 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000474 rm -rf vendor
475 cp -r /usr/local/vendor-7.0 vendor
476 ./vendor/bin/phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800477 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000478}
479
Bo Yang34cdaf42016-10-03 21:59:58 +0000480build_php7.0_c() {
481 use_php 7.0
482 cd php/tests && /bin/bash ./test.sh && cd ../..
483}
484
Bo Yangc8bd36e2016-09-30 19:07:33 +0000485build_php_all() {
486 build_php5.5
487 build_php5.6
488 build_php7.0
489 build_php5.5_c
490 build_php5.6_c
491 # build_php7.0_c
Bo Yangc96dd662016-10-04 17:32:08 +0000492 build_php5.5_zts_c
Bo Yangc8bd36e2016-09-30 19:07:33 +0000493}
494
Paul Yang51c5ff82016-10-25 17:27:05 -0700495build_php_all_32() {
496 build_php5.5_32
Paul Yangdf839072016-11-10 11:20:50 -0800497 build_php5.5_c_32
Paul Yang51c5ff82016-10-25 17:27:05 -0700498}
499
Josh Haberman738393b2016-02-18 20:10:23 -0800500# Note: travis currently does not support testing more than one language so the
501# .travis.yml cheats and claims to only be cpp. If they add multiple language
502# support, this should probably get updated to install steps and/or
503# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
504
505# .travis.yml uses matrix.exclude to block the cases where app-get can't be
506# use to install things.
507
508# -------- main --------
509
Josh Haberman738393b2016-02-18 20:10:23 -0800510if [ "$#" -ne 1 ]; then
511 echo "
512Usage: $0 { cpp |
Feng Xiaoa4f68b12016-07-19 17:20:31 -0700513 cpp_distcheck |
Josh Haberman738393b2016-02-18 20:10:23 -0800514 csharp |
Josh Haberman738393b2016-02-18 20:10:23 -0800515 java_jdk7 |
516 java_oracle7 |
Feng Xiaobaa40232016-07-29 14:11:21 -0700517 java_compatibility |
Josh Haberman738393b2016-02-18 20:10:23 -0800518 javanano_jdk7 |
519 javanano_oracle7 |
520 objectivec_ios |
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400521 objectivec_ios_debug |
522 objectivec_ios_release |
Josh Haberman738393b2016-02-18 20:10:23 -0800523 objectivec_osx |
Sergio Campamáf0c14922016-06-14 11:26:01 -0700524 objectivec_cocoapods_integration |
Josh Haberman738393b2016-02-18 20:10:23 -0800525 python |
526 python_cpp |
Jie Luoea511492017-01-23 15:11:00 -0800527 python_compatibility |
Josh Habermanffc81182016-02-22 15:39:29 -0800528 ruby21 |
529 ruby22 |
Feng Xiao20fbb352016-07-21 18:04:56 -0700530 jruby |
Bo Yangfd332d12016-09-30 00:07:47 +0000531 ruby_all |
532 php5.5 |
533 php5.5_c |
534 php5.6 |
535 php5.6_c |
536 php7.0 |
Bo Yangc8bd36e2016-09-30 19:07:33 +0000537 php7.0_c |
538 php_all)
Josh Haberman738393b2016-02-18 20:10:23 -0800539"
540 exit 1
541fi
542
543set -e # exit immediately on error
544set -x # display all commands
545eval "build_$1"