-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjunits.sh
More file actions
executable file
·64 lines (52 loc) · 1.63 KB
/
junits.sh
File metadata and controls
executable file
·64 lines (52 loc) · 1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Clean out any old sandboxes, make a new one
OUTDIR=sandbox
rm -fr $OUTDIR; mkdir -p $OUTDIR
# Check for os
SEP=:
case "`uname`" in
CYGWIN* )
SEP=";"
;;
esac
# Run cleanup on interrupt or exit
function cleanup () {
kill -9 ${PID_1} ${PID_2} ${PID_3} ${PID_4} 1> /dev/null 2>&1
wait 1> /dev/null 2>&1
RC=`cat $OUTDIR/status.0`
if [ $RC -ne 0 ]; then
cat $OUTDIR/out.0
echo junit tests FAILED
else
echo junit tests PASSED
fi
exit $RC
}
trap cleanup SIGTERM SIGINT
# Find java command
if [ -z "$TEST_JAVA_HOME" ]; then
# Use default
JAVA_CMD="java"
else
# Use test java home
JAVA_CMD="$TEST_JAVA_HOME/bin/java"
fi
MAX_MEM="-Xmx15g -Xms15g -XX:+PrintGC"
# Command to invoke test.
JVM="nice $JAVA_CMD $MAX_MEM -ea -cp build/*${SEP}lib/*"
echo "$JVM" > $OUTDIR/jvm_cmd.txt
# Runner
JUNIT_RUNNER="org.junit.runner.JUnitCore"
# find all java in the src/test directory
# add 'sort' to get determinism on order of tests on different machines
# methods within a class can still reorder due to junit?
# '/usr/bin/sort' needed to avoid windows native sort when run in cygwin
(cd src/test/java; /usr/bin/find . -name '*.java' | cut -c3- | sed 's/.....$//' | sed -e 's/\//./g') | grep -v ComparisonUtils | /usr/bin/sort > $OUTDIR/tests.txt
# Launch last driver JVM. All output redir'd at the OS level to sandbox files.
echo Running junits...
while read p; do
echo Running test $p
($JVM $JUNIT_RUNNER $p 2>&1 ; echo $? > $OUTDIR/status.0) 1>> $OUTDIR/out.0 2>&1
done < $OUTDIR/tests.txt
grep EXECUTION $OUTDIR/out.0 | cut "-d " -f23,20 | awk '{print $2 " " $1}'| sort -gr | head -n 10 >> $OUTDIR/out.0
cleanup