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
|
@ -37,6 +37,7 @@ ZoteroUnit.prototype = {
|
||||||
this.noquit = !this.makeTestData && this.noquit;
|
this.noquit = !this.makeTestData && this.noquit;
|
||||||
this.runTests = !this.makeTestData;
|
this.runTests = !this.makeTestData;
|
||||||
this.bail = cmdLine.handleFlag("bail", false);
|
this.bail = cmdLine.handleFlag("bail", false);
|
||||||
|
this.startAt = cmdLine.handleFlagWithParam("startAtTestFile", false);
|
||||||
this.grep = cmdLine.handleFlagWithParam("grep", false);
|
this.grep = cmdLine.handleFlagWithParam("grep", false);
|
||||||
this.timeout = cmdLine.handleFlagWithParam("ZoteroTestTimeout", false);
|
this.timeout = cmdLine.handleFlagWithParam("ZoteroTestTimeout", false);
|
||||||
},
|
},
|
||||||
|
|
|
@ -236,25 +236,37 @@ var assert = chai.assert,
|
||||||
// Set up tests to run
|
// Set up tests to run
|
||||||
var run = ZoteroUnit.runTests;
|
var run = ZoteroUnit.runTests;
|
||||||
if(run && ZoteroUnit.tests) {
|
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,
|
var testDirectory = getTestDataDirectory().parent,
|
||||||
testFiles = [];
|
testFiles = [];
|
||||||
if(ZoteroUnit.tests == "all") {
|
if(ZoteroUnit.tests == "all") {
|
||||||
var enumerator = testDirectory.directoryEntries;
|
var enumerator = testDirectory.directoryEntries;
|
||||||
|
let startFile = ZoteroUnit.startAt ? getTestFilename(ZoteroUnit.startAt) : false;
|
||||||
|
let started = !startFile;
|
||||||
while(enumerator.hasMoreElements()) {
|
while(enumerator.hasMoreElements()) {
|
||||||
var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
|
var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile);
|
||||||
if(file.leafName.endsWith(".js")) {
|
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();
|
testFiles.sort();
|
||||||
} else {
|
} else {
|
||||||
var specifiedTests = ZoteroUnit.tests.split(",");
|
var specifiedTests = ZoteroUnit.tests.split(",");
|
||||||
for (let test of specifiedTests) {
|
for (let test of specifiedTests) {
|
||||||
// Allow foo, fooTest, fooTest.js, and tests/fooTest.js
|
let fname = getTestFilename(test);
|
||||||
test = test.replace(/\.js$/, "");
|
|
||||||
test = test.replace(/Test$/, "");
|
|
||||||
test = test.replace(/^tests[/\\]/, "");
|
|
||||||
let fname = test + "Test.js";
|
|
||||||
let file = testDirectory.clone();
|
let file = testDirectory.clone();
|
||||||
file.append(fname);
|
file.append(fname);
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
|
|
|
@ -38,6 +38,7 @@ Options
|
||||||
-f stop after first test failure
|
-f stop after first test failure
|
||||||
-g only run tests matching the given pattern (grep)
|
-g only run tests matching the given pattern (grep)
|
||||||
-h display this help
|
-h display this help
|
||||||
|
-s TEST start at the given test
|
||||||
-t generate test data and quit
|
-t generate test data and quit
|
||||||
-x FX_EXECUTABLE path to Firefox executable (default: $FX_EXECUTABLE)
|
-x FX_EXECUTABLE path to Firefox executable (default: $FX_EXECUTABLE)
|
||||||
TESTS set of tests to run (default: all)
|
TESTS set of tests to run (default: all)
|
||||||
|
@ -47,7 +48,7 @@ DONE
|
||||||
|
|
||||||
DEBUG=false
|
DEBUG=false
|
||||||
DEBUG_LEVEL=5
|
DEBUG_LEVEL=5
|
||||||
while getopts "bcd:fg:htx:" opt; do
|
while getopts "bcd:fg:hs:tx:" opt; do
|
||||||
case $opt in
|
case $opt in
|
||||||
b)
|
b)
|
||||||
FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
|
FX_ARGS="$FX_ARGS -ZoteroSkipBundledFiles"
|
||||||
|
@ -68,6 +69,12 @@ while getopts "bcd:fg:htx:" opt; do
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
;;
|
;;
|
||||||
|
s)
|
||||||
|
if [[ -z "$OPTARG" ]] || [[ ${OPTARG:0:1} = "-" ]]; then
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
FX_ARGS="$FX_ARGS -startAtTestFile $OPTARG"
|
||||||
|
;;
|
||||||
t)
|
t)
|
||||||
FX_ARGS="$FX_ARGS -makeTestData"
|
FX_ARGS="$FX_ARGS -makeTestData"
|
||||||
;;
|
;;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user