GeezerVison is showing github.com — test_runner: give the root test a harness reference · nodejs/node@15503ff
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/test_runner/harness.js +6-1Lines changed: 6 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -136,7 +136,7 @@ function setup(root) { |
136 | 136 | createProcessEventHandler('unhandledRejection', root); |
137 | 137 | const coverage = configureCoverage(root, globalOptions); |
138 | 138 | const exitHandler = () => { |
139 | | - root.coverage = collectCoverage(root, coverage); |
| 139 | + root.harness.coverage = collectCoverage(root, coverage); |
140 | 140 | root.postRun(new ERR_TEST_FAILURE( |
141 | 141 | 'Promise resolution is still pending but the event loop has already resolved', |
142 | 142 | kCancelledByParent)); |
@@ -160,6 +160,11 @@ function setup(root) { |
160 | 160 | process.on('SIGTERM', terminationHandler); |
161 | 161 | } |
162 | 162 |
|
| 163 | + root.harness = { |
| 164 | + __proto__: null, |
| 165 | + bootstrapComplete: false, |
| 166 | + coverage: null, |
| 167 | + }; |
163 | 168 | root.startTime = hrtime(); |
164 | 169 |
|
165 | 170 | wasRootSetup.add(root); |
|
Collapse file
Copy file name to clipboardExpand all lines: lib/internal/test_runner/test.js +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -252,7 +252,7 @@ class Test extends AsyncResource { |
252 | 252 | this.#outerSignal?.addEventListener('abort', this.#abortHandler); |
253 | 253 |
|
254 | 254 | this.fn = fn; |
255 | | - this.coverage = null; // Configured on the root test by the test harness. |
| 255 | + this.harness = null; // Configured on the root test by the test harness. |
256 | 256 | this.mock = null; |
257 | 257 | this.name = name; |
258 | 258 | this.parent = parent; |
@@ -651,8 +651,8 @@ class Test extends AsyncResource { |
651 | 651 | this.reporter.diagnostic(this.nesting, kFilename, `todo ${counters.todo}`); |
652 | 652 | this.reporter.diagnostic(this.nesting, kFilename, `duration_ms ${this.#duration()}`); |
653 | 653 |
|
654 | | - if (this.coverage) { |
655 | | - this.reporter.coverage(this.nesting, kFilename, this.coverage); |
| 654 | + if (this.harness?.coverage) { |
| 655 | + this.reporter.coverage(this.nesting, kFilename, this.harness.coverage); |
656 | 656 | } |
657 | 657 |
|
658 | 658 | this.reporter.push(null); |
|