Skip to content

Commit

Permalink
test_runner: use paths for test locations
Browse files Browse the repository at this point in the history
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 <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>
  • Loading branch information
cjihrig authored and marco-ippolito committed May 17, 2024
1 parent 743281a commit be587e3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions lib/internal/test_runner/test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const {
PromisePrototypeThen,
PromiseResolve,
SafePromisePrototypeFinally,
StringPrototypeStartsWith,
ReflectApply,
RegExpPrototypeExec,
SafeMap,
Expand Down Expand Up @@ -58,6 +59,7 @@ const {
} = require('internal/validators');
const { setTimeout } = require('timers');
const { TIMEOUT_MAX } = require('internal/timers');
const { fileURLToPath } = require('internal/url');
const { availableParallelism } = require('os');
const { bigint: hrtime } = process.hrtime;
const kCallbackAndPromisePresent = 'callbackAndPromisePresent';
Expand Down Expand Up @@ -385,6 +387,10 @@ class Test extends AsyncResource {
this.loc.file = entry.originalSource;
}
}

if (StringPrototypeStartsWith(this.loc.file, 'file://')) {
this.loc.file = fileURLToPath(this.loc.file);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ TAP version 13
not ok 1 - fails
---
duration_ms: *
location: 'file:///test/fixtures/test-runner/output/source_mapped_locations.ts:5:1'
location: '/test/fixtures/test-runner/output/source_mapped_locations.ts:5:1'
failureType: 'testCodeFailure'
error: |-
Expected values to be strictly equal:
Expand Down

0 comments on commit be587e3

Please sign in to comment.