Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 1 | #!/bin/bash |
Josh Haberman | 67c727c | 2016-03-04 14:21:18 -0800 | [diff] [blame] | 2 | # |
Feng Xiao | 9de4e64 | 2018-07-13 16:55:32 -0700 | [diff] [blame] | 3 | # 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 Haberman | 0f8c25d | 2016-02-19 09:11:38 -0800 | [diff] [blame] | 6 | |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 7 | # For when some other test needs the C++ main build, including protoc and |
| 8 | # libprotobuf. |
| 9 | internal_build_cpp() { |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 10 | if [ -f src/protoc ]; then |
| 11 | # Already built. |
| 12 | return |
| 13 | fi |
| 14 | |
Carlos O'Ryan | 3c5442a | 2018-03-26 16:54:32 -0400 | [diff] [blame] | 15 | # Initialize any submodules. |
| 16 | git submodule update --init --recursive |
| 17 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 18 | ./autogen.sh |
Ben Wolsieffer | 56b40a8 | 2018-10-04 20:25:10 -0400 | [diff] [blame] | 19 | ./configure CXXFLAGS="-fPIC -std=c++11" # -fPIC is needed for python cpp test. |
| 20 | # See python/setup.py for more details |
Joshua Haberman | f5e8ee4 | 2019-03-06 12:04:17 -0800 | [diff] [blame] | 21 | make -j$(nproc) |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 22 | } |
| 23 | |
| 24 | build_cpp() { |
| 25 | internal_build_cpp |
Joshua Haberman | f5e8ee4 | 2019-03-06 12:04:17 -0800 | [diff] [blame] | 26 | make check -j$(nproc) || (cat src/test-suite.log; false) |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 27 | cd conformance && make test_cpp && cd .. |
Josh Haberman | cb36bde | 2016-04-29 09:52:20 -0700 | [diff] [blame] | 28 | |
Thomas Van Lenten | bc9d077 | 2016-12-08 16:19:58 -0500 | [diff] [blame] | 29 | # The benchmark code depends on cmake, so test if it is installed before |
| 30 | # trying to do the build. |
Thomas Van Lenten | bc9d077 | 2016-12-08 16:19:58 -0500 | [diff] [blame] | 31 | if [[ $(type cmake 2>/dev/null) ]]; then |
| 32 | # Verify benchmarking code can build successfully. |
Yilun Chong | 34843ed | 2017-12-13 14:34:52 -0800 | [diff] [blame] | 33 | cd benchmarks && make cpp-benchmark && cd .. |
Thomas Van Lenten | bc9d077 | 2016-12-08 16:19:58 -0500 | [diff] [blame] | 34 | else |
| 35 | echo "" |
| 36 | echo "WARNING: Skipping validation of the bench marking code, cmake isn't installed." |
| 37 | echo "" |
| 38 | fi |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 39 | } |
| 40 | |
Hao Nguyen | 4f8a635 | 2019-01-23 10:02:51 -0800 | [diff] [blame] | 41 | build_cpp_tcmalloc() { |
| 42 | internal_build_cpp |
| 43 | ./configure LIBS=-ltcmalloc && make clean && make \ |
| 44 | PTHREAD_CFLAGS='-pthread -DGOOGLE_PROTOBUF_HEAP_CHECK_DRACONIAN' \ |
| 45 | check |
| 46 | cd src |
Adam Cozzette | d135f07 | 2019-01-25 10:28:52 -0800 | [diff] [blame] | 47 | PPROF_PATH=/usr/bin/google-pprof HEAPCHECK=strict ./protobuf-test |
Hao Nguyen | 4f8a635 | 2019-01-23 10:02:51 -0800 | [diff] [blame] | 48 | } |
| 49 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 50 | build_cpp_distcheck() { |
Adam Cozzette | 45aba80 | 2019-03-11 14:39:49 -0700 | [diff] [blame] | 51 | grep -q -- "-Og" src/Makefile.am && |
| 52 | echo "The -Og flag is incompatible with Clang versions older than 4.0." && |
| 53 | exit 1 |
| 54 | |
Carlos O'Ryan | 3c5442a | 2018-03-26 16:54:32 -0400 | [diff] [blame] | 55 | # Initialize any submodules. |
| 56 | git submodule update --init --recursive |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 57 | ./autogen.sh |
| 58 | ./configure |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 59 | make dist |
| 60 | |
| 61 | # List all files that should be included in the distribution package. |
Jisi Liu | 55fdbe5 | 2017-08-23 11:35:48 -0700 | [diff] [blame] | 62 | git ls-files | grep "^\(java\|python\|objectivec\|csharp\|js\|ruby\|php\|cmake\|examples\|src/google/protobuf/.*\.proto\)" |\ |
Jie Luo | ea51149 | 2017-01-23 15:11:00 -0800 | [diff] [blame] | 63 | grep -v ".gitignore" | grep -v "java/compatibility_tests" |\ |
Jie Luo | 7288689 | 2017-02-09 16:49:52 -0800 | [diff] [blame] | 64 | grep -v "python/compatibility_tests" | grep -v "csharp/compatibility_tests" > dist.lst |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 65 | # Unzip the dist tar file. |
| 66 | DIST=`ls *.tar.gz` |
| 67 | tar -xf $DIST |
| 68 | cd ${DIST//.tar.gz} |
| 69 | # Check if every file exists in the dist tar file. |
| 70 | FILES_MISSING="" |
| 71 | for FILE in $(<../dist.lst); do |
Feng Xiao | acd5b05 | 2018-08-09 21:21:01 -0700 | [diff] [blame] | 72 | [ -f "$FILE" ] || { |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 73 | echo "$FILE is not found!" |
| 74 | FILES_MISSING="$FILE $FILES_MISSING" |
Feng Xiao | acd5b05 | 2018-08-09 21:21:01 -0700 | [diff] [blame] | 75 | } |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 76 | done |
| 77 | cd .. |
| 78 | if [ ! -z "$FILES_MISSING" ]; then |
| 79 | echo "Missing files in EXTRA_DIST: $FILES_MISSING" |
| 80 | exit 1 |
| 81 | fi |
| 82 | |
| 83 | # Do the regular dist-check for C++. |
Joshua Haberman | f5e8ee4 | 2019-03-06 12:04:17 -0800 | [diff] [blame] | 84 | make distcheck -j$(nproc) |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 85 | } |
| 86 | |
Hao Nguyen | f85c823 | 2019-03-07 14:34:28 -0800 | [diff] [blame] | 87 | build_dist_install() { |
| 88 | # Initialize any submodules. |
| 89 | git submodule update --init --recursive |
| 90 | ./autogen.sh |
| 91 | ./configure |
| 92 | make dist |
| 93 | |
| 94 | # Unzip the dist tar file and install it. |
| 95 | DIST=`ls *.tar.gz` |
| 96 | tar -xf $DIST |
| 97 | pushd ${DIST//.tar.gz} |
| 98 | ./configure && make check -j4 && make install |
| 99 | |
| 100 | export LD_LIBRARY_PATH=/usr/local/lib |
| 101 | |
| 102 | # Try to install Java |
| 103 | pushd java |
| 104 | use_java jdk7 |
| 105 | $MVN install |
| 106 | popd |
| 107 | |
| 108 | # Try to install Python |
| 109 | virtualenv --no-site-packages venv |
| 110 | source venv/bin/activate |
| 111 | pushd python |
| 112 | python setup.py clean build sdist |
| 113 | pip install dist/protobuf-*.tar.gz |
| 114 | popd |
| 115 | deactivate |
| 116 | rm -rf python/venv |
| 117 | } |
| 118 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 119 | build_csharp() { |
Jon Skeet | 9a9a66e | 2017-10-25 08:03:50 +0100 | [diff] [blame] | 120 | # Required for conformance tests and to regenerate protos. |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 121 | internal_build_cpp |
Josh Haberman | ffc8118 | 2016-02-22 15:39:29 -0800 | [diff] [blame] | 122 | NUGET=/usr/local/bin/nuget.exe |
Jon Skeet | b6defa7 | 2015-08-04 10:01:40 +0100 | [diff] [blame] | 123 | |
Jan Tattermusch | 67fee07 | 2019-03-12 04:48:10 -0400 | [diff] [blame] | 124 | # Disable some unwanted dotnet options |
| 125 | export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=true |
| 126 | export DOTNET_CLI_TELEMETRY_OPTOUT=true |
| 127 | |
| 128 | # TODO(jtattermusch): is this still needed with "first time experience" |
| 129 | # disabled? |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 130 | # Perform "dotnet new" once to get the setup preprocessing out of the |
| 131 | # way. That spews a lot of output (including backspaces) into logs |
| 132 | # otherwise, and can cause problems. It doesn't matter if this step |
| 133 | # is performed multiple times; it's cheap after the first time anyway. |
Jon Skeet | f26e8c2 | 2017-05-04 08:51:46 +0100 | [diff] [blame] | 134 | # (It also doesn't matter if it's unnecessary, which it will be on some |
| 135 | # systems. It's necessary on Jenkins in order to avoid unprintable |
| 136 | # characters appearing in the JUnit output.) |
Jon Skeet | 10a8fb4 | 2016-07-14 22:01:47 +0100 | [diff] [blame] | 137 | mkdir dotnettmp |
| 138 | (cd dotnettmp; dotnet new > /dev/null) |
| 139 | rm -rf dotnettmp |
| 140 | |
Jon Skeet | 9a9a66e | 2017-10-25 08:03:50 +0100 | [diff] [blame] | 141 | # Check that the protos haven't broken C# codegen. |
| 142 | # TODO(jonskeet): Fail if regenerating creates any changes. |
| 143 | csharp/generate_protos.sh |
Brent Shaffer | 6737954 | 2018-05-23 16:43:30 -0700 | [diff] [blame] | 144 | |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 145 | csharp/buildall.sh |
Josh Haberman | e891c29 | 2015-12-30 16:03:49 -0800 | [diff] [blame] | 146 | cd conformance && make test_csharp && cd .. |
Jie Luo | 7288689 | 2017-02-09 16:49:52 -0800 | [diff] [blame] | 147 | |
| 148 | # Run csharp compatibility test between 3.0.0 and the current version. |
| 149 | csharp/compatibility_tests/v3.0.0/test.sh 3.0.0 |
Jan Tattermusch | ddb36ef | 2015-05-18 17:34:02 -0700 | [diff] [blame] | 150 | } |
| 151 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 152 | build_golang() { |
| 153 | # Go build needs `protoc`. |
| 154 | internal_build_cpp |
| 155 | # Add protoc to the path so that the examples build finds it. |
| 156 | export PATH="`pwd`/src:$PATH" |
| 157 | |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 158 | export GOPATH="$HOME/gocode" |
Feng Xiao | a0a17e2 | 2018-08-23 15:35:52 -0700 | [diff] [blame] | 159 | mkdir -p "$GOPATH/src/github.com/protocolbuffers" |
Feng Xiao | afe98de | 2018-08-22 11:55:30 -0700 | [diff] [blame] | 160 | rm -f "$GOPATH/src/github.com/protocolbuffers/protobuf" |
| 161 | ln -s "`pwd`" "$GOPATH/src/github.com/protocolbuffers/protobuf" |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 162 | export PATH="$GOPATH/bin:$PATH" |
| 163 | go get github.com/golang/protobuf/protoc-gen-go |
| 164 | |
Feng Xiao | 8136ccb | 2017-09-12 12:00:20 -0700 | [diff] [blame] | 165 | cd examples && PROTO_PATH="-I../src -I." make gotest && cd .. |
Tim Swast | 7e31c4d | 2015-11-20 15:32:53 -0800 | [diff] [blame] | 166 | } |
| 167 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 168 | use_java() { |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 169 | version=$1 |
| 170 | case "$version" in |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 171 | jdk7) |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 172 | export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 173 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 174 | ;; |
| 175 | oracle7) |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 176 | export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 177 | export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 178 | ;; |
| 179 | esac |
| 180 | |
Feng Xiao | 9de4e64 | 2018-07-13 16:55:32 -0700 | [diff] [blame] | 181 | MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository |
Yilun Chong | 2b7ee38 | 2018-09-23 17:07:02 -0700 | [diff] [blame] | 182 | MVN="$MVN -e -X -Dhttps.protocols=TLSv1.2 -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY" |
Josh Haberman | 1ee0fda | 2016-03-03 16:02:55 -0800 | [diff] [blame] | 183 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 184 | which java |
| 185 | java -version |
Feng Xiao | ad49ed7 | 2016-07-21 11:37:46 -0700 | [diff] [blame] | 186 | $MVN -version |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 189 | # --batch-mode supresses download progress output that spams the logs. |
Josh Haberman | b28b3f6 | 2016-02-20 12:17:10 -0800 | [diff] [blame] | 190 | MVN="mvn --batch-mode" |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 191 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 192 | build_java() { |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 193 | version=$1 |
| 194 | dir=java_$version |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 195 | # Java build needs `protoc`. |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 196 | internal_build_cpp |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 197 | cp -r java $dir |
| 198 | cd $dir && $MVN clean && $MVN test |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 199 | cd ../.. |
| 200 | } |
| 201 | |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 202 | # The conformance tests are hard-coded to work with the $ROOT/java directory. |
| 203 | # So this can't run in parallel with two different sets of tests. |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 204 | build_java_with_conformance_tests() { |
| 205 | # Java build needs `protoc`. |
| 206 | internal_build_cpp |
Josh Haberman | d08c39c | 2016-02-20 12:03:39 -0800 | [diff] [blame] | 207 | cd java && $MVN test && $MVN install |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 208 | cd util && $MVN package assembly:single |
Feng Xiao | af81dcf | 2015-12-21 03:25:59 -0800 | [diff] [blame] | 209 | cd ../.. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 210 | cd conformance && make test_java && cd .. |
| 211 | } |
| 212 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 213 | build_java_jdk7() { |
| 214 | use_java jdk7 |
Feng Xiao | 9e5fb55 | 2015-12-21 11:08:18 -0800 | [diff] [blame] | 215 | build_java_with_conformance_tests |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 216 | } |
| 217 | build_java_oracle7() { |
| 218 | use_java oracle7 |
Josh Haberman | 2f3f1de | 2016-03-01 15:37:17 -0800 | [diff] [blame] | 219 | build_java oracle7 |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 220 | } |
Feng Xiao | baa4023 | 2016-07-29 14:11:21 -0700 | [diff] [blame] | 221 | build_java_compatibility() { |
| 222 | use_java jdk7 |
| 223 | internal_build_cpp |
| 224 | # Use the unit-tests extraced from 2.5.0 to test the compatibilty between |
| 225 | # 3.0.0-beta-4 and the current version. |
| 226 | cd java/compatibility_tests/v2.5.0 |
| 227 | ./test.sh 3.0.0-beta-4 |
| 228 | } |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 229 | |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 230 | build_objectivec_ios() { |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 231 | # Reused the build script that takes care of configuring and ensuring things |
| 232 | # are up to date. The OS X test runs the objc conformance test, so skip it |
| 233 | # here. |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 234 | objectivec/DevTools/full_mac_build.sh \ |
Thomas Van Lenten | bd00671 | 2019-01-07 16:42:22 -0500 | [diff] [blame] | 235 | --core-only --skip-xcode-osx --skip-xcode-tvos --skip-objc-conformance "$@" |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 236 | } |
| 237 | |
| 238 | build_objectivec_ios_debug() { |
| 239 | build_objectivec_ios --skip-xcode-release |
| 240 | } |
| 241 | |
| 242 | build_objectivec_ios_release() { |
| 243 | build_objectivec_ios --skip-xcode-debug |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 244 | } |
| 245 | |
| 246 | build_objectivec_osx() { |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 247 | # Reused the build script that takes care of configuring and ensuring things |
| 248 | # are up to date. |
| 249 | objectivec/DevTools/full_mac_build.sh \ |
Thomas Van Lenten | bd00671 | 2019-01-07 16:42:22 -0500 | [diff] [blame] | 250 | --core-only --skip-xcode-ios --skip-xcode-tvos |
| 251 | } |
| 252 | |
| 253 | build_objectivec_tvos() { |
| 254 | # Reused the build script that takes care of configuring and ensuring things |
| 255 | # are up to date. The OS X test runs the objc conformance test, so skip it |
| 256 | # here. |
| 257 | objectivec/DevTools/full_mac_build.sh \ |
| 258 | --core-only --skip-xcode-ios --skip-xcode-osx --skip-objc-conformance "$@" |
| 259 | } |
| 260 | |
| 261 | build_objectivec_tvos_debug() { |
| 262 | build_objectivec_tvos --skip-xcode-release |
| 263 | } |
| 264 | |
| 265 | build_objectivec_tvos_release() { |
| 266 | build_objectivec_tvos --skip-xcode-debug |
Thomas Van Lenten | 9642b82 | 2015-06-10 17:21:23 -0400 | [diff] [blame] | 267 | } |
Dan O'Reilly | 5de2a81 | 2015-08-20 18:19:56 -0400 | [diff] [blame] | 268 | |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 269 | build_objectivec_cocoapods_integration() { |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 270 | # Update pod to the latest version. |
Yilun Chong | 89b914f | 2019-02-26 12:52:06 -0800 | [diff] [blame] | 271 | gem install cocoapods --no_document |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 272 | objectivec/Tests/CocoaPods/run_tests.sh |
| 273 | } |
| 274 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 275 | build_python() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 276 | internal_build_cpp |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 277 | cd python |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 278 | if [ $(uname -s) == "Linux" ]; then |
Jie Luo | 610e433 | 2017-08-22 16:23:21 -0700 | [diff] [blame] | 279 | envlist=py\{27,33,34,35,36\}-python |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 280 | else |
| 281 | envlist=py27-python |
| 282 | fi |
| 283 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 284 | cd .. |
| 285 | } |
| 286 | |
Paul Yang | 4dec4f9 | 2018-12-18 18:07:24 -0800 | [diff] [blame] | 287 | build_python_version() { |
| 288 | internal_build_cpp |
| 289 | cd python |
| 290 | envlist=$1 |
| 291 | tox -e $envlist |
| 292 | cd .. |
| 293 | } |
| 294 | |
| 295 | build_python27() { |
| 296 | build_python_version py27-python |
| 297 | } |
| 298 | |
| 299 | build_python33() { |
| 300 | build_python_version py33-python |
| 301 | } |
| 302 | |
| 303 | build_python34() { |
| 304 | build_python_version py34-python |
| 305 | } |
| 306 | |
| 307 | build_python35() { |
| 308 | build_python_version py35-python |
| 309 | } |
| 310 | |
| 311 | build_python36() { |
| 312 | build_python_version py36-python |
| 313 | } |
| 314 | |
| 315 | build_python37() { |
| 316 | build_python_version py37-python |
| 317 | } |
| 318 | |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 319 | build_python_cpp() { |
Josh Haberman | 181c7f2 | 2015-07-15 11:05:10 -0700 | [diff] [blame] | 320 | internal_build_cpp |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 321 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 322 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 323 | cd python |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 324 | if [ $(uname -s) == "Linux" ]; then |
Jie Luo | 610e433 | 2017-08-22 16:23:21 -0700 | [diff] [blame] | 325 | envlist=py\{27,33,34,35,36\}-cpp |
Dan O'Reilly | 76f8a3f | 2015-08-21 18:51:47 -0400 | [diff] [blame] | 326 | else |
| 327 | envlist=py27-cpp |
| 328 | fi |
| 329 | tox -e $envlist |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 330 | cd .. |
| 331 | } |
| 332 | |
Paul Yang | 4dec4f9 | 2018-12-18 18:07:24 -0800 | [diff] [blame] | 333 | build_python_cpp_version() { |
| 334 | internal_build_cpp |
| 335 | export LD_LIBRARY_PATH=../src/.libs # for Linux |
| 336 | export DYLD_LIBRARY_PATH=../src/.libs # for OS X |
| 337 | cd python |
| 338 | envlist=$1 |
| 339 | tox -e $envlist |
| 340 | cd .. |
| 341 | } |
| 342 | |
| 343 | build_python27_cpp() { |
| 344 | build_python_cpp_version py27-cpp |
| 345 | } |
| 346 | |
| 347 | build_python33_cpp() { |
| 348 | build_python_cpp_version py33-cpp |
| 349 | } |
| 350 | |
| 351 | build_python34_cpp() { |
| 352 | build_python_cpp_version py34-cpp |
| 353 | } |
| 354 | |
| 355 | build_python35_cpp() { |
| 356 | build_python_cpp_version py35-cpp |
| 357 | } |
| 358 | |
| 359 | build_python36_cpp() { |
| 360 | build_python_cpp_version py36-cpp |
| 361 | } |
| 362 | |
| 363 | build_python37_cpp() { |
| 364 | build_python_cpp_version py37-cpp |
| 365 | } |
| 366 | |
Jie Luo | ea51149 | 2017-01-23 15:11:00 -0800 | [diff] [blame] | 367 | build_python_compatibility() { |
| 368 | internal_build_cpp |
| 369 | # Use the unit-tests extraced from 2.5.0 to test the compatibilty. |
| 370 | cd python/compatibility_tests/v2.5.0 |
| 371 | # Test between 2.5.0 and the current version. |
| 372 | ./test.sh 2.5.0 |
| 373 | # Test between 3.0.0-beta-1 and the current version. |
| 374 | ./test.sh 3.0.0-beta-1 |
| 375 | } |
| 376 | |
Paul Yang | 78ba021 | 2018-07-02 15:11:36 -0700 | [diff] [blame] | 377 | build_ruby23() { |
| 378 | internal_build_cpp # For conformance tests. |
Paul Yang | 333b3ce | 2018-10-18 11:16:55 -0700 | [diff] [blame] | 379 | cd ruby && bash travis-test.sh ruby-2.3.8 && cd .. |
Paul Yang | 78ba021 | 2018-07-02 15:11:36 -0700 | [diff] [blame] | 380 | } |
| 381 | build_ruby24() { |
| 382 | internal_build_cpp # For conformance tests. |
| 383 | cd ruby && bash travis-test.sh ruby-2.4 && cd .. |
| 384 | } |
| 385 | build_ruby25() { |
| 386 | internal_build_cpp # For conformance tests. |
Paul Yang | 333b3ce | 2018-10-18 11:16:55 -0700 | [diff] [blame] | 387 | cd ruby && bash travis-test.sh ruby-2.5.1 && cd .. |
Paul Yang | 78ba021 | 2018-07-02 15:11:36 -0700 | [diff] [blame] | 388 | } |
Paul Yang | de9e1a0 | 2019-01-03 14:25:50 -0800 | [diff] [blame] | 389 | build_ruby26() { |
| 390 | internal_build_cpp # For conformance tests. |
| 391 | cd ruby && bash travis-test.sh ruby-2.6.0 && cd .. |
Chris Fallin | 20e94b2 | 2015-05-13 16:43:48 -0700 | [diff] [blame] | 392 | } |
| 393 | |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 394 | build_javascript() { |
| 395 | internal_build_cpp |
Josh Haberman | 0d2d8bc | 2015-12-28 06:43:42 -0800 | [diff] [blame] | 396 | cd js && npm install && npm test && cd .. |
Josh Haberman | f873d32 | 2016-06-08 12:38:15 -0700 | [diff] [blame] | 397 | cd conformance && make test_nodejs && cd .. |
Josh Haberman | e9cf31e | 2015-12-21 15:18:17 -0800 | [diff] [blame] | 398 | } |
| 399 | |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 400 | generate_php_test_proto() { |
| 401 | internal_build_cpp |
| 402 | pushd php/tests |
| 403 | # Generate test file |
| 404 | rm -rf generated |
| 405 | mkdir generated |
Bo Yang | f46a01d | 2017-09-12 15:04:34 -0700 | [diff] [blame] | 406 | ../../src/protoc --php_out=generated \ |
michaelbausor | 6a51c03 | 2018-10-07 16:56:41 -0700 | [diff] [blame] | 407 | -I../../src -I. \ |
Brent Shaffer | 6737954 | 2018-05-23 16:43:30 -0700 | [diff] [blame] | 408 | proto/empty/echo.proto \ |
Bo Yang | f46a01d | 2017-09-12 15:04:34 -0700 | [diff] [blame] | 409 | proto/test.proto \ |
| 410 | proto/test_include.proto \ |
| 411 | proto/test_no_namespace.proto \ |
| 412 | proto/test_prefix.proto \ |
| 413 | proto/test_php_namespace.proto \ |
| 414 | proto/test_empty_php_namespace.proto \ |
| 415 | proto/test_reserved_enum_lower.proto \ |
| 416 | proto/test_reserved_enum_upper.proto \ |
| 417 | proto/test_reserved_enum_value_lower.proto \ |
| 418 | proto/test_reserved_enum_value_upper.proto \ |
| 419 | proto/test_reserved_message_lower.proto \ |
| 420 | proto/test_reserved_message_upper.proto \ |
| 421 | proto/test_service.proto \ |
| 422 | proto/test_service_namespace.proto \ |
michaelbausor | 6a51c03 | 2018-10-07 16:56:41 -0700 | [diff] [blame] | 423 | proto/test_wrapper_type_setters.proto \ |
Paul Yang | c15a326 | 2017-08-02 07:42:27 -0700 | [diff] [blame] | 424 | proto/test_descriptors.proto |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 425 | pushd ../../src |
Paul Yang | bcda919 | 2017-11-03 12:30:09 -0700 | [diff] [blame] | 426 | ./protoc --php_out=../php/tests/generated -I../php/tests -I. \ |
| 427 | ../php/tests/proto/test_import_descriptor_proto.proto |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 428 | popd |
| 429 | popd |
| 430 | } |
| 431 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 432 | use_php() { |
| 433 | VERSION=$1 |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 434 | export PATH=/usr/local/php-${VERSION}/bin:$PATH |
| 435 | export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$CPLUS_INCLUDE_PATH |
| 436 | export C_INCLUDE_PATH=/usr/local/php-${VERSION}/include/php/main:/usr/local/php-${VERSION}/include/php/:$C_INCLUDE_PATH |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 437 | generate_php_test_proto |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 438 | } |
| 439 | |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 440 | use_php_zts() { |
| 441 | VERSION=$1 |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 442 | export PATH=/usr/local/php-${VERSION}-zts/bin:$PATH |
| 443 | export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$CPLUS_INCLUDE_PATH |
| 444 | export C_INCLUDE_PATH=/usr/local/php-${VERSION}-zts/include/php/main:/usr/local/php-${VERSION}-zts/include/php/:$C_INCLUDE_PATH |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 445 | generate_php_test_proto |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 446 | } |
| 447 | |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 448 | use_php_bc() { |
| 449 | VERSION=$1 |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 450 | export PATH=/usr/local/php-${VERSION}-bc/bin:$PATH |
| 451 | export CPLUS_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$CPLUS_INCLUDE_PATH |
| 452 | export C_INCLUDE_PATH=/usr/local/php-${VERSION}-bc/include/php/main:/usr/local/php-${VERSION}-bc/include/php/:$C_INCLUDE_PATH |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 453 | generate_php_test_proto |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 454 | } |
| 455 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 456 | build_php5.5() { |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 457 | use_php 5.5 |
Paul Yang | dd8d5f5 | 2017-03-08 14:31:34 -0800 | [diff] [blame] | 458 | |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 459 | pushd php |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 460 | rm -rf vendor |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 461 | composer update |
| 462 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 463 | popd |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 464 | pushd conformance |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 465 | make test_php |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 466 | popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 467 | } |
| 468 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 469 | build_php5.5_c() { |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 470 | use_php 5.5 |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 471 | pushd php/tests |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 472 | /bin/bash ./test.sh 5.5 |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 473 | popd |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 474 | # TODO(teboring): Add it back |
| 475 | # pushd conformance |
| 476 | # make test_php_c |
| 477 | # popd |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 478 | } |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 479 | |
David Supplee | 93533f7 | 2019-03-12 21:30:06 -0700 | [diff] [blame] | 480 | build_php5.5_mixed() { |
| 481 | use_php 5.5 |
| 482 | pushd php |
| 483 | rm -rf vendor |
| 484 | composer update |
| 485 | /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf |
| 486 | php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit |
| 487 | popd |
| 488 | } |
| 489 | |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 490 | build_php5.5_zts_c() { |
| 491 | use_php_zts 5.5 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 492 | cd php/tests && /bin/bash ./test.sh 5.5-zts && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 493 | # TODO(teboring): Add it back |
| 494 | # pushd conformance |
| 495 | # make test_php_zts_c |
| 496 | # popd |
Paul Yang | df83907 | 2016-11-10 11:20:50 -0800 | [diff] [blame] | 497 | } |
| 498 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 499 | build_php5.6() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 500 | use_php 5.6 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 501 | pushd php |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 502 | rm -rf vendor |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 503 | composer update |
| 504 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 505 | popd |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 506 | pushd conformance |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 507 | make test_php |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 508 | popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 509 | } |
| 510 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 511 | build_php5.6_c() { |
| 512 | use_php 5.6 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 513 | cd php/tests && /bin/bash ./test.sh 5.6 && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 514 | # TODO(teboring): Add it back |
| 515 | # pushd conformance |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 516 | # make test_php_c |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 517 | # popd |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 518 | } |
| 519 | |
David Supplee | 93533f7 | 2019-03-12 21:30:06 -0700 | [diff] [blame] | 520 | build_php5.6_mixed() { |
| 521 | use_php 5.6 |
| 522 | pushd php |
| 523 | rm -rf vendor |
| 524 | composer update |
| 525 | /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf |
| 526 | php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit |
| 527 | popd |
| 528 | } |
| 529 | |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 530 | build_php5.6_zts_c() { |
| 531 | use_php_zts 5.6 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 532 | cd php/tests && /bin/bash ./test.sh 5.6-zts && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 533 | # TODO(teboring): Add it back |
| 534 | # pushd conformance |
| 535 | # make test_php_zts_c |
| 536 | # popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 537 | } |
| 538 | |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 539 | build_php5.6_mac() { |
Paul Yang | 46ae90d | 2016-12-08 11:16:49 -0800 | [diff] [blame] | 540 | generate_php_test_proto |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 541 | # Install PHP |
| 542 | curl -s https://php-osx.liip.ch/install.sh | bash -s 5.6 |
Paul Yang | 1f2dbc8 | 2016-11-08 11:38:34 -0800 | [diff] [blame] | 543 | PHP_FOLDER=`find /usr/local -type d -name "php5-5.6*"` # The folder name may change upon time |
| 544 | export PATH="$PHP_FOLDER/bin:$PATH" |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 545 | |
| 546 | # Install phpunit |
Bo Yang | 8400e29 | 2019-01-28 20:58:58 +0000 | [diff] [blame] | 547 | curl https://phar.phpunit.de/phpunit-5.6.8.phar -L -o phpunit.phar |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 548 | chmod +x phpunit.phar |
| 549 | sudo mv phpunit.phar /usr/local/bin/phpunit |
| 550 | |
| 551 | # Install valgrind |
| 552 | echo "#! /bin/bash" > valgrind |
| 553 | chmod ug+x valgrind |
| 554 | sudo mv valgrind /usr/local/bin/valgrind |
| 555 | |
| 556 | # Test |
| 557 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 558 | # TODO(teboring): Add it back |
| 559 | # pushd conformance |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 560 | # make test_php_c |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 561 | # popd |
Bo Yang | 63448e6 | 2016-10-05 18:28:13 -0700 | [diff] [blame] | 562 | } |
| 563 | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 564 | build_php7.0() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 565 | use_php 7.0 |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 566 | pushd php |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 567 | rm -rf vendor |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 568 | composer update |
| 569 | ./vendor/bin/phpunit |
Paul Yang | e3e38b8 | 2016-12-08 14:39:20 -0800 | [diff] [blame] | 570 | popd |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 571 | pushd conformance |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 572 | make test_php |
Paul Yang | 3975664 | 2017-02-01 12:47:58 -0800 | [diff] [blame] | 573 | popd |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 574 | } |
| 575 | |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 576 | build_php7.0_c() { |
| 577 | use_php 7.0 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 578 | cd php/tests && /bin/bash ./test.sh 7.0 && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 579 | # TODO(teboring): Add it back |
| 580 | # pushd conformance |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 581 | # make test_php_c |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 582 | # popd |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 583 | } |
| 584 | |
David Supplee | 93533f7 | 2019-03-12 21:30:06 -0700 | [diff] [blame] | 585 | build_php7.0_mixed() { |
| 586 | use_php 7.0 |
| 587 | pushd php |
| 588 | rm -rf vendor |
| 589 | composer update |
| 590 | /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf |
| 591 | php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit |
| 592 | popd |
| 593 | } |
| 594 | |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 595 | build_php7.0_zts_c() { |
| 596 | use_php_zts 7.0 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 597 | cd php/tests && /bin/bash ./test.sh 7.0-zts && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 598 | # TODO(teboring): Add it back. |
| 599 | # pushd conformance |
| 600 | # make test_php_zts_c |
| 601 | # popd |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 602 | } |
| 603 | |
| 604 | build_php7.0_mac() { |
| 605 | generate_php_test_proto |
| 606 | # Install PHP |
| 607 | curl -s https://php-osx.liip.ch/install.sh | bash -s 7.0 |
| 608 | PHP_FOLDER=`find /usr/local -type d -name "php7-7.0*"` # The folder name may change upon time |
| 609 | export PATH="$PHP_FOLDER/bin:$PATH" |
| 610 | |
| 611 | # Install phpunit |
| 612 | curl https://phar.phpunit.de/phpunit-5.6.0.phar -L -o phpunit.phar |
| 613 | chmod +x phpunit.phar |
| 614 | sudo mv phpunit.phar /usr/local/bin/phpunit |
| 615 | |
| 616 | # Install valgrind |
| 617 | echo "#! /bin/bash" > valgrind |
| 618 | chmod ug+x valgrind |
| 619 | sudo mv valgrind /usr/local/bin/valgrind |
| 620 | |
| 621 | # Test |
| 622 | cd php/tests && /bin/bash ./test.sh && cd ../.. |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 623 | # TODO(teboring): Add it back |
| 624 | # pushd conformance |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 625 | # make test_php_c |
Paul Yang | ecca6ea | 2017-06-30 12:14:09 -0700 | [diff] [blame] | 626 | # popd |
Bo Yang | 34cdaf4 | 2016-10-03 21:59:58 +0000 | [diff] [blame] | 627 | } |
| 628 | |
Paul Yang | 25abd7b | 2017-05-05 11:14:11 -0700 | [diff] [blame] | 629 | build_php_compatibility() { |
| 630 | internal_build_cpp |
| 631 | php/tests/compatibility_test.sh |
| 632 | } |
| 633 | |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 634 | build_php7.1() { |
| 635 | use_php 7.1 |
| 636 | pushd php |
| 637 | rm -rf vendor |
Paul Yang | d7c4409 | 2018-12-18 10:57:03 -0800 | [diff] [blame] | 638 | composer update |
| 639 | ./vendor/bin/phpunit |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 640 | popd |
| 641 | pushd conformance |
Paul Yang | bdcbcab | 2018-07-26 13:52:22 -0700 | [diff] [blame] | 642 | make test_php |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 643 | popd |
| 644 | } |
| 645 | |
| 646 | build_php7.1_c() { |
Paul Yang | bdcbcab | 2018-07-26 13:52:22 -0700 | [diff] [blame] | 647 | ENABLE_CONFORMANCE_TEST=$1 |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 648 | use_php 7.1 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 649 | cd php/tests && /bin/bash ./test.sh 7.1 && cd ../.. |
Paul Yang | bdcbcab | 2018-07-26 13:52:22 -0700 | [diff] [blame] | 650 | if [ "$ENABLE_CONFORMANCE_TEST" = "true" ] |
| 651 | then |
| 652 | pushd conformance |
| 653 | make test_php_c |
| 654 | popd |
| 655 | fi |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 656 | } |
| 657 | |
David Supplee | 93533f7 | 2019-03-12 21:30:06 -0700 | [diff] [blame] | 658 | build_php7.1_mixed() { |
| 659 | use_php 7.1 |
| 660 | pushd php |
| 661 | rm -rf vendor |
| 662 | composer update |
| 663 | /bin/bash ./tests/compile_extension.sh ./ext/google/protobuf |
| 664 | php -dextension=./ext/google/protobuf/modules/protobuf.so ./vendor/bin/phpunit |
| 665 | popd |
| 666 | } |
| 667 | |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 668 | build_php7.1_zts_c() { |
| 669 | use_php_zts 7.1 |
Paul Yang | 51293f3 | 2018-01-25 11:31:05 -0800 | [diff] [blame] | 670 | cd php/tests && /bin/bash ./test.sh 7.1-zts && cd ../.. |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 671 | pushd conformance |
| 672 | # make test_php_c |
| 673 | popd |
| 674 | } |
| 675 | |
Paul Yang | 25abd7b | 2017-05-05 11:14:11 -0700 | [diff] [blame] | 676 | build_php_all_32() { |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 677 | build_php5.5 |
| 678 | build_php5.6 |
| 679 | build_php7.0 |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 680 | build_php7.1 |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 681 | build_php5.5_c |
| 682 | build_php5.6_c |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 683 | build_php7.0_c |
Paul Yang | bdcbcab | 2018-07-26 13:52:22 -0700 | [diff] [blame] | 684 | build_php7.1_c $1 |
David Supplee | 93533f7 | 2019-03-12 21:30:06 -0700 | [diff] [blame] | 685 | build_php5.5_mixed |
| 686 | build_php5.6_mixed |
| 687 | build_php7.0_mixed |
| 688 | build_php7.1_mixed |
Bo Yang | c96dd66 | 2016-10-04 17:32:08 +0000 | [diff] [blame] | 689 | build_php5.5_zts_c |
Paul Yang | 190b527 | 2017-04-19 16:23:51 -0700 | [diff] [blame] | 690 | build_php5.6_zts_c |
| 691 | build_php7.0_zts_c |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 692 | build_php7.1_zts_c |
Paul Yang | 51c5ff8 | 2016-10-25 17:27:05 -0700 | [diff] [blame] | 693 | } |
| 694 | |
Paul Yang | 25abd7b | 2017-05-05 11:14:11 -0700 | [diff] [blame] | 695 | build_php_all() { |
Paul Yang | bdcbcab | 2018-07-26 13:52:22 -0700 | [diff] [blame] | 696 | build_php_all_32 true |
Paul Yang | 25abd7b | 2017-05-05 11:14:11 -0700 | [diff] [blame] | 697 | build_php_compatibility |
| 698 | } |
| 699 | |
Yilun Chong | 6adc3d7 | 2018-12-18 16:20:23 -0800 | [diff] [blame] | 700 | build_benchmark() { |
Yilun Chong | 152c830 | 2018-12-20 17:15:51 -0800 | [diff] [blame] | 701 | use_php 7.2 |
Yilun Chong | 6adc3d7 | 2018-12-18 16:20:23 -0800 | [diff] [blame] | 702 | cd kokoro/linux/benchmark && ./run.sh |
| 703 | } |
| 704 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 705 | # -------- main -------- |
| 706 | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 707 | if [ "$#" -ne 1 ]; then |
| 708 | echo " |
| 709 | Usage: $0 { cpp | |
Feng Xiao | a4f68b1 | 2016-07-19 17:20:31 -0700 | [diff] [blame] | 710 | cpp_distcheck | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 711 | csharp | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 712 | java_jdk7 | |
| 713 | java_oracle7 | |
Feng Xiao | baa4023 | 2016-07-29 14:11:21 -0700 | [diff] [blame] | 714 | java_compatibility | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 715 | objectivec_ios | |
Thomas Van Lenten | 368a2f4 | 2016-05-24 11:27:33 -0400 | [diff] [blame] | 716 | objectivec_ios_debug | |
| 717 | objectivec_ios_release | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 718 | objectivec_osx | |
Thomas Van Lenten | bd00671 | 2019-01-07 16:42:22 -0500 | [diff] [blame] | 719 | objectivec_tvos | |
| 720 | objectivec_tvos_debug | |
| 721 | objectivec_tvos_release | |
Sergio Campamá | f0c1492 | 2016-06-14 11:26:01 -0700 | [diff] [blame] | 722 | objectivec_cocoapods_integration | |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 723 | python | |
| 724 | python_cpp | |
Jie Luo | ea51149 | 2017-01-23 15:11:00 -0800 | [diff] [blame] | 725 | python_compatibility | |
Paul Yang | 39df66e | 2018-10-12 12:36:33 -0700 | [diff] [blame] | 726 | ruby23 | |
| 727 | ruby24 | |
| 728 | ruby25 | |
Paul Yang | de9e1a0 | 2019-01-03 14:25:50 -0800 | [diff] [blame] | 729 | ruby26 | |
Feng Xiao | 20fbb35 | 2016-07-21 18:04:56 -0700 | [diff] [blame] | 730 | jruby | |
Bo Yang | fd332d1 | 2016-09-30 00:07:47 +0000 | [diff] [blame] | 731 | ruby_all | |
| 732 | php5.5 | |
| 733 | php5.5_c | |
| 734 | php5.6 | |
| 735 | php5.6_c | |
| 736 | php7.0 | |
Bo Yang | c8bd36e | 2016-09-30 19:07:33 +0000 | [diff] [blame] | 737 | php7.0_c | |
Paul Yang | 25abd7b | 2017-05-05 11:14:11 -0700 | [diff] [blame] | 738 | php_compatibility | |
Paul Yang | 2231931 | 2017-05-10 15:59:59 -0700 | [diff] [blame] | 739 | php7.1 | |
| 740 | php7.1_c | |
Yilun Chong | 6adc3d7 | 2018-12-18 16:20:23 -0800 | [diff] [blame] | 741 | php_all | |
Hao Nguyen | f85c823 | 2019-03-07 14:34:28 -0800 | [diff] [blame] | 742 | dist_install | |
Yilun Chong | 152c830 | 2018-12-20 17:15:51 -0800 | [diff] [blame] | 743 | benchmark) |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 744 | " |
| 745 | exit 1 |
| 746 | fi |
| 747 | |
| 748 | set -e # exit immediately on error |
| 749 | set -x # display all commands |
Feng Xiao | 9de4e64 | 2018-07-13 16:55:32 -0700 | [diff] [blame] | 750 | cd $(dirname $0) |
Josh Haberman | 738393b | 2016-02-18 20:10:23 -0800 | [diff] [blame] | 751 | eval "build_$1" |