summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-08-06 21:56:56 -0400
committerGitHub <noreply@github.com>2023-08-06 21:56:56 -0400
commitb9b03869489213fa9b24d7416afe9e3e27c81ce7 (patch)
tree7727f2906b0864b1242c9d8030ca6416ee053409 /cli/tests
parent7b5bc87f296d39e531051e1c0bb6cafa3808ab92 (diff)
feat(unstable): rename `deno_modules` to `vendor` (#20065)
Renames the unstable `deno_modules` directory and corresponding settings to `vendor` after feedback. Also causes the vendoring of the `node_modules` directory which can be disabled via `--node-modules-dir=false` or `"nodeModulesDir": false`.
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/lsp_tests.rs14
-rw-r--r--cli/tests/integration/npm_tests.rs14
-rw-r--r--cli/tests/integration/run_tests.rs55
3 files changed, 49 insertions, 34 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs
index 28591d631..d540c5f37 100644
--- a/cli/tests/integration/lsp_tests.rs
+++ b/cli/tests/integration/lsp_tests.rs
@@ -8768,7 +8768,7 @@ fn lsp_node_modules_dir() {
}
#[test]
-fn lsp_deno_modules_dir() {
+fn lsp_vendor_dir() {
let context = TestContextBuilder::new()
.use_http_server()
.use_temp_cwd()
@@ -8804,11 +8804,11 @@ fn lsp_deno_modules_dir() {
cache(&mut client);
- assert!(!temp_dir.path().join("deno_modules").exists());
+ assert!(!temp_dir.path().join("vendor").exists());
temp_dir.write(
temp_dir.path().join("deno.json"),
- "{ \"denoModulesDir\": true, \"lock\": false }\n",
+ "{ \"vendor\": true, \"lock\": false }\n",
);
let refresh_config = |client: &mut LspClient| {
client.write_notification(
@@ -8852,10 +8852,10 @@ fn lsp_deno_modules_dir() {
// no caching necessary because it was already cached. It should exist now
assert!(temp_dir
.path()
- .join("deno_modules/http_localhost_4545/subdir/mod1.ts")
+ .join("vendor/http_localhost_4545/subdir/mod1.ts")
.exists());
- // the declaration should be found in the deno_modules directory
+ // the declaration should be found in the vendor directory
let res = client.write_request(
"textDocument/references",
json!({
@@ -8869,7 +8869,7 @@ fn lsp_deno_modules_dir() {
}),
);
- // ensure that it's using the deno_modules directory
+ // ensure that it's using the vendor directory
let references = res.as_array().unwrap();
assert_eq!(references.len(), 2, "references: {:#?}", references);
let uri = references[1]
@@ -8881,7 +8881,7 @@ fn lsp_deno_modules_dir() {
.unwrap();
let file_path = temp_dir
.path()
- .join("deno_modules/http_localhost_4545/subdir/mod1.ts");
+ .join("vendor/http_localhost_4545/subdir/mod1.ts");
let remote_file_uri = file_path.uri_file();
assert_eq!(uri, remote_file_uri.as_str());
diff --git a/cli/tests/integration/npm_tests.rs b/cli/tests/integration/npm_tests.rs
index 34b6add26..c44335efc 100644
--- a/cli/tests/integration/npm_tests.rs
+++ b/cli/tests/integration/npm_tests.rs
@@ -2023,8 +2023,14 @@ pub fn node_modules_dir_config_file() {
let deno_cache_cmd = test_context.new_command().args("cache --quiet main.ts");
deno_cache_cmd.run();
+ assert!(node_modules_dir.exists());
+ // now try adding a vendor flag, it should exist
+ rm_node_modules();
+ temp_dir.write("deno.json", r#"{ "vendor": true }"#);
+ deno_cache_cmd.run();
assert!(node_modules_dir.exists());
+
rm_node_modules();
temp_dir.write("deno.json", r#"{ "nodeModulesDir": false }"#);
@@ -2040,6 +2046,14 @@ pub fn node_modules_dir_config_file() {
.args("cache --quiet --node-modules-dir main.ts")
.run();
assert!(node_modules_dir.exists());
+
+ // should override the `--vendor` flag
+ rm_node_modules();
+ test_context
+ .new_command()
+ .args("cache --quiet --node-modules-dir=false --vendor main.ts")
+ .run();
+ assert!(!node_modules_dir.exists());
}
#[test]
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index 25046253e..ce837a2a4 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -102,8 +102,9 @@ itest!(_017_import_redirect_check {
output: "run/017_import_redirect.ts.out",
});
-itest!(_017_import_redirect_deno_modules_dir {
- args: "run --quiet --reload --deno-modules-dir --check $TESTDATA/run/017_import_redirect.ts",
+itest!(_017_import_redirect_vendor_dir {
+ args:
+ "run --quiet --reload --vendor --check $TESTDATA/run/017_import_redirect.ts",
output: "run/017_import_redirect.ts.out",
temp_cwd: true,
});
@@ -163,9 +164,9 @@ itest!(_027_redirect_typescript {
http_server: true,
});
-itest!(_027_redirect_typescript_deno_modules_dir {
+itest!(_027_redirect_typescript_vendor_dir {
args:
- "run --quiet --reload --deno-modules-dir $TESTDATA/run/027_redirect_typescript.ts",
+ "run --quiet --reload --vendor $TESTDATA/run/027_redirect_typescript.ts",
output: "run/027_redirect_typescript.ts.out",
http_server: true,
temp_cwd: true,
@@ -201,9 +202,9 @@ itest!(_033_import_map_remote {
http_server: true,
});
-itest!(_033_import_map_deno_modules_dir_remote {
+itest!(_033_import_map_vendor_dir_remote {
args:
- "run --quiet --reload --import-map=http://127.0.0.1:4545/import_maps/import_map_remote.json --deno-modules-dir --unstable $TESTDATA/import_maps/test_remote.ts",
+ "run --quiet --reload --import-map=http://127.0.0.1:4545/import_maps/import_map_remote.json --vendor --unstable $TESTDATA/import_maps/test_remote.ts",
output: "run/033_import_map_remote.out",
http_server: true,
temp_cwd: true,
@@ -1706,8 +1707,8 @@ itest!(jsx_import_source_pragma_with_config_no_check {
http_server: true,
});
-itest!(jsx_import_source_pragma_with_config_deno_modules_dir {
- args: "run --reload --config jsx/deno-jsx.jsonc --no-lock --deno-modules-dir $TESTDATA/run/jsx_import_source_pragma.tsx",
+itest!(jsx_import_source_pragma_with_config_vendor_dir {
+ args: "run --reload --config jsx/deno-jsx.jsonc --no-lock --vendor $TESTDATA/run/jsx_import_source_pragma.tsx",
output: "run/jsx_import_source.out",
http_server: true,
temp_cwd: true,
@@ -1767,9 +1768,9 @@ itest!(reference_types_error {
exit_code: 1,
});
-itest!(reference_types_error_deno_modules_dir {
+itest!(reference_types_error_vendor_dir {
args:
- "run --config run/checkjs.tsconfig.json --check --deno-modules-dir $TESTDATA/run/reference_types_error.js",
+ "run --config run/checkjs.tsconfig.json --check --vendor $TESTDATA/run/reference_types_error.js",
output: "run/reference_types_error.js.out",
exit_code: 1,
});
@@ -4494,16 +4495,16 @@ itest!(extension_dynamic_import {
});
#[test]
-pub fn deno_modules_dir_config_file() {
+pub fn vendor_dir_config_file() {
let test_context = TestContextBuilder::new()
.use_http_server()
.use_temp_cwd()
.build();
let temp_dir = test_context.temp_dir();
- let deno_modules_dir = temp_dir.path().join("deno_modules");
- let rm_deno_modules = || std::fs::remove_dir_all(&deno_modules_dir).unwrap();
+ let vendor_dir = temp_dir.path().join("vendor");
+ let rm_vendor_dir = || std::fs::remove_dir_all(&vendor_dir).unwrap();
- temp_dir.write("deno.json", r#"{ "denoModulesDir": true }"#);
+ temp_dir.write("deno.json", r#"{ "vendor": true }"#);
temp_dir.write(
"main.ts",
r#"import { returnsHi } from 'http://localhost:4545/subdir/mod1.ts';
@@ -4513,25 +4514,25 @@ console.log(returnsHi());"#,
let deno_run_cmd = test_context.new_command().args("run --quiet main.ts");
deno_run_cmd.run().assert_matches_text("Hi\n");
- assert!(deno_modules_dir.exists());
- rm_deno_modules();
- temp_dir.write("deno.json", r#"{ "denoModulesDir": false }"#);
+ assert!(vendor_dir.exists());
+ rm_vendor_dir();
+ temp_dir.write("deno.json", r#"{ "vendor": false }"#);
deno_run_cmd.run().assert_matches_text("Hi\n");
- assert!(!deno_modules_dir.exists());
+ assert!(!vendor_dir.exists());
test_context
.new_command()
- .args("cache --quiet --deno-modules-dir main.ts")
+ .args("cache --quiet --vendor main.ts")
.run();
- assert!(deno_modules_dir.exists());
- rm_deno_modules();
+ assert!(vendor_dir.exists());
+ rm_vendor_dir();
- temp_dir.write("deno.json", r#"{ "denoModulesDir": true }"#);
+ temp_dir.write("deno.json", r#"{ "vendor": true }"#);
let cache_command = test_context.new_command().args("cache --quiet main.ts");
cache_command.run();
- assert!(deno_modules_dir.exists());
- let mod1_file = deno_modules_dir
+ assert!(vendor_dir.exists());
+ let mod1_file = vendor_dir
.join("http_localhost_4545")
.join("subdir")
.join("mod1.ts");
@@ -4563,20 +4564,20 @@ console.log(returnsHi());"#,
.run()
.skip_output_check();
assert_eq!(
- deno_modules_dir.join("manifest.json").read_json_value(),
+ vendor_dir.join("manifest.json").read_json_value(),
json!({
"folders": {
"http://localhost:4545/subdir/CAPITALS/": "http_localhost_4545/subdir/#capitals_c75d7"
}
})
);
- deno_modules_dir
+ vendor_dir
.join("http_localhost_4545/subdir/#capitals_c75d7/hello_there.ts")
.write("console.log('hello there');");
test_context
.new_command()
// todo(dsherret): seems wrong that we don't auto-discover the config file to get the vendor directory for this
- .args("run --deno-modules-dir http://localhost:4545/subdir/CAPITALS/hello_there.ts")
+ .args("run --vendor http://localhost:4545/subdir/CAPITALS/hello_there.ts")
.run()
.assert_matches_text("hello there\n");
}