summaryrefslogtreecommitdiff
path: root/tools/permission_prompt_test.ts
blob: 0d5b864519102d25b515ff988d12d879baa2765e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { args, listen, env, exit, makeTempDirSync, readFile, run } = Deno;

const name = args[1];
const test = {
  needsRead: () => {
    readFile("package.json");
  },
  needsWrite: () => {
    makeTempDirSync();
  },
  needsEnv: () => {
    env().home;
  },
  needsNet: () => {
    listen("tcp", "127.0.0.1:4540");
  },
  needsRun: async () => {
    const process = run({
      args: [
        "python",
        "-c",
        "import sys; sys.stdout.write('hello'); sys.stdout.flush()"
      ]
    });
    await process.status();
  }
}[name];

if (!test) {
  console.log("Unknown test:", name);
  exit(1);
}

test();