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