From 64354f41125642d420d80cbf617dfb8ddca398e5 Mon Sep 17 00:00:00 2001 From: Nick Hanley Date: Tue, 7 Mar 2023 00:00:51 -0500 Subject: [PATCH] chore(tests): use temp dir in test `missing_deno_dir` (#18057) Fixes #18056 --- cli/tests/integration/repl_tests.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index 5e36108428..efbde55c30 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -604,21 +604,22 @@ fn lexical_scoped_variable() { #[test] fn missing_deno_dir() { use std::fs::read_dir; - use std::fs::remove_dir_all; - const DENO_DIR: &str = "nonexistent"; - let test_deno_dir = test_util::testdata_path().join(DENO_DIR); + let temp_dir = TempDir::new(); + let deno_dir_path = temp_dir.path().join("deno"); let (out, err) = util::run_and_collect_output( true, "repl", Some(vec!["1"]), 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()), ]), false, ); - assert!(read_dir(&test_deno_dir).is_ok()); - remove_dir_all(&test_deno_dir).unwrap(); + assert!(read_dir(deno_dir_path).is_ok()); assert_ends_with!(out, "1\n"); assert!(err.is_empty()); }