www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 238ab8069938b45e2baf826c75f1b116ab52a712
parent b7daef6bf4331eacdf4033f4493fb194cbb06276
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 16 Dec 2016 04:21:21 -0500

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

Diffstat:
Mtest/components/zotero-unit.js | 1+
Mtest/content/runtests.js | 24++++++++++++++++++------
Mtest/runtests.sh | 9++++++++-
3 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/test/components/zotero-unit.js b/test/components/zotero-unit.js @@ -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); }, diff --git a/test/content/runtests.js b/test/content/runtests.js @@ -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()) { diff --git a/test/runtests.sh b/test/runtests.sh @@ -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" ;;