1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-24 15:19:26 -05:00

chore(tests): use temp dir in test missing_deno_dir (#18057)

Fixes #18056
This commit is contained in:
Nick Hanley 2023-03-07 00:00:51 -05:00 committed by GitHub
parent 805e8b39ce
commit 64354f4112
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -604,21 +604,22 @@ fn lexical_scoped_variable() {
#[test] #[test]
fn missing_deno_dir() { fn missing_deno_dir() {
use std::fs::read_dir; use std::fs::read_dir;
use std::fs::remove_dir_all; let temp_dir = TempDir::new();
const DENO_DIR: &str = "nonexistent"; let deno_dir_path = temp_dir.path().join("deno");
let test_deno_dir = test_util::testdata_path().join(DENO_DIR);
let (out, err) = util::run_and_collect_output( let (out, err) = util::run_and_collect_output(
true, true,
"repl", "repl",
Some(vec!["1"]), Some(vec!["1"]),
Some(vec![ Some(vec![
("DENO_DIR".to_owned(), DENO_DIR.to_owned()), (
"DENO_DIR".to_owned(),
deno_dir_path.to_str().unwrap().to_owned(),
),
("NO_COLOR".to_owned(), "1".to_owned()), ("NO_COLOR".to_owned(), "1".to_owned()),
]), ]),
false, false,
); );
assert!(read_dir(&test_deno_dir).is_ok()); assert!(read_dir(deno_dir_path).is_ok());
remove_dir_all(&test_deno_dir).unwrap();
assert_ends_with!(out, "1\n"); assert_ends_with!(out, "1\n");
assert!(err.is_empty()); assert!(err.is_empty());
} }