OLD | NEW |
1 #!/usr/bin/env bash | 1 #!/bin/bash |
| 2 # |
| 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. |
2 | 6 |
3 # Note: travis currently does not support testing more than one language so the | 7 on_travis() { |
4 # .travis.yml cheats and claims to only be cpp. If they add multiple language | 8 if [ "$TRAVIS" == "true" ]; then |
5 # support, this should probably get updated to install steps and/or | 9 "$@" |
6 # rvm/gemfile/jdk/etc. entries rather than manually doing the work. | 10 fi |
7 | 11 } |
8 # .travis.yml uses matrix.exclude to block the cases where app-get can't be | |
9 # use to install things. | |
10 | 12 |
11 # For when some other test needs the C++ main build, including protoc and | 13 # For when some other test needs the C++ main build, including protoc and |
12 # libprotobuf. | 14 # libprotobuf. |
13 internal_build_cpp() { | 15 internal_build_cpp() { |
14 if [ $(uname -s) == "Linux" ]; then | 16 if [ -f src/protoc ]; then |
| 17 # Already built. |
| 18 return |
| 19 fi |
| 20 |
| 21 if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then |
15 # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more | 22 # Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more |
16 # decent C++ 11 support in order to compile conformance tests. | 23 # decent C++ 11 support in order to compile conformance tests. |
17 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y | 24 sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y |
18 sudo apt-get update -qq | 25 sudo apt-get update -qq |
19 sudo apt-get install -qq g++-4.8 | 26 sudo apt-get install -qq g++-4.8 |
20 export CXX="g++-4.8" CC="gcc-4.8" | 27 export CXX="g++-4.8" CC="gcc-4.8" |
21 fi | 28 fi |
22 | 29 |
23 ./autogen.sh | 30 ./autogen.sh |
24 ./configure | 31 ./configure |
25 make -j2 | 32 make -j2 |
26 } | 33 } |
27 | 34 |
28 build_cpp() { | 35 build_cpp() { |
29 internal_build_cpp | 36 internal_build_cpp |
30 make check -j2 | 37 make check -j2 |
31 cd conformance && make test_cpp && cd .. | 38 cd conformance && make test_cpp && cd .. |
| 39 |
| 40 # Verify benchmarking code can build successfully. |
| 41 cd benchmarks && make && ./generate-datasets && cd .. |
32 } | 42 } |
33 | 43 |
34 build_cpp_distcheck() { | 44 build_cpp_distcheck() { |
35 ./autogen.sh | 45 ./autogen.sh |
36 ./configure | 46 ./configure |
37 make distcheck -j2 | 47 make distcheck -j2 |
38 } | 48 } |
39 | 49 |
40 build_csharp() { | 50 build_csharp() { |
41 # Just for the conformance tests. We don't currently | 51 # Just for the conformance tests. We don't currently |
42 # need to really build protoc, but it's simplest to keep with the | 52 # need to really build protoc, but it's simplest to keep with the |
43 # conventions of the other builds. | 53 # conventions of the other builds. |
44 internal_build_cpp | 54 internal_build_cpp |
| 55 NUGET=/usr/local/bin/nuget.exe |
45 | 56 |
46 # Install latest version of Mono | 57 if [ "$TRAVIS" == "true" ]; then |
47 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6
A14DA29AA6A19B38D3D831EF | 58 # Install latest version of Mono |
48 echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee
/etc/apt/sources.list.d/mono-xamarin.list | 59 sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BF
F6A14DA29AA6A19B38D3D831EF |
49 echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat m
ain" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list | 60 echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo t
ee /etc/apt/sources.list.d/mono-xamarin.list |
50 sudo apt-get update -qq | 61 echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat
main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list |
51 sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit | 62 sudo apt-get update -qq |
52 wget www.nuget.org/NuGet.exe -O nuget.exe | 63 sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit |
| 64 wget www.nuget.org/NuGet.exe -O nuget.exe |
| 65 NUGET=../../nuget.exe |
| 66 fi |
53 | 67 |
54 (cd csharp/src; mono ../../nuget.exe restore) | 68 (cd csharp/src; mono $NUGET restore) |
55 csharp/buildall.sh | 69 csharp/buildall.sh |
56 # TODO(xiaofeng): The conformance tests are disable because the testee program | 70 cd conformance && make test_csharp && cd .. |
57 # crashes on some inputs. | |
58 # cd conformance && make test_csharp && cd .. | |
59 } | 71 } |
60 | 72 |
61 build_golang() { | 73 build_golang() { |
62 # Go build needs `protoc`. | 74 # Go build needs `protoc`. |
63 internal_build_cpp | 75 internal_build_cpp |
64 # Add protoc to the path so that the examples build finds it. | 76 # Add protoc to the path so that the examples build finds it. |
65 export PATH="`pwd`/src:$PATH" | 77 export PATH="`pwd`/src:$PATH" |
66 | 78 |
67 # Install Go and the Go protobuf compiler plugin. | 79 # Install Go and the Go protobuf compiler plugin. |
68 sudo apt-get update -qq | 80 sudo apt-get update -qq |
69 sudo apt-get install -qq golang | 81 sudo apt-get install -qq golang |
70 export GOPATH="$HOME/gocode" | 82 export GOPATH="$HOME/gocode" |
71 mkdir -p "$GOPATH/src/github.com/google" | 83 mkdir -p "$GOPATH/src/github.com/google" |
72 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" | 84 ln -s "`pwd`" "$GOPATH/src/github.com/google/protobuf" |
73 export PATH="$GOPATH/bin:$PATH" | 85 export PATH="$GOPATH/bin:$PATH" |
74 go get github.com/golang/protobuf/protoc-gen-go | 86 go get github.com/golang/protobuf/protoc-gen-go |
75 | 87 |
76 cd examples && make gotest && cd .. | 88 cd examples && make gotest && cd .. |
77 } | 89 } |
78 | 90 |
79 use_java() { | 91 use_java() { |
80 version=$1 | 92 version=$1 |
81 case "$version" in | 93 case "$version" in |
82 jdk6) | 94 jdk6) |
83 sudo apt-get install openjdk-6-jdk | 95 on_travis sudo apt-get install openjdk-6-jdk |
84 export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH | 96 export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH |
85 ;; | 97 ;; |
86 jdk7) | 98 jdk7) |
87 sudo apt-get install openjdk-7-jdk | 99 on_travis sudo apt-get install openjdk-7-jdk |
88 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH | 100 export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH |
89 ;; | 101 ;; |
90 oracle7) | 102 oracle7) |
91 sudo apt-get install python-software-properties # for apt-add-repository | 103 if [ "$TRAVIS" == "true" ]; then |
92 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select tr
ue" | \ | 104 sudo apt-get install python-software-properties # for apt-add-repository |
93 sudo debconf-set-selections | 105 echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select
true" | \ |
94 yes | sudo apt-add-repository ppa:webupd8team/java | 106 sudo debconf-set-selections |
95 yes | sudo apt-get install oracle-java7-installer | 107 yes | sudo apt-add-repository ppa:webupd8team/java |
| 108 yes | sudo apt-get install oracle-java7-installer |
| 109 fi; |
96 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH | 110 export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH |
97 ;; | 111 ;; |
98 esac | 112 esac |
99 | 113 |
| 114 if [ "$TRAVIS" != "true" ]; then |
| 115 MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository |
| 116 MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY" |
| 117 fi; |
| 118 |
100 which java | 119 which java |
101 java -version | 120 java -version |
102 } | 121 } |
103 | 122 |
| 123 # --batch-mode supresses download progress output that spams the logs. |
| 124 MVN="mvn --batch-mode" |
| 125 |
104 build_java() { | 126 build_java() { |
| 127 version=$1 |
| 128 dir=java_$version |
105 # Java build needs `protoc`. | 129 # Java build needs `protoc`. |
106 internal_build_cpp | 130 internal_build_cpp |
107 cd java && mvn test && mvn install | 131 cp -r java $dir |
108 cd util && mvn test | 132 cd $dir && $MVN clean && $MVN test |
109 cd ../.. | 133 cd ../.. |
110 } | 134 } |
111 | 135 |
| 136 # The conformance tests are hard-coded to work with the $ROOT/java directory. |
| 137 # So this can't run in parallel with two different sets of tests. |
112 build_java_with_conformance_tests() { | 138 build_java_with_conformance_tests() { |
113 # Java build needs `protoc`. | 139 # Java build needs `protoc`. |
114 internal_build_cpp | 140 internal_build_cpp |
115 cd java && mvn test && mvn install | 141 cd java && $MVN test && $MVN install |
116 cd util && mvn test && mvn assembly:single | 142 cd util && $MVN package assembly:single |
117 cd ../.. | 143 cd ../.. |
118 cd conformance && make test_java && cd .. | 144 cd conformance && make test_java && cd .. |
119 } | 145 } |
120 | 146 |
121 build_javanano() { | 147 build_javanano() { |
122 # Java build needs `protoc`. | 148 # Java build needs `protoc`. |
123 internal_build_cpp | 149 internal_build_cpp |
124 cd javanano && mvn test && cd .. | 150 cd javanano && $MVN test && cd .. |
125 } | 151 } |
126 | 152 |
127 build_java_jdk6() { | 153 build_java_jdk6() { |
128 use_java jdk6 | 154 use_java jdk6 |
129 build_java | 155 build_java jdk6 |
130 } | 156 } |
131 build_java_jdk7() { | 157 build_java_jdk7() { |
132 use_java jdk7 | 158 use_java jdk7 |
133 build_java_with_conformance_tests | 159 build_java_with_conformance_tests |
134 } | 160 } |
135 build_java_oracle7() { | 161 build_java_oracle7() { |
136 use_java oracle7 | 162 use_java oracle7 |
137 build_java | 163 build_java oracle7 |
138 } | 164 } |
139 | 165 |
140 build_javanano_jdk6() { | 166 build_javanano_jdk6() { |
141 use_java jdk6 | 167 use_java jdk6 |
142 build_javanano | 168 build_javanano |
143 } | 169 } |
144 build_javanano_jdk7() { | 170 build_javanano_jdk7() { |
145 use_java jdk7 | 171 use_java jdk7 |
146 build_javanano | 172 build_javanano |
147 } | 173 } |
148 build_javanano_oracle7() { | 174 build_javanano_oracle7() { |
149 use_java oracle7 | 175 use_java oracle7 |
150 build_javanano | 176 build_javanano |
151 } | 177 } |
152 | 178 |
153 internal_install_python_deps() { | 179 internal_install_python_deps() { |
| 180 if [ "$TRAVIS" != "true" ]; then |
| 181 return; |
| 182 fi |
154 # Install tox (OS X doesn't have pip). | 183 # Install tox (OS X doesn't have pip). |
155 if [ $(uname -s) == "Darwin" ]; then | 184 if [ $(uname -s) == "Darwin" ]; then |
156 sudo easy_install tox | 185 sudo easy_install tox |
157 else | 186 else |
158 sudo pip install tox | 187 sudo pip install tox |
159 fi | 188 fi |
160 # Only install Python2.6/3.x on Linux. | 189 # Only install Python2.6/3.x on Linux. |
161 if [ $(uname -s) == "Linux" ]; then | 190 if [ $(uname -s) == "Linux" ]; then |
162 sudo apt-get install -y python-software-properties # for apt-add-repository | 191 sudo apt-get install -y python-software-properties # for apt-add-repository |
163 sudo apt-add-repository -y ppa:fkrull/deadsnakes | 192 sudo apt-add-repository -y ppa:fkrull/deadsnakes |
(...skipping 10 matching lines...) Expand all Loading... |
174 # We don't use a before_install because we test multiple OSes. | 203 # We don't use a before_install because we test multiple OSes. |
175 brew update | 204 brew update |
176 brew outdated xctool || brew upgrade xctool | 205 brew outdated xctool || brew upgrade xctool |
177 # Reused the build script that takes care of configuring and ensuring things | 206 # Reused the build script that takes care of configuring and ensuring things |
178 # are up to date. Xcode and conformance tests will be directly invoked. | 207 # are up to date. Xcode and conformance tests will be directly invoked. |
179 objectivec/DevTools/full_mac_build.sh \ | 208 objectivec/DevTools/full_mac_build.sh \ |
180 --core-only --skip-xcode --skip-objc-conformance | 209 --core-only --skip-xcode --skip-objc-conformance |
181 } | 210 } |
182 | 211 |
183 internal_xctool_debug_and_release() { | 212 internal_xctool_debug_and_release() { |
184 xctool -configuration Debug "$@" | 213 # Always use -reporter plain to avoid escape codes in output (makes travis |
185 xctool -configuration Release "$@" | 214 # logs easier to read). |
| 215 xctool -reporter plain -configuration Debug "$@" |
| 216 xctool -reporter plain -configuration Release "$@" |
186 } | 217 } |
187 | 218 |
188 build_objectivec_ios() { | 219 build_objectivec_ios() { |
189 internal_objectivec_common | 220 internal_objectivec_common |
190 # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool | 221 # https://github.com/facebook/xctool/issues/509 - unlike xcodebuild, xctool |
191 # doesn't support >1 destination, so we have to build first and then run the | 222 # doesn't support >1 destination, so we have to build first and then run the |
192 # tests one destination at a time. | 223 # tests one destination at a time. |
193 internal_xctool_debug_and_release \ | 224 internal_xctool_debug_and_release \ |
194 -project objectivec/ProtocolBuffers_iOS.xcodeproj \ | 225 -project objectivec/ProtocolBuffers_iOS.xcodeproj \ |
195 -scheme ProtocolBuffers \ | 226 -scheme ProtocolBuffers \ |
196 -sdk iphonesimulator \ | 227 -sdk iphonesimulator \ |
197 build-tests | 228 build-tests |
198 IOS_DESTINATIONS=( | 229 IOS_DESTINATIONS=( |
199 "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit | 230 "platform=iOS Simulator,name=iPhone 4s,OS=8.1" # 32bit |
200 "platform=iOS Simulator,name=iPhone 6,OS=9.1" # 64bit | 231 "platform=iOS Simulator,name=iPhone 6,OS=9.2" # 64bit |
201 "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit | 232 "platform=iOS Simulator,name=iPad 2,OS=8.1" # 32bit |
202 "platform=iOS Simulator,name=iPad Air,OS=9.1" # 64bit | 233 "platform=iOS Simulator,name=iPad Air,OS=9.2" # 64bit |
203 ) | 234 ) |
204 for i in "${IOS_DESTINATIONS[@]}" ; do | 235 for i in "${IOS_DESTINATIONS[@]}" ; do |
205 internal_xctool_debug_and_release \ | 236 internal_xctool_debug_and_release \ |
206 -project objectivec/ProtocolBuffers_iOS.xcodeproj \ | 237 -project objectivec/ProtocolBuffers_iOS.xcodeproj \ |
207 -scheme ProtocolBuffers \ | 238 -scheme ProtocolBuffers \ |
208 -sdk iphonesimulator \ | 239 -sdk iphonesimulator \ |
209 -destination "${i}" \ | 240 -destination "${i}" \ |
210 run-tests | 241 run-tests |
211 done | 242 done |
212 } | 243 } |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
271 build_jruby() { | 302 build_jruby() { |
272 internal_build_cpp # For conformance tests. | 303 internal_build_cpp # For conformance tests. |
273 cd ruby && bash travis-test.sh jruby && cd .. | 304 cd ruby && bash travis-test.sh jruby && cd .. |
274 } | 305 } |
275 | 306 |
276 build_javascript() { | 307 build_javascript() { |
277 internal_build_cpp | 308 internal_build_cpp |
278 cd js && npm install && npm test && cd .. | 309 cd js && npm install && npm test && cd .. |
279 } | 310 } |
280 | 311 |
| 312 # Note: travis currently does not support testing more than one language so the |
| 313 # .travis.yml cheats and claims to only be cpp. If they add multiple language |
| 314 # support, this should probably get updated to install steps and/or |
| 315 # rvm/gemfile/jdk/etc. entries rather than manually doing the work. |
| 316 |
| 317 # .travis.yml uses matrix.exclude to block the cases where app-get can't be |
| 318 # use to install things. |
| 319 |
281 # -------- main -------- | 320 # -------- main -------- |
282 | 321 |
283 if [ "$#" -ne 1 ]; then | 322 if [ "$#" -ne 1 ]; then |
284 echo " | 323 echo " |
285 Usage: $0 { cpp | | 324 Usage: $0 { cpp | |
286 csharp | | 325 csharp | |
287 java_jdk6 | | 326 java_jdk6 | |
288 java_jdk7 | | 327 java_jdk7 | |
289 java_oracle7 | | 328 java_oracle7 | |
290 javanano_jdk6 | | 329 javanano_jdk6 | |
291 javanano_jdk7 | | 330 javanano_jdk7 | |
292 javanano_oracle7 | | 331 javanano_oracle7 | |
293 objectivec_ios | | 332 objectivec_ios | |
294 objectivec_osx | | 333 objectivec_osx | |
295 python | | 334 python | |
296 python_cpp | | 335 python_cpp | |
297 ruby_19 | | 336 ruby19 | |
298 ruby_20 | | 337 ruby20 | |
299 ruby_21 | | 338 ruby21 | |
300 ruby_22 | | 339 ruby22 | |
301 jruby } | 340 jruby } |
302 " | 341 " |
303 exit 1 | 342 exit 1 |
304 fi | 343 fi |
305 | 344 |
306 set -e # exit immediately on error | 345 set -e # exit immediately on error |
307 set -x # display all commands | 346 set -x # display all commands |
308 eval "build_$1" | 347 eval "build_$1" |
OLD | NEW |