Skip to content

Commit 55a03fe

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 1cc6cbf commit 55a03fe

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
@@ -183,6 +183,17 @@ class FileTest extends Test {
183183
#rawBufferSize = 0;
184184
#reportedChildren = 0;
185185
failedSubtests = false;
186+
187+
constructor(options) {
188+
super(options);
189+
this.loc ??= {
190+
__proto__: null,
191+
line: 1,
192+
column: 1,
193+
file: resolve(this.name),
194+
};
195+
}
196+
186197
#skipReporting() {
187198
return this.#reportedChildren > 0 && (!this.error || this.error.failureType === kSubtestsFailed);
188199
}
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)