2016-02-18 22:55:00 +00:00
|
|
|
#!/bin/bash
|
2016-03-04 22:21:18 +00:00
|
|
|
#
|
|
|
|
# This is the script that runs inside Docker, once the image has been built,
|
|
|
|
# to execute all tests for the "pull request" project.
|
2016-02-18 22:55:00 +00:00
|
|
|
|
2016-02-23 22:28:02 +00:00
|
|
|
WORKSPACE_BASE=`pwd`
|
2016-02-18 22:55:00 +00:00
|
|
|
MY_DIR="$(dirname "$0")"
|
2016-03-04 22:21:18 +00:00
|
|
|
TEST_SCRIPT=$MY_DIR/../tests.sh
|
2016-02-18 22:55:00 +00:00
|
|
|
BUILD_DIR=/tmp/protobuf
|
|
|
|
|
2016-02-19 20:33:17 +00:00
|
|
|
set -e # exit immediately on error
|
2016-02-19 04:10:23 +00:00
|
|
|
set -x # display all commands
|
|
|
|
|
2016-03-04 22:21:18 +00:00
|
|
|
# The protobuf repository is mounted into our Docker image, but read-only.
|
|
|
|
# We clone into a directory inside Docker (this is faster than cp).
|
2016-02-18 22:55:00 +00:00
|
|
|
rm -rf $BUILD_DIR
|
|
|
|
mkdir -p $BUILD_DIR
|
|
|
|
cd $BUILD_DIR
|
|
|
|
git clone /var/local/jenkins/protobuf
|
|
|
|
cd protobuf
|
2016-02-19 03:13:07 +00:00
|
|
|
|
2016-03-04 22:21:18 +00:00
|
|
|
# Set up the directory where our test output is going to go.
|
2016-02-19 20:33:17 +00:00
|
|
|
OUTPUT_DIR=`mktemp -d`
|
2016-02-23 22:28:02 +00:00
|
|
|
LOG_OUTPUT_DIR=$OUTPUT_DIR/logs
|
|
|
|
mkdir -p $LOG_OUTPUT_DIR/1/cpp
|
2016-02-19 04:10:23 +00:00
|
|
|
|
2016-02-23 22:28:02 +00:00
|
|
|
################################################################################
|
2016-02-19 20:33:17 +00:00
|
|
|
# cpp build needs to run first, non-parallelized, so that protoc is available
|
|
|
|
# for other builds.
|
2016-02-23 22:28:02 +00:00
|
|
|
|
|
|
|
# Output filenames to follow the overall scheme used by parallel, ie:
|
|
|
|
# $DIR/logs/1/cpp/stdout
|
|
|
|
# $DIR/logs/1/cpp/stderr
|
|
|
|
# $DIR/logs/1/csharp/stdout
|
|
|
|
# $DIR/logs/1/csharp/stderr
|
|
|
|
# $DIR/logs/1/java_jdk7/stdout
|
|
|
|
# $DIR/logs/1/java_jdk7/stderr
|
|
|
|
CPP_STDOUT=$LOG_OUTPUT_DIR/1/cpp/stdout
|
|
|
|
CPP_STDERR=$LOG_OUTPUT_DIR/1/cpp/stderr
|
2016-03-04 01:04:36 +00:00
|
|
|
|
2016-03-04 22:21:18 +00:00
|
|
|
# Time the C++ build, so we can put this info in the test output.
|
2016-03-04 01:04:36 +00:00
|
|
|
# It's important that we get /usr/bin/time (which supports -f and -o) and not
|
|
|
|
# the bash builtin "time" which doesn't.
|
|
|
|
TIME_CMD="/usr/bin/time -f %e -o $LOG_OUTPUT_DIR/1/cpp/build_time"
|
|
|
|
|
|
|
|
$TIME_CMD $TEST_SCRIPT cpp > >(tee $CPP_STDOUT) 2> >(tee $CPP_STDERR >&2)
|
2016-02-19 20:33:17 +00:00
|
|
|
|
2016-03-04 22:21:18 +00:00
|
|
|
# Other tests are run in parallel.
|
2016-02-19 20:33:17 +00:00
|
|
|
|
2016-02-23 22:28:02 +00:00
|
|
|
parallel --results $LOG_OUTPUT_DIR --joblog $OUTPUT_DIR/joblog $TEST_SCRIPT ::: \
|
2016-02-22 23:39:29 +00:00
|
|
|
csharp \
|
2016-02-19 20:48:33 +00:00
|
|
|
java_jdk7 \
|
|
|
|
javanano_jdk7 \
|
2016-02-22 23:39:29 +00:00
|
|
|
java_oracle7 \
|
|
|
|
javanano_oracle7 \
|
2016-02-19 20:48:33 +00:00
|
|
|
python \
|
2016-02-22 23:39:29 +00:00
|
|
|
python_cpp \
|
2016-02-23 22:28:02 +00:00
|
|
|
ruby21 \
|
|
|
|
|| true # Process test results even if tests fail.
|
2016-02-19 20:48:33 +00:00
|
|
|
|
2016-03-04 22:21:18 +00:00
|
|
|
cat $OUTPUT_DIR/joblog
|
|
|
|
|
2016-02-23 22:28:02 +00:00
|
|
|
# The directory that is copied from Docker back into the Jenkins workspace.
|
|
|
|
COPY_FROM_DOCKER=/var/local/git/protobuf/testoutput
|
|
|
|
mkdir -p $COPY_FROM_DOCKER
|
|
|
|
TESTOUTPUT_XML_FILE=$COPY_FROM_DOCKER/testresults.xml
|
2016-02-22 23:39:29 +00:00
|
|
|
|
2016-03-04 22:21:18 +00:00
|
|
|
# Process all the output files from "parallel" and package them into a single
|
|
|
|
# .xml file with detailed, broken-down test output.
|
|
|
|
python $MY_DIR/make_test_output.py $OUTPUT_DIR > $TESTOUTPUT_XML_FILE
|
2016-02-23 22:28:02 +00:00
|
|
|
|
|
|
|
ls -l $TESTOUTPUT_XML_FILE
|