commit c11f1069d7136b2c9c60d2cfa8445f67f8da765e
parent dcfddac519e6bcb9842b6279ed13525ce95563ce
Author: Dan Stillman <dstillman@zotero.org>
Date: Tue, 20 Jun 2017 00:47:13 -0400
Add -e flag to runtests.sh to stop tests after a given file
This is useful when trying to debug an error that only happens after a
number of other tests have run -- specify -e and run tests from either
an earlier file with -s or from the beginning.
Diffstat:
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/test/components/zotero-unit.js b/test/components/zotero-unit.js
@@ -38,6 +38,7 @@ ZoteroUnit.prototype = {
this.runTests = !this.makeTestData;
this.bail = cmdLine.handleFlag("bail", false);
this.startAt = cmdLine.handleFlagWithParam("startAtTestFile", false);
+ this.stopAt = cmdLine.handleFlagWithParam("stopAtTestFile", false);
this.grep = cmdLine.handleFlagWithParam("grep", false);
this.timeout = cmdLine.handleFlagWithParam("ZoteroTestTimeout", false);
},
diff --git a/test/content/runtests.js b/test/content/runtests.js
@@ -240,6 +240,7 @@ if(run && ZoteroUnit.tests) {
var enumerator = testDirectory.directoryEntries;
let startFile = ZoteroUnit.startAt ? getTestFilename(ZoteroUnit.startAt) : false;
let started = !startFile;
+ let stopFile = ZoteroUnit.stopAt ? getTestFilename(ZoteroUnit.stopAt) : false;
while(enumerator.hasMoreElements()) {
var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
if(file.leafName.endsWith(".js")) {
@@ -247,6 +248,9 @@ if(run && ZoteroUnit.tests) {
testFiles.push(file.leafName);
started = true;
}
+ if (file.leafName == stopFile) {
+ break;
+ }
}
}
if (!started) {
diff --git a/test/runtests.sh b/test/runtests.sh
@@ -35,6 +35,7 @@ Options
-b skip bundled translator/style installation
-c open JavaScript console and don't quit on completion
-d LEVEL enable debug logging
+ -e TEST end at the given test
-f stop after first test failure
-g only run tests matching the given pattern (grep)
-h display this help
@@ -48,7 +49,7 @@ DONE
DEBUG=false
DEBUG_LEVEL=5
-while getopts "bcd:fg:hs:tx:" opt; do
+while getopts "bcd:e:fg:hs:tx:" opt; do
case $opt in
b)
FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
@@ -60,6 +61,12 @@ while getopts "bcd:fg:hs:tx:" opt; do
DEBUG=true
DEBUG_LEVEL="$OPTARG"
;;
+ e)
+ if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
+ usage
+ fi
+ FX_ARGS="$FX_ARGS -stopAtTestFile $OPTARG"
+ ;;
f)
FX_ARGS="$FX_ARGS -bail"
;;