From 2c25ca70ca07cf1ddf388187eb046749a677f82b Mon Sep 17 00:00:00 2001 From: Sergey Chernyshev Date: Thu, 25 Apr 2024 04:22:16 +0200 Subject: [PATCH] test_runner: add test location for FileTests This commit adds the previously missing test location for FileTest tests. Fixes: https://github.com/nodejs/node/issues/49926 Fixes: https://github.com/nodejs/node/issues/49927 PR-URL: https://github.com/nodejs/node/pull/49999 Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Luigi Pinca --- .../lib/internal/test_runner/runner.js | 11 ++++++++++ .../parallel/test-runner-filetest-location.js | 20 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 graal-nodejs/test/parallel/test-runner-filetest-location.js diff --git a/graal-nodejs/lib/internal/test_runner/runner.js b/graal-nodejs/lib/internal/test_runner/runner.js index b99ce3bac02..2dd9ea678e3 100644 --- a/graal-nodejs/lib/internal/test_runner/runner.js +++ b/graal-nodejs/lib/internal/test_runner/runner.js @@ -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); } diff --git a/graal-nodejs/test/parallel/test-runner-filetest-location.js b/graal-nodejs/test/parallel/test-runner-filetest-location.js new file mode 100644 index 00000000000..4e09bcd35ee --- /dev/null +++ b/graal-nodejs/test/parallel/test-runner-filetest-location.js @@ -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); +}));