Skip to content
Draft
Show file tree
Hide file tree
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
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,12 @@ $Q FAIL=""; for dir in $1; do \
done; test -z "$$FAIL" || (echo "Failed packages; $$FAIL"; exit 1)
endef

define individual_looptest
$Q FAIL=""; for dir in $1; do \
./scripts/run_tests_separately.sh "$$dir" $(TEST_ARG) -coverprofile=$@ $(TEST_TAG) -exec /usr/bin/true | tee -a test.log || FAIL="$$FAIL $$dir"; \
done; test -z "$$FAIL" || (echo "Failed packages; $$FAIL"; exit 1)
endef

test: ## Build and run all tests locally
$Q rm -f test
$Q rm -f test.log
Expand All @@ -673,13 +679,13 @@ test_dirs:
test_e2e:
$Q rm -f test
$Q rm -f test.log
$Q $(call looptest,$(INTEG_TEST_ROOT))
$Q $(call individual_looptest,$(INTEG_TEST_ROOT))

# need to run end-to-end xdc tests with race detector off because of ringpop bug causing data race issue
test_e2e_xdc:
$Q rm -f test
$Q rm -f test.log
$Q $(call looptest,$(INTEG_TEST_XDC_ROOT))
$Q $(call individual_looptest,$(INTEG_TEST_XDC_ROOT))

cover_profile:
$Q mkdir -p $(BUILD)
Expand Down
34 changes: 34 additions & 0 deletions scripts/run_tests_separately.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/usr/bin/env bash

set -eou pipefail

# basic idea:
# - `go test -list` to print all the test names
# - janky `jq` to filter that output, because -json doesn't differentiate
# between "what you asked for" vs "the package's results"
# vs "random in-test output" which is absolutely ridiculous imo
# - iterate through that output and execute it, so we can tell which test
# produced what output / failed / etc

target="$1"
shift

test_names_orig="$(go test -list '.' -json "$target")"
test_name_lines="$(
echo "$test_names_orig" \
| jq 'select(.Action == "output") | select(.Output | startswith("Test"))' --compact-output --raw-output
)"
test_names_and_args="$(
echo "$test_name_lines" \
| jq '{"package":(.Package | ltrimstr("github.com/uber/cadence/")), "name":(.Output | rtrimstr("\n"))}' --compact-output --raw-output
)"

while read -r each_test; do
pkg="$(echo "$each_test" | jq .package --raw-output)"
tst="'^$(echo "$each_test" | jq .name --raw-output)\$'"
cmd="go test ${*@Q} -run ${tst} ./${pkg}"
echo "----------------------------------------------"
echo "$cmd"
eval "$cmd"
echo "----------------------------------------------"
done < <(echo "$test_names_and_args")
Loading