diff --git a/chrome/content/zotero/tools/testTranslators/testTranslators.js b/chrome/content/zotero/tools/testTranslators/testTranslators.js index d4a4d01feb..6375f7c251 100644 --- a/chrome/content/zotero/tools/testTranslators/testTranslators.js +++ b/chrome/content/zotero/tools/testTranslators/testTranslators.js @@ -170,10 +170,10 @@ TranslatorTestView.prototype.serialize = function(serializedData) { "output":this._outputView.getOutput(), "label":this._label.textContent, "isSupported":this.isSupported, - "pending":parseInt(this._pending.textContent), - "failed":parseInt(this._failed.textContent), - "succeeded":parseInt(this._succeeded.textContent), - "unknown":parseInt(this._unknown.textContent) + "pending":this._translatorTester.pending, + "failed":this._translatorTester.failed, + "succeeded":this._translatorTester.succeeded, + "unknown":this._translatorTester.unknown }; } diff --git a/chrome/content/zotero/tools/testTranslators/translatorTester.js b/chrome/content/zotero/tools/testTranslators/translatorTester.js index ebbb4ba14a..4a6b4569e3 100644 --- a/chrome/content/zotero/tools/testTranslators/translatorTester.js +++ b/chrome/content/zotero/tools/testTranslators/translatorTester.js @@ -153,6 +153,7 @@ Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallba me._debug(this, "TranslatorTester: "+me.translator.label+" Test "+testNumber+": "+status+" ("+message+")"); me[status].push(test); + test.message = message; if(testDoneCallback) testDoneCallback(me, test, status, message); me.runTests(testDoneCallback, true); }; @@ -217,8 +218,12 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback me._runTestTranslate(translate, translators, test, testDoneCallback); }); translate.setHandler("debug", this._debug); + var errorReturned; + translate.setHandler("error", function(obj, err) { + errorReturned = err; + }); translate.setHandler("done", function(obj, returnValue) { - me._checkResult(test, obj, returnValue, testDoneCallback); + me._checkResult(test, obj, returnValue, errorReturned, testDoneCallback); }); translate.setHandler("select", function(obj, items, callback) { if(test.items !== "multiple" && test.items.length <= 1) { @@ -275,9 +280,23 @@ Zotero_TranslatorTester.prototype._runTestTranslate = function(translate, transl * @param {Object} test Test that was executed * @param {Zotero.Translate} translate The Zotero.Translate instance * @param {Boolean} returnValue Whether translation completed successfully + * @param {Error} error Error code, if one was specified * @param {Function} testDoneCallback A callback to be executed when test is complete */ -Zotero_TranslatorTester.prototype._checkResult = function(test, translate, returnValue, testDoneCallback) { +Zotero_TranslatorTester.prototype._checkResult = function(test, translate, returnValue, error, testDoneCallback) { + if(error) { + var errorString = "Translation failed: "+error.toString(); + if(typeof error === "object") { + for(var i in error) { + if(typeof(error[i]) != "object") { + errorString += "\n"+i+' => '+error[i]; + } + } + } + testDoneCallback(this, test, "failed", errorString); + return; + } + if(!returnValue) { testDoneCallback(this, test, "failed", "Translation failed; examine debug output for errors"); return; @@ -299,6 +318,7 @@ Zotero_TranslatorTester.prototype._checkResult = function(test, translate, retur var translatedItem = Zotero_TranslatorTester._sanitizeItem(translate.newItems[i]); if(!this._compare(testItem, translatedItem)) { + test.translatedItem = testItem; testDoneCallback(this, test, "unknown", "Item "+i+" does not match"); return; }