blob: 4ac6b7c68dd95aead81b2a685406969169c70e0d [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
41 # Verify benchmarking code can build successfully.
Joshua Habermana289d432016-09-23 11:07:45 -070042 git submodule init
43 git submodule update
44 cd third_party/benchmark && cmake -DCMAKE_BUILD_TYPE=Release && make && cd ../..
Josh Haberman49a89182016-04-29 10:19:03 -070045 cd benchmarks && make && ./generate-datasets && cd ..
Chris Fallin20e94b22015-05-13 16:43:48 -070046}
47
48build_cpp_distcheck() {
49 ./autogen.sh
50 ./configure
Feng Xiaoa4f68b12016-07-19 17:20:31 -070051 make dist
52
53 # List all files that should be included in the distribution package.
Bo Yangfd332d12016-09-30 00:07:47 +000054 git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|cmake\|examples\)" |\
Feng Xiaoa4f68b12016-07-19 17:20:31 -070055 grep -v ".gitignore" | grep -v "java/compatibility_tests" > dist.lst
56 # Unzip the dist tar file.
57 DIST=`ls *.tar.gz`
58 tar -xf $DIST
59 cd ${DIST//.tar.gz}
60 # Check if every file exists in the dist tar file.
61 FILES_MISSING=""
62 for FILE in $(<../dist.lst); do
63 if ! file $FILE &>/dev/null; then
64 echo "$FILE is not found!"
65 FILES_MISSING="$FILE $FILES_MISSING"
66 fi
67 done
68 cd ..
69 if [ ! -z "$FILES_MISSING" ]; then
70 echo "Missing files in EXTRA_DIST: $FILES_MISSING"
71 exit 1
72 fi
73
74 # Do the regular dist-check for C++.
Josh Haberman67c727c2016-03-04 14:21:18 -080075 make distcheck -j2
Chris Fallin20e94b22015-05-13 16:43:48 -070076}
77
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070078build_csharp() {
Jon Skeetb6defa72015-08-04 10:01:40 +010079 # Just for the conformance tests. We don't currently
80 # need to really build protoc, but it's simplest to keep with the
81 # conventions of the other builds.
82 internal_build_cpp
Josh Habermanffc81182016-02-22 15:39:29 -080083 NUGET=/usr/local/bin/nuget.exe
Jon Skeetb6defa72015-08-04 10:01:40 +010084
Josh Habermanffc81182016-02-22 15:39:29 -080085 if [ "$TRAVIS" == "true" ]; then
86 # Install latest version of Mono
87 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
Jon Skeet10a8fb42016-07-14 22:01:47 +010088 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 1397BC53640DB551
Josh Habermanffc81182016-02-22 15:39:29 -080089 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 -080090 sudo apt-get update -qq
91 sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
Jon Skeet10a8fb42016-07-14 22:01:47 +010092
93 # Then install the dotnet SDK as per Ubuntu 14.04 instructions on dot.net.
Jon Skeetdeaea212016-07-19 17:57:46 -070094 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 +010095 sudo apt-key adv --keyserver apt-mo.trafficmanager.net --recv-keys 417A0893
96 sudo apt-get update -qq
97 sudo apt-get install -qq dotnet-dev-1.0.0-preview2-003121
Josh Habermanffc81182016-02-22 15:39:29 -080098 fi
Jan Tattermuschddb36ef2015-05-18 17:34:02 -070099
Jon Skeet10a8fb42016-07-14 22:01:47 +0100100 # Perform "dotnet new" once to get the setup preprocessing out of the
101 # way. That spews a lot of output (including backspaces) into logs
102 # otherwise, and can cause problems. It doesn't matter if this step
103 # is performed multiple times; it's cheap after the first time anyway.
104 mkdir dotnettmp
105 (cd dotnettmp; dotnet new > /dev/null)
106 rm -rf dotnettmp
107
108 (cd csharp/src; dotnet restore)
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 ..
Jan Tattermuschddb36ef2015-05-18 17:34:02 -0700111}
112
Tim Swast7e31c4d2015-11-20 15:32:53 -0800113build_golang() {
114 # Go build needs `protoc`.
115 internal_build_cpp
116 # Add protoc to the path so that the examples build finds it.
117 export PATH="`pwd`/src:$PATH"
118
119 # Install Go and the Go protobuf compiler plugin.
Feng Xiao20fbb352016-07-21 18:04:56 -0700120 on_travis sudo apt-get update -qq
121 on_travis sudo apt-get install -qq golang
122
Tim Swast7e31c4d2015-11-20 15:32:53 -0800123 export GOPATH="$HOME/gocode"
124 mkdir -p "$GOPATH/src/github.com/google"
Feng Xiao20fbb352016-07-21 18:04:56 -0700125 rm -f "$GOPATH/src/github.com/google/protobuf"
Tim Swast7e31c4d2015-11-20 15:32:53 -0800126 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf"
127 export PATH="$GOPATH/bin:$PATH"
128 go get github.com/golang/protobuf/protoc-gen-go
129
130 cd examples && make gotest && cd ..
131}
132
Chris Fallin20e94b22015-05-13 16:43:48 -0700133use_java() {
Chris Fallin20e94b22015-05-13 16:43:48 -0700134 version=$1
135 case "$version" in
Chris Fallin20e94b22015-05-13 16:43:48 -0700136 jdk7)
Josh Haberman0f8c25d2016-02-19 09:11:38 -0800137 on_travis sudo apt-get install openjdk-7-jdk
Chris Fallin20e94b22015-05-13 16:43:48 -0700138 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
Feng Xiaoad49ed72016-07-21 11:37:46 -0700139 export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64
Chris Fallin20e94b22015-05-13 16:43:48 -0700140 ;;
141 oracle7)
Josh Habermanffc81182016-02-22 15:39:29 -0800142 if [ "$TRAVIS" == "true" ]; then
143 sudo apt-get install python-software-properties # for apt-add-repository
144 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
145 sudo debconf-set-selections
146 yes | sudo apt-add-repository ppa:webupd8team/java
147 yes | sudo apt-get install oracle-java7-installer
148 fi;
Chris Fallin20e94b22015-05-13 16:43:48 -0700149 export PATH=/usr/lib/jvm/java-7-oracle/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 esac
153
Josh Haberman1ee0fda2016-03-03 16:02:55 -0800154 if [ "$TRAVIS" != "true" ]; then
155 MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
156 MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
157 fi;
158
Chris Fallin20e94b22015-05-13 16:43:48 -0700159 which java
160 java -version
Feng Xiaoad49ed72016-07-21 11:37:46 -0700161 $MVN -version
Chris Fallin20e94b22015-05-13 16:43:48 -0700162}
163
Josh Habermand08c39c2016-02-20 12:03:39 -0800164# --batch-mode supresses download progress output that spams the logs.
Josh Habermanb28b3f62016-02-20 12:17:10 -0800165MVN="mvn --batch-mode"
Josh Habermand08c39c2016-02-20 12:03:39 -0800166
Chris Fallin20e94b22015-05-13 16:43:48 -0700167build_java() {
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800168 version=$1
169 dir=java_$version
Chris Fallin20e94b22015-05-13 16:43:48 -0700170 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700171 internal_build_cpp
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800172 cp -r java $dir
173 cd $dir && $MVN clean && $MVN test
Feng Xiao9e5fb552015-12-21 11:08:18 -0800174 cd ../..
175}
176
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800177# The conformance tests are hard-coded to work with the $ROOT/java directory.
178# So this can't run in parallel with two different sets of tests.
Feng Xiao9e5fb552015-12-21 11:08:18 -0800179build_java_with_conformance_tests() {
180 # Java build needs `protoc`.
181 internal_build_cpp
Josh Habermand08c39c2016-02-20 12:03:39 -0800182 cd java && $MVN test && $MVN install
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800183 cd util && $MVN package assembly:single
Feng Xiaoaf81dcf2015-12-21 03:25:59 -0800184 cd ../..
Chris Fallin20e94b22015-05-13 16:43:48 -0700185 cd conformance && make test_java && cd ..
186}
187
188build_javanano() {
189 # Java build needs `protoc`.
Josh Haberman181c7f22015-07-15 11:05:10 -0700190 internal_build_cpp
Josh Habermanb28b3f62016-02-20 12:17:10 -0800191 cd javanano && $MVN test && cd ..
Chris Fallin20e94b22015-05-13 16:43:48 -0700192}
193
Chris Fallin20e94b22015-05-13 16:43:48 -0700194build_java_jdk7() {
195 use_java jdk7
Feng Xiao9e5fb552015-12-21 11:08:18 -0800196 build_java_with_conformance_tests
Chris Fallin20e94b22015-05-13 16:43:48 -0700197}
198build_java_oracle7() {
199 use_java oracle7
Josh Haberman2f3f1de2016-03-01 15:37:17 -0800200 build_java oracle7
Chris Fallin20e94b22015-05-13 16:43:48 -0700201}
Feng Xiaobaa40232016-07-29 14:11:21 -0700202build_java_compatibility() {
203 use_java jdk7
204 internal_build_cpp
205 # Use the unit-tests extraced from 2.5.0 to test the compatibilty between
206 # 3.0.0-beta-4 and the current version.
207 cd java/compatibility_tests/v2.5.0
208 ./test.sh 3.0.0-beta-4
209}
Chris Fallin20e94b22015-05-13 16:43:48 -0700210
Chris Fallin20e94b22015-05-13 16:43:48 -0700211build_javanano_jdk7() {
212 use_java jdk7
213 build_javanano
214}
215build_javanano_oracle7() {
216 use_java oracle7
217 build_javanano
218}
219
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400220internal_install_python_deps() {
Josh Haberman483533d2016-02-19 12:48:33 -0800221 if [ "$TRAVIS" != "true" ]; then
222 return;
223 fi
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400224 # Install tox (OS X doesn't have pip).
225 if [ $(uname -s) == "Darwin" ]; then
226 sudo easy_install tox
227 else
228 sudo pip install tox
229 fi
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400230 # Only install Python2.6/3.x on Linux.
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400231 if [ $(uname -s) == "Linux" ]; then
232 sudo apt-get install -y python-software-properties # for apt-add-repository
233 sudo apt-add-repository -y ppa:fkrull/deadsnakes
234 sudo apt-get update -qq
235 sudo apt-get install -y python2.6 python2.6-dev
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400236 sudo apt-get install -y python3.3 python3.3-dev
237 sudo apt-get install -y python3.4 python3.4-dev
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400238 fi
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400239}
240
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400241build_objectivec_ios() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400242 # Reused the build script that takes care of configuring and ensuring things
243 # are up to date. The OS X test runs the objc conformance test, so skip it
244 # here.
245 # Note: travis has xctool installed, and we've looked at using it in the past
246 # but it has ended up proving unreliable (bugs), an they are removing build
247 # support in favor of xcbuild (or just xcodebuild).
248 objectivec/DevTools/full_mac_build.sh \
249 --core-only --skip-xcode-osx --skip-objc-conformance "$@"
250}
251
252build_objectivec_ios_debug() {
253 build_objectivec_ios --skip-xcode-release
254}
255
256build_objectivec_ios_release() {
257 build_objectivec_ios --skip-xcode-debug
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400258}
259
260build_objectivec_osx() {
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400261 # Reused the build script that takes care of configuring and ensuring things
262 # are up to date.
263 objectivec/DevTools/full_mac_build.sh \
264 --core-only --skip-xcode-ios
Thomas Van Lenten9642b822015-06-10 17:21:23 -0400265}
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400266
Sergio Campamáf0c14922016-06-14 11:26:01 -0700267build_objectivec_cocoapods_integration() {
268 # First, load the RVM environment in bash, needed to update ruby.
269 source ~/.rvm/scripts/rvm
Sergio Campamáf6d1d1a2016-07-15 13:59:09 -0700270 # Update rvm to the latest version. This is needed to solve
271 # https://github.com/google/protobuf/issues/1786 and may not be needed in the
272 # future when Travis updates the default version of rvm.
273 rvm get head
Sergio Campamáf0c14922016-06-14 11:26:01 -0700274 # Update ruby to 2.2.3 as the default one crashes with segmentation faults
275 # when using pod.
276 rvm use 2.2.3 --install --binary --fuzzy
277 # Update pod to the latest version.
278 gem install cocoapods --no-ri --no-rdoc
279 objectivec/Tests/CocoaPods/run_tests.sh
280}
281
Chris Fallin20e94b22015-05-13 16:43:48 -0700282build_python() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700283 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400284 internal_install_python_deps
Chris Fallin20e94b22015-05-13 16:43:48 -0700285 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400286 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400287 if [ $(uname -s) == "Linux" ]; then
Jie Luo2850a982015-10-09 17:07:03 -0700288 envlist=py\{26,27,33,34\}-python
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400289 else
290 envlist=py27-python
291 fi
292 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700293 cd ..
294}
295
296build_python_cpp() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700297 internal_build_cpp
Dan O'Reilly5de2a812015-08-20 18:19:56 -0400298 internal_install_python_deps
Bo Yangfd332d12016-09-30 00:07:47 +0000299 export LD_LIBRARY_PATH=../src/.libs # for Linux
300 export DYLD_LIBRARY_PATH=../src/.libs # for OS X
Chris Fallin20e94b22015-05-13 16:43:48 -0700301 cd python
Dan O'Reillyd9598ca2015-08-26 20:30:41 -0400302 # Only test Python 2.6/3.x on Linux
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400303 if [ $(uname -s) == "Linux" ]; then
Jisi Liu72bd9c92015-10-06 10:48:57 -0700304 # py26 is currently disabled due to json_format
305 envlist=py\{27,33,34\}-cpp
Dan O'Reilly76f8a3f2015-08-21 18:51:47 -0400306 else
307 envlist=py27-cpp
308 fi
309 tox -e $envlist
Chris Fallin20e94b22015-05-13 16:43:48 -0700310 cd ..
311}
312
Chris Fallin20e94b22015-05-13 16:43:48 -0700313build_ruby21() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700314 internal_build_cpp # For conformance tests.
Chris Fallin20e94b22015-05-13 16:43:48 -0700315 cd ruby && bash travis-test.sh ruby-2.1 && cd ..
316}
317build_ruby22() {
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.2 && cd ..
320}
321build_jruby() {
Josh Haberman181c7f22015-07-15 11:05:10 -0700322 internal_build_cpp # For conformance tests.
Feng Xiao20fbb352016-07-21 18:04:56 -0700323 # TODO(xiaofeng): Upgrade to jruby-9.x. There are some broken jests to be
324 # fixed.
325 cd ruby && bash travis-test.sh jruby-1.7 && cd ..
326}
327build_ruby_all() {
328 build_ruby21
329 build_ruby22
330 build_jruby
Chris Fallin20e94b22015-05-13 16:43:48 -0700331}
332
Josh Habermane9cf31e2015-12-21 15:18:17 -0800333build_javascript() {
334 internal_build_cpp
Josh Haberman0d2d8bc2015-12-28 06:43:42 -0800335 cd js && npm install && npm test && cd ..
Josh Habermane9cf31e2015-12-21 15:18:17 -0800336}
337
Bo Yangc8bd36e2016-09-30 19:07:33 +0000338use_php() {
339 VERSION=$1
340 PHP=`which php`
341 PHP_CONFIG=`which php-config`
342 PHPIZE=`which phpize`
343 rm $PHP
344 rm $PHP_CONFIG
345 rm $PHPIZE
346 cp "/usr/bin/php$VERSION" $PHP
347 cp "/usr/bin/php-config$VERSION" $PHP_CONFIG
348 cp "/usr/bin/phpize$VERSION" $PHPIZE
349}
350
Bo Yangc96dd662016-10-04 17:32:08 +0000351use_php_zts() {
352 VERSION=$1
353 PHP=`which php`
354 PHP_CONFIG=`which php-config`
355 PHPIZE=`which phpize`
356 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php" $PHP
357 ln -sfn "/usr/local/php-${VERSION}-zts/bin/php-config" $PHP_CONFIG
358 ln -sfn "/usr/local/php-${VERSION}-zts/bin/phpize" $PHPIZE
359}
360
Paul Yang51c5ff82016-10-25 17:27:05 -0700361use_php_bc() {
362 VERSION=$1
363 PHP=`which php`
364 PHP_CONFIG=`which php-config`
365 PHPIZE=`which phpize`
366 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php" $PHP
367 ln -sfn "/usr/local/php-${VERSION}-bc/bin/php-config" $PHP_CONFIG
368 ln -sfn "/usr/local/php-${VERSION}-bc/bin/phpize" $PHPIZE
369}
370
Bo Yangfd332d12016-09-30 00:07:47 +0000371build_php5.5() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000372 use_php 5.5
Bo Yangfd332d12016-09-30 00:07:47 +0000373 rm -rf vendor
374 cp -r /usr/local/vendor-5.5 vendor
375 ./vendor/bin/phpunit
376}
377
Bo Yang34cdaf42016-10-03 21:59:58 +0000378build_php5.5_c() {
379 use_php 5.5
380 cd php/tests && /bin/bash ./test.sh && cd ../..
381}
Bo Yang34cdaf42016-10-03 21:59:58 +0000382
Bo Yangc96dd662016-10-04 17:32:08 +0000383build_php5.5_zts_c() {
384 use_php_zts 5.5
Bo Yang4f3d20a2016-10-05 10:54:39 -0700385 wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
Bo Yangc96dd662016-10-04 17:32:08 +0000386 cd php/tests && /bin/bash ./test.sh && cd ../..
387}
388
Paul Yang51c5ff82016-10-25 17:27:05 -0700389build_php5.5_32() {
390 use_php_bc 5.5
391 rm -rf vendor
392 cp -r /usr/local/vendor-5.5 vendor
393 ./vendor/bin/phpunit
394}
395
Paul Yangdf839072016-11-10 11:20:50 -0800396build_php5.5_c_32() {
397 use_php_bc 5.5
398 wget https://phar.phpunit.de/phpunit-old.phar -O /usr/bin/phpunit
399 cd php/tests && /bin/bash ./test.sh && cd ../..
400}
401
Bo Yangfd332d12016-09-30 00:07:47 +0000402build_php5.6() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000403 use_php 5.6
Bo Yangfd332d12016-09-30 00:07:47 +0000404 rm -rf vendor
405 cp -r /usr/local/vendor-5.6 vendor
406 ./vendor/bin/phpunit
407}
408
Bo Yang34cdaf42016-10-03 21:59:58 +0000409build_php5.6_c() {
410 use_php 5.6
Bo Yangfd332d12016-09-30 00:07:47 +0000411 cd php/tests && /bin/bash ./test.sh && cd ../..
412}
413
Bo Yang63448e62016-10-05 18:28:13 -0700414build_php5.6_mac() {
415 # Install PHP
416 curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6
Paul Yang1f2dbc82016-11-08 11:38:34 -0800417 PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time
418 export PATH="$PHP_FOLDER/bin:$PATH"
Bo Yang63448e62016-10-05 18:28:13 -0700419
420 # Install phpunit
421 curl https://phar.phpunit.de/phpunit.phar -L -o phpunit.phar
422 chmod +x phpunit.phar
423 sudo mv phpunit.phar /usr/local/bin/phpunit
424
425 # Install valgrind
426 echo "#! /bin/bash" > valgrind
427 chmod ug+x valgrind
428 sudo mv valgrind /usr/local/bin/valgrind
429
430 # Test
431 cd php/tests && /bin/bash ./test.sh && cd ../..
432}
433
Bo Yangfd332d12016-09-30 00:07:47 +0000434build_php7.0() {
Bo Yangc8bd36e2016-09-30 19:07:33 +0000435 use_php 7.0
Bo Yangfd332d12016-09-30 00:07:47 +0000436 rm -rf vendor
437 cp -r /usr/local/vendor-7.0 vendor
438 ./vendor/bin/phpunit
439}
440
Bo Yang34cdaf42016-10-03 21:59:58 +0000441build_php7.0_c() {
442 use_php 7.0
443 cd php/tests && /bin/bash ./test.sh && cd ../..
444}
445
Bo Yangc8bd36e2016-09-30 19:07:33 +0000446build_php_all() {
447 build_php5.5
448 build_php5.6
449 build_php7.0
450 build_php5.5_c
451 build_php5.6_c
452 # build_php7.0_c
Bo Yangc96dd662016-10-04 17:32:08 +0000453 build_php5.5_zts_c
Bo Yangc8bd36e2016-09-30 19:07:33 +0000454}
455
Paul Yang51c5ff82016-10-25 17:27:05 -0700456build_php_all_32() {
457 build_php5.5_32
Paul Yangdf839072016-11-10 11:20:50 -0800458 build_php5.5_c_32
Paul Yang51c5ff82016-10-25 17:27:05 -0700459}
460
Josh Haberman738393b2016-02-18 20:10:23 -0800461# Note: travis currently does not support testing more than one language so the
462# .travis.yml cheats and claims to only be cpp. If they add multiple language
463# support, this should probably get updated to install steps and/or
464# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
465
466# .travis.yml uses matrix.exclude to block the cases where app-get can't be
467# use to install things.
468
469# -------- main --------
470
Josh Haberman738393b2016-02-18 20:10:23 -0800471if [ "$#" -ne 1 ]; then
472 echo "
473Usage: $0 { cpp |
Feng Xiaoa4f68b12016-07-19 17:20:31 -0700474 cpp_distcheck |
Josh Haberman738393b2016-02-18 20:10:23 -0800475 csharp |
Josh Haberman738393b2016-02-18 20:10:23 -0800476 java_jdk7 |
477 java_oracle7 |
Feng Xiaobaa40232016-07-29 14:11:21 -0700478 java_compatibility |
Josh Haberman738393b2016-02-18 20:10:23 -0800479 javanano_jdk7 |
480 javanano_oracle7 |
481 objectivec_ios |
Thomas Van Lenten368a2f42016-05-24 11:27:33 -0400482 objectivec_ios_debug |
483 objectivec_ios_release |
Josh Haberman738393b2016-02-18 20:10:23 -0800484 objectivec_osx |
Sergio Campamáf0c14922016-06-14 11:26:01 -0700485 objectivec_cocoapods_integration |
Josh Haberman738393b2016-02-18 20:10:23 -0800486 python |
487 python_cpp |
Josh Habermanffc81182016-02-22 15:39:29 -0800488 ruby21 |
489 ruby22 |
Feng Xiao20fbb352016-07-21 18:04:56 -0700490 jruby |
Bo Yangfd332d12016-09-30 00:07:47 +0000491 ruby_all |
492 php5.5 |
493 php5.5_c |
494 php5.6 |
495 php5.6_c |
496 php7.0 |
Bo Yangc8bd36e2016-09-30 19:07:33 +0000497 php7.0_c |
498 php_all)
Josh Haberman738393b2016-02-18 20:10:23 -0800499"
500 exit 1
501fi
502
503set -e # exit immediately on error
504set -x # display all commands
505eval "build_$1"