diff --git a/cli/ops/testing.rs b/cli/ops/testing.rs index 450f55a41a..826a4eb7a0 100644 --- a/cli/ops/testing.rs +++ b/cli/ops/testing.rs @@ -1,3 +1,4 @@ +use crate::tools::test_runner::TestEvent; use crate::tools::test_runner::TestMessage; use deno_core::error::generic_error; use deno_core::error::AnyError; @@ -5,6 +6,7 @@ use deno_core::serde_json; use deno_core::serde_json::json; use deno_core::serde_json::Value; use deno_core::JsRuntime; +use deno_core::ModuleSpecifier; use deno_core::OpState; use deno_core::ZeroCopyBuf; use deno_runtime::ops::worker_host::create_worker_permissions; @@ -81,9 +83,14 @@ fn op_post_test_message( _zero_copy: Option, ) -> Result { let args: PostTestMessageArgs = serde_json::from_value(args)?; - let sender = state.borrow::>().clone(); + let origin = state.borrow::().to_string(); + let message = args.message; - if sender.send(args.message).is_err() { + let event = TestEvent { origin, message }; + + let sender = state.borrow::>().clone(); + + if sender.send(event).is_err() { Ok(json!(false)) } else { Ok(json!(true)) diff --git a/cli/tests/test/allow_all.out b/cli/tests/test/allow_all.out index 3edb88d0f5..3be26c6e04 100644 --- a/cli/tests/test/allow_all.out +++ b/cli/tests/test/allow_all.out @@ -1,5 +1,5 @@ [WILDCARD] -running 14 tests +running 14 tests from [WILDCARD] test read false ... ok [WILDCARD] test read true ... ok [WILDCARD] test write false ... ok [WILDCARD] diff --git a/cli/tests/test/allow_none.out b/cli/tests/test/allow_none.out index 6565a0800d..96fb722782 100644 --- a/cli/tests/test/allow_none.out +++ b/cli/tests/test/allow_none.out @@ -1,5 +1,5 @@ [WILDCARD] -running 7 tests +running 7 tests from [WILDCARD] test read ... FAILED [WILDCARD] test write ... FAILED [WILDCARD] test net ... FAILED [WILDCARD] diff --git a/cli/tests/test/deno_test.out b/cli/tests/test/deno_test.out index 338f804eda..18ca1c4e8a 100644 --- a/cli/tests/test/deno_test.out +++ b/cli/tests/test/deno_test.out @@ -1,5 +1,5 @@ [WILDCARD] -running 4 tests +running 4 tests from [WILDCARD] test fail1 ... FAILED [WILDCARD] test fail2 ... FAILED [WILDCARD] test success1 ... ok [WILDCARD] diff --git a/cli/tests/test/deno_test_fail_fast.out b/cli/tests/test/deno_test_fail_fast.out index 9fb82c1c64..ea0d9d369c 100644 --- a/cli/tests/test/deno_test_fail_fast.out +++ b/cli/tests/test/deno_test_fail_fast.out @@ -1,5 +1,5 @@ [WILDCARD] -running 4 tests +running 4 tests from [WILDCARD] test fail1 ... FAILED [WILDCARD] failures: diff --git a/cli/tests/test/deno_test_only.ts.out b/cli/tests/test/deno_test_only.ts.out index 25a0b1a0cb..75b5af29b0 100644 --- a/cli/tests/test/deno_test_only.ts.out +++ b/cli/tests/test/deno_test_only.ts.out @@ -1,5 +1,5 @@ [WILDCARD] -running 1 tests +running 1 tests from [WILDCARD] test def ... ok ([WILDCARD]) test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 2 filtered out ([WILDCARD]) diff --git a/cli/tests/test/deno_test_unresolved_promise.out b/cli/tests/test/deno_test_unresolved_promise.out index e1ec640ab5..249f1d6872 100644 --- a/cli/tests/test/deno_test_unresolved_promise.out +++ b/cli/tests/test/deno_test_unresolved_promise.out @@ -1,4 +1,4 @@ -running 2 tests +running 2 tests from [WILDCARD] test unresolved promise ... test result: FAILED. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] diff --git a/cli/tests/test/exit_sanitizer_test.out b/cli/tests/test/exit_sanitizer_test.out index 25df34b345..3161c45ab5 100644 --- a/cli/tests/test/exit_sanitizer_test.out +++ b/cli/tests/test/exit_sanitizer_test.out @@ -1,5 +1,5 @@ Check [WILDCARD]/exit_sanitizer_test.ts -running 3 tests +running 3 tests from [WILDCARD] test exit(0) ... FAILED ([WILDCARD]) test exit(1) ... FAILED ([WILDCARD]) test exit(2) ... FAILED ([WILDCARD]) diff --git a/cli/tests/test/quiet_test.out b/cli/tests/test/quiet_test.out index 4b57c50fec..5ad03240d3 100644 --- a/cli/tests/test/quiet_test.out +++ b/cli/tests/test/quiet_test.out @@ -1,4 +1,4 @@ -running 1 tests +running 1 tests from [WILDCARD] test log ... ok [WILDCARD] test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out [WILDCARD] diff --git a/cli/tests/test/test_finally_cleartimeout.out b/cli/tests/test/test_finally_cleartimeout.out index ddad7cce98..1c4d62b4ec 100644 --- a/cli/tests/test/test_finally_cleartimeout.out +++ b/cli/tests/test/test_finally_cleartimeout.out @@ -1,5 +1,5 @@ Check [WILDCARD]/test_finally_cleartimeout.ts -running 2 tests +running 2 tests from [WILDCARD] test error ... FAILED ([WILDCARD]) test success ... ok ([WILDCARD]) diff --git a/cli/tools/test_runner.rs b/cli/tools/test_runner.rs index 2849402e96..f856390b97 100644 --- a/cli/tools/test_runner.rs +++ b/cli/tools/test_runner.rs @@ -53,8 +53,14 @@ pub enum TestMessage { }, } +#[derive(Debug, Clone, Deserialize)] +pub struct TestEvent { + pub origin: String, + pub message: TestMessage, +} + trait TestReporter { - fn visit_message(&mut self, message: TestMessage); + fn visit_event(&mut self, event: TestEvent); fn done(&mut self); } @@ -87,14 +93,14 @@ impl PrettyTestReporter { } impl TestReporter for PrettyTestReporter { - fn visit_message(&mut self, message: TestMessage) { - match &message { + fn visit_event(&mut self, event: TestEvent) { + match &event.message { TestMessage::Plan { pending, filtered, only: _, } => { - println!("running {} tests", pending); + println!("running {} tests from {}", pending, event.origin); self.pending += pending; self.filtered_out += filtered; } @@ -249,7 +255,7 @@ pub async fn run_test_file( main_module: ModuleSpecifier, test_module: ModuleSpecifier, permissions: Permissions, - channel: Sender, + channel: Sender, ) -> Result<(), AnyError> { let mut worker = create_main_worker(&program_state, main_module.clone(), permissions, true); @@ -259,7 +265,7 @@ pub async fn run_test_file( js_runtime .op_state() .borrow_mut() - .put::>(channel.clone()); + .put::>(channel.clone()); } let mut maybe_coverage_collector = if let Some(ref coverage_dir) = @@ -357,7 +363,7 @@ pub async fn run_tests( program_state.file_fetcher.insert_cached(test_file); - let (sender, receiver) = channel::(); + let (sender, receiver) = channel::(); let join_handles = test_modules.iter().map(move |main_module| { let program_state = program_state.clone(); @@ -395,8 +401,8 @@ pub async fn run_tests( let mut planned = 0; let mut reported = 0; - for message in receiver.iter() { - match message.clone() { + for event in receiver.iter() { + match event.message.clone() { TestMessage::Plan { pending, filtered: _, @@ -422,7 +428,7 @@ pub async fn run_tests( _ => {} } - reporter.visit_message(message); + reporter.visit_event(event); if has_error && fail_fast { break;