Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

invalid location in tap reported when there is something that keep the tests from exiting and run global timeout reached #49926

Closed
rluvaton opened this issue Sep 28, 2023 · 3 comments · Fixed by #49999
Labels
confirmed-bug Issues with confirmed bugs. test_runner Issues and PRs related to the test runner subsystem.

Comments

@rluvaton
Copy link
Member

Version

20.7.0

Platform

Darwin Razs-MacBook-Pro.local 23.0.0 Darwin Kernel Version 23.0.0: Fri Sep 15 14:41:43 PDT 2023; root:xnu-10002.1.13~1/RELEASE_ARM64_T6000 arm64

Subsystem

test_runner

What steps will reproduce the bug?

  1. clone https://github.com/rluvaton/tap-reporter-have-invalid-location-when-failed-on-before-hook-timeout
  2. run npm test

How often does it reproduce? Is there a required condition?

the test runner should stop the tests when there is something that keeps it running

What is the expected behavior? Why is that the expected behavior?

to not see undefined:undefined:undefined in the location

What do you see instead?

$ node ./run-tests.js

TAP version 13
# Subtest: should work
ok 1 - should work
  ---
  duration_ms: 1.079375
  ...
# Subtest: ./a.test.js
not ok 1 - ./a.test.js
  ---
  duration_ms: 5001.997458
  location: 'undefined:undefined:undefined' <--------------- invalid
  failureType: 'testTimeoutFailure'
  error: 'test timed out after 5000ms'
  code: 'ERR_TEST_FAILURE'
  stack: |-
    async Promise.allSettled (index 0)
  ...
1..2
# tests 2
# suites 0
# pass 1
# fail 0
# cancelled 1
# skipped 0
# todo 0
# duration_ms 5006.3885

Process finished with exit code 0

Additional information

No response

@rluvaton rluvaton added confirmed-bug Issues with confirmed bugs. test_runner Issues and PRs related to the test runner subsystem. labels Sep 28, 2023
@cjihrig
Copy link
Contributor

cjihrig commented Sep 29, 2023

I believe the fix for this issue and issue #49927 is:

diff --git a/lib/internal/test_runner/runner.js b/lib/internal/test_runner/runner.js
index 08f9b48dda..6e6faf5000 100644
--- a/lib/internal/test_runner/runner.js
+++ b/lib/internal/test_runner/runner.js
@@ -139,6 +139,17 @@ class FileTest extends Test {
   #rawBufferSize = 0;
   #reportedChildren = 0;
   failedSubtests = false;
+
+  constructor(options) {
+    super(options);
+    this.loc ??= {
+      __proto__: null,
+      line: 1,
+      column: 1,
+      file: this.name,
+    };
+  }
+
   #skipReporting() {
     return this.#reportedChildren > 0 && (!this.error || this.error.failureType === kSubtestsFailed);
   }

We should probably add path.resolve() around the location's file. In a semver major change, I think we should call path.resolve() on the input before calling super(options).

@MoLow
Copy link
Member

MoLow commented Oct 1, 2023

@razvanbh @cjihrig will one of you open a PR?

@cjihrig
Copy link
Contributor

cjihrig commented Oct 1, 2023

I didn't have time to write a test the other day when I posted that comment and hoped someone would have by now 😄. I can do it today.

cjihrig added a commit to cjihrig/node that referenced this issue Oct 1, 2023
This commit adds the previously missing test location for
FileTest tests.

Fixes: nodejs#49926
Fixes: nodejs#49927
cjihrig added a commit to cjihrig/node that referenced this issue Oct 1, 2023
This commit adds the previously missing test location for
FileTest tests.

Fixes: nodejs#49926
Fixes: nodejs#49927
nodejs-github-bot pushed a commit that referenced this issue Oct 3, 2023
This commit adds the previously missing test location for
FileTest tests.

Fixes: #49926
Fixes: #49927
PR-URL: #49999
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
alexfernandez pushed a commit to alexfernandez/node that referenced this issue Nov 1, 2023
This commit adds the previously missing test location for
FileTest tests.

Fixes: nodejs#49926
Fixes: nodejs#49927
PR-URL: nodejs#49999
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this issue Nov 11, 2023
This commit adds the previously missing test location for
FileTest tests.

Fixes: #49926
Fixes: #49927
PR-URL: #49999
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
targos pushed a commit that referenced this issue Nov 27, 2023
This commit adds the previously missing test location for
FileTest tests.

Fixes: #49926
Fixes: #49927
PR-URL: #49999
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
debadree25 pushed a commit to debadree25/node that referenced this issue Apr 15, 2024
This commit adds the previously missing test location for
FileTest tests.

Fixes: nodejs#49926
Fixes: nodejs#49927
PR-URL: nodejs#49999
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
sercher added a commit to sercher/graaljs that referenced this issue Apr 25, 2024
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 <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
sercher added a commit to sercher/graaljs that referenced this issue Apr 25, 2024
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 <[email protected]>
Reviewed-By: Chemi Atlow <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed-bug Issues with confirmed bugs. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants