diff options
Diffstat (limited to 'tools/permission_prompt_test.ts')
-rw-r--r-- | tools/permission_prompt_test.ts | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/tools/permission_prompt_test.ts b/tools/permission_prompt_test.ts index 0d5b86451..a4c9e4362 100644 --- a/tools/permission_prompt_test.ts +++ b/tools/permission_prompt_test.ts @@ -1,21 +1,54 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -const { args, listen, env, exit, makeTempDirSync, readFile, run } = Deno; +const { args, listen, env, exit, makeTempDirSync, readFileSync, run } = Deno; + +const firstCheckFailedMessage = "First check failed"; const name = args[1]; const test = { - needsRead: () => { - readFile("package.json"); + needsRead: async () => { + try { + readFileSync("package.json"); + } catch (e) { + console.log(firstCheckFailedMessage); + } + readFileSync("package.json"); }, needsWrite: () => { + try { + makeTempDirSync(); + } catch (e) { + console.log(firstCheckFailedMessage); + } makeTempDirSync(); }, needsEnv: () => { + try { + env().home; + } catch (e) { + console.log(firstCheckFailedMessage); + } env().home; }, needsNet: () => { - listen("tcp", "127.0.0.1:4540"); + try { + listen("tcp", "127.0.0.1:4540"); + } catch (e) { + console.log(firstCheckFailedMessage); + } + listen("tcp", "127.0.0.1:4541"); }, - needsRun: async () => { + needsRun: () => { + try { + const process = run({ + args: [ + "python", + "-c", + "import sys; sys.stdout.write('hello'); sys.stdout.flush()" + ] + }); + } catch (e) { + console.log(firstCheckFailedMessage); + } const process = run({ args: [ "python", @@ -23,7 +56,6 @@ const test = { "import sys; sys.stdout.write('hello'); sys.stdout.flush()" ] }); - await process.status(); } }[name]; |