wasm-bindgen-test: Rename console_*_redirect to on_console_*

Since we are no longer redirecting all console logs, and are instead just
observing them.
This commit is contained in:
Nick Fitzgerald 2019-01-14 14:50:05 -08:00
parent a94f3f4403
commit 56c4385f42
4 changed files with 18 additions and 18 deletions

View File

@ -22,16 +22,16 @@
};
console.log = function(...args) {
if (window.console_log_redirect) {
window.console_log_redirect(args);
if (window.on_console_log) {
window.on_console_log(args);
}
orig_console_log.apply(this, args);
};
console.error = function(...args) {
if (window.console_error_redirect) {
window.console_error_redirect(args);
if (window.on_console_error) {
window.on_console_error(args);
}
orig_console_error.apply(this, args);

View File

@ -9,16 +9,16 @@
const orig_console_error = console.error;
console.log = function(...args) {
if (window.console_log_redirect) {
window.console_log_redirect(args);
if (window.on_console_log) {
window.on_console_log(args);
}
orig_console_log.apply(this, args);
};
console.error = function(...args) {
if (window.console_error_redirect) {
window.console_error_redirect(args);
if (window.on_console_error) {
window.on_console_error(args);
}
orig_console_error.apply(this, args);

View File

@ -16,23 +16,23 @@ pub fn execute(
r#"
const {{ exit }} = require('process');
let console_log_redirect = null;
let console_error_redirect = null;
let on_console_log = null;
let on_console_error = null;
// override `console.log` and `console.error` before we import tests to
// ensure they're bound correctly in wasm. This'll allow us to intercept
// all these calls and capture the output of tests
const prev_log = console.log;
console.log = function(...args) {{
if (console_log_redirect) {{
console_log_redirect(args);
if (on_console_log) {{
on_console_log(args);
}}
prev_log.apply(null, args);
}};
const prev_error = console.error;
console.error = function(...args) {{
if (console_error_redirect) {{
console_error_redirect(args);
if (on_console_error) {{
on_console_error(args);
}}
prev_error.apply(null, args);
}};
@ -44,8 +44,8 @@ pub fn execute(
const wasm = require("./{0}_bg");
cx = new support.Context();
console_log_redirect = support.__wbgtest_console_log;
console_error_redirect = support.__wbgtest_console_error;
on_console_log = support.__wbgtest_console_log;
on_console_error = support.__wbgtest_console_error;
// Forward runtime arguments. These arguments are also arguments to the
// `wasm-bindgen-test-runner` which forwards them to node which we

View File

@ -31,8 +31,8 @@ pub fn spawn(
await wasm.booted;
const cx = new Context();
window.console_log_redirect = __wbgtest_console_log;
window.console_error_redirect = __wbgtest_console_error;
window.on_console_log = __wbgtest_console_log;
window.on_console_error = __wbgtest_console_error;
// Forward runtime arguments. These arguments are also arguments to the
// `wasm-bindgen-test-runner` which forwards them to node which we