Skip to content

Commit 54168b7

Browse files
cjihrigtargos
authored andcommitted
test_runner: add test location for FileTests
This commit adds the previously missing test location for FileTest tests. Fixes: #49926 Fixes: #49927 PR-URL: #49999 Reviewed-By: Moshe Atlow <moshe@atlow.co.il> Reviewed-By: Chemi Atlow <chemi@atlow.co.il> Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
1 parent 1d9c371 commit 54168b7

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

lib/internal/test_runner/runner.js

+11
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,17 @@ class FileTest extends Test {
185185
#rawBufferSize = 0;
186186
#reportedChildren = 0;
187187
failedSubtests = false;
188+
189+
constructor(options) {
190+
super(options);
191+
this.loc ??= {
192+
__proto__: null,
193+
line: 1,
194+
column: 1,
195+
file: resolve(this.name),
196+
};
197+
}
198+
188199
#skipReporting() {
189200
return this.#reportedChildren > 0 && (!this.error || this.error.failureType === kSubtestsFailed);
190201
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
const common = require('../common');
3+
const fixtures = require('../common/fixtures');
4+
const { strictEqual } = require('node:assert');
5+
const { relative } = require('node:path');
6+
const { run } = require('node:test');
7+
const fixture = fixtures.path('test-runner', 'never_ending_sync.js');
8+
const relativePath = relative(process.cwd(), fixture);
9+
const stream = run({
10+
files: [relativePath],
11+
timeout: common.platformTimeout(100),
12+
});
13+
14+
stream.on('test:fail', common.mustCall((result) => {
15+
strictEqual(result.name, relativePath);
16+
strictEqual(result.details.error.failureType, 'testTimeoutFailure');
17+
strictEqual(result.line, 1);
18+
strictEqual(result.column, 1);
19+
strictEqual(result.file, fixture);
20+
}));

0 commit comments

Comments
 (0)