Skip to content

Commit 328642b

Browse files
cjihrignodejs-github-bot
authored andcommitted
test_runner: use paths for test locations
This commit transforms test locations to paths when V8 provides file URLs (which seems to be for ESM files). Fixes: #51610 PR-URL: #52010 Fixes: #51392 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com> Reviewed-By: Chengzhong Wu <legendecas@gmail.com> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
1 parent 6d625fe commit 328642b

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/internal/test_runner/test.js

+6
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const {
1414
PromisePrototypeThen,
1515
PromiseResolve,
1616
SafePromisePrototypeFinally,
17+
StringPrototypeStartsWith,
1718
StringPrototypeTrim,
1819
ReflectApply,
1920
RegExpPrototypeExec,
@@ -58,6 +59,7 @@ const {
5859
} = require('internal/validators');
5960
const { setTimeout } = require('timers');
6061
const { TIMEOUT_MAX } = require('internal/timers');
62+
const { fileURLToPath } = require('internal/url');
6163
const { availableParallelism } = require('os');
6264
const { bigint: hrtime } = process.hrtime;
6365
const kCallbackAndPromisePresent = 'callbackAndPromisePresent';
@@ -383,6 +385,10 @@ class Test extends AsyncResource {
383385
this.loc.file = entry.originalSource;
384386
}
385387
}
388+
389+
if (StringPrototypeStartsWith(this.loc.file, 'file://')) {
390+
this.loc.file = fileURLToPath(this.loc.file);
391+
}
386392
}
387393
}
388394

test/fixtures/test-runner/output/source_mapped_locations.snapshot

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ TAP version 13
33
not ok 1 - fails
44
---
55
duration_ms: *
6-
location: 'file:///test/fixtures/test-runner/output/source_mapped_locations.ts:5:1'
6+
location: '/test/fixtures/test-runner/output/source_mapped_locations.ts:5:1'
77
failureType: 'testCodeFailure'
88
error: |-
99
Expected values to be strictly equal:

0 commit comments

Comments
 (0)