Skip to content

Commit c36c8dc

Browse files
paulgrockFishrock123
authored andcommitted
doc: add documentation for test common module
Alphabetized list of methods and properties for the common.js module. Add table of contents to the top of the readme. PR-URL: #8840 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Santiago Gimeno <santiago.gimeno@gmail.com> Reviewed-By: Franziska Hinkelmann <franziska.hinkelmann@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
1 parent a604a82 commit c36c8dc

File tree

1 file changed

+249
-1
lines changed

1 file changed

+249
-1
lines changed

test/README.md

Lines changed: 249 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
# Tests
1+
# Table of Contents
2+
* [Test directories](#test-directories)
3+
* [Common module API](#common-module-api)
4+
5+
## Test Directories
26

37
### abort
48

@@ -126,3 +130,247 @@ and `setInterval`).
126130
| Runs on CI |
127131
|:----------:|
128132
| No |
133+
134+
135+
## Common module API
136+
137+
The common.js module is used by tests for consistency across repeated
138+
tasks. It has a number of helpful functions and properties to help with
139+
writing tests.
140+
141+
### allowGlobals(...whitelist)
142+
* `whitelist` [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array) Array of Globals
143+
* return [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
144+
145+
Takes `whitelist` and concats that with predefined `knownGlobals`.
146+
147+
### arrayStream
148+
A stream to push an array into a REPL
149+
150+
### busyLoop(time)
151+
* `time` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
152+
153+
Blocks for `time` amount of time.
154+
155+
### ddCommand(filename, kilobytes)
156+
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
157+
158+
Platform normalizes the `dd` command
159+
160+
### enoughTestMem
161+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
162+
163+
Check if there is more than 1gb of total memory.
164+
165+
### expectWarning(name, expected)
166+
* `name` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
167+
* `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)
168+
169+
Tests whether `name` and `expected` are part of a raised warning.
170+
171+
### hasCrypto
172+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
173+
174+
Checks for 'openssl'.
175+
176+
### hasFipsCrypto
177+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
178+
179+
Checks `hasCrypto` and `crypto` with fips.
180+
181+
### hasIPv6
182+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
183+
184+
Checks whether `IPv6` is supported on this platform.
185+
186+
### hasMultiLocalhost
187+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
188+
189+
Checks if there are multiple localhosts available.
190+
191+
### fail(msg)
192+
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
193+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
194+
195+
Throws an `AssertionError` with `msg`
196+
197+
### faketimeCli
198+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
199+
200+
Return the path to the fake.
201+
202+
### fileExists(pathname)
203+
* pathname [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
204+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
205+
206+
Checks if `pathname` exists
207+
208+
### fixturesDir
209+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
210+
211+
Path to the 'fixtures' directory.
212+
213+
### globalCheck
214+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
215+
216+
Turn this off if the test should not check for global leaks.
217+
218+
### inFreeBSDJail
219+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
220+
221+
Checks whether free BSD Jail is true or false.
222+
223+
### isAix
224+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
225+
226+
Platform check for Advanced Interactive eXecutive (AIX).
227+
228+
### isAlive(pid)
229+
* `pid` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
230+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
231+
232+
Attempts to 'kill' `pid`
233+
234+
### isFreeBSD
235+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
236+
237+
Platform check for Free BSD.
238+
239+
### isLinux
240+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
241+
242+
Platform check for Linux.
243+
244+
### isLinuxPPCBE
245+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
246+
247+
Platform check for Linux on PowerPC.
248+
249+
### isOSX
250+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
251+
252+
Platform check for OS X.
253+
254+
### isSunOS
255+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
256+
257+
Platform check for SunOS.
258+
259+
### isWindows
260+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
261+
262+
Platform check for Windows.
263+
264+
### isWOW64
265+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
266+
267+
Platform check for Windows 32-bit on Windows 64-bit.
268+
269+
### leakedGlobals
270+
* return [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
271+
272+
Checks whether any globals are not on the `knownGlobals` list.
273+
274+
### libDir
275+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
276+
277+
Path to the 'lib' directory.
278+
279+
### localhostIPv4
280+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
281+
282+
Gets IP of localhost
283+
284+
### localIPv6Hosts
285+
* return [&lt;Array>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)
286+
287+
Array of IPV6 hosts.
288+
289+
### mustCall(fn[, expected])
290+
* fn [&lt;Function>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function)
291+
* expected [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = 1
292+
293+
Number of times `fn` should be called.
294+
295+
### nodeProcessAborted(exitCode, signal)
296+
* `exitCode` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
297+
* `signal` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
298+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
299+
300+
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.
301+
302+
### opensslCli
303+
* return [&lt;Boolean>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Boolean_type)
304+
305+
Checks whether 'opensslCli' is supported.
306+
307+
### platformTimeout(ms)
308+
* `ms` [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
309+
* return [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type)
310+
311+
Platform normalizes timeout.
312+
313+
### PIPE
314+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
315+
316+
Path to the test sock.
317+
318+
### PORT
319+
* return [&lt;Number>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Number_type) default = `12346`
320+
321+
Port tests are running on.
322+
323+
### refreshTmpDir
324+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
325+
326+
Deletes the 'tmp' dir and recreates it
327+
328+
### rootDir
329+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
330+
331+
Path to the 'root' directory. either `/` or `c:\\` (windows)
332+
333+
### skip(msg)
334+
* `msg` [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
335+
336+
Logs '1..0 # Skipped: ' + `msg`
337+
338+
### spawnCat(options)
339+
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
340+
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
341+
342+
Platform normalizes the `cat` command.
343+
344+
### spawnPwd(options)
345+
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
346+
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
347+
348+
Platform normalizes the `pwd` command.
349+
350+
### spawnSyncCat(options)
351+
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
352+
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
353+
354+
Synchronous version of `spawnCat`.
355+
356+
### spawnSyncPwd(options)
357+
* `options` [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
358+
* return [&lt;Object>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)
359+
360+
Synchronous version of `spawnPwd`.
361+
362+
### testDir
363+
364+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
365+
366+
Path to the 'test' directory.
367+
368+
### tmpDir
369+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
370+
371+
Path to the 'tmp' directory.
372+
373+
### tmpDirName
374+
* return [&lt;String>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#String_type)
375+
376+
Name of the temp directory used by tests.

0 commit comments

Comments
 (0)