From 848ed41b4063c4621771fa1b27e9e987567ee5d8 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sat, 2 Dec 2023 11:29:46 +0100 Subject: [PATCH] ci(win test): deal better with hanging tests When tests hang, we do not see anything in the output, and the job just times out after 6 hours (!). To add insult to injury, the timeout prevents the `failed-tests-windows` artifact from being uploaded that is supposed to help with diagnosing the issue better. So let's first establish a generous timeout of 20 minutes for the `win test` matrix jobs (they typically take less than 10 minutes), and then handle the timed-out tests in addition to the failed ones, using the presence of a `.out` file in `t/test-results/` combined with the absence of a `.exit` file as a strong indicator that the corresponding test timed out. Signed-off-by: Johannes Schindelin --- .github/workflows/main.yml | 8 +++++++- ci/lib.sh | 15 +++++++++++++-- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 9fdbd5402898bf..d0e8e1e13181f1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -149,13 +149,19 @@ jobs: run: tar xf artifacts.tar.gz && tar xf tracked.tar.gz - uses: git-for-windows/setup-git-for-windows-sdk@v1 - name: test + id: test shell: bash + timeout-minutes: 20 run: . /etc/profile && ci/run-test-slice.sh ${{matrix.nr}} 10 + - name: handle timed-out tests + if: failure() && steps.test.outcome == 'failure' && env.FAILED_TEST_ARTIFACTS == '' + shell: bash + run: . /etc/profile && . ci/lib.sh && { handle_failed_tests || test $? = 1; } - name: print test failures if: failure() && env.FAILED_TEST_ARTIFACTS != '' shell: bash run: ci/print-test-failures.sh - - name: Upload failed tests' directories + - name: Upload failed/timed-out tests' directories if: failure() && env.FAILED_TEST_ARTIFACTS != '' uses: actions/upload-artifact@v3 with: diff --git a/ci/lib.sh b/ci/lib.sh index c749b21366b950..ca8e0c16aa6605 100755 --- a/ci/lib.sh +++ b/ci/lib.sh @@ -180,15 +180,26 @@ handle_failed_tests () { } create_failed_test_artifacts () { + # Handle timed-out tests + for test_out in t/test-results/*.out + do + test -f "${test_out%.out}.exit" || + echo timed-out >"${test_out%.out}.exit" + done + mkdir -p t/failed-test-artifacts for test_exit in t/test-results/*.exit do - test 0 != "$(cat "$test_exit")" || continue + case "$(cat "$test_exit")" in + 0) continue;; + timed-out) label="Timed-out";; + *) label="Failed";; + esac test_name="${test_exit%.exit}" test_name="${test_name##*/}" - printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n" + printf "\\e[33m\\e[1m=== ${label} test: ${test_name} ===\\e[m\\n" echo "The full logs are in the 'print test failures' step below." echo "See also the 'failed-tests-*' artifacts attached to this run." cat "t/test-results/$test_name.markup"