blob: fc7c95c4d657e365b2cfda43f6a48af9e533fe1e [file] [log] [blame]
Josh Haberman738393b2016-02-18 20:10:23 -08001#!/bin/bash
Josh Haberman67c727c2016-03-04 14:21:18 -08002#
Feng Xiao9de4e642018-07-13 16:55:32 -07003# Build and runs tests for the protobuf project. We use this script to run
4# tests on kokoro (Ubuntu and MacOS). It can run locally as well but you
5# will need to make sure the required compilers/tools are available.
Josh Haberman0f8c25d2016-02-19 09:11:38 -08006
Josh Haberman181c7f22015-07-15 11:05:10 -07007# For when some other test needs the C++ main build, including protoc and
8# libprotobuf.
9internal_build_cpp() {
Josh Haberman738393b2016-02-18 20:10:23 -080010 if [ -f src/protoc ]; then
11 # Already built.
12 return
13 fi
14
Carlos O'Ryan3c5442a2018-03-26 16:54:32 -040015 # Initialize any submodules.
16 git submodule update --init --recursive
17
Chris Fallin20e94b22015-05-13 16:43:48 -070018 ./autogen.sh
Paul Yangdaba6652016-10-07 16:09:26 -070019 ./configure CXXFLAGS="-fPIC" # -fPIC is needed for python cpp test.
20 # See python/setup.py for more details
Feng Xiaof0b8a572018-08-09 15:22:22 -070021 make -j4
Josh Haberman181c7f22015-07-15 11:05:10 -070022}
23
24build_cpp() {
25 internal_build_cpp
Feng Xiaof0b8a572018-08-09 15:22:22 -070026 make check -j4 || (cat src/test-suite.log; false)
Bo Yangfd332d12016-09-30 00:07:47 +000027 cd conformance && make test_cpp && cd ..
Josh Habermancb36bde2016-04-29 09:52:20 -070028
Thomas Van Lentenbc9d0772016-12-08 16:19:58 -050029 # The benchmark code depends on cmake, so test if it is installed before
30 # trying to do the build.
Thomas Van Lentenbc9d0772016-12-08 16:19:58 -050031 if [[ $(type cmake 2>/dev/null) ]]; then
32 # Verify benchmarking code can build successfully.
Yilun Chong34843ed2017-12-13 14:34:52 -080033 cd benchmarks && make cpp-benchmark && cd ..
Thomas Van Lentenbc9d0772016-12-08 16:19:58 -050034 else
35 echo ""
36 echo "WARNING: Skipping validation of the bench marking code, cmake isn't installed."
37 echo ""
38 fi
Chris Fallin20e94b22015-05-13 16:43:48 -070039}
40
41build_cpp_distcheck() {
Carlos O'Ryan3c5442a2018-03-26 16:54:32 -040042 # Initialize any submodules.
43 git submodule update --init --recursive
Chris Fallin20e94b22015-05-13 16:43:48 -070044 ./autogen.sh
45 ./configure
Feng Xiaoa4f68b12016-07-19 17:20:31 -070046 make dist
47
48 # List all files that should be included in the distribution package.
Jisi Liu55fdbe52017-08-23 11:35:48 -070049 git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\
Jie Luoea511492017-01-23 15:11:00 -080050 grep -v ".gitignore" | grep -v "java/compatibility_tests" |\
Jie Luo72886892017-02-09 16:49:52 -080051 grep -v "python/compatibility_tests" | grep -v "csharp/compatibility_tests" > dist.lst
Feng Xiaoa4f68b12016-07-19 17:20:31 -070052 # Unzip the dist tar file.
53 DIST=`ls *.tar.gz`
54 tar -xf $DIST
55 cd ${DIST//.tar.gz}
56 # Check if every file exists in the dist tar file.
57 FILES_MISSING=""
58 for FILE in $(<../dist.lst); do
Feng Xiaoacd5b052018-08-09 21:21:01 -070059 [ -f "$FILE" ] || {
Feng Xiaoa4f68b12016-07-19 17:20:31 -070060 echo "$FILE is not found!"
61 FILES_MISSING="$FILE $FILES_MISSING"
Feng Xiaoacd5b052018-08-09 21:21:01 -070062 }
Feng Xiaoa4f68b12016-07-19 17:20:31 -070063 done
64 cd ..
65 if [ ! -z "$FILES_MISSING" ]; then
66 echo "Missing files in EXTRA_DIST: $FILES_MISSING"
67 exit 1
68 fi
69
70 # Do the regular dist-check for C++.
Feng Xiaof0b8a572018-08-09 15:22:22 -070071 make distcheck -j4
Chris Fallin20e94b22015-05-13 16:43:48 -070072}
73
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070074build_csharp() {
Jon Skeet9a9a66e2017-10-25 08:03:50 +010075 # Required for conformance tests and to regenerate protos.
Jon Skeetb6defa72015-08-04 10:01:40 +010076 internal_build_cpp
Josh Habermanffc81182016-02-22 15:39:29 -080077 NUGET=/usr/local/bin/nuget.exe
Jon Skeetb6defa72015-08-04 10:01:40 +010078
Jon Skeet10a8fb42016-07-14 22:01:47 +010079 # Perform "dotnet new" once to get the setup preprocessing out of the
80 # way. That spews a lot of output (including backspaces) into logs
81 # otherwise, and can cause problems. It doesn't matter if this step
82 # is performed multiple times; it's cheap after the first time anyway.
Jon Skeetf26e8c22017-05-04 08:51:46 +010083 # (It also doesn't matter if it's unnecessary, which it will be on some
84 # systems. It's necessary on Jenkins in order to avoid unprintable
85 # characters appearing in the JUnit output.)
Jon Skeet10a8fb42016-07-14 22:01:47 +010086 mkdir dotnettmp
87 (cd dotnettmp; dotnet new > /dev/null)
88 rm -rf dotnettmp
89
Jon Skeet9a9a66e2017-10-25 08:03:50 +010090 # Check that the protos haven't broken C# codegen.
91 # TODO(jonskeet): Fail if regenerating creates any changes.
92 csharp/generate_protos.sh
Brent Shaffer67379542018-05-23 16:43:30 -070093
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070094 csharp/buildall.sh
Josh Habermane891c292015-12-30 16:03:49 -080095 cd conformance && make test_csharp && cd ..
Jie Luo72886892017-02-09 16:49:52 -080096
97 # Run csharp compatibility test between 3.0.0 and the current version.
98 csharp/compatibility_tests/v3.0.0/test.sh 3.0.0
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070099}
100
Tim Swast7e31c4d2015-11-20 15:32:53 -0800101build_golang() {
102 # Go build needs `protoc`.
103 internal_build_cpp
104 # Add protoc to the path so that the examples build finds it.
105 export PATH="`pwd`/src:$PATH"
106
Tim Swast7e31c4d2015-11-20 15:32:53 -0800107 export GOPATH="$HOME/gocode"
Feng Xiaoa0a17e22018-08-23 15:35:52 -0700108 mkdir -p "$GOPATH/src/github.com/protocolbuffers"
Feng Xiaoafe98de2018-08-22 11:55:30 -0700109 rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf"
110 ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf"
Tim Swast7e31c4d2015-11-20 15:32:53 -0800111 export PATH="$GOPATH/bin:$PATH"
112 go get github.com/golang/protobuf/protoc-gen-go
113
Feng Xiao8136ccb2017-09-12 12:00:20 -0700114 cd examples && PROTO_PATH="-I../src -I." make gotest && cd ..
Tim Swast7e31c4d2015-11-20 15:32:53 -0800115}
116
Chris Fallin20e94b22015-05-13 16:43:48 -0700117use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -0700118 version=$1
119 case "$version" in
Chris Fallin20e94b22015-05-13 16:43:48 -0700120 jdk7)
Chris Fallin20e94b22015-05-13 16:43:48 -0700121 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700122 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700123 ;;
124 oracle7)
Chris Fallin20e94b22015-05-13 16:43:48 -0700125 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700126 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700127 ;;
128 esac
129
Feng Xiao9de4e642018-07-13 16:55:32 -0700130 MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
Yilun Chong2b7ee382018-09-23 17:07:02 -0700131 MVN="$MVN -e -X -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
Josh Haberman1ee0fda2016-03-03 16:02:55 -0800132
Chris Fallin20e94b22015-05-13 16:43:48 -0700133 which java
134 java -version
Feng Xiaoad49ed72016-07-21 11:37:46 -0700135 $MVN -version
Chris Fallin20e94b22015-05-13 16:43:48 -0700136}
137
Josh Habermand08c39c2016-02-20 12:03:39 -0800138# --batch-mode supresses download progress output that spams the logs.
Josh Habermanb28b3f62016-02-20 12:17:10 -0800139MVN="mvn --batch-mode"
Josh Habermand08c39c2016-02-20 12:03:39 -0800140
Chris Fallin20e94b22015-05-13 16:43:48 -0700141build_java() {
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800142 version=$1
143 dir=java_$version
Chris Fallin20e94b22015-05-13 16:43:48 -0700144 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700145 internal_build_cpp
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800146 cp -r java $dir
147 cd $dir && $MVN clean && $MVN test
Feng Xiao9e5fb552015-12-21 11:08:18 -0800148 cd ../..
149}
150
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800151# The conformance tests are hard-coded to work with the $ROOT/java directory.
152# So this can't run in parallel with two different sets of tests.
Feng Xiao9e5fb552015-12-21 11:08:18 -0800153build_java_with_conformance_tests() {
154 # Java build needs `protoc`.
155 internal_build_cpp
Josh Habermand08c39c2016-02-20 12:03:39 -0800156 cd java && $MVN test && $MVN install
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800157 cd util && $MVN package assembly:single
Feng Xiaoaf81dcf2015-12-21 03:25:59 -0800158 cd ../..
Chris Fallin20e94b22015-05-13 16:43:48 -0700159 cd conformance && make test_java && cd ..
160}
161
Chris Fallin20e94b22015-05-13 16:43:48 -0700162build_java_jdk7() {
163 use_java jdk7
Feng Xiao9e5fb552015-12-21 11:08:18 -0800164 build_java_with_conformance_tests
Chris Fallin20e94b22015-05-13 16:43:48 -0700165}
166build_java_oracle7() {
167 use_java oracle7
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800168 build_java oracle7
Chris Fallin20e94b22015-05-13 16:43:48 -0700169}
Feng Xiaobaa40232016-07-29 14:11:21 -0700170build_java_compatibility() {
171 use_java jdk7
172 internal_build_cpp
173 # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
174 # 3.0.0-beta-4 and the current version.
175 cd java/compatibility_tests/v2.5.0
176 ./test.sh 3.0.0-beta-4
177}
Chris Fallin20e94b22015-05-13 16:43:48 -0700178
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400179build_objectivec_ios() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400180 # Reused the build script that takes care of configuring and ensuring things
181 # are up to date. The OS X test runs the objc conformance test, so skip it
182 # here.
183 # Note: travis has xctool installed, and we've looked at using it in the past
184 # but it has ended up proving unreliable (bugs), an they are removing build
185 # support in favor of xcbuild (or just xcodebuild).
186 objectivec/DevTools/full_mac_build.sh \
187 --core-only --skip-xcode-osx --skip-objc-conformance "$@"
188}
189
190build_objectivec_ios_debug() {
191 build_objectivec_ios --skip-xcode-release
192}
193
194build_objectivec_ios_release() {
195 build_objectivec_ios --skip-xcode-debug
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400196}
197
198build_objectivec_osx() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400199 # Reused the build script that takes care of configuring and ensuring things
200 # are up to date.
201 objectivec/DevTools/full_mac_build.sh \
202 --core-only --skip-xcode-ios
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400203}
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400204
Sergio Campamáf0c14922016-06-14 11:26:01 -0700205build_objectivec_cocoapods_integration() {
Sergio Campamáf0c14922016-06-14 11:26:01 -0700206 # Update pod to the latest version.
207 gem install cocoapods --no-ri --no-rdoc
208 objectivec/Tests/CocoaPods/run_tests.sh
209}
210
Chris Fallin20e94b22015-05-13 16:43:48 -0700211build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700212 internal_build_cpp
Chris Fallin20e94b22015-05-13 16:43:48 -0700213 cd python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400214 if [ $(uname -s) == "Linux" ]; then
Jie Luo610e4332017-08-22 16:23:21 -0700215 envlist=py\{27,33,34,35,36\}-python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400216 else
217 envlist=py27-python
218 fi
219 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700220 cd ..
221}
222
223build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700224 internal_build_cpp
Bo Yangfd332d12016-09-30 00:07:47 +0000225 export LD_LIBRARY_PATH=../src/.libs # for Linux
226 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700227 cd python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400228 if [ $(uname -s) == "Linux" ]; then
Jie Luo610e4332017-08-22 16:23:21 -0700229 envlist=py\{27,33,34,35,36\}-cpp
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400230 else
231 envlist=py27-cpp
232 fi
233 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700234 cd ..
235}
236
Jie Luoea511492017-01-23 15:11:00 -0800237build_python_compatibility() {
238 internal_build_cpp
239 # Use the unit-tests extraced from 2.5.0 to test the compatibilty.
240 cd python/compatibility_tests/v2.5.0
241 # Test between 2.5.0 and the current version.
242 ./test.sh 2.5.0
243 # Test between 3.0.0-beta-1 and the current version.
244 ./test.sh 3.0.0-beta-1
245}
246
Chris Fallin20e94b22015-05-13 16:43:48 -0700247build_ruby21() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700248 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700249 cd ruby && bash travis-test.sh ruby-2.1 && cd ..
250}
251build_ruby22() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700252 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700253 cd ruby && bash travis-test.sh ruby-2.2 && cd ..
254}
Paul Yang78ba0212018-07-02 15:11:36 -0700255build_ruby23() {
256 internal_build_cpp # For conformance tests.
257 cd ruby && bash travis-test.sh ruby-2.3 && cd ..
258}
259build_ruby24() {
260 internal_build_cpp # For conformance tests.
261 cd ruby && bash travis-test.sh ruby-2.4 && cd ..
262}
263build_ruby25() {
264 internal_build_cpp # For conformance tests.
265 cd ruby && bash travis-test.sh ruby-2.5.0 && cd ..
266}
Feng Xiao20fbb352016-07-21 18:04:56 -0700267build_ruby_all() {
268 build_ruby21
269 build_ruby22
Paul Yang78ba0212018-07-02 15:11:36 -0700270 build_ruby23
271 build_ruby24
272 build_ruby25
Chris Fallin20e94b22015-05-13 16:43:48 -0700273}
274
Josh Habermane9cf31e2015-12-21 15:18:17 -0800275build_javascript() {
276 internal_build_cpp
Josh Haberman0d2d8bc2015-12-28 06:43:42 -0800277 cd js && npm install && npm test && cd ..
Josh Habermanf873d322016-06-08 12:38:15 -0700278 cd conformance && make test_nodejs && cd ..
Josh Habermane9cf31e2015-12-21 15:18:17 -0800279}
280
Paul Yang46ae90d2016-12-08 11:16:49 -0800281generate_php_test_proto() {
282 internal_build_cpp
283 pushd php/tests
284 # Generate test file
285 rm -rf generated
286 mkdir generated
Bo Yangf46a01d2017-09-12 15:04:34 -0700287 ../../src/protoc --php_out=generated \
michaelbausor6a51c032018-10-07 16:56:41 -0700288 -I../../src -I. \
Brent Shaffer67379542018-05-23 16:43:30 -0700289 proto/empty/echo.proto \
Bo Yangf46a01d2017-09-12 15:04:34 -0700290 proto/test.proto \
291 proto/test_include.proto \
292 proto/test_no_namespace.proto \
293 proto/test_prefix.proto \
294 proto/test_php_namespace.proto \
295 proto/test_empty_php_namespace.proto \
296 proto/test_reserved_enum_lower.proto \
297 proto/test_reserved_enum_upper.proto \
298 proto/test_reserved_enum_value_lower.proto \
299 proto/test_reserved_enum_value_upper.proto \
300 proto/test_reserved_message_lower.proto \
301 proto/test_reserved_message_upper.proto \
302 proto/test_service.proto \
303 proto/test_service_namespace.proto \
michaelbausor6a51c032018-10-07 16:56:41 -0700304 proto/test_wrapper_type_setters.proto \
Paul Yangc15a3262017-08-02 07:42:27 -0700305 proto/test_descriptors.proto
Paul Yang46ae90d2016-12-08 11:16:49 -0800306 pushd ../../src
Paul Yangbcda9192017-11-03 12:30:09 -0700307 ./protoc --php_out=../php/tests/generated -I../php/tests -I. \
308 ../php/tests/proto/test_import_descriptor_proto.proto
Paul Yang46ae90d2016-12-08 11:16:49 -0800309 popd
310 popd
311}
312
Bo Yangc8bd36e2016-09-30 19:07:33 +0000313use_php() {
314 VERSION=$1
315 PHP=`which php`
316 PHP_CONFIG=`which php-config`
317 PHPIZE=`which phpize`
Paul Yang190b5272017-04-19 16:23:51 -0700318 ln -sfn "/usr/local/php-${VERSION}/bin/php" $PHP
319 ln -sfn "/usr/local/php-${VERSION}/bin/php-config" $PHP_CONFIG
320 ln -sfn "/usr/local/php-${VERSION}/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800321 generate_php_test_proto
Bo Yangc8bd36e2016-09-30 19:07:33 +0000322}
323
Bo Yangc96dd662016-10-04 17:32:08 +0000324use_php_zts() {
325 VERSION=$1
326 PHP=`which php`
327 PHP_CONFIG=`which php-config`
328 PHPIZE=`which phpize`
329 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP
330 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG
331 ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800332 generate_php_test_proto
Bo Yangc96dd662016-10-04 17:32:08 +0000333}
334
Paul Yang51c5ff82016-10-25 17:27:05 -0700335use_php_bc() {
336 VERSION=$1
337 PHP=`which php`
338 PHP_CONFIG=`which php-config`
339 PHPIZE=`which phpize`
340 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP
341 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG
342 ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE
Paul Yang46ae90d2016-12-08 11:16:49 -0800343 generate_php_test_proto
Paul Yang51c5ff82016-10-25 17:27:05 -0700344}
345
Bo Yangfd332d12016-09-30 00:07:47 +0000346build_php5.5() {
Paul Yang190b5272017-04-19 16:23:51 -0700347 use_php 5.5
Paul Yangdd8d5f52017-03-08 14:31:34 -0800348
Paul Yange3e38b82016-12-08 14:39:20 -0800349 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000350 rm -rf vendor
351 cp -r /usr/local/vendor-5.5 vendor
Paul Yang190b5272017-04-19 16:23:51 -0700352 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
353 phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800354 popd
Paul Yang39756642017-02-01 12:47:58 -0800355 pushd conformance
Paul Yangecca6ea2017-06-30 12:14:09 -0700356 make test_php
Paul Yang39756642017-02-01 12:47:58 -0800357 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000358}
359
Bo Yang34cdaf42016-10-03 21:59:58 +0000360build_php5.5_c() {
Paul Yang190b5272017-04-19 16:23:51 -0700361 use_php 5.5
362 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
Paul Yangecca6ea2017-06-30 12:14:09 -0700363 pushd php/tests
Paul Yang51293f32018-01-25 11:31:05 -0800364 /bin/bash ./test.sh 5.5
Paul Yang39756642017-02-01 12:47:58 -0800365 popd
Paul Yangecca6ea2017-06-30 12:14:09 -0700366 # TODO(teboring): Add it back
367 # pushd conformance
368 # make test_php_c
369 # popd
Bo Yang34cdaf42016-10-03 21:59:58 +0000370}
Bo Yang34cdaf42016-10-03 21:59:58 +0000371
Bo Yangc96dd662016-10-04 17:32:08 +0000372build_php5.5_zts_c() {
373 use_php_zts 5.5
Paul Yang190b5272017-04-19 16:23:51 -0700374 wget https://phar.phpunit.de/phpunit-4.8.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800375 cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700376 # TODO(teboring): Add it back
377 # pushd conformance
378 # make test_php_zts_c
379 # popd
Paul Yangdf839072016-11-10 11:20:50 -0800380}
381
Bo Yangfd332d12016-09-30 00:07:47 +0000382build_php5.6() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000383 use_php 5.6
Paul Yange3e38b82016-12-08 14:39:20 -0800384 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000385 rm -rf vendor
386 cp -r /usr/local/vendor-5.6 vendor
Paul Yang190b5272017-04-19 16:23:51 -0700387 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
388 phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800389 popd
Paul Yang39756642017-02-01 12:47:58 -0800390 pushd conformance
Paul Yangecca6ea2017-06-30 12:14:09 -0700391 make test_php
Paul Yang39756642017-02-01 12:47:58 -0800392 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000393}
394
Bo Yang34cdaf42016-10-03 21:59:58 +0000395build_php5.6_c() {
396 use_php 5.6
Paul Yang190b5272017-04-19 16:23:51 -0700397 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800398 cd php/tests && /bin/bash ./test.sh 5.6 && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700399 # TODO(teboring): Add it back
400 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700401 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700402 # popd
Paul Yang190b5272017-04-19 16:23:51 -0700403}
404
405build_php5.6_zts_c() {
406 use_php_zts 5.6
407 wget https://phar.phpunit.de/phpunit-5.7.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800408 cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700409 # TODO(teboring): Add it back
410 # pushd conformance
411 # make test_php_zts_c
412 # popd
Bo Yangfd332d12016-09-30 00:07:47 +0000413}
414
Bo Yang63448e62016-10-05 18:28:13 -0700415build_php5.6_mac() {
Paul Yang46ae90d2016-12-08 11:16:49 -0800416 generate_php_test_proto
Bo Yang63448e62016-10-05 18:28:13 -0700417 # Install PHP
418 curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
Paul Yang1f2dbc82016-11-08 11:38:34 -0800419 PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
420 export PATH="$PHP_FOLDER/bin:$PATH"
Bo Yang63448e62016-10-05 18:28:13 -0700421
422 # Install phpunit
Paul Yangc0027432017-02-07 10:55:48 -0800423 curl https://phar.phpunit.de/phpunit-5.6.10.phar -L -o phpunit.phar
Bo Yang63448e62016-10-05 18:28:13 -0700424 chmod +x phpunit.phar
425 sudo mv phpunit.phar /usr/local/bin/phpunit
426
427 # Install valgrind
428 echo "#! /bin/bash" > valgrind
429 chmod ug+x valgrind
430 sudo mv valgrind /usr/local/bin/valgrind
431
432 # Test
433 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700434 # TODO(teboring): Add it back
435 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700436 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700437 # popd
Bo Yang63448e62016-10-05 18:28:13 -0700438}
439
Bo Yangfd332d12016-09-30 00:07:47 +0000440build_php7.0() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000441 use_php 7.0
Paul Yange3e38b82016-12-08 14:39:20 -0800442 pushd php
Bo Yangfd332d12016-09-30 00:07:47 +0000443 rm -rf vendor
444 cp -r /usr/local/vendor-7.0 vendor
Paul Yang190b5272017-04-19 16:23:51 -0700445 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
446 phpunit
Paul Yange3e38b82016-12-08 14:39:20 -0800447 popd
Paul Yang39756642017-02-01 12:47:58 -0800448 pushd conformance
Paul Yangecca6ea2017-06-30 12:14:09 -0700449 make test_php
Paul Yang39756642017-02-01 12:47:58 -0800450 popd
Bo Yangfd332d12016-09-30 00:07:47 +0000451}
452
Bo Yang34cdaf42016-10-03 21:59:58 +0000453build_php7.0_c() {
454 use_php 7.0
Paul Yang190b5272017-04-19 16:23:51 -0700455 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800456 cd php/tests && /bin/bash ./test.sh 7.0 && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700457 # TODO(teboring): Add it back
458 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700459 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700460 # popd
Paul Yang190b5272017-04-19 16:23:51 -0700461}
462
463build_php7.0_zts_c() {
464 use_php_zts 7.0
465 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800466 cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700467 # TODO(teboring): Add it back.
468 # pushd conformance
469 # make test_php_zts_c
470 # popd
Paul Yang190b5272017-04-19 16:23:51 -0700471}
472
473build_php7.0_mac() {
474 generate_php_test_proto
475 # Install PHP
476 curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0
477 PHP_FOLDER=`find /usr/local -type d -name "php7-7.0*"` # The folder name may change upon time
478 export PATH="$PHP_FOLDER/bin:$PATH"
479
480 # Install phpunit
481 curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar
482 chmod +x phpunit.phar
483 sudo mv phpunit.phar /usr/local/bin/phpunit
484
485 # Install valgrind
486 echo "#! /bin/bash" > valgrind
487 chmod ug+x valgrind
488 sudo mv valgrind /usr/local/bin/valgrind
489
490 # Test
491 cd php/tests && /bin/bash ./test.sh && cd ../..
Paul Yangecca6ea2017-06-30 12:14:09 -0700492 # TODO(teboring): Add it back
493 # pushd conformance
Paul Yang190b5272017-04-19 16:23:51 -0700494 # make test_php_c
Paul Yangecca6ea2017-06-30 12:14:09 -0700495 # popd
Bo Yang34cdaf42016-10-03 21:59:58 +0000496}
497
Paul Yang25abd7b2017-05-05 11:14:11 -0700498build_php_compatibility() {
499 internal_build_cpp
500 php/tests/compatibility_test.sh
501}
502
Paul Yang22319312017-05-10 15:59:59 -0700503build_php7.1() {
504 use_php 7.1
505 pushd php
506 rm -rf vendor
507 cp -r /usr/local/vendor-7.1 vendor
508 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
509 phpunit
510 popd
511 pushd conformance
Paul Yangbdcbcab2018-07-26 13:52:22 -0700512 make test_php
Paul Yang22319312017-05-10 15:59:59 -0700513 popd
514}
515
516build_php7.1_c() {
Paul Yangbdcbcab2018-07-26 13:52:22 -0700517 ENABLE_CONFORMANCE_TEST=$1
Paul Yang22319312017-05-10 15:59:59 -0700518 use_php 7.1
519 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800520 cd php/tests && /bin/bash ./test.sh 7.1 && cd ../..
Paul Yangbdcbcab2018-07-26 13:52:22 -0700521 if [ "$ENABLE_CONFORMANCE_TEST" = "true" ]
522 then
523 pushd conformance
524 make test_php_c
525 popd
526 fi
Paul Yang22319312017-05-10 15:59:59 -0700527}
528
529build_php7.1_zts_c() {
530 use_php_zts 7.1
531 wget https://phar.phpunit.de/phpunit-5.6.0.phar -O /usr/bin/phpunit
Paul Yang51293f32018-01-25 11:31:05 -0800532 cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../..
Paul Yang22319312017-05-10 15:59:59 -0700533 pushd conformance
534 # make test_php_c
535 popd
536}
537
Paul Yang25abd7b2017-05-05 11:14:11 -0700538build_php_all_32() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000539 build_php5.5
540 build_php5.6
541 build_php7.0
Paul Yang22319312017-05-10 15:59:59 -0700542 build_php7.1
Bo Yangc8bd36e2016-09-30 19:07:33 +0000543 build_php5.5_c
544 build_php5.6_c
Paul Yang190b5272017-04-19 16:23:51 -0700545 build_php7.0_c
Paul Yangbdcbcab2018-07-26 13:52:22 -0700546 build_php7.1_c $1
Bo Yangc96dd662016-10-04 17:32:08 +0000547 build_php5.5_zts_c
Paul Yang190b5272017-04-19 16:23:51 -0700548 build_php5.6_zts_c
549 build_php7.0_zts_c
Paul Yang22319312017-05-10 15:59:59 -0700550 build_php7.1_zts_c
Paul Yang51c5ff82016-10-25 17:27:05 -0700551}
552
Paul Yang25abd7b2017-05-05 11:14:11 -0700553build_php_all() {
Paul Yangbdcbcab2018-07-26 13:52:22 -0700554 build_php_all_32 true
Paul Yang25abd7b2017-05-05 11:14:11 -0700555 build_php_compatibility
556}
557
Josh Haberman738393b2016-02-18 20:10:23 -0800558# -------- main --------
559
Josh Haberman738393b2016-02-18 20:10:23 -0800560if [ "$#" -ne 1 ]; then
561 echo "
562Usage: $0 { cpp |
Feng Xiaoa4f68b12016-07-19 17:20:31 -0700563 cpp_distcheck |
Josh Haberman738393b2016-02-18 20:10:23 -0800564 csharp |
Josh Haberman738393b2016-02-18 20:10:23 -0800565 java_jdk7 |
566 java_oracle7 |
Feng Xiaobaa40232016-07-29 14:11:21 -0700567 java_compatibility |
Josh Haberman738393b2016-02-18 20:10:23 -0800568 objectivec_ios |
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400569 objectivec_ios_debug |
570 objectivec_ios_release |
Josh Haberman738393b2016-02-18 20:10:23 -0800571 objectivec_osx |
Sergio Campamáf0c14922016-06-14 11:26:01 -0700572 objectivec_cocoapods_integration |
Josh Haberman738393b2016-02-18 20:10:23 -0800573 python |
574 python_cpp |
Jie Luoea511492017-01-23 15:11:00 -0800575 python_compatibility |
Josh Habermanffc81182016-02-22 15:39:29 -0800576 ruby21 |
577 ruby22 |
Feng Xiao20fbb352016-07-21 18:04:56 -0700578 jruby |
Bo Yangfd332d12016-09-30 00:07:47 +0000579 ruby_all |
580 php5.5 |
581 php5.5_c |
582 php5.6 |
583 php5.6_c |
584 php7.0 |
Bo Yangc8bd36e2016-09-30 19:07:33 +0000585 php7.0_c |
Paul Yang25abd7b2017-05-05 11:14:11 -0700586 php_compatibility |
Paul Yang22319312017-05-10 15:59:59 -0700587 php7.1 |
588 php7.1_c |
Bo Yangc8bd36e2016-09-30 19:07:33 +0000589 php_all)
Josh Haberman738393b2016-02-18 20:10:23 -0800590"
591 exit 1
592fi
593
594set -e # exit immediately on error
595set -x # display all commands
Feng Xiao9de4e642018-07-13 16:55:32 -0700596cd $(dirname $0)
Josh Haberman738393b2016-02-18 20:10:23 -0800597eval "build_$1"