mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix(cli/tools/test): print module tests originate from (#10428)
This commit is contained in:
parent
6804b2f889
commit
abaec7a88e
11 changed files with 34 additions and 21 deletions
|
@ -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<ZeroCopyBuf>,
|
||||
) -> Result<Value, AnyError> {
|
||||
let args: PostTestMessageArgs = serde_json::from_value(args)?;
|
||||
let sender = state.borrow::<Sender<TestMessage>>().clone();
|
||||
let origin = state.borrow::<ModuleSpecifier>().to_string();
|
||||
let message = args.message;
|
||||
|
||||
if sender.send(args.message).is_err() {
|
||||
let event = TestEvent { origin, message };
|
||||
|
||||
let sender = state.borrow::<Sender<TestEvent>>().clone();
|
||||
|
||||
if sender.send(event).is_err() {
|
||||
Ok(json!(false))
|
||||
} else {
|
||||
Ok(json!(true))
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
[WILDCARD]
|
||||
running 4 tests
|
||||
running 4 tests from [WILDCARD]
|
||||
test fail1 ... FAILED [WILDCARD]
|
||||
|
||||
failures:
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
|
@ -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])
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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])
|
||||
|
||||
|
|
|
@ -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<TestMessage>,
|
||||
channel: Sender<TestEvent>,
|
||||
) -> 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::<Sender<TestMessage>>(channel.clone());
|
||||
.put::<Sender<TestEvent>>(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::<TestMessage>();
|
||||
let (sender, receiver) = channel::<TestEvent>();
|
||||
|
||||
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;
|
||||
|
|
Loading…
Reference in a new issue