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: https://github.com/nodejs/node/issues/51610
PR-URL: https://github.com/nodejs/node/pull/52010
Fixes: https://github.com/nodejs/node/issues/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>
This commit is contained in:
cjihrig authored and Node.js GitHub Bot committed 2024-03-11 08:56:16 +00:00
1 parent 6d625fe616
commit 328642bbb9
2 files changed
+7 -1

No files matched your search

+6
View File
@@ -14,6 +14,7 @@ const {
PromisePrototypeThen,
PromiseResolve,
SafePromisePrototypeFinally,
StringPrototypeStartsWith,
StringPrototypeTrim,
ReflectApply,
RegExpPrototypeExec,
@@ -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';
@@ -383,6 +385,10 @@ class Test extends AsyncResource {
this.loc.file = entry.originalSource;
}
}
if (StringPrototypeStartsWith(this.loc.file, 'file://')) {
this.loc.file = fileURLToPath(this.loc.file);
}
}
}
@@ -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: