blob: 50c45fa9cdf5d04f47461168a90b70e0526455f8 [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.
Jisi Liu55fdbe52017-08-23 11:35:48 -070064 git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\
Jie Luoea511492017-01-23 15:11:00 -080065 grep -v ".gitignore" | grep -v "java/compatibility_tests" |\
Jie Luo72886892017-02-09 16:49:52 -080066 grep -v "python/compatibility_tests" | grep -v "csharp/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 Skeet9a9a66e2017-10-25 08:03:50 +010090 # Required for conformance tests and to regenerate protos.
Jon Skeetb6defa72015-08-04 10:01:40 +010091 internal_build_cpp
Josh Habermanffc81182016-02-22 15:39:29 -080092 NUGET=/usr/local/bin/nuget.exe
Jon Skeetb6defa72015-08-04 10:01:40 +010093
Jon Skeet10a8fb42016-07-14 22:01:47 +010094 # Perform "dotnet new" once to get the setup preprocessing out of the
95 # way. That spews a lot of output (including backspaces) into logs
96 # otherwise, and can cause problems. It doesn't matter if this step
97 # is performed multiple times; it's cheap after the first time anyway.
Jon Skeetf26e8c22017-05-04 08:51:46 +010098 # (It also doesn't matter if it's unnecessary, which it will be on some
99 # systems. It's necessary on Jenkins in order to avoid unprintable
100 # characters appearing in the JUnit output.)
Jon Skeet10a8fb42016-07-14 22:01:47 +0100101 mkdir dotnettmp
102 (cd dotnettmp; dotnet new > /dev/null)
103 rm -rf dotnettmp
104
Jon Skeet9a9a66e2017-10-25 08:03:50 +0100105 # Check that the protos haven't broken C# codegen.
106 # TODO(jonskeet): Fail if regenerating creates any changes.
107 csharp/generate_protos.sh
108
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700109 csharp/buildall.sh
Josh Habermane891c292015-12-30 16:03:49 -0800110 cd conformance && make test_csharp && cd ..
Jie Luo72886892017-02-09 16:49:52 -0800111
112 # Run csharp compatibility test between 3.0.0 and the current version.
113 csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700114}
115
Tim Swast7e31c4d2015-11-20 15:32:53 -0800116build_golang() {
117 # Go build needs `protoc`.
118 internal_build_cpp
119 # Add protoc to the path so that the examples build finds it.
120 export PATH="`pwd`/src:$PATH"
121
122 # Install Go and the Go protobuf compiler plugin.
Feng Xiao20fbb352016-07-21 18:04:56 -0700123 on_travis sudo apt-get update -qq
124 on_travis sudo apt-get install -qq golang
125
Tim Swast7e31c4d2015-11-20 15:32:53 -0800126 export GOPATH="$HOME/gocode"
127 mkdir -p "$GOPATH/src/github.com/google"
Feng Xiao20fbb352016-07-21 18:04:56 -0700128 rm -f "$GOPATH/src/github.com/google/protobuf"
Tim Swast7e31c4d2015-11-20 15:32:53 -0800129 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf"
130 export PATH="$GOPATH/bin:$PATH"
131 go get github.com/golang/protobuf/protoc-gen-go
132
Feng Xiao8136ccb2017-09-12 12:00:20 -0700133 cd examples && PROTO_PATH="-I../src -I." make gotest && cd ..
Tim Swast7e31c4d2015-11-20 15:32:53 -0800134}
135
Chris Fallin20e94b22015-05-13 16:43:48 -0700136use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -0700137 version=$1
138 case "$version" in
Chris Fallin20e94b22015-05-13 16:43:48 -0700139 jdk7)
Josh Haberman0f8c25d2016-02-19 09:11:38 -0800140 on_travis sudo apt-get install openjdk-7-jdk
Chris Fallin20e94b22015-05-13 16:43:48 -0700141 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700142 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700143 ;;
144 oracle7)
Josh Habermanffc81182016-02-22 15:39:29 -0800145 if [ "$TRAVIS" == "true" ]; then
146 sudo apt-get install python-software-properties # for apt-add-repository
147 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
148 sudo debconf-set-selections
149 yes | sudo apt-add-repository ppa:webupd8team/java
150 yes | sudo apt-get install oracle-java7-installer
151 fi;
Chris Fallin20e94b22015-05-13 16:43:48 -0700152 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700153 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700154 ;;
155 esac
156
Josh Haberman1ee0fda2016-03-03 16:02:55 -0800157 if [ "$TRAVIS" != "true" ]; then
158 MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
159 MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
160 fi;
161
Chris Fallin20e94b22015-05-13 16:43:48 -0700162 which java
163 java -version
Feng Xiaoad49ed72016-07-21 11:37:46 -0700164 $MVN -version
Chris Fallin20e94b22015-05-13 16:43:48 -0700165}
166
Josh Habermand08c39c2016-02-20 12:03:39 -0800167# --batch-mode supresses download progress output that spams the logs.
Josh Habermanb28b3f62016-02-20 12:17:10 -0800168MVN="mvn --batch-mode"
Josh Habermand08c39c2016-02-20 12:03:39 -0800169
Chris Fallin20e94b22015-05-13 16:43:48 -0700170build_java() {
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800171 version=$1
172 dir=java_$version
Chris Fallin20e94b22015-05-13 16:43:48 -0700173 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700174 internal_build_cpp
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800175 cp -r java $dir
176 cd $dir && $MVN clean && $MVN test
Feng Xiao9e5fb552015-12-21 11:08:18 -0800177 cd ../..
178}
179
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800180# The conformance tests are hard-coded to work with the $ROOT/java directory.
181# So this can't run in parallel with two different sets of tests.
Feng Xiao9e5fb552015-12-21 11:08:18 -0800182build_java_with_conformance_tests() {
183 # Java build needs `protoc`.
184 internal_build_cpp
Josh Habermand08c39c2016-02-20 12:03:39 -0800185 cd java && $MVN test && $MVN install
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800186 cd util && $MVN package assembly:single
Feng Xiaoaf81dcf2015-12-21 03:25:59 -0800187 cd ../..
Chris Fallin20e94b22015-05-13 16:43:48 -0700188 cd conformance && make test_java && cd ..
189}
190
191build_javanano() {
192 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700193 internal_build_cpp
Josh Habermanb28b3f62016-02-20 12:17:10 -0800194 cd javanano && $MVN test && cd ..
Chris Fallin20e94b22015-05-13 16:43:48 -0700195}
196
Chris Fallin20e94b22015-05-13 16:43:48 -0700197build_java_jdk7() {
198 use_java jdk7
Feng Xiao9e5fb552015-12-21 11:08:18 -0800199 build_java_with_conformance_tests
Chris Fallin20e94b22015-05-13 16:43:48 -0700200}
201build_java_oracle7() {
202 use_java oracle7
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800203 build_java oracle7
Chris Fallin20e94b22015-05-13 16:43:48 -0700204}
Feng Xiaobaa40232016-07-29 14:11:21 -0700205build_java_compatibility() {
206 use_java jdk7
207 internal_build_cpp
208 # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
209 # 3.0.0-beta-4 and the current version.
210 cd java/compatibility_tests/v2.5.0
211 ./test.sh 3.0.0-beta-4
212}
Chris Fallin20e94b22015-05-13 16:43:48 -0700213
Chris Fallin20e94b22015-05-13 16:43:48 -0700214build_javanano_jdk7() {
215 use_java jdk7
216 build_javanano
217}
218build_javanano_oracle7() {
219 use_java oracle7
220 build_javanano
221}
222
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400223internal_install_python_deps() {
Josh Haberman483533d2016-02-19 12:48:33 -0800224 if [ "$TRAVIS" != "true" ]; then
225 return;
226 fi
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400227 # Install tox (OS X doesn't have pip).
228 if [ $(uname -s) == "Darwin" ]; then
229 sudo easy_install tox
230 else
231 sudo pip install tox
232 fi
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400233 # Only install Python2.6/3.x on Linux.
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400234 if [ $(uname -s) == "Linux" ]; then
235 sudo apt-get install -y python-software-properties # for apt-add-repository
236 sudo apt-add-repository -y ppa:fkrull/deadsnakes
237 sudo apt-get update -qq
Jie Luoc2aa26e2017-08-18 13:15:06 -0700238 sudo apt-get install -y python3.3 python3.3-dev
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400239 sudo apt-get install -y python3.4 python3.4-dev
Jie Luo028d6f12017-08-22 10:36:52 -0700240 sudo apt-get install -y python3.5 python3.5-dev
241 sudo apt-get install -y python3.6 python3.6-dev
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400242 fi
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400243}
244
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400245build_objectivec_ios() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400246 # Reused the build script that takes care of configuring and ensuring things
247 # are up to date. The OS X test runs the objc conformance test, so skip it
248 # here.
249 # Note: travis has xctool installed, and we've looked at using it in the past
250 # but it has ended up proving unreliable (bugs), an they are removing build
251 # support in favor of xcbuild (or just xcodebuild).
252 objectivec/DevTools/full_mac_build.sh \
253 --core-only --skip-xcode-osx --skip-objc-conformance "$@"
254}
255
256build_objectivec_ios_debug() {
257 build_objectivec_ios --skip-xcode-release
258}
259
260build_objectivec_ios_release() {
261 build_objectivec_ios --skip-xcode-debug
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400262}
263
264build_objectivec_osx() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400265 # Reused the build script that takes care of configuring and ensuring things
266 # are up to date.
267 objectivec/DevTools/full_mac_build.sh \
268 --core-only --skip-xcode-ios
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400269}
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400270
Sergio Campamáf0c14922016-06-14 11:26:01 -0700271build_objectivec_cocoapods_integration() {
Sergio Campamáf0c14922016-06-14 11:26:01 -0700272 # Update pod to the latest version.
273 gem install cocoapods --no-ri --no-rdoc
274 objectivec/Tests/CocoaPods/run_tests.sh
275}
276
Chris Fallin20e94b22015-05-13 16:43:48 -0700277build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700278 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400279 internal_install_python_deps
Chris Fallin20e94b22015-05-13 16:43:48 -0700280 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400281 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400282 if [ $(uname -s) == "Linux" ]; then
Jie Luo610e4332017-08-22 16:23:21 -0700283 envlist=py\{27,33,34,35,36\}-python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400284 else
285 envlist=py27-python
286 fi
287 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700288 cd ..
289}
290
291build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700292 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400293 internal_install_python_deps
Bo Yangfd332d12016-09-30 00:07:47 +0000294 export LD_LIBRARY_PATH=../src/.libs # for Linux
295 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700296 cd python
Jie Luo610e4332017-08-22 16:23:21 -0700297 # Only test Python 3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400298 if [ $(uname -s) == "Linux" ]; then
Jie Luo610e4332017-08-22 16:23:21 -0700299 envlist=py\{27,33,34,35,36\}-cpp
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400300 else
301 envlist=py27-cpp
302 fi
303 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700304 cd ..
305}
306
Jie Luoea511492017-01-23 15:11:00 -0800307build_python_compatibility() {
308 internal_build_cpp
309 # Use the unit-tests extraced from 2.5.0 to test the compatibilty.
310 cd python/compatibility_tests/v2.5.0
311 # Test between 2.5.0 and the current version.
312 ./test.sh 2.5.0
313 # Test between 3.0.0-beta-1 and the current version.
314 ./test.sh 3.0.0-beta-1
315}
316
Chris Fallin20e94b22015-05-13 16:43:48 -0700317build_ruby21() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700318 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700319 cd ruby && bash travis-test.sh ruby-2.1 && cd ..
320}
321build_ruby22() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700322 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700323 cd ruby && bash travis-test.sh ruby-2.2 && cd ..
324}
325build_jruby() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700326 internal_build_cpp # For conformance tests.
Feng Xiao20fbb352016-07-21 18:04:56 -0700327 # TODO(xiaofeng): Upgrade to jruby-9.x. There are some broken jests to be
328 # fixed.
329 cd ruby && bash travis-test.sh jruby-1.7 && cd ..
330}
331build_ruby_all() {
332 build_ruby21
333 build_ruby22
Paul Yange3e38b82016-12-08 14:39:20 -0800334 # TODO(teboring): Disable jruby test temperarily for it randomly fails.
335 # https://grpc-testing.appspot.com/job/protobuf_pull_request/735/consoleFull.
Paul Yangd8f54c42016-12-08 16:27:56 -0800336 # build_jruby
Chris Fallin20e94b22015-05-13 16:43:48 -0700337}
338
Josh Habermane9cf31e2015-12-21 15:18:17 -0800339build_javascript() {
340 internal_build_cpp
Josh Haberman0d2d8bc2015-12-28 06:43:42 -0800341 cd js && npm install && npm test && cd ..
Josh Habermanf873d322016-06-08 12:38:15 -0700342 cd conformance && make test_nodejs && cd ..
Josh Habermane9cf31e2015-12-21 15:18:17 -0800343}
344
Paul Yang46ae90d2016-12-08 11:16:49 -0800345generate_php_test_proto() {
346 internal_build_cpp
347 pushd php/tests
348 # Generate test file
349 rm -rf generated
350 mkdir generated
Bo Yangf46a01d2017-09-12 15:04:34 -0700351 ../../src/protoc --php_out=generated \
352 proto/test.proto \
353 proto/test_include.proto \
354 proto/test_no_namespace.proto \
355 proto/test_prefix.proto \
356 proto/test_php_namespace.proto \
357 proto/test_empty_php_namespace.proto \
358 proto/test_reserved_enum_lower.proto \
359 proto/test_reserved_enum_upper.proto \
360 proto/test_reserved_enum_value_lower.proto \
361 proto/test_reserved_enum_value_upper.proto \
362 proto/test_reserved_message_lower.proto \
363 proto/test_reserved_message_upper.proto \
364 proto/test_service.proto \
365 proto/test_service_namespace.proto \
Paul Yangc15a3262017-08-02 07:42:27 -0700366 proto/test_descriptors.proto
Paul Yang46ae90d2016-12-08 11:16:49 -0800367 pushd ../../src
Paul Yangbcda9192017-11-03 12:30:09 -0700368 ./protoc --php_out=../php/tests/generated -I../php/tests -I. \
369 ../php/tests/proto/test_import_descriptor_proto.proto
Paul Yang46ae90d2016-12-08 11:16:49 -0800370 popd
371 popd
372}
373
Bo Yangc8bd36e2016-09-30 19:07:33 +0000374use_php() {
375 VERSION=$1
376 PHP=`which php`
377 PHP_CONFIG=`which php-config`
378 PHPIZE=`which phpize`
Paul Yang190b5272017-04-19 16:23:51 -0700379 ln -sfn "/usr/local/php-${VERSION}/bin/php" $PHP
380 ln -sfn "/usr/local/php-${VERSION}/bin/php-config" $PHP_CONFIG
381 ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800382 generate_php_test_proto
Bo Yangc8bd36e2016-09-30 19:07:33 +0000383}
384
Bo Yangc96dd662016-10-04 17:32:08 +0000385use_php_zts() {
386 VERSION=$1
387 PHP=`which php`
388 PHP_CONFIG=`which php-config`
389 PHPIZE=`which phpize`
390 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP
391 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG
392 ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800393 generate_php_test_proto
Bo Yangc96dd662016-10-04 17:32:08 +0000394}
395
Paul Yang51c5ff82016-10-25 17:27:05 -0700396use_php_bc() {
397 VERSION=$1
398 PHP=`which php`
399 PHP_CONFIG=`which php-config`
400 PHPIZE=`which phpize`
401 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP
402 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG
403 ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800404 generate_php_test_proto
Paul Yang51c5ff82016-10-25 17:27:05 -0700405}
406
Bo Yangfd332d12016-09-30 00:07:47 +0000407build_php5.5() {
Paul Yang190b5272017-04-19 16:23:51 -0700408 use_php 5.5
Paul Yangdd8d5f52017-03-08 14:31:34 -0800409
Paul Yange3e38b82016-12-08 14:39:20 -0800410 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000411 rm -rf vendor
412 cp -r /usr/local/vendor-5.5 vendor
Paul Yang190b5272017-04-19 16:23:51 -0700413 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
414 phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800415 popd
Paul Yang39756642017-02-01 12:47:58 -0800416 pushd conformance
Paul Yangecca6ea2017-06-30 12:14:09 -0700417 make test_php
Paul Yang39756642017-02-01 12:47:58 -0800418 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000419}
420
Bo Yang34cdaf42016-10-03 21:59:58 +0000421build_php5.5_c() {
Paul Yang190b5272017-04-19 16:23:51 -0700422 use_php 5.5
423 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
Paul Yangecca6ea2017-06-30 12:14:09 -0700424 pushd php/tests
425 /bin/bash ./test.sh
Paul Yang39756642017-02-01 12:47:58 -0800426 popd
Paul Yangecca6ea2017-06-30 12:14:09 -0700427 # TODO(teboring): Add it back
428 # pushd conformance
429 # make test_php_c
430 # popd
Bo Yang34cdaf42016-10-03 21:59:58 +0000431}
Bo Yang34cdaf42016-10-03 21:59:58 +0000432
Bo Yangc96dd662016-10-04 17:32:08 +0000433build_php5.5_zts_c() {
434 use_php_zts 5.5
Paul Yang190b5272017-04-19 16:23:51 -0700435 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
Bo Yangc96dd662016-10-04 17:32:08 +0000436 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700437 # TODO(teboring): Add it back
438 # pushd conformance
439 # make test_php_zts_c
440 # popd
Paul Yangdf839072016-11-10 11:20:50 -0800441}
442
Bo Yangfd332d12016-09-30 00:07:47 +0000443build_php5.6() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000444 use_php 5.6
Paul Yange3e38b82016-12-08 14:39:20 -0800445 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000446 rm -rf vendor
447 cp -r /usr/local/vendor-5.6 vendor
Paul Yang190b5272017-04-19 16:23:51 -0700448 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
449 phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800450 popd
Paul Yang39756642017-02-01 12:47:58 -0800451 pushd conformance
Paul Yangecca6ea2017-06-30 12:14:09 -0700452 make test_php
Paul Yang39756642017-02-01 12:47:58 -0800453 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000454}
455
Bo Yang34cdaf42016-10-03 21:59:58 +0000456build_php5.6_c() {
457 use_php 5.6
Paul Yang190b5272017-04-19 16:23:51 -0700458 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
Bo Yangfd332d12016-09-30 00:07:47 +0000459 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700460 # TODO(teboring): Add it back
461 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700462 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700463 # popd
Paul Yang190b5272017-04-19 16:23:51 -0700464}
465
466build_php5.6_zts_c() {
467 use_php_zts 5.6
468 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
469 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700470 # TODO(teboring): Add it back
471 # pushd conformance
472 # make test_php_zts_c
473 # popd
Bo Yangfd332d12016-09-30 00:07:47 +0000474}
475
Bo Yang63448e62016-10-05 18:28:13 -0700476build_php5.6_mac() {
Paul Yang46ae90d2016-12-08 11:16:49 -0800477 generate_php_test_proto
Bo Yang63448e62016-10-05 18:28:13 -0700478 # Install PHP
479 curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
Paul Yang1f2dbc82016-11-08 11:38:34 -0800480 PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
481 export PATH="$PHP_FOLDER/bin:$PATH"
Bo Yang63448e62016-10-05 18:28:13 -0700482
483 # Install phpunit
Paul Yangc0027432017-02-07 10:55:48 -0800484 curl https://phar.phpunit.de/phpunit-5.6.10.phar -L -o phpunit.phar
Bo Yang63448e62016-10-05 18:28:13 -0700485 chmod +x phpunit.phar
486 sudo mv phpunit.phar /usr/local/bin/phpunit
487
488 # Install valgrind
489 echo "#! /bin/bash" > valgrind
490 chmod ug+x valgrind
491 sudo mv valgrind /usr/local/bin/valgrind
492
493 # Test
494 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700495 # TODO(teboring): Add it back
496 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700497 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700498 # popd
Bo Yang63448e62016-10-05 18:28:13 -0700499}
500
Bo Yangfd332d12016-09-30 00:07:47 +0000501build_php7.0() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000502 use_php 7.0
Paul Yange3e38b82016-12-08 14:39:20 -0800503 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000504 rm -rf vendor
505 cp -r /usr/local/vendor-7.0 vendor
Paul Yang190b5272017-04-19 16:23:51 -0700506 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
507 phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800508 popd
Paul Yang39756642017-02-01 12:47:58 -0800509 pushd conformance
Paul Yangecca6ea2017-06-30 12:14:09 -0700510 make test_php
Paul Yang39756642017-02-01 12:47:58 -0800511 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000512}
513
Bo Yang34cdaf42016-10-03 21:59:58 +0000514build_php7.0_c() {
515 use_php 7.0
Paul Yang190b5272017-04-19 16:23:51 -0700516 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
Bo Yang34cdaf42016-10-03 21:59:58 +0000517 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700518 # TODO(teboring): Add it back
519 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700520 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700521 # popd
Paul Yang190b5272017-04-19 16:23:51 -0700522}
523
524build_php7.0_zts_c() {
525 use_php_zts 7.0
526 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
527 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700528 # TODO(teboring): Add it back.
529 # pushd conformance
530 # make test_php_zts_c
531 # popd
Paul Yang190b5272017-04-19 16:23:51 -0700532}
533
534build_php7.0_mac() {
535 generate_php_test_proto
536 # Install PHP
537 curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
538 PHP_FOLDER=`find /usr/local -type d -name "php7-7.0*"` # The folder name may change upon time
539 export PATH="$PHP_FOLDER/bin:$PATH"
540
541 # Install phpunit
542 curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar
543 chmod +x phpunit.phar
544 sudo mv phpunit.phar /usr/local/bin/phpunit
545
546 # Install valgrind
547 echo "#! /bin/bash" > valgrind
548 chmod ug+x valgrind
549 sudo mv valgrind /usr/local/bin/valgrind
550
551 # Test
552 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700553 # TODO(teboring): Add it back
554 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700555 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700556 # popd
Bo Yang34cdaf42016-10-03 21:59:58 +0000557}
558
Paul Yang25abd7b2017-05-05 11:14:11 -0700559build_php_compatibility() {
560 internal_build_cpp
561 php/tests/compatibility_test.sh
562}
563
Paul Yang22319312017-05-10 15:59:59 -0700564build_php7.1() {
565 use_php 7.1
566 pushd php
567 rm -rf vendor
568 cp -r /usr/local/vendor-7.1 vendor
569 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
570 phpunit
571 popd
572 pushd conformance
573 # TODO(teboring): Add it back
574 # make test_php
575 popd
576}
577
578build_php7.1_c() {
579 use_php 7.1
580 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
581 cd php/tests && /bin/bash ./test.sh && cd ../..
582 pushd conformance
583 # make test_php_c
584 popd
585}
586
587build_php7.1_zts_c() {
588 use_php_zts 7.1
589 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
590 cd php/tests && /bin/bash ./test.sh && cd ../..
591 pushd conformance
592 # make test_php_c
593 popd
594}
595
Paul Yang25abd7b2017-05-05 11:14:11 -0700596build_php_all_32() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000597 build_php5.5
598 build_php5.6
599 build_php7.0
Paul Yang22319312017-05-10 15:59:59 -0700600 build_php7.1
Bo Yangc8bd36e2016-09-30 19:07:33 +0000601 build_php5.5_c
602 build_php5.6_c
Paul Yang190b5272017-04-19 16:23:51 -0700603 build_php7.0_c
Paul Yang22319312017-05-10 15:59:59 -0700604 build_php7.1_c
Bo Yangc96dd662016-10-04 17:32:08 +0000605 build_php5.5_zts_c
Paul Yang190b5272017-04-19 16:23:51 -0700606 build_php5.6_zts_c
607 build_php7.0_zts_c
Paul Yang22319312017-05-10 15:59:59 -0700608 build_php7.1_zts_c
Paul Yang51c5ff82016-10-25 17:27:05 -0700609}
610
Paul Yang25abd7b2017-05-05 11:14:11 -0700611build_php_all() {
612 build_php_all_32
613 build_php_compatibility
614}
615
Josh Haberman738393b2016-02-18 20:10:23 -0800616# Note: travis currently does not support testing more than one language so the
617# .travis.yml cheats and claims to only be cpp. If they add multiple language
618# support, this should probably get updated to install steps and/or
619# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
620
621# .travis.yml uses matrix.exclude to block the cases where app-get can't be
622# use to install things.
623
624# -------- main --------
625
Josh Haberman738393b2016-02-18 20:10:23 -0800626if [ "$#" -ne 1 ]; then
627 echo "
628Usage: $0 { cpp |
Feng Xiaoa4f68b12016-07-19 17:20:31 -0700629 cpp_distcheck |
Josh Haberman738393b2016-02-18 20:10:23 -0800630 csharp |
Josh Haberman738393b2016-02-18 20:10:23 -0800631 java_jdk7 |
632 java_oracle7 |
Feng Xiaobaa40232016-07-29 14:11:21 -0700633 java_compatibility |
Josh Haberman738393b2016-02-18 20:10:23 -0800634 javanano_jdk7 |
635 javanano_oracle7 |
636 objectivec_ios |
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400637 objectivec_ios_debug |
638 objectivec_ios_release |
Josh Haberman738393b2016-02-18 20:10:23 -0800639 objectivec_osx |
Sergio Campamáf0c14922016-06-14 11:26:01 -0700640 objectivec_cocoapods_integration |
Josh Haberman738393b2016-02-18 20:10:23 -0800641 python |
642 python_cpp |
Jie Luoea511492017-01-23 15:11:00 -0800643 python_compatibility |
Josh Habermanffc81182016-02-22 15:39:29 -0800644 ruby21 |
645 ruby22 |
Feng Xiao20fbb352016-07-21 18:04:56 -0700646 jruby |
Bo Yangfd332d12016-09-30 00:07:47 +0000647 ruby_all |
648 php5.5 |
649 php5.5_c |
650 php5.6 |
651 php5.6_c |
652 php7.0 |
Bo Yangc8bd36e2016-09-30 19:07:33 +0000653 php7.0_c |
Paul Yang25abd7b2017-05-05 11:14:11 -0700654 php_compatibility |
Paul Yang22319312017-05-10 15:59:59 -0700655 php7.1 |
656 php7.1_c |
Bo Yangc8bd36e2016-09-30 19:07:33 +0000657 php_all)
Josh Haberman738393b2016-02-18 20:10:23 -0800658"
659 exit 1
660fi
661
662set -e # exit immediately on error
663set -x # display all commands
664eval "build_$1"