Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 24 additions & 16 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,30 @@ function run_and_expect_silence() {
# Testing Helpers
#
function run_unit_tests() {
go test "${UNIT_FLAGS[@]}" "${UNIT_PACKAGES[@]}" "${FILTER[@]}"
# Sleep 50ms instead of 1000ms at the end of each package's unittests.
# Speeds up running lots of small unittests.
# https://go.dev/doc/articles/race_detector#Options
export GORACE="atexit_sleep_ms=50"
# If unit test packages are not specified: set flags to run unit tests
# for all boulder packages
if [ -z "${UNIT_PACKAGES[@]+x}" ]
then
# The ra and sa unittests conflict because they both mutate the database.
# Exclude the ra from our first test run, then run on its own.
# https://github.com/letsencrypt/boulder/issues/1499
go_test $(go list ./... | grep -v boulder/ra)
go_test ./ra
else
go_test "${UNIT_PACKAGES[@]}"
fi

}

#
# Run `go test` on a given set of packages.
#
function go_test() {
go test "${UNIT_FLAGS[@]}" "${FILTER[@]}" "$@"
}

#
Expand Down Expand Up @@ -176,21 +199,6 @@ then
FILTER=(--filter "${FILTER[@]}")
fi

# If unit test packages are not specified: set flags to run unit tests
# for all boulder packages
if [ -z "${UNIT_PACKAGES[@]+x}" ]
then
# '-p=1' configures unit tests to run serially, rather than in parallel. Our
# unit tests depend on mutating a database and then cleaning up after
# themselves. If these test were run in parallel, they could fail spuriously
# due to one test modifying a table (especially registrations) while another
# test is reading from it.
# https://github.com/letsencrypt/boulder/issues/1499
# https://pkg.go.dev/cmd/go#hdr-Testing_flags
UNIT_FLAGS+=("-p=1")
UNIT_PACKAGES+=("./...")
fi

print_heading "Boulder Test Suite CLI"
print_heading "Settings:"

Expand Down