summaryrefslogtreecommitdiff
path: root/cli/js/tests/resources_test.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2020-03-13 15:57:32 +0100
committerGitHub <noreply@github.com>2020-03-13 15:57:32 +0100
commitaab1acaed163f91aa5e89b079c5312336abb2088 (patch)
treee102ee075fc37ae2a264e4c95c6f85a62ccb661e /cli/js/tests/resources_test.ts
parente435c2be158ce8657dbff0664b6db222fe4e586c (diff)
refactor: unit test runner communicates using TCP socket (#4336)
Rewrites "cli/js/unit_test_runner.ts" to communicate with spawned subprocesses using TCP socket. * Rewrite "Deno.runTests()" by factoring out testing logic to private "TestApi" class. "TestApi" implements "AsyncIterator" that yields "TestEvent"s, which is an interface for different types of event occuring during running tests. * Add "reporter" argument to "Deno.runTests()" to allow users to provide custom reporting mechanism for tests. It's represented by "TestReporter" interface, that implements hook functions for each type of "TestEvent". If "reporter" is not provided then default console reporting is used (via "ConsoleReporter"). * Change how "unit_test_runner" communicates with spawned suprocesses. Instead of parsing text data from child's stdout, a TCP socket is created and used for communication. "unit_test_runner" can run in either "master" or "worker" mode. Former is responsible for test discovery and establishing needed permission combinations; while latter (that is spawned by "master") executes tests that match given permission set. * Use "SocketReporter" that implements "TestReporter" interface to send output of tests to "master" process. Data is sent as stringified JSON and then parsed by "master" as structured data. "master" applies it's own reporting logic to output tests to console (by reusing default "ConsoleReporter").
Diffstat (limited to 'cli/js/tests/resources_test.ts')
-rw-r--r--cli/js/tests/resources_test.ts8
1 files changed, 4 insertions, 4 deletions
diff --git a/cli/js/tests/resources_test.ts b/cli/js/tests/resources_test.ts
index 84b713a6d..680fac8b7 100644
--- a/cli/js/tests/resources_test.ts
+++ b/cli/js/tests/resources_test.ts
@@ -1,5 +1,5 @@
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
-import { unitTest, assertEquals } from "./test_util.ts";
+import { unitTest, assertEquals, assert } from "./test_util.ts";
unitTest(function resourcesStdio(): void {
const res = Deno.resources();
@@ -21,10 +21,10 @@ unitTest({ perms: { net: true } }, async function resourcesNet(): Promise<
Object.values(res).filter((r): boolean => r === "tcpListener").length,
1
);
- assertEquals(
- Object.values(res).filter((r): boolean => r === "tcpStream").length,
- 2
+ const tcpStreams = Object.values(res).filter(
+ (r): boolean => r === "tcpStream"
);
+ assert(tcpStreams.length >= 2);
listenerConn.close();
dialerConn.close();