diff options
| author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2020-03-04 17:31:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-04 17:31:14 +0100 |
| commit | 8d96dffa410a149d0fff6115bd97f41fc1fe7459 (patch) | |
| tree | b00dc7a78e5030b68741de8bf9dde83b9fa07364 /cli/js/signal_test.ts | |
| parent | 30682cf74fa039d3493c74101dca2dbb3a8d49b6 (diff) | |
refactor: rewrite testPerm into unitTest (#4231)
Rewrite "testPerm" helper function used for testing of internal
runtime code. It's been renamed to "unitTest" and provides API that
is extensible in the future by accepting optional "UnitTestOptions"
argument. "test" helper was also removed and replaced by
overloaded version of "unitTest" that takes only function argument.
"UnitTestOptions" currently supports "perms" and "skip"
options, where former works exactly as first argument to "testPerm"
did, while the latter allows to conditionally skip tests.
Diffstat (limited to 'cli/js/signal_test.ts')
| -rw-r--r-- | cli/js/signal_test.ts | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/cli/js/signal_test.ts b/cli/js/signal_test.ts index a0588b987..e1d00c669 100644 --- a/cli/js/signal_test.ts +++ b/cli/js/signal_test.ts @@ -1,7 +1,6 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. import { - test, - testPerm, + unitTest, assert, assertEquals, assertThrows, @@ -14,8 +13,9 @@ function defer(n: number): Promise<void> { }); } -if (Deno.build.os === "win") { - test(async function signalsNotImplemented(): Promise<void> { +unitTest( + { skip: Deno.build.os !== "win" }, + async function signalsNotImplemented(): Promise<void> { assertThrows( () => { Deno.signal(1); @@ -100,9 +100,12 @@ if (Deno.build.os === "win") { Error, "not implemented" ); - }); -} else { - testPerm({ run: true }, async function signalStreamTest(): Promise<void> { + } +); + +unitTest( + { skip: Deno.build.os === "win", perms: { run: true, net: true } }, + async function signalStreamTest(): Promise<void> { const resolvable = createResolvable(); // This prevents the program from exiting. const t = setInterval(() => {}, 1000); @@ -131,9 +134,12 @@ if (Deno.build.os === "win") { // for more explanation see `FIXME` in `cli/js/timers.ts::setGlobalTimeout` await defer(20); await resolvable; - }); + } +); - testPerm({ run: true }, async function signalPromiseTest(): Promise<void> { +unitTest( + { skip: Deno.build.os === "win", perms: { run: true } }, + async function signalPromiseTest(): Promise<void> { const resolvable = createResolvable(); // This prevents the program from exiting. const t = setInterval(() => {}, 1000); @@ -151,9 +157,12 @@ if (Deno.build.os === "win") { // for more explanation see `FIXME` in `cli/js/timers.ts::setGlobalTimeout` await defer(20); await resolvable; - }); + } +); - testPerm({ run: true }, async function signalShorthandsTest(): Promise<void> { +unitTest( + { skip: Deno.build.os === "win", perms: { run: true } }, + async function signalShorthandsTest(): Promise<void> { let s: Deno.SignalStream; s = Deno.signals.alarm(); // for SIGALRM assert(s instanceof Deno.SignalStream); @@ -188,5 +197,5 @@ if (Deno.build.os === "win") { s = Deno.signals.windowChange(); // for SIGWINCH assert(s instanceof Deno.SignalStream); s.dispose(); - }); -} + } +); |
