diff options
Diffstat (limited to 'cli/js/os_test.ts')
-rw-r--r-- | cli/js/os_test.ts | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/cli/js/os_test.ts b/cli/js/os_test.ts index 35b9f126a..0c851be51 100644 --- a/cli/js/os_test.ts +++ b/cli/js/os_test.ts @@ -1,14 +1,13 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { - test, - testPerm, assert, assertEquals, assertNotEquals, - assertThrows + assertThrows, + unitTest } from "./test_util.ts"; -testPerm({ env: true }, function envSuccess(): void { +unitTest({ perms: { env: true } }, function envSuccess(): void { const env = Deno.env(); assert(env !== null); // eslint-disable-next-line @typescript-eslint/camelcase @@ -18,12 +17,12 @@ testPerm({ env: true }, function envSuccess(): void { assertEquals(Deno.env("test_var"), env.test_var); }); -testPerm({ env: true }, function envNotFound(): void { +unitTest({ perms: { env: true } }, function envNotFound(): void { const r = Deno.env("env_var_does_not_exist!"); assertEquals(r, undefined); }); -test(function envPermissionDenied1(): void { +unitTest(function envPermissionDenied1(): void { let err; try { Deno.env(); @@ -35,7 +34,7 @@ test(function envPermissionDenied1(): void { assertEquals(err.name, "PermissionDenied"); }); -test(function envPermissionDenied2(): void { +unitTest(function envPermissionDenied2(): void { let err; try { Deno.env("PATH"); @@ -47,11 +46,12 @@ test(function envPermissionDenied2(): void { assertEquals(err.name, "PermissionDenied"); }); -if (Deno.build.os === "win") { - // This test verifies that on Windows, environment variables are - // case-insensitive. Case normalization needs be done using the collation - // that Windows uses, rather than naively using String.toLowerCase(). - testPerm({ env: true, run: true }, async function envCaseInsensitive() { +// This test verifies that on Windows, environment variables are +// case-insensitive. Case normalization needs be done using the collation +// that Windows uses, rather than naively using String.toLowerCase(). +unitTest( + { skip: Deno.build.os !== "win", perms: { env: true, run: true } }, + async function envCaseInsensitive() { // Utility function that runs a Deno subprocess with the environment // specified in `inputEnv`. The subprocess reads the environment variables // which are in the keys of `expectedEnv` and writes them to stdout as JSON. @@ -61,9 +61,9 @@ if (Deno.build.os === "win") { expectedEnv: Record<string, string> ): Promise<void> => { const src = ` - console.log( - ${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env(k)) - )`; + console.log( + ${JSON.stringify(Object.keys(expectedEnv))}.map(k => Deno.env(k)) + )`; const proc = Deno.run({ args: [Deno.execPath(), "eval", src], env: inputEnv, @@ -108,14 +108,14 @@ if (Deno.build.os === "win") { { [c2]: "Dz", [uc2]: "DZ" }, { [c2]: "Dz", [uc2]: "DZ", [lc2]: "DZ" } ); - }); -} + } +); -test(function osPid(): void { +unitTest(function osPid(): void { assert(Deno.pid > 0); }); -testPerm({ env: true }, function getDir(): void { +unitTest({ perms: { env: true } }, function getDir(): void { type supportOS = "mac" | "win" | "linux"; interface Runtime { @@ -263,7 +263,7 @@ testPerm({ env: true }, function getDir(): void { } }); -testPerm({}, function getDirWithoutPermission(): void { +unitTest(function getDirWithoutPermission(): void { assertThrows( () => Deno.dir("home"), Deno.errors.PermissionDenied, @@ -271,11 +271,11 @@ testPerm({}, function getDirWithoutPermission(): void { ); }); -testPerm({ env: true }, function execPath(): void { +unitTest({ perms: { env: true } }, function execPath(): void { assertNotEquals(Deno.execPath(), ""); }); -testPerm({ env: false }, function execPathPerm(): void { +unitTest({ perms: { env: false } }, function execPathPerm(): void { let caughtError = false; try { Deno.execPath(); @@ -287,12 +287,12 @@ testPerm({ env: false }, function execPathPerm(): void { assert(caughtError); }); -testPerm({ env: true }, function loadavgSuccess(): void { +unitTest({ perms: { env: true } }, function loadavgSuccess(): void { const load = Deno.loadavg(); assertEquals(load.length, 3); }); -testPerm({ env: false }, function loadavgPerm(): void { +unitTest({ perms: { env: false } }, function loadavgPerm(): void { let caughtError = false; try { Deno.loadavg(); @@ -304,11 +304,11 @@ testPerm({ env: false }, function loadavgPerm(): void { assert(caughtError); }); -testPerm({ env: true }, function hostnameDir(): void { +unitTest({ perms: { env: true } }, function hostnameDir(): void { assertNotEquals(Deno.hostname(), ""); }); -testPerm({ env: false }, function hostnamePerm(): void { +unitTest({ perms: { env: false } }, function hostnamePerm(): void { let caughtError = false; try { Deno.hostname(); @@ -320,11 +320,11 @@ testPerm({ env: false }, function hostnamePerm(): void { assert(caughtError); }); -testPerm({ env: true }, function releaseDir(): void { +unitTest({ perms: { env: true } }, function releaseDir(): void { assertNotEquals(Deno.osRelease(), ""); }); -testPerm({ env: false }, function releasePerm(): void { +unitTest({ perms: { env: false } }, function releasePerm(): void { let caughtError = false; try { Deno.osRelease(); |