Skip to content

Commit 1e8287f

Browse files
committed
fixup! test_runner: throw on invalid source maps
1 parent 51f959c commit 1e8287f

File tree

4 files changed

+5
-5
lines changed

4 files changed

+5
-5
lines changed

doc/api/errors.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2577,7 +2577,7 @@ A call was made and the UDP subsystem was not running.
25772577

25782578
### `ERR_SOURCE_MAP_CANNOT_PARSE`
25792579

2580-
The source map could not be parsed because it is not valid JSON.
2580+
The source map could not be parsed because it does not exist, or is not valid JSON.
25812581

25822582
<a id="ERR_SOURCE_MAP_MISSING_SOURCE"></a>
25832583

lib/internal/errors.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ E('ERR_SOCKET_CONNECTION_TIMEOUT',
17041704
E('ERR_SOCKET_DGRAM_IS_CONNECTED', 'Already connected', Error);
17051705
E('ERR_SOCKET_DGRAM_NOT_CONNECTED', 'Not connected', Error);
17061706
E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running', Error);
1707-
E('ERR_SOURCE_MAP_CANNOT_PARSE', `The source map for '%s' does not exist or is not valid JSON.`, Error);
1707+
E('ERR_SOURCE_MAP_CORRUPT', `The source map for '%s' does not exist or is corrupt.`, Error);
17081708
E('ERR_SOURCE_MAP_MISSING_SOURCE', `Cannot find '%s' imported from the source map for '%s'`, Error);
17091709
E('ERR_SRI_PARSE',
17101710
'Subresource Integrity string %j had an unexpected %j at position %d',

lib/internal/test_runner/coverage.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ const { fileURLToPath } = require('internal/url');
3232
const { kMappings, SourceMap } = require('internal/source_map/source_map');
3333
const {
3434
codes: {
35-
ERR_SOURCE_MAP_CANNOT_PARSE,
35+
ERR_SOURCE_MAP_CORRUPT,
3636
ERR_SOURCE_MAP_MISSING_SOURCE,
3737
},
3838
} = require('internal/errors');
@@ -354,7 +354,7 @@ class TestCoverage {
354354
continue;
355355
}
356356
const { data, lineLengths } = sourceMapCache[url];
357-
if (!data) throw new ERR_SOURCE_MAP_CANNOT_PARSE(url);
357+
if (!data) throw new ERR_SOURCE_MAP_CORRUPT(url);
358358
let offset = 0;
359359
const executedLines = ArrayPrototypeMap(lineLengths, (length, i) => {
360360
const coverageLine = new CoverageLine(i + 1, offset, null, length + 1);

test/parallel/test-runner-coverage-source-map.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ describe('Coverage with source maps', async () => {
8888
await it(`should throw when a source map ${message}`, async (t) => {
8989
const spawned = await common.spawnPromisified(process.execPath, [...flags, file]);
9090

91-
const error = `The source map for '${pathToFileURL(file)}' does not exist or is not valid JSON`;
91+
const error = `The source map for '${pathToFileURL(file)}' does not exist or is corrupt`;
9292
t.assert.strictEqual(spawned.stderr, '');
9393
t.assert.ok(spawned.stdout.includes(error));
9494
t.assert.strictEqual(spawned.code, 1);

0 commit comments

Comments
 (0)