From 08a674bf917185fe9d00907120d3f03599a810a0 Mon Sep 17 00:00:00 2001 From: andy finch Date: Mon, 18 Mar 2019 16:46:23 -0400 Subject: More permissions prompt options (#1926) --- tools/permission_prompt_test.ts | 44 +++++++++++++++++++++++++++++++++++------ 1 file changed, 38 insertions(+), 6 deletions(-) (limited to 'tools/permission_prompt_test.ts') 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]; -- cgit v1.2.3