summaryrefslogtreecommitdiff
path: root/cli/tests
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2023-08-06 12:25:48 -0400
committerGitHub <noreply@github.com>2023-08-06 12:25:48 -0400
commit7b5bc87f296d39e531051e1c0bb6cafa3808ab92 (patch)
treeaafd08a578d97a73197e9273d30cfaefe05cc871 /cli/tests
parentc1c8eb3d558bedf6588179ae93737bd6afe5a368 (diff)
fix(unstable): vendor cache should support adding files to hashed directories (#20070)
This changes the design of the manifest.json file to have a separate "folders" map for mapping hashed directories. This allows, for example, to add files in a folder like `http_localhost_8000/#testing_5de71/` and have them be resolved automatically as long as their remaining components are identity-mappable to the file system (not hashed). It also saves space in the manifest.json file by only including the hashed directory instead of each descendant file. ``` // manifest.json { "folders": { "https://localhost/NOT_MAPPABLE/": "localhost/#not_mappable_5cefgh" }, "modules": { "https://localhost/folder/file": { "headers": { "content-type": "application/javascript" } }, } } // folder structure localhost - folder - #file_2defn (note: I've made up the hashes in these examples) - #not_mappable_5cefgh - mod.ts - etc.ts - more_files.ts ```
Diffstat (limited to 'cli/tests')
-rw-r--r--cli/tests/integration/run_tests.rs26
-rw-r--r--cli/tests/testdata/subdir/CAPITALS/main.js3
2 files changed, 29 insertions, 0 deletions
diff --git a/cli/tests/integration/run_tests.rs b/cli/tests/integration/run_tests.rs
index e83932011..25046253e 100644
--- a/cli/tests/integration/run_tests.rs
+++ b/cli/tests/integration/run_tests.rs
@@ -1,5 +1,6 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
+use deno_core::serde_json::json;
use deno_core::url;
use deno_runtime::deno_fetch::reqwest;
use std::io::Read;
@@ -4553,4 +4554,29 @@ console.log(returnsHi());"#,
// now it should run
deno_run_cmd.run().assert_matches_text("bye bye bye\n");
assert!(lockfile.exists());
+
+ // ensure we can add and execute files in directories that have a hash in them
+ test_context
+ .new_command()
+ // http_localhost_4545/subdir/#capitals_c75d7/main.js
+ .args("cache http://localhost:4545/subdir/CAPITALS/main.js")
+ .run()
+ .skip_output_check();
+ assert_eq!(
+ deno_modules_dir.join("manifest.json").read_json_value(),
+ json!({
+ "folders": {
+ "http://localhost:4545/subdir/CAPITALS/": "http_localhost_4545/subdir/#capitals_c75d7"
+ }
+ })
+ );
+ deno_modules_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")
+ .run()
+ .assert_matches_text("hello there\n");
}
diff --git a/cli/tests/testdata/subdir/CAPITALS/main.js b/cli/tests/testdata/subdir/CAPITALS/main.js
new file mode 100644
index 000000000..768d1391f
--- /dev/null
+++ b/cli/tests/testdata/subdir/CAPITALS/main.js
@@ -0,0 +1,3 @@
+export function returnsUppperHi() {
+ return "HI";
+}