diff options
author | Nayeem Rahman <nayeemrmn99@gmail.com> | 2021-02-07 23:14:05 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 10:14:05 +1100 |
commit | 0cac243a835d86ad5f37d50bdd1634bd4fe2d2d6 (patch) | |
tree | 1dc1a5a7b124f65017487bd322f6cf41cee288b1 /cli/tests/integration_tests.rs | |
parent | 45b465f8392b58f3cc524502737e98feecdf2c25 (diff) |
fix(cli): check for inline source maps before external ones (#9394)
Fixes #6965
Diffstat (limited to 'cli/tests/integration_tests.rs')
-rw-r--r-- | cli/tests/integration_tests.rs | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c79988412..db09aa421 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -2656,6 +2656,35 @@ console.log("finish"); exit_code: 1, }); + #[test] + fn _083_legacy_external_source_map() { + let _g = util::http_server(); + let deno_dir = TempDir::new().expect("tempdir fail"); + let module_url = url::Url::parse( + "http://localhost:4545/cli/tests/083_legacy_external_source_map.ts", + ) + .unwrap(); + // Write a faulty old external source map. + let faulty_map_path = deno_dir.path().join("gen/http/localhost_PORT4545/9576bd5febd0587c5c4d88d57cb3ac8ebf2600c529142abe3baa9a751d20c334.js.map"); + std::fs::create_dir_all(faulty_map_path.parent().unwrap()) + .expect("Failed to create faulty source map dir."); + std::fs::write(faulty_map_path, "{\"version\":3,\"file\":\"\",\"sourceRoot\":\"\",\"sources\":[\"http://localhost:4545/cli/tests/083_legacy_external_source_map.ts\"],\"names\":[],\"mappings\":\";AAAA,MAAM,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC\"}").expect("Failed to write faulty source map."); + let output = Command::new(util::deno_exe_path()) + .env("DENO_DIR", deno_dir.path()) + .current_dir(util::root_path()) + .arg("run") + .arg(module_url.to_string()) + .output() + .expect("Failed to spawn script"); + // Before https://github.com/denoland/deno/issues/6965 was fixed, the faulty + // old external source map would cause a panic while formatting the error + // and the exit code would be 101. The external source map should be ignored + // in favor of the inline one. + assert_eq!(output.status.code(), Some(1)); + let out = std::str::from_utf8(&output.stdout).unwrap(); + assert_eq!(out, ""); + } + itest!(js_import_detect { args: "run --quiet --reload js_import_detect.ts", output: "js_import_detect.ts.out", |