summaryrefslogtreecommitdiff
path: root/cli/tools/test.rs
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2022-03-09 01:34:31 +0100
committerGitHub <noreply@github.com>2022-03-09 01:34:31 +0100
commit85cb6f256341b262ef4f0f67ddba034bea3033b1 (patch)
tree868445cdb59e7520b08173374ca20afbdf1dae61 /cli/tools/test.rs
parent22dbbf75f36315d4a203011ff9e37c7e56a7bef0 (diff)
refactor(test): use tokio::sync::mpsc::unbounded_channel (#13881)
This causes to block one less thread when running "deno test" subcommand.
Diffstat (limited to 'cli/tools/test.rs')
-rw-r--r--cli/tools/test.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/cli/tools/test.rs b/cli/tools/test.rs
index 7e673fac4..74646986d 100644
--- a/cli/tools/test.rs
+++ b/cli/tools/test.rs
@@ -50,11 +50,11 @@ use std::collections::HashSet;
use std::io::Write;
use std::num::NonZeroUsize;
use std::path::PathBuf;
-use std::sync::mpsc::channel;
-use std::sync::mpsc::Sender;
use std::sync::Arc;
use std::time::Duration;
use std::time::Instant;
+use tokio::sync::mpsc::unbounded_channel;
+use tokio::sync::mpsc::UnboundedSender;
/// The test mode is used to determine how a specifier is to be tested.
#[derive(Debug, Clone, PartialEq)]
@@ -445,7 +445,7 @@ async fn test_specifier(
permissions: Permissions,
specifier: ModuleSpecifier,
mode: TestMode,
- channel: Sender<TestEvent>,
+ channel: UnboundedSender<TestEvent>,
options: TestSpecifierOptions,
) -> Result<(), AnyError> {
let mut worker = create_main_worker(
@@ -793,7 +793,7 @@ async fn test_specifiers(
specifiers_with_mode
};
- let (sender, receiver) = channel::<TestEvent>();
+ let (sender, mut receiver) = unbounded_channel::<TestEvent>();
let concurrent_jobs = options.concurrent_jobs;
let fail_fast = options.fail_fast;
@@ -822,12 +822,12 @@ async fn test_specifiers(
create_reporter(concurrent_jobs.get() > 1, log_level != Some(Level::Error));
let handler = {
- tokio::task::spawn_blocking(move || {
+ tokio::task::spawn(async move {
let earlier = Instant::now();
let mut summary = TestSummary::new();
let mut used_only = false;
- for event in receiver.iter() {
+ while let Some(event) = receiver.recv().await {
match event {
TestEvent::Plan(plan) => {
summary.total += plan.total;