forked from kaitai-io/kaitai_struct_tests
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-go
executable file
·65 lines (53 loc) · 2.05 KB
/
ci-go
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
64
65
#!/bin/sh
. ./config
DIVIDER=":"
CWD=$(pwd)
if [ "$OS" = "Windows_NT" ]; then
DIVIDER=";"
# GOPATH needs the real Windows path, `pwd -W` should work (at least works for me in Git Bash for Windows (MSYS2 terminal))
CWD=$(pwd -W || pwd)
fi
export GOPATH="$CWD/compiled/go${DIVIDER}$GOPATH"
# Symlink Go runtime libraries from full umbrella project checkout
mkdir -p compiled/go/src/github.com/kaitai-io
rm -rf compiled/go/src/github.com/kaitai-io/kaitai_struct_go_runtime
ln -s ../../../../../../runtime/go compiled/go/src/github.com/kaitai-io/kaitai_struct_go_runtime
ABS_TEST_OUT_DIR="$(pwd)/$TEST_OUT_DIR"
ABS_REPORT_LOG="$ABS_TEST_OUT_DIR/go/report.log"
mkdir -p "$TEST_OUT_DIR/go"
rm -f "$TEST_OUT_DIR/go/build.fails"
cd spec/go
keep_compiling=1
while [ "$keep_compiling" = 1 ]; do
if { GO111MODULE=off go test -v . >"$ABS_REPORT_LOG" 2>&1; ex=$?; [ $ex -eq 1 ] || [ $ex -eq 0 ]; }; then
keep_compiling=0
cat "$ABS_REPORT_LOG"
else
echo "Got error:"
cat "$ABS_REPORT_LOG"
if [ -n "$NO_RECOVER" ]; then
echo "No recovery requested, bailing out"
exit 1
fi
if egrep "^\.\.[\\/]\.\.[\\/]compiled[\\/]go[\\/].*:[0-9][0-9]*:" "$ABS_REPORT_LOG" >"$ABS_TEST_OUT_DIR/go/err.now"; then
cat "$ABS_TEST_OUT_DIR/go/err.now" >>"$ABS_TEST_OUT_DIR/go/build.fails"
sed -e 's/:.*//' -e 's/\\/\//g' <"$ABS_TEST_OUT_DIR/go/err.now" | sort -u >"$ABS_TEST_OUT_DIR/go/to_delete.now"
xargs rm <"$ABS_TEST_OUT_DIR/go/to_delete.now"
echo "Trying to recover, deleting..."
cat "$ABS_TEST_OUT_DIR/go/to_delete.now"
keep_compiling=1
else
echo "Unable to recover, bailing out :("
keep_compiling=0
exit 1
fi
fi
done
cd ../..
go-junit-report -in "$ABS_TEST_OUT_DIR/go/report.log" -out "$ABS_TEST_OUT_DIR/go/report.xml"
COUNT_TOTAL=$(grep '^=== RUN' "$ABS_REPORT_LOG" | wc -l)
COUNT_FAIL=$(grep '^--- FAIL' "$ABS_REPORT_LOG" | wc -l)
COUNT_PASS=$(grep '^--- PASS' "$ABS_REPORT_LOG" | wc -l)
echo "Totals: $COUNT_TOTAL ran, $COUNT_PASS passed, $COUNT_FAIL failed"
./kst-adoption-report go
aggregate/convert_to_json go "$TEST_OUT_DIR/go" "$TEST_OUT_DIR/go/ci.json"