From 3b78f6c4493093701660bba496d87342ffbc08d7 Mon Sep 17 00:00:00 2001 From: Satya Rohith Date: Wed, 21 Apr 2021 21:22:00 +0530 Subject: fix: do not panic on not found cwd (#10238) --- cli/tests/dont_panic_not_found_cwd.ts | 3 +++ cli/tests/integration_tests.rs | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 cli/tests/dont_panic_not_found_cwd.ts (limited to 'cli/tests') diff --git a/cli/tests/dont_panic_not_found_cwd.ts b/cli/tests/dont_panic_not_found_cwd.ts new file mode 100644 index 000000000..e5ae1dfa4 --- /dev/null +++ b/cli/tests/dont_panic_not_found_cwd.ts @@ -0,0 +1,3 @@ +const dir = Deno.makeTempDirSync(); +Deno.chdir(dir); +Deno.removeSync(dir); diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index d178512c5..28d2dc7c6 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -5144,6 +5144,25 @@ console.log("finish"); assert!(stderr.contains("BadResource")); } + #[cfg(not(windows))] + #[test] + fn should_not_panic_on_not_found_cwd() { + let output = util::deno_cmd() + .current_dir(util::root_path()) + .arg("run") + .arg("--allow-write") + .arg("--allow-read") + .arg("cli/tests/dont_panic_not_found_cwd.ts") + .stderr(std::process::Stdio::piped()) + .spawn() + .unwrap() + .wait_with_output() + .unwrap(); + assert!(!output.status.success()); + let stderr = std::str::from_utf8(&output.stderr).unwrap().trim(); + assert!(stderr.contains("Failed to get current working directory")); + } + #[cfg(windows)] // Clippy suggests to remove the `NoStd` prefix from all variants. I disagree. #[allow(clippy::enum_variant_names)] -- cgit v1.2.3