@@ -6,6 +6,7 @@ This directory contains modules used to test the Node.js implementation.
6
6
7
7
* [ ArrayStream module] ( #arraystream-module )
8
8
* [ Benchmark module] ( #benchmark-module )
9
+ * [ Child process module] ( #child-process-module )
9
10
* [ Common module API] ( #common-module-api )
10
11
* [ Countdown module] ( #countdown-module )
11
12
* [ CPU Profiler module] ( #cpu-profiler-module )
@@ -35,6 +36,42 @@ The `benchmark` module is used by tests to run benchmarks.
35
36
* ` env ` [ \< Object>] [ <Object> ] Environment variables to be applied during the
36
37
run.
37
38
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
+
38
75
## Common Module API
39
76
40
77
The ` common ` module is used by tests for consistency across repeated
@@ -1086,6 +1123,7 @@ See [the WPT tests README][] for details.
1086
1123
[ <ArrayBufferView> ] : https://developer.mozilla.org/en-US/docs/Web/API/ArrayBufferView
1087
1124
[ <Buffer> ] : https://nodejs.org/api/buffer.html#buffer_class_buffer
1088
1125
[ <BufferSource> ] : https://developer.mozilla.org/en-US/docs/Web/API/BufferSource
1126
+ [ <ChildProcess> ] : ../../doc/api/child_process.md#class-childprocess
1089
1127
[ <Error> ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error
1090
1128
[ <Function> ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function
1091
1129
[ <Object> ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
0 commit comments