forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
/
teamcity-testrace.sh
executable file
·57 lines (49 loc) · 1.87 KB
/
teamcity-testrace.sh
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
#!/usr/bin/env bash
set -euo pipefail
source "$(dirname "${0}")/teamcity-support.sh"
tc_prepare
export TMPDIR=$PWD/artifacts/testrace
mkdir -p "$TMPDIR"
tc_start_block "Determine changed packages"
if tc_release_branch; then
pkgspec=./pkg/...
echo "On release branch ($TC_BUILD_BRANCH), so running testrace on all packages ($pkgspec)"
else
pkgspec=$(changed_go_pkgs)
if [[ $(echo "$pkgspec" | wc -w) -gt 10 ]]; then
echo "PR #$TC_BUILD_BRANCH changed many packages; skipping race detector tests"
exit 0
elif [[ -z "$pkgspec" ]]; then
echo "PR #$TC_BUILD_BRANCH has no changed packages; skipping race detector tests"
exit 0
fi
if [[ $pkgspec == *"./pkg/sql/opt"* ]]; then
# If one opt package was changed, run all opt packages (the optimizer puts
# various checks behind the race flag to keep them out of release builds).
echo "$pkgspec" | sed 's$./pkg/sql/opt/[^ ]*$$g'
pkgspec=$(echo "$pkgspec" | sed 's$./pkg/sql/opt[^ ]*$$g')
pkgspec="$pkgspec ./pkg/sql/opt/..."
fi
echo "PR #$TC_BUILD_BRANCH has changed packages; running race detector tests on $pkgspec"
fi
tc_end_block "Determine changed packages"
tc_start_block "Compile C dependencies"
# Buffer noisy output and only print it on failure.
run build/builder.sh make -Otarget c-deps GOFLAGS=-race &> artifacts/race-c-build.log || (cat artifacts/race-c-build.log && false)
rm artifacts/race-c-build.log
tc_end_block "Compile C dependencies"
# Expect the timeout to come from the TC environment.
TESTTIMEOUT=${TESTTIMEOUT:-45m}
for pkg in $pkgspec; do
tc_start_block "Run ${pkg} under race detector"
run_json_test build/builder.sh env \
COCKROACH_LOGIC_TESTS_SKIP=true \
GOMAXPROCS=8 \
stdbuf -oL -eL \
make testrace \
GOTESTFLAGS=-json \
PKG="$pkg" \
TESTTIMEOUT="${TESTTIMEOUT}" \
TESTFLAGS="-v $TESTFLAGS"
tc_end_block "Run ${pkg} under race detector"
done