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
  • Loading branch information
cjihrig committed Mar 8, 2024
1 parent 3e39c37 commit 0f4d2e0
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 @@ -379,6 +381,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 0f4d2e0

Please sign in to comment.