mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +00:00
fix(test): actually capture stdout and stderr in workers (#14435)
This commit is contained in:
parent
671f56f8ff
commit
de33017a8b
8 changed files with 136 additions and 94 deletions
|
@ -16,6 +16,7 @@ use crate::lsp::logging::lsp_log;
|
|||
use crate::ops;
|
||||
use crate::proc_state;
|
||||
use crate::tools::test;
|
||||
use crate::tools::test::TestEventSender;
|
||||
|
||||
use deno_core::anyhow::anyhow;
|
||||
use deno_core::error::AnyError;
|
||||
|
@ -180,21 +181,20 @@ async fn test_specifier(
|
|||
permissions: Permissions,
|
||||
specifier: ModuleSpecifier,
|
||||
mode: test::TestMode,
|
||||
channel: mpsc::UnboundedSender<test::TestEvent>,
|
||||
sender: TestEventSender,
|
||||
token: CancellationToken,
|
||||
options: Option<Value>,
|
||||
) -> Result<(), AnyError> {
|
||||
if !token.is_cancelled() {
|
||||
let (stdout, stderr) = test::create_stdout_stderr_pipes(channel.clone());
|
||||
let mut worker = create_main_worker(
|
||||
&ps,
|
||||
specifier.clone(),
|
||||
permissions,
|
||||
vec![ops::testing::init(channel.clone())],
|
||||
vec![ops::testing::init(sender.clone())],
|
||||
Stdio {
|
||||
stdin: StdioPipe::Inherit,
|
||||
stdout: StdioPipe::File(stdout),
|
||||
stderr: StdioPipe::File(stderr),
|
||||
stdout: StdioPipe::File(sender.stdout()),
|
||||
stderr: StdioPipe::File(sender.stderr()),
|
||||
},
|
||||
);
|
||||
|
||||
|
@ -318,6 +318,7 @@ impl TestRun {
|
|||
.await?;
|
||||
|
||||
let (sender, mut receiver) = mpsc::unbounded_channel::<test::TestEvent>();
|
||||
let sender = TestEventSender::new(sender);
|
||||
|
||||
let (concurrent_jobs, fail_fast) =
|
||||
if let flags::DenoSubcommand::Test(test_flags) = &ps.flags.subcommand {
|
||||
|
@ -754,19 +755,14 @@ impl test::TestReporter for LspTestReporter {
|
|||
self.progress(lsp_custom::TestRunProgressMessage::Started { test });
|
||||
}
|
||||
|
||||
fn report_output(&mut self, output: &test::TestOutput) {
|
||||
fn report_output(&mut self, output: &[u8]) {
|
||||
let test = self.current_origin.as_ref().and_then(|origin| {
|
||||
self
|
||||
.stack
|
||||
.get(origin)
|
||||
.and_then(|v| v.last().map(|td| td.into()))
|
||||
});
|
||||
let value = match output {
|
||||
test::TestOutput::String(value) => value.replace('\n', "\r\n"),
|
||||
test::TestOutput::Bytes(bytes) => {
|
||||
String::from_utf8_lossy(bytes).replace('\n', "\r\n")
|
||||
}
|
||||
};
|
||||
let value = String::from_utf8_lossy(output).replace('\n', "\r\n");
|
||||
|
||||
self.progress(lsp_custom::TestRunProgressMessage::Output {
|
||||
value,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue