pull_request_in_docker.sh 2.2 KB
Newer Older
1
#!/bin/bash
2 3 4
#
# This is the script that runs inside Docker, once the image has been built,
# 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 10
BUILD_DIR=/tmp/protobuf

11
set -e  # exit immediately on error
12 13
set -x  # display all commands

14 15
# The protobuf repository is mounted into our Docker image, but read-only.
# We clone into a directory inside Docker (this is faster than cp).
16 17 18 19 20
rm -rf $BUILD_DIR
mkdir -p $BUILD_DIR
cd $BUILD_DIR
git clone /var/local/jenkins/protobuf
cd protobuf
Josh Haberman's avatar
Josh Haberman committed
21

22
# Set up the directory where our test output is going to go.
23
OUTPUT_DIR=`mktemp -d`
24 25
LOG_OUTPUT_DIR=$OUTPUT_DIR/logs
mkdir -p $LOG_OUTPUT_DIR/1/cpp
26

27
################################################################################
28 29
# cpp build needs to run first, non-parallelized, so that protoc is available
# for other builds.
30 31 32 33 34 35 36 37 38 39

# 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
40

41
# Time the C++ build, so we can put this info in the test output.
42 43 44 45 46
# 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)
47

48 49
# Other tests are run in parallel. TEST_SET is defined in
# buildcmds/pull_request{_32}.sh
50

51
parallel --results $LOG_OUTPUT_DIR --joblog $OUTPUT_DIR/joblog $TEST_SCRIPT ::: \
52
  $TEST_SET \
53
  || true  # Process test results even if tests fail.
54

55 56
cat $OUTPUT_DIR/joblog

57 58 59 60
# 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
61

62 63 64
# 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
65 66

ls -l $TESTOUTPUT_XML_FILE