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: nodejs#51610
PR-URL: nodejs#52010
Fixes: nodejs#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 jcbhmr committed May 15, 2024
1 parent 8b5916d commit b490049
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 @@ -14,6 +14,7 @@ const {
PromisePrototypeThen,
PromiseResolve,
SafePromisePrototypeFinally,
StringPrototypeStartsWith,
StringPrototypeTrim,
ReflectApply,
RegExpPrototypeExec,
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 @@ -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);
}
}
}

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 b490049

Please sign in to comment.