summaryrefslogtreecommitdiff
path: root/cli/tests/integration/cache_tests.rs
diff options
context:
space:
mode:
authorLuca Casonato <hello@lcas.dev>2022-02-03 14:08:17 +0100
committerGitHub <noreply@github.com>2022-02-03 14:08:17 +0100
commit681c3be18de764d3844acbff4a05ac5f40bc3a5f (patch)
tree8389c8885e10d14b4f019916738d869659c73848 /cli/tests/integration/cache_tests.rs
parented3086e4b129843c13a009112cf21dfd05745905 (diff)
fix: don't crash when $HOME is a relative path (#13581)
Absolutize the cache/home dir before use in DenoDir.
Diffstat (limited to 'cli/tests/integration/cache_tests.rs')
-rw-r--r--cli/tests/integration/cache_tests.rs30
1 files changed, 30 insertions, 0 deletions
diff --git a/cli/tests/integration/cache_tests.rs b/cli/tests/integration/cache_tests.rs
index 773f98f6b..f7d9fb486 100644
--- a/cli/tests/integration/cache_tests.rs
+++ b/cli/tests/integration/cache_tests.rs
@@ -48,3 +48,33 @@ itest!(ignore_require {
output_str: Some(""),
exit_code: 0,
});
+
+// This test only runs on linux, because it hardcodes the XDG_CACHE_HOME env var
+// which is only used on linux.
+#[cfg(target_os = "linux")]
+#[test]
+fn relative_home_dir() {
+ use tempfile::TempDir;
+ use test_util as util;
+
+ let deno_dir = TempDir::new_in(util::testdata_path()).unwrap();
+ let path = deno_dir.path().strip_prefix(util::testdata_path()).unwrap();
+
+ let mut deno_cmd = util::deno_cmd();
+ let output = deno_cmd
+ .current_dir(util::testdata_path())
+ .env("XDG_CACHE_HOME", path)
+ .env_remove("HOME")
+ .env_remove("DENO_DIR")
+ .arg("cache")
+ .arg("--reload")
+ .arg("--no-check")
+ .arg("002_hello.ts")
+ .stdout(std::process::Stdio::piped())
+ .spawn()
+ .unwrap()
+ .wait_with_output()
+ .unwrap();
+ assert!(output.status.success());
+ assert_eq!(output.stdout, b"");
+}