diff --git a/crates/cli/src/commands.rs b/crates/cli/src/commands.rs index 5765bf7a..74a37645 100644 --- a/crates/cli/src/commands.rs +++ b/crates/cli/src/commands.rs @@ -374,29 +374,10 @@ mod tests { #[test] fn js_config_from_config_values() -> Result<()> { let group = JsConfig::from_group_values(&Plugin::Default, vec![])?; - assert_eq!(group.get("redirect-stdout-to-stderr"), None); assert_eq!(group.get("javy-stream-io"), None); assert_eq!(group.get("simd-json-builtins"), None); assert_eq!(group.get("text-encoding"), None); - let group = JsConfig::from_group_values( - &Plugin::Default, - vec![JsGroupValue::Option(JsGroupOption { - name: "redirect-stdout-to-stderr".to_string(), - enabled: false, - })], - )?; - assert_eq!(group.get("redirect-stdout-to-stderr"), Some(false)); - - let group = JsConfig::from_group_values( - &Plugin::Default, - vec![JsGroupValue::Option(JsGroupOption { - name: "redirect-stdout-to-stderr".to_string(), - enabled: true, - })], - )?; - assert_eq!(group.get("redirect-stdout-to-stderr"), Some(true)); - let group = JsConfig::from_group_values( &Plugin::Default, vec![JsGroupValue::Option(JsGroupOption { @@ -454,10 +435,6 @@ mod tests { let group = JsConfig::from_group_values( &Plugin::Default, vec![ - JsGroupValue::Option(JsGroupOption { - name: "redirect-stdout-to-stderr".to_string(), - enabled: false, - }), JsGroupValue::Option(JsGroupOption { name: "javy-stream-io".to_string(), enabled: false, @@ -472,7 +449,6 @@ mod tests { }), ], )?; - assert_eq!(group.get("redirect-stdout-to-stderr"), Some(false)); assert_eq!(group.get("javy-stream-io"), Some(false)); assert_eq!(group.get("simd-json-builtins"), Some(false)); assert_eq!(group.get("text-encoding"), Some(false)); diff --git a/crates/cli/tests/dylib_test.rs b/crates/cli/tests/dylib_test.rs index 425b20ae..c0d61302 100644 --- a/crates/cli/tests/dylib_test.rs +++ b/crates/cli/tests/dylib_test.rs @@ -4,7 +4,7 @@ use std::str; #[test] fn test_dylib() -> Result<()> { - let js_src = "console.log(42);"; + let js_src = "console.error(42);"; let mut runner = Runner::with_dylib(plugin_module()?)?; let (_, logs, _) = runner.exec_through_dylib(js_src, UseExportedFn::EvalBytecode)?; @@ -15,7 +15,7 @@ fn test_dylib() -> Result<()> { #[test] fn test_dylib_with_invoke_with_no_fn_name() -> Result<()> { - let js_src = "console.log(42);"; + let js_src = "console.error(42);"; let mut runner = Runner::with_dylib(plugin_module()?)?; let (_, logs, _) = runner.exec_through_dylib(js_src, UseExportedFn::Invoke(None))?; @@ -46,7 +46,7 @@ fn test_dylib_with_error() -> Result<()> { #[test] fn test_dylib_with_exported_func() -> Result<()> { - let js_src = "export function foo() { console.log('In foo'); }; console.log('Toplevel');"; + let js_src = "export function foo() { console.error('In foo'); }; console.error('Toplevel');"; let mut runner = Runner::with_dylib(plugin_module()?)?; diff --git a/crates/cli/tests/dynamic-linking-scripts/console.js b/crates/cli/tests/dynamic-linking-scripts/console.js index 753a47d5..be179a28 100644 --- a/crates/cli/tests/dynamic-linking-scripts/console.js +++ b/crates/cli/tests/dynamic-linking-scripts/console.js @@ -1 +1 @@ -console.log(42); +console.error(42); diff --git a/crates/cli/tests/dynamic-linking-scripts/linking-arrow-func.js b/crates/cli/tests/dynamic-linking-scripts/linking-arrow-func.js index 74413b1c..0f65a944 100644 --- a/crates/cli/tests/dynamic-linking-scripts/linking-arrow-func.js +++ b/crates/cli/tests/dynamic-linking-scripts/linking-arrow-func.js @@ -1 +1 @@ -export default () => console.log(42) +export default () => console.error(42) diff --git a/crates/cli/tests/dynamic-linking-scripts/linking-with-func-without-flag.js b/crates/cli/tests/dynamic-linking-scripts/linking-with-func-without-flag.js index 97893cac..16bab918 100644 --- a/crates/cli/tests/dynamic-linking-scripts/linking-with-func-without-flag.js +++ b/crates/cli/tests/dynamic-linking-scripts/linking-with-func-without-flag.js @@ -1,5 +1,5 @@ export function foo() { - console.log('In foo'); + console.error('In foo'); }; -console.log('Toplevel'); +console.error('Toplevel'); diff --git a/crates/cli/tests/dynamic-linking-scripts/linking-with-func.js b/crates/cli/tests/dynamic-linking-scripts/linking-with-func.js index dde17cac..0961851a 100644 --- a/crates/cli/tests/dynamic-linking-scripts/linking-with-func.js +++ b/crates/cli/tests/dynamic-linking-scripts/linking-with-func.js @@ -1,5 +1,5 @@ export function fooBar() { - console.log('In foo'); + console.error('In foo'); }; -console.log('Toplevel'); +console.error('Toplevel'); diff --git a/crates/cli/tests/dynamic_linking_test.rs b/crates/cli/tests/dynamic_linking_test.rs index 2df6ba5e..8b22c7b7 100644 --- a/crates/cli/tests/dynamic_linking_test.rs +++ b/crates/cli/tests/dynamic_linking_test.rs @@ -104,13 +104,10 @@ fn test_producers_section_present(builder: &mut Builder) -> Result<()> { commands(not(Compile)) )] fn test_using_runtime_flag_with_dynamic_triggers_error(builder: &mut Builder) -> Result<()> { - let build_result = builder - .input("console.js") - .redirect_stdout_to_stderr(false) - .build(); - assert!(build_result.is_err_and(|e| e.to_string().contains( - "error: Property redirect-stdout-to-stderr is not supported for runtime configuration" - ))); + let build_result = builder.input("console.js").text_encoding(false).build(); + assert!(build_result.is_err_and(|e| e + .to_string() + .contains("error: Property text-encoding is not supported for runtime configuration"))); Ok(()) } diff --git a/crates/cli/tests/integration_test.rs b/crates/cli/tests/integration_test.rs index 7b9356ed..19baeb5c 100644 --- a/crates/cli/tests/integration_test.rs +++ b/crates/cli/tests/integration_test.rs @@ -21,7 +21,7 @@ fn test_identity(builder: &mut Builder) -> Result<()> { let (output, _, fuel_consumed) = run_with_u8s(&mut runner, 42); assert_eq!(42, output); - assert_fuel_consumed_within_threshold(47_773, fuel_consumed); + assert_fuel_consumed_within_threshold(46_797, fuel_consumed); Ok(()) } @@ -41,7 +41,7 @@ fn test_recursive_fib(builder: &mut Builder) -> Result<()> { let (output, _, fuel_consumed) = run_with_u8s(&mut runner, 5); assert_eq!(8, output); - assert_fuel_consumed_within_threshold(69_306, fuel_consumed); + assert_fuel_consumed_within_threshold(67_869, fuel_consumed); Ok(()) } @@ -74,27 +74,10 @@ fn test_encoding(builder: &mut Builder) -> Result<()> { Ok(()) } -#[javy_cli_test(commands(not(Build)))] -fn test_logging_with_compile(builder: &mut Builder) -> Result<()> { +#[javy_cli_test] +fn test_console_log(builder: &mut Builder) -> Result<()> { let mut runner = builder.input("logging.js").build()?; - let (output, logs, fuel_consumed) = run(&mut runner, &[]); - assert!(output.is_empty()); - assert_eq!( - "hello world from console.log\nhello world from console.error\n", - logs.as_str(), - ); - assert_fuel_consumed_within_threshold(35_042, fuel_consumed); - Ok(()) -} - -#[javy_cli_test(commands(not(Compile)))] -fn test_logging_without_redirect(builder: &mut Builder) -> Result<()> { - let mut runner = builder - .input("logging.js") - .redirect_stdout_to_stderr(false) - .build()?; - let (output, logs, fuel_consumed) = run(&mut runner, &[]); assert_eq!(b"hello world from console.log\n".to_vec(), output); assert_eq!("hello world from console.error\n", logs.as_str()); @@ -102,23 +85,6 @@ fn test_logging_without_redirect(builder: &mut Builder) -> Result<()> { Ok(()) } -#[javy_cli_test(commands(not(Compile)))] -fn test_logging_with_redirect(builder: &mut Builder) -> Result<()> { - let mut runner = builder - .input("logging.js") - .redirect_stdout_to_stderr(true) - .build()?; - - let (output, logs, fuel_consumed) = run(&mut runner, &[]); - assert!(output.is_empty()); - assert_eq!( - "hello world from console.log\nhello world from console.error\n", - logs.as_str(), - ); - assert_fuel_consumed_within_threshold(35_007, fuel_consumed); - Ok(()) -} - #[javy_cli_test(commands(not(Compile)))] fn test_using_plugin_with_static_build(builder: &mut Builder) -> Result<()> { let mut runner = builder.plugin(Plugin::User).input("plugin.js").build()?; diff --git a/crates/cli/tests/sample-scripts/exported-default-arrow-fn.js b/crates/cli/tests/sample-scripts/exported-default-arrow-fn.js index 74413b1c..0f65a944 100644 --- a/crates/cli/tests/sample-scripts/exported-default-arrow-fn.js +++ b/crates/cli/tests/sample-scripts/exported-default-arrow-fn.js @@ -1 +1 @@ -export default () => console.log(42) +export default () => console.error(42) diff --git a/crates/cli/tests/sample-scripts/exported-default-fn.js b/crates/cli/tests/sample-scripts/exported-default-fn.js index f44b9fb3..b6772c6e 100644 --- a/crates/cli/tests/sample-scripts/exported-default-fn.js +++ b/crates/cli/tests/sample-scripts/exported-default-fn.js @@ -1,3 +1,3 @@ export default function () { - console.log(42); + console.error(42); } diff --git a/crates/cli/tests/sample-scripts/exported-fn-no-semicolon.js b/crates/cli/tests/sample-scripts/exported-fn-no-semicolon.js index bbcadd34..71b4de16 100644 --- a/crates/cli/tests/sample-scripts/exported-fn-no-semicolon.js +++ b/crates/cli/tests/sample-scripts/exported-fn-no-semicolon.js @@ -1,3 +1,3 @@ export function foo() { - console.log("Hello from bar!"); + console.error("Hello from bar!"); } diff --git a/crates/cli/tests/sample-scripts/exported-fn.js b/crates/cli/tests/sample-scripts/exported-fn.js index d7d86a44..b11e3bd5 100644 --- a/crates/cli/tests/sample-scripts/exported-fn.js +++ b/crates/cli/tests/sample-scripts/exported-fn.js @@ -1,13 +1,13 @@ export function bar() { - console.log("Hello from bar!"); + console.error("Hello from bar!"); } export function foo() { - console.log("Hello from foo"); + console.error("Hello from foo"); } export function fooBar() { - console.log("Hello from fooBar"); + console.error("Hello from fooBar"); } -console.log("Hello from top-level"); +console.error("Hello from top-level"); diff --git a/crates/cli/tests/sample-scripts/exported-promise-fn.js b/crates/cli/tests/sample-scripts/exported-promise-fn.js index 65508f95..4cf03cc7 100644 --- a/crates/cli/tests/sample-scripts/exported-promise-fn.js +++ b/crates/cli/tests/sample-scripts/exported-promise-fn.js @@ -1,7 +1,7 @@ export async function foo() { - console.log(await Promise.resolve("inside foo")); + console.error(await Promise.resolve("inside foo")); } (async function () { - console.log(await Promise.resolve("Top-level")); + console.error(await Promise.resolve("Top-level")); })(); diff --git a/crates/plugin/src/lib.rs b/crates/plugin/src/lib.rs index 41e9101e..5e316693 100644 --- a/crates/plugin/src/lib.rs +++ b/crates/plugin/src/lib.rs @@ -17,10 +17,8 @@ pub extern "C" fn initialize_runtime() { // variable in subsequent invocations so a different value can't be used to // initialize a runtime with a different configuration. let mut config = Config::default(); - // Preserve defaults that used to be passed from the Javy CLI. config .text_encoding(true) - .redirect_stdout_to_stderr(true) .javy_stream_io(true) .simd_json_builtins(true); diff --git a/crates/plugin/src/shared_config/mod.rs b/crates/plugin/src/shared_config/mod.rs index ac337cf8..27faaeb5 100644 --- a/crates/plugin/src/shared_config/mod.rs +++ b/crates/plugin/src/shared_config/mod.rs @@ -13,8 +13,6 @@ runtime_config! { #[derive(Debug, Default, Deserialize)] #[serde(deny_unknown_fields, rename_all = "kebab-case")] pub struct SharedConfig { - /// Whether to redirect the output of console.log to standard error. - redirect_stdout_to_stderr: Option, /// Whether to enable the `Javy.readSync` and `Javy.writeSync` builtins. javy_stream_io: Option, /// Whether to override the `JSON.parse` and `JSON.stringify` @@ -35,9 +33,6 @@ impl SharedConfig { } pub fn apply_to_config(&self, config: &mut Config) { - if let Some(enable) = self.redirect_stdout_to_stderr { - config.redirect_stdout_to_stderr(enable); - } if let Some(enable) = self.javy_stream_io { config.javy_stream_io(enable); } diff --git a/crates/runner/src/lib.rs b/crates/runner/src/lib.rs index 59e6850f..871c7c90 100644 --- a/crates/runner/src/lib.rs +++ b/crates/runner/src/lib.rs @@ -72,8 +72,6 @@ pub struct Builder { wit: Option, /// The name of the wit world. world: Option, - /// Whether console.log should write to stderr. - redirect_stdout_to_stderr: Option, /// Whether to enable the `Javy.IO` builtins. javy_stream_io: Option, /// Whether to override JSON.parse and JSON.stringify with a SIMD based @@ -104,7 +102,6 @@ impl Default for Builder { built: false, preload: None, command: JavyCommand::Build, - redirect_stdout_to_stderr: None, javy_stream_io: None, simd_json_builtins: None, text_encoding: None, @@ -145,11 +142,6 @@ impl Builder { self } - pub fn redirect_stdout_to_stderr(&mut self, enabled: bool) -> &mut Self { - self.redirect_stdout_to_stderr = Some(enabled); - self - } - pub fn javy_stream_io(&mut self, enabled: bool) -> &mut Self { self.javy_stream_io = Some(enabled); self @@ -197,7 +189,6 @@ impl Builder { wit, world, root, - redirect_stdout_to_stderr, javy_stream_io, simd_json_builtins, text_encoding, @@ -224,7 +215,6 @@ impl Builder { input, wit, world, - redirect_stdout_to_stderr, javy_stream_io, simd_json_builtins, text_encoding, @@ -300,7 +290,6 @@ impl Runner { source: impl AsRef, wit: Option, world: Option, - redirect_stdout_to_stderr: Option, javy_stream_io: Option, override_json_parse_and_stringify: Option, text_encoding: Option, @@ -321,7 +310,6 @@ impl Runner { &wit_file, &world, preload.is_some(), - &redirect_stdout_to_stderr, &javy_stream_io, &override_json_parse_and_stringify, &text_encoding, @@ -549,7 +537,6 @@ impl Runner { wit: &Option, world: &Option, dynamic: bool, - redirect_stdout_to_stderr: &Option, javy_stream_io: &Option, simd_json_builtins: &Option, text_encoding: &Option, @@ -575,14 +562,6 @@ impl Runner { args.push("dynamic".to_string()); } - if let Some(redirect_stdout_to_stderr) = *redirect_stdout_to_stderr { - args.push("-J".to_string()); - args.push(format!( - "redirect-stdout-to-stderr={}", - if redirect_stdout_to_stderr { "y" } else { "n" } - )); - } - if let Some(enabled) = *javy_stream_io { args.push("-J".to_string()); args.push(format!(