blob: 887f97c59ba3ae8f0197b8226e22a2535fc4a9dc [file] [log] [blame]
Josh Haberman57be1d72016-02-18 14:55:00 -08001#!/bin/bash
Josh Haberman67c727c2016-03-04 14:21:18 -08002#
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.
Josh Haberman57be1d72016-02-18 14:55:00 -08005
Josh Haberman38bc1552016-02-23 14:28:02 -08006WORKSPACE_BASE=`pwd`
Josh Haberman57be1d72016-02-18 14:55:00 -08007MY_DIR="$(dirname "$0")"
Josh Haberman67c727c2016-03-04 14:21:18 -08008TEST_SCRIPT=$MY_DIR/../tests.sh
Josh Haberman57be1d72016-02-18 14:55:00 -08009BUILD_DIR=/tmp/protobuf
10
Josh Haberman0b931bc2016-02-19 12:33:17 -080011set -e # exit immediately on error
Josh Haberman738393b2016-02-18 20:10:23 -080012set -x # display all commands
13
Josh Haberman67c727c2016-03-04 14:21:18 -080014# 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).
Josh Haberman57be1d72016-02-18 14:55:00 -080016rm -rf $BUILD_DIR
17mkdir -p $BUILD_DIR
18cd $BUILD_DIR
19git clone /var/local/jenkins/protobuf
20cd protobuf
Josh Habermand33e93b2016-02-18 19:13:07 -080021
Josh Haberman67c727c2016-03-04 14:21:18 -080022# Set up the directory where our test output is going to go.
Josh Haberman0b931bc2016-02-19 12:33:17 -080023OUTPUT_DIR=`mktemp -d`
Josh Haberman38bc1552016-02-23 14:28:02 -080024LOG_OUTPUT_DIR=$OUTPUT_DIR/logs
25mkdir -p $LOG_OUTPUT_DIR/1/cpp
Josh Haberman738393b2016-02-18 20:10:23 -080026
Josh Haberman38bc1552016-02-23 14:28:02 -080027################################################################################
Josh Haberman0b931bc2016-02-19 12:33:17 -080028# cpp build needs to run first, non-parallelized, so that protoc is available
29# for other builds.
Josh Haberman38bc1552016-02-23 14:28:02 -080030
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
Josh Haberman2bda98f2016-03-03 17:04:36 -080040
Josh Haberman67c727c2016-03-04 14:21:18 -080041# Time the C++ build, so we can put this info in the test output.
Josh Haberman2bda98f2016-03-03 17:04:36 -080042# 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)
Josh Haberman0b931bc2016-02-19 12:33:17 -080047
Josh Haberman67c727c2016-03-04 14:21:18 -080048# Other tests are run in parallel.
Josh Haberman0b931bc2016-02-19 12:33:17 -080049
Josh Haberman38bc1552016-02-23 14:28:02 -080050parallel --results $LOG_OUTPUT_DIR --joblog $OUTPUT_DIR/joblog $TEST_SCRIPT ::: \
Josh Habermanffc81182016-02-22 15:39:29 -080051 csharp \
Josh Haberman483533d2016-02-19 12:48:33 -080052 java_jdk7 \
53 javanano_jdk7 \
Josh Habermanffc81182016-02-22 15:39:29 -080054 java_oracle7 \
55 javanano_oracle7 \
Josh Haberman483533d2016-02-19 12:48:33 -080056 python \
Josh Habermanffc81182016-02-22 15:39:29 -080057 python_cpp \
Josh Haberman38bc1552016-02-23 14:28:02 -080058 ruby21 \
59 || true # Process test results even if tests fail.
Josh Haberman483533d2016-02-19 12:48:33 -080060
Josh Haberman67c727c2016-03-04 14:21:18 -080061cat $OUTPUT_DIR/joblog
62
Josh Haberman38bc1552016-02-23 14:28:02 -080063# 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
Josh Haberman67c727c2016-03-04 14:21:18 -080068# 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
Josh Haberman38bc1552016-02-23 14:28:02 -080071
72ls -l $TESTOUTPUT_XML_FILE