mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-12-24 18:43:33 +03:00
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:
parent
a94f3f4403
commit
56c4385f42
@ -22,16 +22,16 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
console.log = function(...args) {
|
console.log = function(...args) {
|
||||||
if (window.console_log_redirect) {
|
if (window.on_console_log) {
|
||||||
window.console_log_redirect(args);
|
window.on_console_log(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_console_log.apply(this, args);
|
orig_console_log.apply(this, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.error = function(...args) {
|
console.error = function(...args) {
|
||||||
if (window.console_error_redirect) {
|
if (window.on_console_error) {
|
||||||
window.console_error_redirect(args);
|
window.on_console_error(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_console_error.apply(this, args);
|
orig_console_error.apply(this, args);
|
||||||
|
@ -9,16 +9,16 @@
|
|||||||
const orig_console_error = console.error;
|
const orig_console_error = console.error;
|
||||||
|
|
||||||
console.log = function(...args) {
|
console.log = function(...args) {
|
||||||
if (window.console_log_redirect) {
|
if (window.on_console_log) {
|
||||||
window.console_log_redirect(args);
|
window.on_console_log(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_console_log.apply(this, args);
|
orig_console_log.apply(this, args);
|
||||||
};
|
};
|
||||||
|
|
||||||
console.error = function(...args) {
|
console.error = function(...args) {
|
||||||
if (window.console_error_redirect) {
|
if (window.on_console_error) {
|
||||||
window.console_error_redirect(args);
|
window.on_console_error(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
orig_console_error.apply(this, args);
|
orig_console_error.apply(this, args);
|
||||||
|
@ -16,23 +16,23 @@ pub fn execute(
|
|||||||
r#"
|
r#"
|
||||||
const {{ exit }} = require('process');
|
const {{ exit }} = require('process');
|
||||||
|
|
||||||
let console_log_redirect = null;
|
let on_console_log = null;
|
||||||
let console_error_redirect = null;
|
let on_console_error = null;
|
||||||
|
|
||||||
// override `console.log` and `console.error` before we import tests to
|
// override `console.log` and `console.error` before we import tests to
|
||||||
// ensure they're bound correctly in wasm. This'll allow us to intercept
|
// ensure they're bound correctly in wasm. This'll allow us to intercept
|
||||||
// all these calls and capture the output of tests
|
// all these calls and capture the output of tests
|
||||||
const prev_log = console.log;
|
const prev_log = console.log;
|
||||||
console.log = function(...args) {{
|
console.log = function(...args) {{
|
||||||
if (console_log_redirect) {{
|
if (on_console_log) {{
|
||||||
console_log_redirect(args);
|
on_console_log(args);
|
||||||
}}
|
}}
|
||||||
prev_log.apply(null, args);
|
prev_log.apply(null, args);
|
||||||
}};
|
}};
|
||||||
const prev_error = console.error;
|
const prev_error = console.error;
|
||||||
console.error = function(...args) {{
|
console.error = function(...args) {{
|
||||||
if (console_error_redirect) {{
|
if (on_console_error) {{
|
||||||
console_error_redirect(args);
|
on_console_error(args);
|
||||||
}}
|
}}
|
||||||
prev_error.apply(null, args);
|
prev_error.apply(null, args);
|
||||||
}};
|
}};
|
||||||
@ -44,8 +44,8 @@ pub fn execute(
|
|||||||
const wasm = require("./{0}_bg");
|
const wasm = require("./{0}_bg");
|
||||||
|
|
||||||
cx = new support.Context();
|
cx = new support.Context();
|
||||||
console_log_redirect = support.__wbgtest_console_log;
|
on_console_log = support.__wbgtest_console_log;
|
||||||
console_error_redirect = support.__wbgtest_console_error;
|
on_console_error = support.__wbgtest_console_error;
|
||||||
|
|
||||||
// Forward runtime arguments. These arguments are also arguments to the
|
// Forward runtime arguments. These arguments are also arguments to the
|
||||||
// `wasm-bindgen-test-runner` which forwards them to node which we
|
// `wasm-bindgen-test-runner` which forwards them to node which we
|
||||||
|
@ -31,8 +31,8 @@ pub fn spawn(
|
|||||||
await wasm.booted;
|
await wasm.booted;
|
||||||
|
|
||||||
const cx = new Context();
|
const cx = new Context();
|
||||||
window.console_log_redirect = __wbgtest_console_log;
|
window.on_console_log = __wbgtest_console_log;
|
||||||
window.console_error_redirect = __wbgtest_console_error;
|
window.on_console_error = __wbgtest_console_error;
|
||||||
|
|
||||||
// Forward runtime arguments. These arguments are also arguments to the
|
// Forward runtime arguments. These arguments are also arguments to the
|
||||||
// `wasm-bindgen-test-runner` which forwards them to node which we
|
// `wasm-bindgen-test-runner` which forwards them to node which we
|
||||||
|
Loading…
Reference in New Issue
Block a user