Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/_common.js

Issue 29622595: Issue 6090 - Properly use regexp for message matching and proper console override (Closed) Base URL: https://hg.adblockplus.org/adblockpluscore/
Patch Set: Created Nov. 28, 2017, 3:28 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/_common.js
===================================================================
--- a/test/_common.js
+++ b/test/_common.js
@@ -86,20 +86,16 @@
return {[resourceName]: resources[resourceName]};
throw new Error(
"Attempt to import unknown JavaScript module " + resource
);
},
reportError(e) {}
},
- console: {
- log: console.log.bind(console),
- error: console.error.bind(console)
- },
navigator: {
},
onShutdown: {
add() {}
},
URL
};
@@ -416,48 +412,49 @@
}
};
};
console.warn = console.log;
exports.silenceWarnOutput = function(test, msg)
{
- let warnHandler = globals.console.warn;
- globals.console.warn = s =>
+ let warnHandler = console.warn;
+ console.warn = s =>
{
if (s != msg)
warnHandler(s);
};
try
{
return test();
}
finally
{
- globals.console.warn = warnHandler;
+ console.warn = warnHandler;
}
};
exports.silenceAssertionOutput = function(test, msg)
{
- let msgMatch = new RegExp(`^Error: ${msg}[\r\n]`);
- let errorHandler = globals.console.error;
- globals.console.error = s =>
+ let msgMatch = new RegExp("^Error: (.*)[\r\n]");
+ let errorHandler = console.error;
+ console.error = s =>
sergei 2017/11/28 15:46:22 should not we wrap even a single argument of the l
hub 2017/11/28 15:54:20 This follow our code style.
{
- if (!msgMatch.test(s))
+ let match = msgMatch.match(s);
sergei 2017/11/28 15:46:22 AFAIR regexp does not have method `match`, it shou
hub 2017/11/28 15:54:20 Already fixed in the patch update. I have no idea
+ if (!match || match[1] != msg)
errorHandler(s);
};
try
{
return test();
}
finally
{
- globals.console.error = errorHandler;
+ console.error = errorHandler;
}
};
exports.setupRandomResult = function()
{
let randomResult = 0.5;
Object.defineProperty(this, "randomResult", {
get: () => randomResult,
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld