diff options
author | Shreyas <shreyass.ranganatha@gmail.com> | 2023-09-18 23:18:54 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-09-18 17:48:54 +0000 |
commit | d72f5d573a59fc20ba465dffd1698984c7dde024 (patch) | |
tree | 8c6672fdac010faa3b1dd9133bd4e0f1c13e0c47 /cli/tests/unit/command_test.ts | |
parent | 87ddd1f04d2b71aadb3a8a5fb3e4ac15988947c1 (diff) |
fix: `Deno.Command` - improve error message when `cwd` is not a directory (#20460)
Diffstat (limited to 'cli/tests/unit/command_test.ts')
-rw-r--r-- | cli/tests/unit/command_test.ts | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/cli/tests/unit/command_test.ts b/cli/tests/unit/command_test.ts index ce3af08fb..5f56a0c22 100644 --- a/cli/tests/unit/command_test.ts +++ b/cli/tests/unit/command_test.ts @@ -424,6 +424,31 @@ Deno.test({ permissions: { run: true } }, function commandSyncNotFound() { ); }); +Deno.test({ permissions: { run: true, read: true } }, function cwdNotFound() { + assertThrows( + () => + new Deno.Command(Deno.execPath(), { + cwd: Deno.cwd() + "/non-existent-directory", + }).output(), + Deno.errors.NotFound, + "No such cwd", + ); +}); + +Deno.test( + { permissions: { run: true, read: true } }, + function cwdNotDirectory() { + assertThrows( + () => + new Deno.Command(Deno.execPath(), { + cwd: Deno.execPath(), + }).output(), + Deno.errors.NotFound, + "cwd is not a directory", + ); + }, +); + Deno.test( { permissions: { run: true, read: true } }, async function commandFailedWithCode() { @@ -892,12 +917,12 @@ Deno.test( assertThrows( () => new Deno.Command("doesntexist").outputSync(), Error, - "Failed to spawn: doesntexist", + "Failed to spawn 'doesntexist'", ); await assertRejects( async () => await new Deno.Command("doesntexist").output(), Error, - "Failed to spawn: doesntexist", + "Failed to spawn 'doesntexist'", ); }, ); |