Skip to content

Commit d6c4dae

Browse files
chore(ci): fail fast when testing (#1890)
Add failfast flag to `go test` commands in test.sh
1 parent 0e2ebb1 commit d6c4dae

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

test.sh

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ manual() {
3232
set -e
3333
for pkg in $packages; do
3434
echo "===> Testing $pkg"
35-
go test $tags -timeout=25m $covermode $coverprofile -race -parallel 16 $pkg && write_coverage
35+
go test $tags -timeout=25m $covermode $coverprofile -failfast -race -parallel 16 $pkg && write_coverage || return 1
3636
done
3737
echo "==> DONE package tests"
3838

3939
echo "==> Running manual tests"
4040
# Run the special Truncate test.
4141
rm -rf p
4242
set -e
43-
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose$' --manual=true && write_coverage
43+
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose$' -failfast --manual=true && write_coverage || return 1
4444
truncate --size=4096 p/000000.vlog
45-
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose2$' --manual=true && write_coverage
46-
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose3$' --manual=true && write_coverage
45+
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose2$' -failfast --manual=true && write_coverage || return 1
46+
go test $tags $timeout $covermode $coverprofile -run='TestTruncateVlogNoClose3$' -failfast --manual=true && write_coverage || return 1
4747
rm -rf p
4848

4949
# TODO(ibrahim): Let's make these tests have Manual prefix.
@@ -52,14 +52,14 @@ manual() {
5252
# TestValueGCManaged
5353
# TestDropPrefix
5454
# TestDropAllManaged
55-
go test $tags $timeout $covermode $coverprofile -run='TestBigKeyValuePairs$' --manual=true && write_coverage
56-
go test $tags $timeout $covermode $coverprofile -run='TestPushValueLogLimit' --manual=true && write_coverage
57-
go test $tags $timeout $covermode $coverprofile -run='TestKeyCount' --manual=true && write_coverage
58-
go test $tags $timeout $covermode $coverprofile -run='TestIteratePrefix' --manual=true && write_coverage
59-
go test $tags $timeout $covermode $coverprofile -run='TestIterateParallel' --manual=true && write_coverage
60-
go test $tags $timeout $covermode $coverprofile -run='TestBigStream' --manual=true && write_coverage
61-
go test $tags $timeout $covermode $coverprofile -run='TestGoroutineLeak' --manual=true && write_coverage
62-
go test $tags $timeout $covermode $coverprofile -run='TestGetMore' --manual=true && write_coverage
55+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestBigKeyValuePairs$' --manual=true && write_coverage || return 1
56+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestPushValueLogLimit' --manual=true && write_coverage || return 1
57+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestKeyCount' --manual=true && write_coverage || return 1
58+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestIteratePrefix' --manual=true && write_coverage || return 1
59+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestIterateParallel' --manual=true && write_coverage || return 1
60+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestBigStream' --manual=true && write_coverage || return 1
61+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestGoroutineLeak' --manual=true && write_coverage || return 1
62+
go test $tags $timeout $covermode $coverprofile -failfast -run='TestGetMore' --manual=true && write_coverage || return 1
6363

6464
echo "==> DONE manual tests"
6565
}
@@ -69,8 +69,7 @@ root() {
6969
# go test -timeout=25m -v -race github.com/dgraph-io/badger/v4/...
7070

7171
echo "==> Running root level tests."
72-
set -e
73-
go test $tags -v -race -parallel=16 -timeout=25m $covermode $coverprofile . && write_coverage
72+
go test $tags -v -race -parallel=16 -timeout=25m -failfast $covermode $coverprofile . && write_coverage || return 1
7473
echo "==> DONE root level tests"
7574
}
7675

@@ -94,8 +93,8 @@ stream() {
9493
}
9594

9695
write_coverage() {
97-
if [ $CI = "true" ]; then
98-
if [ -f cover_tmp.out ]; then
96+
if [[ $CI = "true" ]]; then
97+
if [[ -f cover_tmp.out ]]; then
9998
sed -i '1d' cover_tmp.out
10099
cat cover_tmp.out >> cover.out && rm cover_tmp.out
101100
fi

0 commit comments

Comments
 (0)