1#!/bin/bash 2# 3# This is the script that runs inside Docker, once the image has been built, 4# to execute all tests for the "pull request" project. 5 6WORKSPACE_BASE=`pwd` 7MY_DIR="$(dirname "$0")" 8TEST_SCRIPT=$MY_DIR/../tests.sh 9BUILD_DIR=/tmp/protobuf 10 11set -e # exit immediately on error 12set -x # display all commands 13 14# The protobuf repository is mounted into our Docker image, but read-only. 15# We clone into a directory inside Docker (this is faster than cp). 16rm -rf $BUILD_DIR 17mkdir -p $BUILD_DIR 18cd $BUILD_DIR 19git clone /var/local/jenkins/protobuf 20cd protobuf 21 22# Set up the directory where our test output is going to go. 23OUTPUT_DIR=`mktemp -d` 24LOG_OUTPUT_DIR=$OUTPUT_DIR/logs 25mkdir -p $LOG_OUTPUT_DIR/1/cpp 26 27################################################################################ 28# cpp build needs to run first, non-parallelized, so that protoc is available 29# for other builds. 30 31# Output filenames to follow the overall scheme used by parallel, ie: 32# $DIR/logs/1/cpp/stdout 33# $DIR/logs/1/cpp/stderr 34# $DIR/logs/1/csharp/stdout 35# $DIR/logs/1/csharp/stderr 36# $DIR/logs/1/java_jdk7/stdout 37# $DIR/logs/1/java_jdk7/stderr 38CPP_STDOUT=$LOG_OUTPUT_DIR/1/cpp/stdout 39CPP_STDERR=$LOG_OUTPUT_DIR/1/cpp/stderr 40 41# Time the C++ build, so we can put this info in the test output. 42# It's important that we get /usr/bin/time (which supports -f and -o) and not 43# the bash builtin "time" which doesn't. 44TIME_CMD="/usr/bin/time -f %e -o $LOG_OUTPUT_DIR/1/cpp/build_time" 45 46$TIME_CMD $TEST_SCRIPT cpp > >(tee $CPP_STDOUT) 2> >(tee $CPP_STDERR >&2) 47 48# Other tests are run in parallel. 49 50parallel --results $LOG_OUTPUT_DIR --joblog $OUTPUT_DIR/joblog $TEST_SCRIPT ::: \ 51 csharp \ 52 java_jdk7 \ 53 javanano_jdk7 \ 54 java_oracle7 \ 55 javanano_oracle7 \ 56 python \ 57 python_cpp \ 58 ruby21 \ 59 || true # Process test results even if tests fail. 60 61cat $OUTPUT_DIR/joblog 62 63# The directory that is copied from Docker back into the Jenkins workspace. 64COPY_FROM_DOCKER=/var/local/git/protobuf/testoutput 65mkdir -p $COPY_FROM_DOCKER 66TESTOUTPUT_XML_FILE=$COPY_FROM_DOCKER/testresults.xml 67 68# Process all the output files from "parallel" and package them into a single 69# .xml file with detailed, broken-down test output. 70python $MY_DIR/make_test_output.py $OUTPUT_DIR > $TESTOUTPUT_XML_FILE 71 72ls -l $TESTOUTPUT_XML_FILE 73