Add -s flag to runtests.sh to start at given file
Useful for restarting after spurious errors when using -f E.g., ./runtests.sh -s syncEngine
This commit is contained in:
parent
b7daef6bf4
commit
238ab80699
3 changed files with 27 additions and 7 deletions
|
@ -37,6 +37,7 @@ ZoteroUnit.prototype = {
|
|||
this.noquit = !this.makeTestData && this.noquit;
|
||||
this.runTests = !this.makeTestData;
|
||||
this.bail = cmdLine.handleFlag("bail", false);
|
||||
this.startAt = cmdLine.handleFlagWithParam("startAtTestFile", false);
|
||||
this.grep = cmdLine.handleFlagWithParam("grep", false);
|
||||
this.timeout = cmdLine.handleFlagWithParam("ZoteroTestTimeout", false);
|
||||
},
|
||||
|
|
|
@ -236,25 +236,37 @@ var assert = chai.assert,
|
|||
// Set up tests to run
|
||||
var run = ZoteroUnit.runTests;
|
||||
if(run && ZoteroUnit.tests) {
|
||||
function getTestFilename(test) {
|
||||
// Allow foo, fooTest, fooTest.js, and tests/fooTest.js
|
||||
test = test.replace(/\.js$/, "");
|
||||
test = test.replace(/Test$/, "");
|
||||
test = test.replace(/^tests[/\\]/, "");
|
||||
return test + "Test.js";
|
||||
}
|
||||
|
||||
var testDirectory = getTestDataDirectory().parent,
|
||||
testFiles = [];
|
||||
if(ZoteroUnit.tests == "all") {
|
||||
var enumerator = testDirectory.directoryEntries;
|
||||
let startFile = ZoteroUnit.startAt ? getTestFilename(ZoteroUnit.startAt) : false;
|
||||
let started = !startFile;
|
||||
while(enumerator.hasMoreElements()) {
|
||||
var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
|
||||
if(file.leafName.endsWith(".js")) {
|
||||
testFiles.push(file.leafName);
|
||||
if (started || file.leafName == startFile) {
|
||||
testFiles.push(file.leafName);
|
||||
started = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!started) {
|
||||
dump(`Invalid start file ${startFile}\n`);
|
||||
}
|
||||
testFiles.sort();
|
||||
} else {
|
||||
var specifiedTests = ZoteroUnit.tests.split(",");
|
||||
for (let test of specifiedTests) {
|
||||
// Allow foo, fooTest, fooTest.js, and tests/fooTest.js
|
||||
test = test.replace(/\.js$/, "");
|
||||
test = test.replace(/Test$/, "");
|
||||
test = test.replace(/^tests[/\\]/, "");
|
||||
let fname = test + "Test.js";
|
||||
let fname = getTestFilename(test);
|
||||
let file = testDirectory.clone();
|
||||
file.append(fname);
|
||||
if (!file.exists()) {
|
||||
|
|
|
@ -38,6 +38,7 @@ Options
|
|||
-f stop after first test failure
|
||||
-g only run tests matching the given pattern (grep)
|
||||
-h display this help
|
||||
-s TEST start at the given test
|
||||
-t generate test data and quit
|
||||
-x FX_EXECUTABLE path to Firefox executable (default: $FX_EXECUTABLE)
|
||||
TESTS set of tests to run (default: all)
|
||||
|
@ -47,7 +48,7 @@ DONE
|
|||
|
||||
DEBUG=false
|
||||
DEBUG_LEVEL=5
|
||||
while getopts "bcd:fg:htx:" opt; do
|
||||
while getopts "bcd:fg:hs:tx:" opt; do
|
||||
case $opt in
|
||||
b)
|
||||
FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
|
||||
|
@ -68,6 +69,12 @@ while getopts "bcd:fg:htx:" opt; do
|
|||
h)
|
||||
usage
|
||||
;;
|
||||
s)
|
||||
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
||||
usage
|
||||
fi
|
||||
FX_ARGS="$FX_ARGS -startAtTestFile $OPTARG"
|
||||
;;
|
||||
t)
|
||||
FX_ARGS="$FX_ARGS -makeTestData"
|
||||
;;
|
||||
|
|
Loading…
Reference in a new issue