diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2023-07-01 23:52:30 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-02 00:52:30 +0200 |
commit | b9c0e7cd550ab14fa7da7e33ed87cbeeeb9785a0 (patch) | |
tree | 9212eb183ab3c21ee71531e54f2c16163d1792b7 /cli/tests | |
parent | 4e2f02639ef2cbcfdd335c4446f6faa6a29ad264 (diff) |
Reland "fix(cli): don't store blob and data urls in the module cache" (#18581)
Relands #18261 now that
https://github.com/lucacasonato/esbuild_deno_loader/pull/54 is landed
and used by fresh.
Fixes #18260.
Diffstat (limited to 'cli/tests')
-rw-r--r-- | cli/tests/integration/lsp_tests.rs | 24 | ||||
-rw-r--r-- | cli/tests/integration/watcher_tests.rs | 41 |
2 files changed, 45 insertions, 20 deletions
diff --git a/cli/tests/integration/lsp_tests.rs b/cli/tests/integration/lsp_tests.rs index 04b17ef00..52f1e55ba 100644 --- a/cli/tests/integration/lsp_tests.rs +++ b/cli/tests/integration/lsp_tests.rs @@ -5612,7 +5612,7 @@ fn lsp_cache_location() { "text": "import * as a from \"http://127.0.0.1:4545/xTypeScriptTypes.js\";\n// @deno-types=\"http://127.0.0.1:4545/type_definitions/foo.d.ts\"\nimport * as b from \"http://127.0.0.1:4545/type_definitions/foo.js\";\nimport * as c from \"http://127.0.0.1:4545/subdir/type_reference.js\";\nimport * as d from \"http://127.0.0.1:4545/subdir/mod1.ts\";\nimport * as e from \"data:application/typescript;base64,ZXhwb3J0IGNvbnN0IGEgPSAiYSI7CgpleHBvcnQgZW51bSBBIHsKICBBLAogIEIsCiAgQywKfQo=\";\nimport * as f from \"./file_01.ts\";\nimport * as g from \"http://localhost:4545/x/a/mod.ts\";\n\nconsole.log(a, b, c, d, e, f, g);\n" } })); - assert_eq!(diagnostics.all().len(), 7); + assert_eq!(diagnostics.all().len(), 6); client.write_request( "deno/cache", json!({ @@ -5708,7 +5708,7 @@ fn lsp_tls_cert() { } })); let diagnostics = diagnostics.all(); - assert_eq!(diagnostics.len(), 7); + assert_eq!(diagnostics.len(), 6); client.write_request( "deno/cache", json!({ @@ -7609,25 +7609,9 @@ fn lsp_data_urls_with_jsx_compiler_option() { } })).all(); - // there will be a diagnostic about not having cached the data url - assert_eq!(diagnostics.len(), 1); - assert_eq!( - diagnostics[0].code, - Some(lsp::NumberOrString::String("no-cache-data".to_string())) - ); + assert_eq!(diagnostics.len(), 0); - // so cache it - client.write_request( - "deno/cache", - json!({ - "referrer": { - "uri": uri, - }, - "uris": [], - }), - ); - - let res = client.write_request( + let res: Value = client.write_request( "textDocument/references", json!({ "textDocument": { diff --git a/cli/tests/integration/watcher_tests.rs b/cli/tests/integration/watcher_tests.rs index e844a2efe..8b8bbb0bf 100644 --- a/cli/tests/integration/watcher_tests.rs +++ b/cli/tests/integration/watcher_tests.rs @@ -1255,6 +1255,47 @@ async fn test_watch_unload_handler_error_on_drop() { check_alive_then_kill(child); } +#[tokio::test] +async fn run_watch_blob_urls_reset() { + let _g = util::http_server(); + let t = TempDir::new(); + let file_to_watch = t.path().join("file_to_watch.js"); + let file_content = r#" + const prevUrl = localStorage.getItem("url"); + if (prevUrl == null) { + console.log("first run, storing blob url"); + const url = URL.createObjectURL( + new Blob(["export {}"], { type: "application/javascript" }), + ); + await import(url); // this shouldn't insert into the fs module cache + localStorage.setItem("url", url); + } else { + await import(prevUrl) + .then(() => console.log("importing old blob url incorrectly works")) + .catch(() => console.log("importing old blob url correctly failed")); + } + "#; + file_to_watch.write(file_content); + let mut child = util::deno_cmd() + .current_dir(util::testdata_path()) + .arg("run") + .arg("--watch") + .arg(&file_to_watch) + .env("NO_COLOR", "1") + .stdout(std::process::Stdio::piped()) + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap(); + let (mut stdout_lines, mut stderr_lines) = child_lines(&mut child); + wait_contains("first run, storing blob url", &mut stdout_lines).await; + wait_contains("finished", &mut stderr_lines).await; + file_to_watch.write(file_content); + wait_contains("importing old blob url correctly failed", &mut stdout_lines) + .await; + wait_contains("finished", &mut stderr_lines).await; + check_alive_then_kill(child); +} + #[cfg(unix)] #[tokio::test] async fn test_watch_sigint() { |