Skip to content

Commit

Permalink
fixup! test_runner: throw on invalid source maps
Browse files Browse the repository at this point in the history
  • Loading branch information
RedYetiDev committed Sep 30, 2024
1 parent 51f959c commit 1e8287f
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion doc/api/errors.md
Original file line number Diff line number Diff line change
Expand Up @@ -2577,7 +2577,7 @@ A call was made and the UDP subsystem was not running.

### `ERR_SOURCE_MAP_CANNOT_PARSE`

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

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

Expand Down
2 changes: 1 addition & 1 deletion lib/internal/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -1704,7 +1704,7 @@ E('ERR_SOCKET_CONNECTION_TIMEOUT',
E('ERR_SOCKET_DGRAM_IS_CONNECTED', 'Already connected', Error);
E('ERR_SOCKET_DGRAM_NOT_CONNECTED', 'Not connected', Error);
E('ERR_SOCKET_DGRAM_NOT_RUNNING', 'Not running', Error);
E('ERR_SOURCE_MAP_CANNOT_PARSE', `The source map for '%s' does not exist or is not valid JSON.`, Error);
E('ERR_SOURCE_MAP_CORRUPT', `The source map for '%s' does not exist or is corrupt.`, Error);
E('ERR_SOURCE_MAP_MISSING_SOURCE', `Cannot find '%s' imported from the source map for '%s'`, Error);
E('ERR_SRI_PARSE',
'Subresource Integrity string %j had an unexpected %j at position %d',
Expand Down
4 changes: 2 additions & 2 deletions lib/internal/test_runner/coverage.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const { fileURLToPath } = require('internal/url');
const { kMappings, SourceMap } = require('internal/source_map/source_map');
const {
codes: {
ERR_SOURCE_MAP_CANNOT_PARSE,
ERR_SOURCE_MAP_CORRUPT,
ERR_SOURCE_MAP_MISSING_SOURCE,
},
} = require('internal/errors');
Expand Down Expand Up @@ -354,7 +354,7 @@ class TestCoverage {
continue;
}
const { data, lineLengths } = sourceMapCache[url];
if (!data) throw new ERR_SOURCE_MAP_CANNOT_PARSE(url);
if (!data) throw new ERR_SOURCE_MAP_CORRUPT(url);
let offset = 0;
const executedLines = ArrayPrototypeMap(lineLengths, (length, i) => {
const coverageLine = new CoverageLine(i + 1, offset, null, length + 1);
Expand Down
2 changes: 1 addition & 1 deletion test/parallel/test-runner-coverage-source-map.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ describe('Coverage with source maps', async () => {
await it(`should throw when a source map ${message}`, async (t) => {
const spawned = await common.spawnPromisified(process.execPath, [...flags, file]);

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

0 comments on commit 1e8287f

Please sign in to comment.