@@ -6,6 +6,7 @@ This directory contains modules used to test the Node.js implementation.
66
77* [ ArrayStream module] ( #arraystream-module )
88* [ Benchmark module] ( #benchmark-module )
9+ * [ Child process module] ( #child-process-module )
910* [ Common module API] ( #common-module-api )
1011* [ Countdown module] ( #countdown-module )
1112* [ CPU Profiler module] ( #cpu-profiler-module )
@@ -35,6 +36,42 @@ The `benchmark` module is used by tests to run benchmarks.
3536* ` env ` [ \< Object>] [ <Object> ] Environment variables to be applied during the
3637 run.
3738
39+ ## Child Process Module
40+
41+ The ` child_process ` module is used by tests that launch child processes.
42+
43+ ### ` expectSyncExit(child, options) `
44+
45+ Checks if a _ synchronous_ child process runs in the way expected. If it does
46+ not, print the stdout and stderr output from the child process and additional
47+ information about it to the stderr of the current process before throwing
48+ and error. This helps gathering more information about test failures
49+ coming from child processes.
50+
51+ * ` child ` [ \< ChildProcess>] [ <ChildProcess> ] : a ` ChildProcess ` instance
52+ returned by ` child_process.spawnSync() ` .
53+ * ` options ` [ \< Object>] [ <Object> ]
54+ * ` status ` [ \< number>] [ <number> ] Expected ` child.status `
55+ * ` signal ` [ \< string>] [ <string> ] | ` null ` Expected ` child.signal `
56+ * ` stderr ` [ \< string>] [ <string> ] | [ \< RegExp>] [ <RegExp> ] |
57+ [ \< Function>] [ <Function> ] Optional. If it's a string, check that the output
58+ to the stderr of the child process is exactly the same as the string. If
59+ it's a regular expression, check that the stderr matches it. If it's a
60+ function, invoke it with the stderr output as a string and check
61+ that it returns true. The function can just throw errors (e.g. assertion
62+ errors) to provide more information if the check fails.
63+ * ` stdout ` [ \< string>] [ <string> ] | [ \< RegExp>] [ <RegExp> ] |
64+ [ \< Function>] [ <Function> ] Optional. Similar to ` stderr ` but for the stdout.
65+ * ` trim ` [ \< boolean>] [ <boolean> ] Optional. Whether this method should trim
66+ out the whitespace characters when checking ` stderr ` and ` stdout ` outputs.
67+ Defaults to ` false ` .
68+
69+ ### ` expectSyncExitWithoutError(child[, options]) `
70+
71+ Similar to ` expectSyncExit() ` with the ` status ` expected to be 0 and
72+ ` signal ` expected to be ` null ` . Any other optional options are passed
73+ into ` expectSyncExit() ` .
74+
3875## Common Module API
3976
4077The ` common ` module is used by tests for consistency across repeated
@@ -1111,6 +1148,7 @@ See [the WPT tests README][] for details.
11111148[ <ArrayBufferView> ] : https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView
11121149[ <Buffer> ] : https://nodejs.org/api/buffer.html#buffer_class_buffer
11131150[ <BufferSource> ] : https://developer.mozilla.org/en-US/docs/Web/API/BufferSource
1151+ [ <ChildProcess> ] : ../../doc/api/child_process.md#class-childprocess
11141152[ <Error> ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
11151153[ <Function> ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
11161154[ <Object> ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
0 commit comments