From d3509ae259d7444ce1826f2b91e27defe329802d Mon Sep 17 00:00:00 2001 From: Tom Najdek Date: Wed, 11 Mar 2026 10:11:14 +0100 Subject: [PATCH] Add support for test retries and enable three retries on CI --- .github/workflows/ci.yml | 2 +- app/assets/commandLineHandler.js | 1 + chrome/content/zotero/modules/commandLineOptions.mjs | 1 + test/content/runtests.js | 6 +++++- test/runtests.sh | 9 +++++++-- 5 files changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0909fe5542..053963323e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -101,7 +101,7 @@ jobs: dpl s3 --bucket zotero-download --local_dir build-zip --upload_dir ci/client --acl public_read - name: Run tests - run: xvfb-run test/runtests.sh -f + run: xvfb-run test/runtests.sh -f -r 3 - name: Cache utilities Node modules id: utilities-node-cache diff --git a/app/assets/commandLineHandler.js b/app/assets/commandLineHandler.js index 560f22c7db..8fe82c1a2f 100644 --- a/app/assets/commandLineHandler.js +++ b/app/assets/commandLineHandler.js @@ -52,6 +52,7 @@ if (processTestOptions) { TestOptions.stopAt = cmdLine.handleFlagWithParam("stopAtTestFile", false); TestOptions.grep = cmdLine.handleFlagWithParam("grep", false); TestOptions.timeout = cmdLine.handleFlagWithParam("ZoteroTestTimeout", false); + TestOptions.retries = cmdLine.handleFlagWithParam("retries", false) || 0; Services.ww.openWindow( null, diff --git a/chrome/content/zotero/modules/commandLineOptions.mjs b/chrome/content/zotero/modules/commandLineOptions.mjs index cfe3f4f3a2..d1c343b460 100644 --- a/chrome/content/zotero/modules/commandLineOptions.mjs +++ b/chrome/content/zotero/modules/commandLineOptions.mjs @@ -21,4 +21,5 @@ export var TestOptions = { stopAt: false, grep: false, timeout: false, + retries: 0, }; diff --git a/test/content/runtests.js b/test/content/runtests.js index fb0b7d7921..702cbe84f2 100644 --- a/test/content/runtests.js +++ b/test/content/runtests.js @@ -115,6 +115,9 @@ function Reporter(runner) { if ('fast' != test.speed) { msg += " ("+Math.round(test.duration)+" ms)"; } + if (test._currentRetry > 0) { + msg += " (passed on retry " + test._currentRetry + ")"; + } dump(msg+"\n"); }); @@ -163,7 +166,8 @@ mocha.setup({ ui: "bdd", reporter: Reporter, timeout: TestOptions.timeout || 10000, - grep: TestOptions.grep + grep: TestOptions.grep, + retries: TestOptions.retries || 0, }); coMocha(Mocha); diff --git a/test/runtests.sh b/test/runtests.sh index 85471d1a17..fbd1758170 100755 --- a/test/runtests.sh +++ b/test/runtests.sh @@ -46,6 +46,7 @@ Options -f stop after first test failure -g only run tests matching the given pattern (grep) -h display this help + -r RETRIES retry failed tests the given number of times (default: 0) -s TEST start at the given test -t generate test data and quit -x EXECUTABLE path to Zotero executable (default: $Z_EXECUTABLE) @@ -56,7 +57,8 @@ DONE DEBUG=false DEBUG_LEVEL=5 -while getopts "bcd:e:fg:hs:tx:" opt; do +RETRIES=0 +while getopts "bcd:e:fg:hr:s:tx:" opt; do case $opt in b) Z_ARGS="$Z_ARGS -ZoteroSkipBundledFiles" @@ -83,6 +85,9 @@ while getopts "bcd:e:fg:hs:tx:" opt; do h) usage ;; + r) + RETRIES="$OPTARG" + ;; s) if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then usage @@ -176,7 +181,7 @@ ZOTERO_TEST=1 "$ROOT_DIR/app/scripts/dir_build" -q makePath FX_PROFILE "$PROFILE" MOZ_NO_REMOTE=1 NO_EM_RESTART=1 "$Z_EXECUTABLE" -profile "$FX_PROFILE" \ - -test "$TESTS" -grep "$GREP" -ZoteroTest $Z_ARGS + -test "$TESTS" -grep "$GREP" -retries "$RETRIES" -ZoteroTest $Z_ARGS # Check for success test -e "$PROFILE/success"