Update translatorTester for use in translation server
This commit is contained in:
parent
91bac0e052
commit
8d61e30a93
1 changed files with 13 additions and 3 deletions
|
@ -24,7 +24,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Timeout for test to complete
|
// Timeout for test to complete
|
||||||
var TEST_RUN_TIMEOUT = 600000;
|
var TEST_RUN_TIMEOUT = 60000;
|
||||||
var EXPORTED_SYMBOLS = ["Zotero_TranslatorTesters"];
|
var EXPORTED_SYMBOLS = ["Zotero_TranslatorTesters"];
|
||||||
|
|
||||||
// For debugging specific translators by label
|
// For debugging specific translators by label
|
||||||
|
@ -410,13 +410,17 @@ Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallba
|
||||||
* @param {Function} testDoneCallback - A callback to be executed when test is complete
|
* @param {Function} testDoneCallback - A callback to be executed when test is complete
|
||||||
*/
|
*/
|
||||||
Zotero_TranslatorTester.prototype.fetchPageAndRunTest = function (test, testDoneCallback) {
|
Zotero_TranslatorTester.prototype.fetchPageAndRunTest = function (test, testDoneCallback) {
|
||||||
|
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||||
|
this._cookieSandbox = require('request').jar();
|
||||||
|
}
|
||||||
Zotero.HTTP.processDocuments(
|
Zotero.HTTP.processDocuments(
|
||||||
test.url,
|
test.url,
|
||||||
(doc) => {
|
(doc) => {
|
||||||
this.runTest(test, doc, function (obj, test, status, message) {
|
this.runTest(test, doc, function (obj, test, status, message) {
|
||||||
testDoneCallback(obj, test, status, message);
|
testDoneCallback(obj, test, status, message);
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
this._cookieSandbox,
|
||||||
)
|
)
|
||||||
.catch(function (e) {
|
.catch(function (e) {
|
||||||
testDoneCallback(this, test, "failed", "Translation failed to initialize: " + e);
|
testDoneCallback(this, test, "failed", "Translation failed to initialize: " + e);
|
||||||
|
@ -442,6 +446,9 @@ Zotero_TranslatorTester.prototype.runTest = function(test, doc, testDoneCallback
|
||||||
} else if(this.type === "search") {
|
} else if(this.type === "search") {
|
||||||
translate.setSearch(test.input);
|
translate.setSearch(test.input);
|
||||||
}
|
}
|
||||||
|
if (translate.setCookieSandbox && this._cookieSandbox) {
|
||||||
|
translate.setCookieSandbox(this._cookieSandbox);
|
||||||
|
}
|
||||||
|
|
||||||
translate.setHandler("translators", function(obj, translators) {
|
translate.setHandler("translators", function(obj, translators) {
|
||||||
me._runTestTranslate(translate, translators, test, testDoneCallback);
|
me._runTestTranslate(translate, translators, test, testDoneCallback);
|
||||||
|
@ -765,5 +772,8 @@ Zotero_TranslatorTester._generateDiff = new function() {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (typeof process === 'object' && process + '' === '[object process]'){
|
if (typeof process === 'object' && process + '' === '[object process]'){
|
||||||
module.exports = Zotero_TranslatorTesters;
|
module.exports = {
|
||||||
|
Tester: Zotero_TranslatorTesters,
|
||||||
|
TranslatorTester: Zotero_TranslatorTester
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue