From 56c4385f420e4c6f61dd809ce7d7e1caeec6f410 Mon Sep 17 00:00:00 2001 From: Nick Fitzgerald Date: Mon, 14 Jan 2019 14:50:05 -0800 Subject: [PATCH] wasm-bindgen-test: Rename `console_*_redirect` to `on_console_*` Since we are no longer redirecting all console logs, and are instead just observing them. --- .../wasm-bindgen-test-runner/index-headless.html | 8 ++++---- .../src/bin/wasm-bindgen-test-runner/index.html | 8 ++++---- .../cli/src/bin/wasm-bindgen-test-runner/node.rs | 16 ++++++++-------- .../src/bin/wasm-bindgen-test-runner/server.rs | 4 ++-- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html b/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html index 8f66a52e..140dd2d9 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html @@ -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); diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/index.html b/crates/cli/src/bin/wasm-bindgen-test-runner/index.html index 1709af62..f45987e7 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/index.html +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/index.html @@ -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); diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs index 2bb2fdf4..c00d81ff 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs @@ -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 diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/server.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/server.rs index b68dccfe..f90978d3 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/server.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/server.rs @@ -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