Make debug messages a little nicer
This commit is contained in:
parent
2cd8ac04e2
commit
b6c8fb4483
1 changed files with 13 additions and 9 deletions
|
@ -121,13 +121,13 @@ Zotero_TranslatorTester.prototype.setTests = function(tests) {
|
||||||
*/
|
*/
|
||||||
Zotero_TranslatorTester.prototype.runTests = function(testDoneCallback, recursiveRun) {
|
Zotero_TranslatorTester.prototype.runTests = function(testDoneCallback, recursiveRun) {
|
||||||
if(!recursiveRun) {
|
if(!recursiveRun) {
|
||||||
var w = (this.pending.length === 1) ? " test" : " tests";
|
var w = (this.pending.length === 1) ? "test" : "tests";
|
||||||
this._debug(this, "TranslatorTester: Running "+this.pending.length+" "+w+" for "+this.translator.label);
|
this._debug(this, "TranslatorTester: Running "+this.pending.length+" "+w+" for "+this.translator.label);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!this.pending.length) {
|
if(!this.pending.length) {
|
||||||
// always call testDoneCallback once if there are no tests
|
// always call testDoneCallback once if there are no tests
|
||||||
if(!recursiveRun && testDoneCallback) testDoneCallback(this, null, "unknown", "No tests present");
|
if(!recursiveRun && testDoneCallback) testDoneCallback(this, null, "unknown", "No tests present\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,10 +139,13 @@ Zotero_TranslatorTester.prototype.runTests = function(testDoneCallback, recursiv
|
||||||
* @param {Function} testDoneCallback A callback to be executed each time a test is complete
|
* @param {Function} testDoneCallback A callback to be executed each time a test is complete
|
||||||
*/
|
*/
|
||||||
Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallback) {
|
Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallback) {
|
||||||
|
|
||||||
var test = this.pending.shift();
|
var test = this.pending.shift();
|
||||||
var testNumber = this.tests.length-this.pending.length;
|
var testNumber = this.tests.length-this.pending.length;
|
||||||
var me = this;
|
var me = this;
|
||||||
|
|
||||||
|
this._debug(this, "\nTranslatorTester: Running "+this.translator.label+" Test "+testNumber);
|
||||||
|
|
||||||
var callback = function(obj, test, status, message) {
|
var callback = function(obj, test, status, message) {
|
||||||
me._debug(this, "TranslatorTester: "+me.translator.label+" Test "+testNumber+": "+status+" ("+message+")");
|
me._debug(this, "TranslatorTester: "+me.translator.label+" Test "+testNumber+": "+status+" ("+message+")");
|
||||||
me[status].push(test);
|
me[status].push(test);
|
||||||
|
@ -151,6 +154,7 @@ Zotero_TranslatorTester.prototype._runTestsRecursively = function(testDoneCallba
|
||||||
};
|
};
|
||||||
|
|
||||||
if(this.type === "web") {
|
if(this.type === "web") {
|
||||||
|
this._debug(this, "TranslatorTester: Translating "+test.url);
|
||||||
this.fetchPageAndRunTest(test, callback);
|
this.fetchPageAndRunTest(test, callback);
|
||||||
} else {
|
} else {
|
||||||
this.runTest(test, null, callback);
|
this.runTest(test, null, callback);
|
||||||
|
@ -368,11 +372,11 @@ Zotero_TranslatorTester.prototype._compare = function(i, j) {
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
this._debug(this, "i is array, j is not");
|
this._debug(this, "TranslatorTester: i is array, j is not");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (Object.prototype.toString.apply(j) === '[object Array]') {
|
} else if (Object.prototype.toString.apply(j) === '[object Array]') {
|
||||||
this._debug(this, "j is array, i is not");
|
this._debug(this, "TranslatorTester: j is array, i is not");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -381,7 +385,7 @@ Zotero_TranslatorTester.prototype._compare = function(i, j) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
this._debug(this, JSON.stringify({i:i, j:j}));
|
this._debug(this, JSON.stringify({i:i, j:j}));
|
||||||
this._debug(this, "Items don't match");
|
this._debug(this, "TranslatorTester: Items don't match");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -411,7 +415,7 @@ Zotero_TranslatorTester.prototype._objectCompare = function(x, y) {
|
||||||
case 'function':
|
case 'function':
|
||||||
if (typeof(x[p])=='undefined'
|
if (typeof(x[p])=='undefined'
|
||||||
|| (y[p].toString() != x[p].toString())) {
|
|| (y[p].toString() != x[p].toString())) {
|
||||||
this._debug(this, "Function "+p+" defined in y, not in x, or definitions differ");
|
this._debug(this, "TranslatorTester: Function "+p+" defined in y, not in x, or definitions differ");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -419,19 +423,19 @@ Zotero_TranslatorTester.prototype._objectCompare = function(x, y) {
|
||||||
if (y[p] != x[p] && x[p] !== false) { // special exemption: x (test item)
|
if (y[p] != x[p] && x[p] !== false) { // special exemption: x (test item)
|
||||||
// can have a property set to false
|
// can have a property set to false
|
||||||
// and we will ignore it here
|
// and we will ignore it here
|
||||||
this._debug(this, "Param "+p+" differs: " + JSON.stringify({x:x[p], y:y[p]}));
|
this._debug(this, "TranslatorTester: Param "+p+" differs: " + JSON.stringify({x:x[p], y:y[p]}));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if(x[p] || x[p] === 0) {
|
} else if(x[p] || x[p] === 0) {
|
||||||
this._debug(this, "Param "+p+" true in x, not in y");
|
this._debug(this, "TranslatorTester: Param "+p+" true in x, not in y");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for(p in x) {
|
for(p in x) {
|
||||||
if((x[p] || x[p] === 0) && typeof(y[p])=='undefined') {
|
if((x[p] || x[p] === 0) && typeof(y[p])=='undefined') {
|
||||||
this._debug(this, "Param "+p+" in x not defined in y");
|
this._debug(this, "TranslatorTester: Param "+p+" in x not defined in y");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue