mirror of
https://github.com/denoland/deno.git
synced 2024-12-29 02:29:06 -05:00
b6e44f91ad
Some `deno_std` tests were failing to print output that was resolved after the last test finished. In addition, output printed before tests began would sometimes appear above the "running X tests ..." line, and sometimes below it depending on timing. We now guarantee that all output is flushed before and after tests run, making the output consistent. Pre-test and post-test output are captured in `------ pre-test output ------` and `------ post-test output ------` blocks to differentiate them from the regular output blocks. Here's an example of a test (that is much noisier than normal, but an example of what the output will look like): ``` Check ./load_unload.ts ------- pre-test output ------- load ----- output end ----- running 1 test from ./load_unload.ts test ... ------- output ------- test ----- output end ----- test ... ok ([WILDCARD]) ------- post-test output ------- unload ----- output end ----- ```
59 lines
1.7 KiB
Rust
59 lines
1.7 KiB
Rust
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
use super::*;
|
|
|
|
mod common;
|
|
mod compound;
|
|
mod dot;
|
|
mod junit;
|
|
mod pretty;
|
|
mod tap;
|
|
|
|
pub use compound::CompoundTestReporter;
|
|
pub use dot::DotTestReporter;
|
|
pub use junit::JunitTestReporter;
|
|
pub use pretty::PrettyTestReporter;
|
|
pub use tap::TapTestReporter;
|
|
|
|
pub trait TestReporter {
|
|
fn report_register(&mut self, description: &TestDescription);
|
|
fn report_plan(&mut self, plan: &TestPlan);
|
|
fn report_wait(&mut self, description: &TestDescription);
|
|
fn report_output(&mut self, output: &[u8]);
|
|
fn report_result(
|
|
&mut self,
|
|
description: &TestDescription,
|
|
result: &TestResult,
|
|
elapsed: u64,
|
|
);
|
|
fn report_uncaught_error(&mut self, origin: &str, error: Box<JsError>);
|
|
fn report_step_register(&mut self, description: &TestStepDescription);
|
|
fn report_step_wait(&mut self, description: &TestStepDescription);
|
|
fn report_step_result(
|
|
&mut self,
|
|
desc: &TestStepDescription,
|
|
result: &TestStepResult,
|
|
elapsed: u64,
|
|
tests: &IndexMap<usize, TestDescription>,
|
|
test_steps: &IndexMap<usize, TestStepDescription>,
|
|
);
|
|
fn report_summary(
|
|
&mut self,
|
|
elapsed: &Duration,
|
|
tests: &IndexMap<usize, TestDescription>,
|
|
test_steps: &IndexMap<usize, TestStepDescription>,
|
|
);
|
|
fn report_sigint(
|
|
&mut self,
|
|
tests_pending: &HashSet<usize>,
|
|
tests: &IndexMap<usize, TestDescription>,
|
|
test_steps: &IndexMap<usize, TestStepDescription>,
|
|
);
|
|
fn report_completed(&mut self);
|
|
fn flush_report(
|
|
&mut self,
|
|
elapsed: &Duration,
|
|
tests: &IndexMap<usize, TestDescription>,
|
|
test_steps: &IndexMap<usize, TestStepDescription>,
|
|
) -> anyhow::Result<()>;
|
|
}
|