commit 6ad195521b1e53a2f34faeef6226ce0a47410bab
parent ad45c3e51aecc2acd864511b32227a81f2d8ad8f
Author: Dan Stillman <dstillman@zotero.org>
Date: Wed, 31 Aug 2016 02:10:23 -0400
Save test results after every translator
Goes with https://github.com/zotero/provo/commit/0813241150a0a5c6e6f527ae28a0bd1d5ce53485
Diffstat:
1 file changed, 6 insertions(+), 30 deletions(-)
diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js
@@ -39,7 +39,7 @@ Zotero_TranslatorTesters = new function() {
/**
* Runs all tests
*/
- this.runAllTests = function(numConcurrentTests, skipTranslators, doneCallback) {
+ this.runAllTests = function (numConcurrentTests, skipTranslators, resultsCallback) {
if(!Zotero) {
Zotero = Components.classes["@zotero.org/Zotero;1"]
.getService(Components.interfaces.nsISupports).wrappedJSObject;
@@ -59,7 +59,7 @@ Zotero_TranslatorTesters = new function() {
};
if(!(--waitingForTranslators)) {
- runTesters(testers, numConcurrentTests, doneCallback);
+ runTesters(testers, numConcurrentTests, resultsCallback);
}
} catch(e) {
Zotero.debug(e);
@@ -73,21 +73,10 @@ Zotero_TranslatorTesters = new function() {
/**
* Runs a specific set of tests
*/
- function runTesters(testers, numConcurrentTests, doneCallback) {
+ function runTesters(testers, numConcurrentTests, resultsCallback) {
var testersRunning = 0;
var results = []
- if("getLocaleCollation" in Zotero) {
- var collation = Zotero.getLocaleCollation();
- var strcmp = function(a, b) {
- return collation.compareString(1, a, b);
- };
- } else {
- var strcmp = function (a, b) {
- return a.toLowerCase().localeCompare(b.toLowerCase());
- };
- }
-
var testerDoneCallback = function(tester) {
try {
if(tester.pending.length) return;
@@ -96,26 +85,13 @@ Zotero_TranslatorTesters = new function() {
// Done translating, so serialize test results
testersRunning--;
- results.push(tester.serialize());
+ let results = tester.serialize();
+ let last = !testers.length && !testersRunning;
+ resultsCallback(results, last);
if(testers.length) {
// Run next tester if one is available
runNextTester();
- } else if(testersRunning === 0) {
- // Testing is done, so sort results
- results = results.sort(function(a, b) {
- if(a.type !== b.type) {
- return TEST_TYPES.indexOf(a.type) - TEST_TYPES.indexOf(b.type);
- }
- return strcmp(a.label, b.label);
- });
-
- // Call done callback
- doneCallback({
- "browser":Zotero.browser,
- "version":Zotero.version,
- "results":results
- });
}
} catch(e) {
Zotero.debug(e);