Skip to content

Commit f236dcb

Browse files
TrottMylesBorins
authored andcommitted
test: move WPT to its own testing module
This is first in a hoped-for series of moves away from a monolithic common.js that is loaded for every test and towards a more modular approach. (In the end, common.js will hopefully contain checks for variables leaking into the global space and perhaps some of the more ubiquitous functions like common.mustCall().) Move the WPT testing code to its own module. PR-URL: #12736 Backport-PR-URL: #13775 Reviewed-By: Gibson Fahnestock <[email protected]> Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Richard Lau <[email protected]>
1 parent b46cf35 commit f236dcb

File tree

7 files changed

+326
-249
lines changed

7 files changed

+326
-249
lines changed

benchmark/http/http_server_for_chunky_client.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ var http = require('http');
55
var fs = require('fs');
66
var spawn = require('child_process').spawn;
77
require('../common.js');
8-
var test = require('../../test/common.js');
9-
var pep = path.dirname(process.argv[1]) + '/_chunky_http_client.js';
8+
var test = require('../../test/common');
9+
var pep = `${path.dirname(process.argv[1])}/_chunky_http_client.js`;
1010
var PIPE = test.PIPE;
1111

1212
try {

test/README.md

+9-243
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,13 @@
11
# Node.js Core Tests
22

3-
This folder contains code and data used to test the Node.js implementation.
3+
This directory contains code and data used to test the Node.js implementation.
44

55
For a detailed guide on how to write tests in this
66
directory, see [the guide on writing tests](../doc/guides/writing-tests.md).
77

88
On how to run tests in this direcotry, see
99
[the contributing guide](../CONTRIBUTING.md#step-5-test).
1010

11-
## Table of Contents
12-
13-
* [Test directories](#test-directories)
14-
* [Common module API](#common-module-api)
15-
1611
## Test Directories
1712

1813
<table>
@@ -48,6 +43,14 @@ On how to run tests in this direcotry, see
4843
C++ test that is run as part of the build process.
4944
</td>
5045
</tr>
46+
<tr>
47+
<td>common</td>
48+
<td></td>
49+
<td>
50+
Common modules shared among many tests.
51+
<a href="./common/README.md">[Documentation]</a>
52+
</td>
53+
</tr>
5154
<tr>
5255
<td>debugger</td>
5356
<td>No</td>
@@ -153,240 +156,3 @@ On how to run tests in this direcotry, see
153156
</tr>
154157
</tbody>
155158
</table>
156-
157-
## Common module API
158-
159-
The common.js module is used by tests for consistency across repeated
160-
tasks. It has a number of helpful functions and properties to help with
161-
writing tests.
162-
163-
### allowGlobals(...whitelist)
164-
* `whitelist` [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) Array of Globals
165-
* return [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
166-
167-
Takes `whitelist` and concats that with predefined `knownGlobals`.
168-
169-
### arrayStream
170-
A stream to push an array into a REPL
171-
172-
### busyLoop(time)
173-
* `time` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
174-
175-
Blocks for `time` amount of time.
176-
177-
### crashOnUnhandledRejection()
178-
179-
Installs a `process.on('unhandledRejection')` handler that crashes the process
180-
after a tick. This is useful for tests that use Promises and need to make sure
181-
no unexpected rejections occur, because currently they result in silent
182-
failures.
183-
184-
### ddCommand(filename, kilobytes)
185-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
186-
187-
Platform normalizes the `dd` command
188-
189-
### enoughTestMem
190-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
191-
192-
Check if there is more than 1gb of total memory.
193-
194-
### expectWarning(name, expected)
195-
* `name` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
196-
* `expected` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type) | [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
197-
198-
Tests whether `name` and `expected` are part of a raised warning.
199-
200-
### hasCrypto
201-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
202-
203-
Checks for 'openssl'.
204-
205-
### hasFipsCrypto
206-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
207-
208-
Checks `hasCrypto` and `crypto` with fips.
209-
210-
### hasIPv6
211-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
212-
213-
Checks whether `IPv6` is supported on this platform.
214-
215-
### hasMultiLocalhost
216-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
217-
218-
Checks if there are multiple localhosts available.
219-
220-
### fail(msg)
221-
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
222-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
223-
224-
Throws an `AssertionError` with `msg`
225-
226-
### fileExists(pathname)
227-
* pathname [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
228-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
229-
230-
Checks if `pathname` exists
231-
232-
### fixturesDir
233-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
234-
235-
Path to the 'fixtures' directory.
236-
237-
### globalCheck
238-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
239-
240-
Turn this off if the test should not check for global leaks.
241-
242-
### inFreeBSDJail
243-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
244-
245-
Checks whether free BSD Jail is true or false.
246-
247-
### isAix
248-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
249-
250-
Platform check for Advanced Interactive eXecutive (AIX).
251-
252-
### isAlive(pid)
253-
* `pid` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
254-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
255-
256-
Attempts to 'kill' `pid`
257-
258-
### isFreeBSD
259-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
260-
261-
Platform check for Free BSD.
262-
263-
### isLinux
264-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
265-
266-
Platform check for Linux.
267-
268-
### isLinuxPPCBE
269-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
270-
271-
Platform check for Linux on PowerPC.
272-
273-
### isOSX
274-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
275-
276-
Platform check for macOS.
277-
278-
### isSunOS
279-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
280-
281-
Platform check for SunOS.
282-
283-
### isWindows
284-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
285-
286-
Platform check for Windows.
287-
288-
### isWOW64
289-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
290-
291-
Platform check for Windows 32-bit on Windows 64-bit.
292-
293-
### leakedGlobals
294-
* return [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
295-
296-
Checks whether any globals are not on the `knownGlobals` list.
297-
298-
### localhostIPv4
299-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
300-
301-
Gets IP of localhost
302-
303-
### localIPv6Hosts
304-
* return [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
305-
306-
Array of IPV6 hosts.
307-
308-
### mustCall(fn[, expected])
309-
* fn [&lt;Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
310-
* expected [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1
311-
* return [&lt;Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
312-
313-
Returns a function that calls `fn`. If the returned function has not been called
314-
exactly `expected` number of times when the test is complete, then the test will
315-
fail.
316-
317-
### nodeProcessAborted(exitCode, signal)
318-
* `exitCode` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
319-
* `signal` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
320-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
321-
322-
Returns `true` if the exit code `exitCode` and/or signal name `signal` represent the exit code and/or signal name of a node process that aborted, `false` otherwise.
323-
324-
### opensslCli
325-
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
326-
327-
Checks whether 'opensslCli' is supported.
328-
329-
### platformTimeout(ms)
330-
* `ms` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
331-
* return [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
332-
333-
Platform normalizes timeout.
334-
335-
### PIPE
336-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
337-
338-
Path to the test sock.
339-
340-
### PORT
341-
* return [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = `12346`
342-
343-
Port tests are running on.
344-
345-
### refreshTmpDir
346-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
347-
348-
Deletes the 'tmp' dir and recreates it
349-
350-
### rootDir
351-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
352-
353-
Path to the 'root' directory. either `/` or `c:\\` (windows)
354-
355-
### skip(msg)
356-
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
357-
358-
Logs '1..0 # Skipped: ' + `msg`
359-
360-
### spawnCat(options)
361-
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
362-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
363-
364-
Platform normalizes the `cat` command.
365-
366-
### spawnPwd(options)
367-
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
368-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
369-
370-
Platform normalizes the `pwd` command.
371-
372-
### spawnSyncCat(options)
373-
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
374-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
375-
376-
Synchronous version of `spawnCat`.
377-
378-
### spawnSyncPwd(options)
379-
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
380-
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
381-
382-
Synchronous version of `spawnPwd`.
383-
384-
### tmpDir
385-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
386-
387-
The realpath of the 'tmp' directory.
388-
389-
### tmpDirName
390-
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
391-
392-
Name of the temp directory used by tests.

0 commit comments

Comments
 (0)