Add support for test retries and enable three retries on CI

This commit is contained in:
Tom Najdek 2026-03-11 10:11:14 +01:00 committed by Dan Stillman
parent be1373dd3a
commit d3509ae259
5 changed files with 15 additions and 4 deletions

View file

@ -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

View file

@ -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,

View file

@ -21,4 +21,5 @@ export var TestOptions = {
stopAt: false,
grep: false,
timeout: false,
retries: 0,
};

View file

@ -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);

View file

@ -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"