diff options
author | Andreu Botella <andreu@andreubotella.com> | 2023-03-05 02:37:54 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-05 01:37:54 +0000 |
commit | 01028fcdf4f379a7285cc15079306e3ac31edcc1 (patch) | |
tree | deec7a6956a845771d995c45adadd9d18ca28fca /cli/tests/integration/compile_tests.rs | |
parent | 2f7222da8a26d8be915b9467fc21649a18f54b77 (diff) |
test(compile): Add a test for dynamic imports in `deno compile` (#18017)
denoland/eszip#115 added support for statically-analyzed dynamic imports
in eszip, which made `deno compile` support dynamic imports starting
from #17858. This PR adds a test for it.
----
This test is adapted from PR #17663.
Closes #17908
Diffstat (limited to 'cli/tests/integration/compile_tests.rs')
-rw-r--r-- | cli/tests/integration/compile_tests.rs | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/cli/tests/integration/compile_tests.rs b/cli/tests/integration/compile_tests.rs index fdeadecd0..add53434f 100644 --- a/cli/tests/integration/compile_tests.rs +++ b/cli/tests/integration/compile_tests.rs @@ -564,3 +564,31 @@ fn check_local_by_default2() { r#"error: TS2322 [ERROR]: Type '12' is not assignable to type '"b"'."# )); } + +#[test] +fn dynamic_import() { + let _guard = util::http_server(); + let dir = TempDir::new(); + let exe = if cfg!(windows) { + dir.path().join("dynamic_import.exe") + } else { + dir.path().join("dynamic_import") + }; + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("compile") + .arg("--output") + .arg(&exe) + .arg(util::testdata_path().join("./compile/dynamic_imports/main.ts")) + .output() + .unwrap(); + assert!(output.status.success()); + + let output = Command::new(&exe).env("NO_COLOR", "").output().unwrap(); + assert!(output.status.success()); + let expected = std::fs::read_to_string( + util::testdata_path().join("./compile/dynamic_imports/main.out"), + ) + .unwrap(); + assert_eq!(String::from_utf8(output.stdout).unwrap(), expected); +} |