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 6 WORKSPACE_BASE=`pwd` 7 MY_DIR="$(dirname "$0")" 8 TEST_SCRIPT=$MY_DIR/../tests.sh 9 BUILD_DIR=/tmp/protobuf 10 11 set -e # exit immediately on error 12 set -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). 16 rm -rf $BUILD_DIR 17 mkdir -p $BUILD_DIR 18 cd $BUILD_DIR 19 git clone /var/local/jenkins/protobuf 20 cd protobuf 21 22 # Set up the directory where our test output is going to go. 23 OUTPUT_DIR=`mktemp -d` 24 LOG_OUTPUT_DIR=$OUTPUT_DIR/logs 25 mkdir -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 38 CPP_STDOUT=$LOG_OUTPUT_DIR/1/cpp/stdout 39 CPP_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. 44 TIME_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 50 parallel --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 61 cat $OUTPUT_DIR/joblog 62 63 # The directory that is copied from Docker back into the Jenkins workspace. 64 COPY_FROM_DOCKER=/var/local/git/protobuf/testoutput 65 mkdir -p $COPY_FROM_DOCKER 66 TESTOUTPUT_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. 70 python $MY_DIR/make_test_output.py $OUTPUT_DIR > $TESTOUTPUT_XML_FILE 71 72 ls -l $TESTOUTPUT_XML_FILE 73