GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — test: improve lcov reporter snapshot diagnostics · nodejs/node@ff9122c

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • test
    • common
      • assertSnapshot.js
    • fixtures/test-runner/output
      • lcov_reporter.js
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎test/common/assertSnapshot.js‎

Copy file name to clipboardExpand all lines: test/common/assertSnapshot.js
+18-1Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,30 @@ function replaceJunitDuration(str) {
235235
// This transform picks only the first line and then the lines from the test
236236
// file.
237237
function pickTestFileFromLcov(str) {
238+
const expectedFile = 'output.js';
238239
const lines = str.split(/\n/);
239240
const firstLineOfTestFile = lines.findIndex(
240-
(line) => line.startsWith('SF:') && line.trim().endsWith('output.js'),
241+
(line) => line.startsWith('SF:') && line.trim().endsWith(expectedFile),
241242
);
243+
244+
if (firstLineOfTestFile === -1) {
245+
assert.fail(
246+
`Could not find LCOV source record ending with ${expectedFile} ` +
247+
`in LCOV output:\n${str || '<empty>'}`,
248+
);
249+
}
250+
242251
const lastLineOfTestFile = lines.findIndex(
243252
(line, index) => index > firstLineOfTestFile && line.trim() === 'end_of_record',
244253
);
254+
255+
if (lastLineOfTestFile === -1) {
256+
assert.fail(
257+
`Could not find end_of_record for LCOV source record ending with ${expectedFile} ` +
258+
`in LCOV output:\n${str}`,
259+
);
260+
}
261+
245262
return (
246263
lines[0] + '\n' + lines.slice(firstLineOfTestFile, lastLineOfTestFile + 1).join('\n') + '\n'
247264
);
Collapse file

‎test/fixtures/test-runner/output/lcov_reporter.js‎

Copy file name to clipboardExpand all lines: test/fixtures/test-runner/output/lcov_reporter.js
+14-1Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ require('../../../common');
33
const fixtures = require('../../../common/fixtures');
44
const spawn = require('node:child_process').spawn;
55

6-
spawn(
6+
const child = spawn(
77
process.execPath,
88
[
99
'--no-warnings',
@@ -14,3 +14,16 @@ spawn(
1414
],
1515
{ stdio: 'inherit' },
1616
);
17+
18+
child.on('error', (err) => {
19+
throw err;
20+
});
21+
22+
child.on('exit', (code, signal) => {
23+
if (signal) {
24+
process.kill(process.pid, signal);
25+
return;
26+
}
27+
28+
process.exitCode = code ?? 1;
29+
});

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.