mirror of
https://github.com/denoland/deno.git
synced 2024-11-01 09:24:20 -04:00
35 lines
697 B
TypeScript
35 lines
697 B
TypeScript
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
|
|
import { args, listen, env, exit, makeTempDirSync, readFile, run} from "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();
|