From ee452ad883c1c711839655a307b39e8eea5bf410 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 3 Mar 2020 18:22:53 +0100 Subject: add assertOps sanitizer in cli/js/ unit tests (#4209) * add "assertOps" test assertion which makes sure test case is not "leaking" ops - ie. after test finishes there are no pending async ops * apply "assertOps" to all tests in "cli/js/" * fix numerous tests leaking ops * document problem with edge case in "clearInterval" and "clearTimeout" implementation where they may leak async ops * move "cli/js/worker_test.ts" to "cli/tests/worker_test.ts" and run as integration test; workers leak ops because of missing "terminate" implementation --- cli/js/performance_test.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'cli/js/performance_test.ts') diff --git a/cli/js/performance_test.ts b/cli/js/performance_test.ts index 7e7f63d8c..227514954 100644 --- a/cli/js/performance_test.ts +++ b/cli/js/performance_test.ts @@ -1,10 +1,13 @@ // Copyright 2018-2020 the Deno authors. All rights reserved. MIT license. -import { testPerm, assert } from "./test_util.ts"; +import { testPerm, assert, createResolvable } from "./test_util.ts"; -testPerm({ hrtime: false }, function now(): void { +testPerm({ hrtime: false }, async function performanceNow(): Promise { + const resolvable = createResolvable(); const start = performance.now(); setTimeout((): void => { const end = performance.now(); assert(end - start >= 10); + resolvable.resolve(); }, 10); + await resolvable; }); -- cgit v1.2.3