www

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

commit 8253b981341c2a1aa21fa953e36c384bb29bb78d
parent 4c456853316312755815f35a66daf621653bdd12
Author: Simon Kornblith <simon@simonster.com>
Date:   Mon,  9 Mar 2015 17:41:17 -0400

Remove index.js and just enumerate the files in the test directory

Diffstat:
Mtest/content/runtests.html | 1-
Mtest/content/runtests.js | 51+++++++++++++++++++++++++++++++++++----------------
Dtest/tests/index.js | 6------
3 files changed, 35 insertions(+), 23 deletions(-)

diff --git a/test/content/runtests.html b/test/content/runtests.html @@ -8,7 +8,6 @@ <script src="chrome://zotero/content/include.js"></script> <script src="resource://zotero-unit/chai/chai.js"></script> <script src="resource://zotero-unit/mocha/mocha.js"></script> - <script src="resource://zotero-unit-tests/index.js"></script> <script src="support.js" version="application/javascript;version=1.8"></script> <script src="runtests.js" version="application/javascript;version=1.8"></script> </body> diff --git a/test/content/runtests.js b/test/content/runtests.js @@ -71,24 +71,43 @@ var assert = chai.assert, expect = chai.expect; // Set up tests to run +var run = true; if(ZoteroUnit.tests) { - document.body.appendChild(document.createTextNode("Running tests...")); - var torun = ZoteroUnit.tests == "all" ? Object.keys(TESTS) : ZoteroUnit.tests.split(","); - - for(var key of torun) { - if(!TESTS[key]) { - dump("Invalid test set "+torun+"\n"); - quit(true); + var testDirectory = getTestDataDirectory().parent, + testFiles = []; + if(ZoteroUnit.tests == "all") { + var enumerator = testDirectory.directoryEntries; + while(enumerator.hasMoreElements()) { + var file = enumerator.getNext().QueryInterface(Components.interfaces.nsIFile); + if(file.leafName.endsWith(".js")) { + testFiles.push(file.leafName); + } } - for(var test of TESTS[key]) { - var el = document.createElement("script"); - el.type = "application/javascript;version=1.8"; - el.src = "resource://zotero-unit-tests/"+test; - document.body.appendChild(el); + } else { + var specifiedTests = ZoteroUnit.tests.split(","); + for(var test of specifiedTests) { + var fname = test+".js", + file = testDirectory.clone(); + file.append(fname); + if(!file.exists()) { + dump("Invalid test file "+test+"\n"); + run = false; + quit(true); + } + testFiles.push(fname); } } + + for(var fname of testFiles) { + var el = document.createElement("script"); + el.type = "application/javascript;version=1.8"; + el.src = "resource://zotero-unit-tests/"+fname; + document.body.appendChild(el); + } } -window.onload = function() { - mocha.run(); -}; -\ No newline at end of file +if(run) { + window.onload = function() { + mocha.run(); + }; +} +\ No newline at end of file diff --git a/test/tests/index.js b/test/tests/index.js @@ -1,6 +0,0 @@ -var TESTS = { - "support":["support.js"], - "utilities":["utilities.js"], - "lookup":["lookup.js"], - "recognizePDF":["recognizePDF.js"] -};