summaryrefslogtreecommitdiff
path: root/cli/worker.rs
diff options
context:
space:
mode:
Diffstat (limited to 'cli/worker.rs')
-rw-r--r--cli/worker.rs55
1 files changed, 21 insertions, 34 deletions
diff --git a/cli/worker.rs b/cli/worker.rs
index c2a1ecc57..bbddf91d2 100644
--- a/cli/worker.rs
+++ b/cli/worker.rs
@@ -270,17 +270,8 @@ mod tests {
use crate::startup_data;
use crate::state::State;
use crate::tokio_util;
- use futures::executor::block_on;
use std::sync::atomic::Ordering;
- pub fn run_in_task<F>(f: F)
- where
- F: FnOnce() + Send + 'static,
- {
- let fut = futures::future::lazy(move |_cx| f());
- tokio_util::run_basic(fut)
- }
-
#[test]
fn execute_mod_esm_imports_a() {
let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
@@ -405,32 +396,28 @@ mod tests {
worker
}
- #[test]
- fn execute_mod_resolve_error() {
- run_in_task(|| {
- // "foo" is not a valid module specifier so this should return an error.
- let mut worker = create_test_worker();
- let module_specifier =
- ModuleSpecifier::resolve_url_or_path("does-not-exist").unwrap();
- let result = block_on(worker.execute_module(&module_specifier));
- assert!(result.is_err());
- })
+ #[tokio::test]
+ async fn execute_mod_resolve_error() {
+ // "foo" is not a valid module specifier so this should return an error.
+ let mut worker = create_test_worker();
+ let module_specifier =
+ ModuleSpecifier::resolve_url_or_path("does-not-exist").unwrap();
+ let result = worker.execute_module(&module_specifier).await;
+ assert!(result.is_err());
}
- #[test]
- fn execute_mod_002_hello() {
- run_in_task(|| {
- // This assumes cwd is project root (an assumption made throughout the
- // tests).
- let mut worker = create_test_worker();
- let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
- .parent()
- .unwrap()
- .join("cli/tests/002_hello.ts");
- let module_specifier =
- ModuleSpecifier::resolve_url_or_path(&p.to_string_lossy()).unwrap();
- let result = block_on(worker.execute_module(&module_specifier));
- assert!(result.is_ok());
- })
+ #[tokio::test]
+ async fn execute_mod_002_hello() {
+ // This assumes cwd is project root (an assumption made throughout the
+ // tests).
+ let mut worker = create_test_worker();
+ let p = std::path::PathBuf::from(env!("CARGO_MANIFEST_DIR"))
+ .parent()
+ .unwrap()
+ .join("cli/tests/002_hello.ts");
+ let module_specifier =
+ ModuleSpecifier::resolve_url_or_path(&p.to_string_lossy()).unwrap();
+ let result = worker.execute_module(&module_specifier).await;
+ assert!(result.is_ok());
}
}