1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-29 02:29:06 -05:00
denoland-deno/tools/permission_prompt_test.ts

68 lines
1.4 KiB
TypeScript
Raw Normal View History

2019-01-21 14:03:30 -05:00
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const { args, env, exit, listen, makeTempDirSync, readFileSync, run } = Deno;
const firstCheckFailedMessage = "First check failed";
const name = args[1];
const test = {
async needsRead(): Promise<void> {
try {
readFileSync("package.json");
} catch (e) {
console.log(firstCheckFailedMessage);
}
readFileSync("package.json");
2019-02-09 05:31:03 -05:00
},
needsWrite(): void {
try {
makeTempDirSync();
} catch (e) {
console.log(firstCheckFailedMessage);
}
makeTempDirSync();
},
needsEnv(): void {
try {
env().home;
} catch (e) {
console.log(firstCheckFailedMessage);
}
env().home;
},
needsNet(): void {
try {
listen({ hostname: "127.0.0.1", port: 4540 });
} catch (e) {
console.log(firstCheckFailedMessage);
}
listen({ hostname: "127.0.0.1", port: 4541 });
2019-01-12 11:29:45 -05:00
},
needsRun(): void {
try {
run({
args: [
"python",
"-c",
"import sys; sys.stdout.write('hello'); sys.stdout.flush()"
]
});
} catch (e) {
console.log(firstCheckFailedMessage);
}
run({
2019-01-13 12:09:45 -05:00
args: [
"python",
"-c",
"import sys; sys.stdout.write('hello'); sys.stdout.flush()"
]
});
}
}[name];
if (!test) {
console.log("Unknown test:", name);
exit(1);
}
test();