Skip to content

Commit

Permalink
test_runner: add test location for FileTests
Browse files Browse the repository at this point in the history
This commit adds the previously missing test location for
FileTest tests.

Fixes: nodejs/node#49926
Fixes: nodejs/node#49927
PR-URL: nodejs/node#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>
  • Loading branch information
sercher committed Apr 25, 2024
1 parent f0691a1 commit 00dec6c
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions graal-nodejs/lib/internal/test_runner/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,17 @@ class FileTest extends Test {
#rawBufferSize = 0;
#reportedChildren = 0;
failedSubtests = false;

constructor(options) {
super(options);
this.loc ??= {
__proto__: null,
line: 1,
column: 1,
file: resolve(this.name),
};
}

#skipReporting() {
return this.#reportedChildren > 0 && (!this.error || this.error.failureType === kSubtestsFailed);
}
Expand Down
20 changes: 20 additions & 0 deletions graal-nodejs/test/parallel/test-runner-filetest-location.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const { strictEqual } = require('node:assert');
const { relative } = require('node:path');
const { run } = require('node:test');
const fixture = fixtures.path('test-runner', 'never_ending_sync.js');
const relativePath = relative(process.cwd(), fixture);
const stream = run({
files: [relativePath],
timeout: common.platformTimeout(100),
});

stream.on('test:fail', common.mustCall((result) => {
strictEqual(result.name, relativePath);
strictEqual(result.details.error.failureType, 'testTimeoutFailure');
strictEqual(result.line, 1);
strictEqual(result.column, 1);
strictEqual(result.file, fixture);
}));

0 comments on commit 00dec6c

Please sign in to comment.