summaryrefslogtreecommitdiff
path: root/tests/integration
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-09-03 01:27:37 +1000
committerGitHub <noreply@github.com>2024-09-02 17:27:37 +0200
commitbc51eca70000e809ef3b64f66e9482316768e02a (patch)
treed9972377959be338e7192e7e53f94584432c263c /tests/integration
parent503f95a54fe290471b0807157e37d2d996ff0357 (diff)
BREAKING: remove `deno bundle` (#25339)
`deno bundle` now produces: ``` error: ⚠️ `deno bundle` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations ``` `deno bundle --help` now produces: ``` ⚠️ `deno bundle` was removed in Deno 2. See the Deno 1.x to 2.x Migration Guide for migration instructions: https://docs.deno.com/runtime/manual/advanced/migrate_deprecations Usage: deno bundle [OPTIONS] Options: -q, --quiet Suppress diagnostic output --unstable Enable all unstable features and APIs. Instead of using this flag, consider enabling individual unstable features To view the list of individual unstable feature flags, run this command again with --help=unstable ```
Diffstat (limited to 'tests/integration')
-rw-r--r--tests/integration/bundle_tests.rs476
-rw-r--r--tests/integration/check_tests.rs5
-rw-r--r--tests/integration/lsp_tests.rs7
-rw-r--r--tests/integration/mod.rs2
-rw-r--r--tests/integration/watcher_tests.rs139
5 files changed, 1 insertions, 628 deletions
diff --git a/tests/integration/bundle_tests.rs b/tests/integration/bundle_tests.rs
deleted file mode 100644
index 20f883293..000000000
--- a/tests/integration/bundle_tests.rs
+++ /dev/null
@@ -1,476 +0,0 @@
-// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
-
-use test_util as util;
-use test_util::assert_contains;
-use test_util::assert_ends_with;
-use test_util::itest;
-use test_util::TempDir;
-
-#[test]
-fn bundle_exports() {
- // First we have to generate a bundle of some module that has exports.
- let mod1 = util::testdata_path().join("subdir/mod1.ts");
- assert!(mod1.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("mod1.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(mod1)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- // Now we try to use that bundle from another module.
- let test = t.path().join("test.js");
- std::fs::write(
- &test,
- "
- import { printHello3 } from \"./mod1.bundle.js\";
- printHello3(); ",
- )
- .unwrap();
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&test)
- .output()
- .unwrap();
- // check the output of the test.ts program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_exports_no_check() {
- // First we have to generate a bundle of some module that has exports.
- let mod1 = util::testdata_path().join("subdir/mod1.ts");
- assert!(mod1.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("mod1.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(mod1)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- // Now we try to use that bundle from another module.
- let test = t.path().join("test.js");
- std::fs::write(
- &test,
- "
- import { printHello3 } from \"./mod1.bundle.js\";
- printHello3(); ",
- )
- .unwrap();
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&test)
- .output()
- .unwrap();
- // check the output of the test.ts program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_circular() {
- // First we have to generate a bundle of some module that has exports.
- let circular1_path = util::testdata_path().join("subdir/circular1.ts");
- assert!(circular1_path.is_file());
- let t = TempDir::new();
- let bundle_path = t.path().join("circular1.bundle.js");
-
- // run this twice to ensure it works even when cached
- for _ in 0..2 {
- let mut deno = util::deno_cmd_with_deno_dir(&t)
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(&circular1_path)
- .arg(&bundle_path)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle_path.is_file());
- }
-
- let output = util::deno_cmd_with_deno_dir(&t)
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&bundle_path)
- .output()
- .unwrap();
- // check the output of the bundle program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "f2\nf1",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_single_module() {
- // First we have to generate a bundle of some module that has exports.
- let single_module = util::testdata_path().join("subdir/single_module.ts");
- assert!(single_module.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("single_module.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(single_module)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&bundle)
- .output()
- .unwrap();
- // check the output of the bundle program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello world!",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_tla() {
- // First we have to generate a bundle of some module that has exports.
- let tla_import = util::testdata_path().join("subdir/tla.ts");
- assert!(tla_import.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("tla.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(tla_import)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- // Now we try to use that bundle from another module.
- let test = t.path().join("test.js");
- std::fs::write(
- &test,
- "
- import { foo } from \"./tla.bundle.js\";
- console.log(foo); ",
- )
- .unwrap();
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&test)
- .output()
- .unwrap();
- // check the output of the test.ts program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_js() {
- // First we have to generate a bundle of some module that has exports.
- let mod6 = util::testdata_path().join("subdir/mod6.js");
- assert!(mod6.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("mod6.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(mod6)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&bundle)
- .output()
- .unwrap();
- // check that nothing went to stderr
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_dynamic_import() {
- let _g = util::http_server();
- let dynamic_import = util::testdata_path().join("bundle/dynamic_import.ts");
- assert!(dynamic_import.is_file());
- let t = TempDir::new();
- let output_path = t.path().join("bundle_dynamic_import.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(dynamic_import)
- .arg(&output_path)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(output_path.is_file());
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--allow-net")
- .arg("--quiet")
- .arg(&output_path)
- .output()
- .unwrap();
- // check the output of the test.ts program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_import_map() {
- let import = util::testdata_path().join("bundle/import_map/main.ts");
- let import_map_path =
- util::testdata_path().join("bundle/import_map/import_map.json");
- assert!(import.is_file());
- let t = TempDir::new();
- let output_path = t.path().join("import_map.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg("--import-map")
- .arg(import_map_path)
- .arg(import)
- .arg(&output_path)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(output_path.is_file());
-
- // Now we try to use that bundle from another module.
- let test = t.path().join("test.js");
- std::fs::write(
- &test,
- "
- import { printHello3 } from \"./import_map.bundle.js\";
- printHello3(); ",
- )
- .unwrap();
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg("--check")
- .arg(&test)
- .output()
- .unwrap();
- // check the output of the test.ts program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_import_map_no_check() {
- let import = util::testdata_path().join("bundle/import_map/main.ts");
- let import_map_path =
- util::testdata_path().join("bundle/import_map/import_map.json");
- assert!(import.is_file());
- let t = TempDir::new();
- let output_path = t.path().join("import_map.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg("--import-map")
- .arg(import_map_path)
- .arg(import)
- .arg(&output_path)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(output_path.is_file());
-
- // Now we try to use that bundle from another module.
- let test = t.path().join("test.js");
- std::fs::write(
- &test,
- "
- import { printHello3 } from \"./import_map.bundle.js\";
- printHello3(); ",
- )
- .unwrap();
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&test)
- .output()
- .unwrap();
- // check the output of the test.ts program.
- assert_ends_with!(
- std::str::from_utf8(&output.stdout).unwrap().trim(),
- "Hello",
- );
- assert_eq!(output.stderr, b"");
-}
-
-#[test]
-fn bundle_json_module() {
- // First we have to generate a bundle of some module that has exports.
- let mod7 = util::testdata_path().join("subdir/mod7.js");
- assert!(mod7.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("mod7.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(mod7)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&bundle)
- .output()
- .unwrap();
- // check that nothing went to stderr
- assert_eq!(output.stderr, b"");
- // ensure the output looks right
- assert_contains!(String::from_utf8(output.stdout).unwrap(), "with space",);
-}
-
-#[test]
-fn bundle_json_module_escape_sub() {
- // First we have to generate a bundle of some module that has exports.
- let mod8 = util::testdata_path().join("subdir/mod8.js");
- assert!(mod8.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("mod8.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("bundle")
- .arg(mod8)
- .arg(&bundle)
- .spawn()
- .unwrap();
- let status = deno.wait().unwrap();
- assert!(status.success());
- assert!(bundle.is_file());
-
- let output = util::deno_cmd()
- .current_dir(util::testdata_path())
- .arg("run")
- .arg(&bundle)
- .output()
- .unwrap();
- // check that nothing went to stderr
- assert_eq!(output.stderr, b"");
- // make sure the output looks right and the escapes were effective
- assert_contains!(
- String::from_utf8(output.stdout).unwrap(),
- "${globalThis}`and string literal`",
- );
-}
-
-itest!(bundle {
- args: "bundle subdir/mod1.ts",
- output: "bundle/bundle.test.out",
-});
-
-itest!(bundle_jsx {
- args: "bundle run/jsx_import_from_ts.ts",
- output: "bundle/jsx.out",
-});
-
-itest!(error_bundle_with_bare_import {
- args: "bundle bundle/bare_imports/error_with_bare_import.ts",
- output: "bundle/bare_imports/error_with_bare_import.ts.out",
- exit_code: 1,
-});
-
-itest!(ts_decorators_bundle {
- args: "bundle bundle/decorators/ts_decorators.ts",
- output: "bundle/decorators/ts_decorators.out",
-});
-
-itest!(bundle_export_specifier_with_alias {
- args: "bundle bundle/file_tests-fixture16.ts",
- output: "bundle/fixture16.out",
-});
-
-itest!(bundle_ignore_directives {
- args: "bundle subdir/mod1.ts",
- output: "bundle/ignore_directives.test.out",
-});
-
-itest!(check_local_by_default_no_errors {
- args: "bundle --quiet bundle/check_local_by_default/no_errors.ts",
- output: "bundle/check_local_by_default/no_errors.out",
- http_server: true,
-});
-
-itest!(check_local_by_default_type_error {
- args: "bundle --quiet bundle/check_local_by_default/type_error.ts",
- output: "bundle/check_local_by_default/type_error.out",
- http_server: true,
- exit_code: 1,
-});
-
-itest!(ts_without_extension {
- args: "bundle --ext ts file_extensions/ts_without_extension",
- output: "bundle/file_extensions/ts_without_extension.out",
-});
-
-itest!(js_without_extension {
- args: "bundle --ext js file_extensions/js_without_extension",
- output: "bundle/file_extensions/js_without_extension.out",
-});
-
-itest!(bundle_shebang_file {
- args: "bundle subdir/shebang_file.js",
- output: "bundle/shebang_file.bundle.out",
-});
diff --git a/tests/integration/check_tests.rs b/tests/integration/check_tests.rs
index bcc01cf5d..8bb0ddde2 100644
--- a/tests/integration/check_tests.rs
+++ b/tests/integration/check_tests.rs
@@ -37,11 +37,6 @@ itest!(check_jsximportsource_importmap_config {
output_str: Some(""),
});
-itest!(bundle_jsximportsource_importmap_config {
- args: "bundle --quiet --config check/jsximportsource_importmap_config/deno.json check/jsximportsource_importmap_config/main.tsx",
- output: "check/jsximportsource_importmap_config/main.bundle.js",
-});
-
itest!(jsx_not_checked {
args: "check check/jsx_not_checked/main.jsx",
output: "check/jsx_not_checked/main.out",
diff --git a/tests/integration/lsp_tests.rs b/tests/integration/lsp_tests.rs
index c3f2f9daa..f6dee785d 100644
--- a/tests/integration/lsp_tests.rs
+++ b/tests/integration/lsp_tests.rs
@@ -1184,8 +1184,7 @@ fn lsp_deno_task() {
"deno.jsonc",
r#"{
"tasks": {
- "build": "deno test",
- "some:test": "deno bundle mod.ts"
+ "build": "deno test"
}
}"#,
);
@@ -1204,10 +1203,6 @@ fn lsp_deno_task() {
"name": "build",
"detail": "deno test",
"sourceUri": temp_dir.url().join("deno.jsonc").unwrap(),
- }, {
- "name": "some:test",
- "detail": "deno bundle mod.ts",
- "sourceUri": temp_dir.url().join("deno.jsonc").unwrap(),
}
])
);
diff --git a/tests/integration/mod.rs b/tests/integration/mod.rs
index d35fabc02..ea3269aaa 100644
--- a/tests/integration/mod.rs
+++ b/tests/integration/mod.rs
@@ -9,8 +9,6 @@
#[path = "bench_tests.rs"]
mod bench;
-#[path = "bundle_tests.rs"]
-mod bundle;
#[path = "cache_tests.rs"]
mod cache;
#[path = "check_tests.rs"]
diff --git a/tests/integration/watcher_tests.rs b/tests/integration/watcher_tests.rs
index abc5365b8..91ac5611f 100644
--- a/tests/integration/watcher_tests.rs
+++ b/tests/integration/watcher_tests.rs
@@ -10,8 +10,6 @@ use util::DenoChild;
use util::assert_not_contains;
-const CLEAR_SCREEN: &str = r#"[2J"#;
-
/// Logs to stderr every time next_line() is called
struct LoggingLines<R>
where
@@ -492,143 +490,6 @@ async fn fmt_check_all_files_on_each_change_test() {
}
#[flaky_test(tokio)]
-async fn bundle_js_watch() {
- use std::path::PathBuf;
- // Test strategy extends this of test bundle_js by adding watcher
- let t = TempDir::new();
- let file_to_watch = t.path().join("file_to_watch.ts");
- file_to_watch.write("console.log('Hello world');");
- assert!(file_to_watch.is_file());
- let t = TempDir::new();
- let bundle = t.path().join("mod6.bundle.js");
- let mut deno = util::deno_cmd()
- .current_dir(t.path())
- .arg("bundle")
- .arg(&file_to_watch)
- .arg(&bundle)
- .arg("--watch")
- .env("NO_COLOR", "1")
- .piped_output()
- .spawn()
- .unwrap();
-
- let (_stdout_lines, mut stderr_lines) = child_lines(&mut deno);
-
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Warning");
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "deno_emit");
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "Bundle started"
- );
- let line = next_line(&mut stderr_lines).await.unwrap();
- assert_contains!(line, "file_to_watch.ts");
- assert_contains!(line, "Check");
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Bundle");
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "mod6.bundle.js"
- );
- let file = PathBuf::from(&bundle);
- assert!(file.is_file());
-
- wait_contains("Bundle finished", &mut stderr_lines).await;
-
- file_to_watch.write("console.log('Hello world2');");
-
- let line = next_line(&mut stderr_lines).await.unwrap();
- // Should not clear screen, as we are in non-TTY environment
- assert_not_contains!(&line, CLEAR_SCREEN);
- assert_contains!(&line, "File change detected!");
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Check");
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "file_to_watch.ts"
- );
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "mod6.bundle.js"
- );
- let file = PathBuf::from(&bundle);
- assert!(file.is_file());
- wait_contains("Bundle finished", &mut stderr_lines).await;
-
- // Confirm that the watcher keeps on working even if the file is updated and has invalid syntax
- file_to_watch.write("syntax error ^^");
-
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "File change detected!"
- );
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "error: ");
- wait_contains("Bundle failed", &mut stderr_lines).await;
- check_alive_then_kill(deno);
-}
-
-/// Confirm that the watcher continues to work even if module resolution fails at the *first* attempt
-#[flaky_test(tokio)]
-async fn bundle_watch_not_exit() {
- let t = TempDir::new();
- let file_to_watch = t.path().join("file_to_watch.ts");
- file_to_watch.write("syntax error ^^");
- let target_file = t.path().join("target.js");
-
- let mut deno = util::deno_cmd()
- .current_dir(t.path())
- .arg("bundle")
- .arg(&file_to_watch)
- .arg(&target_file)
- .arg("--watch")
- .env("NO_COLOR", "1")
- .piped_output()
- .spawn()
- .unwrap();
- let (_stdout_lines, mut stderr_lines) = child_lines(&mut deno);
-
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Warning");
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "deno_emit");
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "Bundle started"
- );
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "error:");
- assert_eq!(next_line(&mut stderr_lines).await.unwrap(), "");
- assert_eq!(
- next_line(&mut stderr_lines).await.unwrap(),
- " syntax error ^^"
- );
- assert_eq!(
- next_line(&mut stderr_lines).await.unwrap(),
- " ~~~~~"
- );
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "Bundle failed"
- );
- // the target file hasn't been created yet
- assert!(!target_file.is_file());
-
- // Make sure the watcher actually restarts and works fine with the proper syntax
- file_to_watch.write("console.log(42);");
-
- assert_contains!(
- next_line(&mut stderr_lines).await.unwrap(),
- "File change detected"
- );
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "Check");
- let line = next_line(&mut stderr_lines).await.unwrap();
- // Should not clear screen, as we are in non-TTY environment
- assert_not_contains!(&line, CLEAR_SCREEN);
- assert_contains!(line, "file_to_watch.ts");
- assert_contains!(next_line(&mut stderr_lines).await.unwrap(), "target.js");
-
- wait_contains("Bundle finished", &mut stderr_lines).await;
-
- // bundled file is created
- assert!(target_file.is_file());
- check_alive_then_kill(deno);
-}
-
-#[flaky_test(tokio)]
async fn run_watch_no_dynamic() {
let t = TempDir::new();
let file_to_watch = t.path().join("file_to_watch.js");