|
@@ -1,17 +1,24 @@
|
|
-#!/usr/bin/env bash
|
|
|
|
|
|
+#!/bin/bash
|
|
|
|
+#
|
|
|
|
+# Build and runs tests for the protobuf project. The tests as written here are
|
|
|
|
+# used by both Jenkins and Travis, though some specialized logic is required to
|
|
|
|
+# handle the differences between them.
|
|
|
|
|
|
-# Note: travis currently does not support testing more than one language so the
|
|
|
|
-# .travis.yml cheats and claims to only be cpp. If they add multiple language
|
|
|
|
-# support, this should probably get updated to install steps and/or
|
|
|
|
-# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
|
|
|
|
-
|
|
|
|
-# .travis.yml uses matrix.exclude to block the cases where app-get can't be
|
|
|
|
-# use to install things.
|
|
|
|
|
|
+on_travis() {
|
|
|
|
+ if [ "$TRAVIS" == "true" ]; then
|
|
|
|
+ "$@"
|
|
|
|
+ fi
|
|
|
|
+}
|
|
|
|
|
|
# For when some other test needs the C++ main build, including protoc and
|
|
# For when some other test needs the C++ main build, including protoc and
|
|
# libprotobuf.
|
|
# libprotobuf.
|
|
internal_build_cpp() {
|
|
internal_build_cpp() {
|
|
- if [ $(uname -s) == "Linux" ]; then
|
|
|
|
|
|
+ if [ -f src/protoc ]; then
|
|
|
|
+ # Already built.
|
|
|
|
+ return
|
|
|
|
+ fi
|
|
|
|
+
|
|
|
|
+ if [[ $(uname -s) == "Linux" && "$TRAVIS" == "true" ]]; then
|
|
# Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more
|
|
# Install GCC 4.8 to replace the default GCC 4.6. We need 4.8 for more
|
|
# decent C++ 11 support in order to compile conformance tests.
|
|
# decent C++ 11 support in order to compile conformance tests.
|
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
|
sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
|
|
@@ -42,16 +49,20 @@ build_csharp() {
|
|
# need to really build protoc, but it's simplest to keep with the
|
|
# need to really build protoc, but it's simplest to keep with the
|
|
# conventions of the other builds.
|
|
# conventions of the other builds.
|
|
internal_build_cpp
|
|
internal_build_cpp
|
|
|
|
+ NUGET=/usr/local/bin/nuget.exe
|
|
|
|
|
|
- # Install latest version of Mono
|
|
|
|
- sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
|
|
|
|
- echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
|
|
|
|
- echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
|
|
|
|
- sudo apt-get update -qq
|
|
|
|
- sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
|
|
|
|
- wget www.nuget.org/NuGet.exe -O nuget.exe
|
|
|
|
|
|
+ if [ "$TRAVIS" == "true" ]; then
|
|
|
|
+ # Install latest version of Mono
|
|
|
|
+ sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
|
|
|
|
+ echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
|
|
|
|
+ echo "deb http://download.mono-project.com/repo/debian wheezy-libtiff-compat main" | sudo tee -a /etc/apt/sources.list.d/mono-xamarin.list
|
|
|
|
+ sudo apt-get update -qq
|
|
|
|
+ sudo apt-get install -qq mono-devel referenceassemblies-pcl nunit
|
|
|
|
+ wget www.nuget.org/NuGet.exe -O nuget.exe
|
|
|
|
+ NUGET=../../nuget.exe
|
|
|
|
+ fi
|
|
|
|
|
|
- (cd csharp/src; mono ../../nuget.exe restore)
|
|
|
|
|
|
+ (cd csharp/src; mono $NUGET restore)
|
|
csharp/buildall.sh
|
|
csharp/buildall.sh
|
|
cd conformance && make test_csharp && cd ..
|
|
cd conformance && make test_csharp && cd ..
|
|
}
|
|
}
|
|
@@ -78,40 +89,54 @@ use_java() {
|
|
version=$1
|
|
version=$1
|
|
case "$version" in
|
|
case "$version" in
|
|
jdk6)
|
|
jdk6)
|
|
- sudo apt-get install openjdk-6-jdk
|
|
|
|
|
|
+ on_travis sudo apt-get install openjdk-6-jdk
|
|
export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH
|
|
export PATH=/usr/lib/jvm/java-6-openjdk-amd64/bin:$PATH
|
|
;;
|
|
;;
|
|
jdk7)
|
|
jdk7)
|
|
- sudo apt-get install openjdk-7-jdk
|
|
|
|
|
|
+ on_travis sudo apt-get install openjdk-7-jdk
|
|
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
|
|
export PATH=/usr/lib/jvm/java-7-openjdk-amd64/bin:$PATH
|
|
;;
|
|
;;
|
|
oracle7)
|
|
oracle7)
|
|
- sudo apt-get install python-software-properties # for apt-add-repository
|
|
|
|
- echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
|
|
|
|
- sudo debconf-set-selections
|
|
|
|
- yes | sudo apt-add-repository ppa:webupd8team/java
|
|
|
|
- yes | sudo apt-get install oracle-java7-installer
|
|
|
|
|
|
+ if [ "$TRAVIS" == "true" ]; then
|
|
|
|
+ sudo apt-get install python-software-properties # for apt-add-repository
|
|
|
|
+ echo "oracle-java7-installer shared/accepted-oracle-license-v1-1 select true" | \
|
|
|
|
+ sudo debconf-set-selections
|
|
|
|
+ yes | sudo apt-add-repository ppa:webupd8team/java
|
|
|
|
+ yes | sudo apt-get install oracle-java7-installer
|
|
|
|
+ fi;
|
|
export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
|
|
export PATH=/usr/lib/jvm/java-7-oracle/bin:$PATH
|
|
;;
|
|
;;
|
|
esac
|
|
esac
|
|
|
|
|
|
|
|
+ if [ "$TRAVIS" != "true" ]; then
|
|
|
|
+ MAVEN_LOCAL_REPOSITORY=/var/maven_local_repository
|
|
|
|
+ MVN="$MVN -e -X --offline -Dmaven.repo.local=$MAVEN_LOCAL_REPOSITORY"
|
|
|
|
+ fi;
|
|
|
|
+
|
|
which java
|
|
which java
|
|
java -version
|
|
java -version
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+# --batch-mode supresses download progress output that spams the logs.
|
|
|
|
+MVN="mvn --batch-mode"
|
|
|
|
+
|
|
build_java() {
|
|
build_java() {
|
|
|
|
+ version=$1
|
|
|
|
+ dir=java_$version
|
|
# Java build needs `protoc`.
|
|
# Java build needs `protoc`.
|
|
internal_build_cpp
|
|
internal_build_cpp
|
|
- cd java && mvn test && mvn install
|
|
|
|
- cd util && mvn test
|
|
|
|
|
|
+ cp -r java $dir
|
|
|
|
+ cd $dir && $MVN clean && $MVN test
|
|
cd ../..
|
|
cd ../..
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+# The conformance tests are hard-coded to work with the $ROOT/java directory.
|
|
|
|
+# So this can't run in parallel with two different sets of tests.
|
|
build_java_with_conformance_tests() {
|
|
build_java_with_conformance_tests() {
|
|
# Java build needs `protoc`.
|
|
# Java build needs `protoc`.
|
|
internal_build_cpp
|
|
internal_build_cpp
|
|
- cd java && mvn test && mvn install
|
|
|
|
- cd util && mvn test && mvn assembly:single
|
|
|
|
|
|
+ cd java && $MVN test && $MVN install
|
|
|
|
+ cd util && $MVN package assembly:single
|
|
cd ../..
|
|
cd ../..
|
|
cd conformance && make test_java && cd ..
|
|
cd conformance && make test_java && cd ..
|
|
}
|
|
}
|
|
@@ -119,12 +144,12 @@ build_java_with_conformance_tests() {
|
|
build_javanano() {
|
|
build_javanano() {
|
|
# Java build needs `protoc`.
|
|
# Java build needs `protoc`.
|
|
internal_build_cpp
|
|
internal_build_cpp
|
|
- cd javanano && mvn test && cd ..
|
|
|
|
|
|
+ cd javanano && $MVN test && cd ..
|
|
}
|
|
}
|
|
|
|
|
|
build_java_jdk6() {
|
|
build_java_jdk6() {
|
|
use_java jdk6
|
|
use_java jdk6
|
|
- build_java
|
|
|
|
|
|
+ build_java jdk6
|
|
}
|
|
}
|
|
build_java_jdk7() {
|
|
build_java_jdk7() {
|
|
use_java jdk7
|
|
use_java jdk7
|
|
@@ -132,7 +157,7 @@ build_java_jdk7() {
|
|
}
|
|
}
|
|
build_java_oracle7() {
|
|
build_java_oracle7() {
|
|
use_java oracle7
|
|
use_java oracle7
|
|
- build_java
|
|
|
|
|
|
+ build_java oracle7
|
|
}
|
|
}
|
|
|
|
|
|
build_javanano_jdk6() {
|
|
build_javanano_jdk6() {
|
|
@@ -149,6 +174,9 @@ build_javanano_oracle7() {
|
|
}
|
|
}
|
|
|
|
|
|
internal_install_python_deps() {
|
|
internal_install_python_deps() {
|
|
|
|
+ if [ "$TRAVIS" != "true" ]; then
|
|
|
|
+ return;
|
|
|
|
+ fi
|
|
# Install tox (OS X doesn't have pip).
|
|
# Install tox (OS X doesn't have pip).
|
|
if [ $(uname -s) == "Darwin" ]; then
|
|
if [ $(uname -s) == "Darwin" ]; then
|
|
sudo easy_install tox
|
|
sudo easy_install tox
|
|
@@ -278,6 +306,14 @@ build_javascript() {
|
|
cd js && npm install && npm test && cd ..
|
|
cd js && npm install && npm test && cd ..
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+# Note: travis currently does not support testing more than one language so the
|
|
|
|
+# .travis.yml cheats and claims to only be cpp. If they add multiple language
|
|
|
|
+# support, this should probably get updated to install steps and/or
|
|
|
|
+# rvm/gemfile/jdk/etc. entries rather than manually doing the work.
|
|
|
|
+
|
|
|
|
+# .travis.yml uses matrix.exclude to block the cases where app-get can't be
|
|
|
|
+# use to install things.
|
|
|
|
+
|
|
# -------- main --------
|
|
# -------- main --------
|
|
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
if [ "$#" -ne 1 ]; then
|
|
@@ -294,10 +330,10 @@ Usage: $0 { cpp |
|
|
objectivec_osx |
|
|
objectivec_osx |
|
|
python |
|
|
python |
|
|
python_cpp |
|
|
python_cpp |
|
|
- ruby_19 |
|
|
|
|
- ruby_20 |
|
|
|
|
- ruby_21 |
|
|
|
|
- ruby_22 |
|
|
|
|
|
|
+ ruby19 |
|
|
|
|
+ ruby20 |
|
|
|
|
+ ruby21 |
|
|
|
|
+ ruby22 |
|
|
jruby }
|
|
jruby }
|
|
"
|
|
"
|
|
exit 1
|
|
exit 1
|