Skip to content

Commit be587e3

Browse files
cjihrigmarco-ippolito
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 Backport-PR-URL: #52872 Fixes: #51392 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Chemi Atlow <[email protected]> Reviewed-By: Moshe Atlow <[email protected]>
1 parent 743281a commit be587e3

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/internal/test_runner/test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const {
1515
PromisePrototypeThen,
1616
PromiseResolve,
1717
SafePromisePrototypeFinally,
18+
StringPrototypeStartsWith,
1819
ReflectApply,
1920
RegExpPrototypeExec,
2021
SafeMap,
@@ -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';
@@ -385,6 +387,10 @@ class Test extends AsyncResource {
385387
this.loc.file = entry.originalSource;
386388
}
387389
}
390+
391+
if (StringPrototypeStartsWith(this.loc.file, 'file://')) {
392+
this.loc.file = fileURLToPath(this.loc.file);
393+
}
388394
}
389395
}
390396

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

Lines changed: 1 addition & 1 deletion
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)