From 262ae2f26b3fd291b3e29dfdd5e43ab312a48a98 Mon Sep 17 00:00:00 2001 From: Casper Beyer Date: Mon, 18 Jan 2021 20:39:35 +0800 Subject: [PATCH] test(node): avoid project directories for cwd case (denoland/deno#9148) --- node/process_test.ts | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/node/process_test.ts b/node/process_test.ts index 40f809edfd19..2a789a5d771f 100644 --- a/node/process_test.ts +++ b/node/process_test.ts @@ -38,17 +38,16 @@ Deno.test({ fn() { assertEquals(process.cwd(), Deno.cwd()); - const currentDir = Deno.cwd(); // to unchange current directory after this test + const currentDir = Deno.cwd(); - const moduleDir = path.dirname(path.fromFileUrl(import.meta.url)); - process.chdir(path.resolve(moduleDir, "..")); + const tempDir = Deno.makeTempDirSync(); + process.chdir(tempDir); + assertEquals( + Deno.realPathSync(process.cwd()), + Deno.realPathSync(tempDir), + ); - assert(process.cwd().match(/\Wstd$/)); - process.chdir("node"); - assert(process.cwd().match(/\Wnode$/)); - process.chdir(".."); - assert(process.cwd().match(/\Wstd$/)); - process.chdir(currentDir); // to unchange current directory after this test + process.chdir(currentDir); }, });