summaryrefslogtreecommitdiff
path: root/cli/tests/permission_test.ts
blob: 763e429b6270ffaea1b411f9b52af390059c0b62 (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
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { args, listen, env, exit, makeTempDirSync, readFileSync, run } = Deno;

const name = args[0];
const test: { [key: string]: Function } = {
  async readRequired(): Promise<void> {
    readFileSync("README.md");
  },
  writeRequired(): void {
    makeTempDirSync();
  },
  envRequired(): void {
    env().home;
  },
  netRequired(): void {
    listen({ transport: "tcp", port: 4541 });
  },
  runRequired(): void {
    run({
      args: [
        "python",
        "-c",
        "import sys; sys.stdout.write('hello'); sys.stdout.flush()"
      ]
    });
  }
};

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

test[name]();