diff options
author | David Sherret <dsherret@users.noreply.github.com> | 2022-05-01 14:44:55 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-01 14:44:55 -0400 |
commit | de33017a8bc3ddc79664df0fae3ded5607b38180 (patch) | |
tree | fc730a65fe488b1e8e5b380734ff0550aeda3681 /cli/lsp/testing/execution.rs | |
parent | 671f56f8ff512fcf4ad016f2b2fdd36c2ac7237f (diff) |
fix(test): actually capture stdout and stderr in workers (#14435)
Diffstat (limited to 'cli/lsp/testing/execution.rs')
-rw-r--r-- | cli/lsp/testing/execution.rs | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/cli/lsp/testing/execution.rs b/cli/lsp/testing/execution.rs index 77a326618..4f4862054 100644 --- a/cli/lsp/testing/execution.rs +++ b/cli/lsp/testing/execution.rs @@ -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, |