1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-11-04 08:54:20 -05:00
denoland-deno/cli/tests/testdata/run/permission_test.ts
Bartek Iwańczuk 4d07ed0efa
chore: rewrite tests and utils to use Deno.Command API (#16895)
Since "Deno.spawn()", "Deno.spawnSync()" and "Deno.spawnChild"
are getting deprecated, this commits rewrites all tests and utilities to
use "Deno.Command" API instead.
2022-12-02 14:43:17 +01:00

30 lines
784 B
TypeScript

// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
const name = Deno.args[0];
// deno-lint-ignore no-explicit-any
const test: { [key: string]: (...args: any[]) => void | Promise<void> } = {
readRequired() {
Deno.readFileSync("assets/hello.txt");
return Promise.resolve();
},
writeRequired() {
Deno.makeTempDirSync();
},
envRequired() {
Deno.env.get("home");
},
netRequired() {
Deno.listen({ transport: "tcp", port: 4541 });
},
async runRequired() {
await new Deno.Command(Deno.build.os === "windows" ? "cmd.exe" : "printf", {
args: Deno.build.os === "windows" ? ["/c", "echo hello"] : ["hello"],
}).output();
},
};
if (!test[name]) {
console.log("Unknown test:", name);
Deno.exit(1);
}
test[name]();