Skip to content

Conversation

@rluvaton
Copy link
Member

@rluvatonrluvaton commented Jul 25, 2023

Fix: #48867

I'm not sure about the solution, WDYT? 🤔

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@rluvatonrluvaton marked this pull request as ready for review July 25, 2023 08:17
@nodejs-github-botnodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Jul 25, 2023
@rluvatonrluvaton marked this pull request as draft July 25, 2023 08:17
@rluvatonrluvaton marked this pull request as ready for review July 25, 2023 08:23
@rluvatonrluvaton marked this pull request as draft July 25, 2023 08:24
@rluvatonrluvaton marked this pull request as ready for review July 25, 2023 18:12
---
duration_ms: *
...
not ok 0 - <root>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if we should change this name. @cjihrig WDYT?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the root test should even show up in the output like this because users will have no clue what it is (the root test is basically an implementation detail). For failed global hooks, I think we should try to do something similar to what we do when we run a test file with no tests that exits with non-zero.

In case it's not clear what I mean:

// foo.jsprocess.exit(1);
$ node --test foo.js ✖ /private/tmp/foo.js (23.390208ms) 'test failed' ℹ tests 1 ℹ suites 0 ℹ pass 0 ℹ fail 1 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 27.586916 ✖ failing tests: ✖ /private/tmp/foo.js (23.390208ms) 'test failed' 

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated, can you take a look?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I should have been a bit more explicit. When I said "something similar" I meant specify the name of the hook, not the filename. For example, "global after hook" or something alone those lines.

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the before failed we have:

'use strict';const{ it, before }=require('node:test');before(()=>{thrownewError('this should fail the test')});it('this is a test',()=>{console.log('this is a test')});
✖ this is a test (0.679959ms) Error: this should fail the test at TestContext.<anonymous> (/Users/rluvaton/dev/open-source/node/node-fork/test/fixtures/test-runner/output/global_after_should_fail_the_test.js:5:9) at TestHook.runInAsyncScope (node:async_hooks:206:9) at TestHook.run (node:internal/test_runner/test:581:25) at TestHook.run (node:internal/test_runner/test:774:18) at TestHook.run (node:internal/util:500:12) at node:internal/test_runner/test:517:20 at async Test.runHook (node:internal/test_runner/test:515:7) at async Test.run (node:internal/test_runner/test:554:9) at async startSubtest (node:internal/test_runner/harness:204:3) ℹ tests 1 ℹ suites 0 ℹ pass 0 ℹ fail 1 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 116.542583 ✖ failing tests: ✖ this is a test (0.679959ms) Error: this should fail the test at TestContext.<anonymous> (/Users/rluvaton/dev/open-source/node/node-fork/test/fixtures/test-runner/output/global_after_should_fail_the_test.js:5:9) at TestHook.runInAsyncScope (node:async_hooks:206:9) at TestHook.run (node:internal/test_runner/test:581:25) at TestHook.run (node:internal/test_runner/test:774:18) at TestHook.run (node:internal/util:500:12) at node:internal/test_runner/test:517:20 at async Test.runHook (node:internal/test_runner/test:515:7) at async Test.run (node:internal/test_runner/test:554:9) at async startSubtest (node:internal/test_runner/harness:204:3) 

Copy link
Contributor

@cjihrigcjihrigJul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With Node 20.5.0, a failing global before() fails the test run with the same error shown in #48913 (comment). I pulled down this PR locally, and verified there is no difference.

With Node 20.5.0, a failing global after() does not fail the test run, and is a bug. This PR does address that, but the failure should be more accurate IMO:

this is a test ✔ this is a test (1.356584ms) ✖ /tmp/foo.js (0.22ms) Error: this should fail the test at TestContext.<anonymous> (/private/tmp/foo.js:5:9) at TestHook.runInAsyncScope (node:async_hooks:206:9) at TestHook.run (node:internal/test_runner/test:581:25) at TestHook.run (node:internal/test_runner/test:774:18) at TestHook.run (node:internal/util:500:12) at node:internal/test_runner/test:517:20 at async Test.runHook (node:internal/test_runner/test:515:7) at async after (node:internal/test_runner/test:543:9) at async Test.run (node:internal/test_runner/test:591:7) at async process.exitHandler (node:internal/test_runner/harness:144:5) ℹ tests 1 ℹ suites 0 ℹ pass 1 ℹ fail 0 ℹ cancelled 0 ℹ skipped 0 ℹ todo 0 ℹ duration_ms 0.22 ✖ failing tests: ✖ /tmp/foo.js (0.22ms) Error: this should fail the test at TestContext.<anonymous> (/private/tmp/foo.js:5:9) at TestHook.runInAsyncScope (node:async_hooks:206:9) at TestHook.run (node:internal/test_runner/test:581:25) at TestHook.run (node:internal/test_runner/test:774:18) at TestHook.run (node:internal/util:500:12) at node:internal/test_runner/test:517:20 at async Test.runHook (node:internal/test_runner/test:515:7) at async after (node:internal/test_runner/test:543:9) at async Test.run (node:internal/test_runner/test:591:7) at async process.exitHandler (node:internal/test_runner/harness:144:5) 

Just looking at that output, I would have no idea that the failure is because the after hook failed. That is important information for users. That's what I'm saying we need to change in #48913 (comment).

EDIT: More specifically, it would be good if ✖ /tmp/foo.js (0.22ms) in this example said ✖ global after hook (0.22ms)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More specifically, it would be good if ✖ /tmp/foo.js (0.22ms) in this example said ✖ global after hook (0.22ms)

it has a failureType: 'hookFailed' , wich is printed in case of the tap reporter, but in spec we seem to omit it.
still - there is a stack trace, isnt that good enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean it's better than the existing bug, but seems like something we could improve 🤷

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ideally, I would prefer each hook that failed to tell that it failed from that hook

Copy link
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be in a different PR, and in that PR I would also align the before to match the right behavior...

@MoLowMoLow requested a review from cjihrigJuly 25, 2023 18:55
Copy link
Member

@MoLowMoLow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@rluvaton
Copy link
MemberAuthor

The test test/parallel/test-runner-cli.js is failing as it picked up new test files, #48787 would have fixed that

@MoLowMoLow added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. request-ci Add this label to start a Jenkins CI on a PR. labels Jul 26, 2023
@github-actionsgithub-actionsbot removed the request-ci Add this label to start a Jenkins CI on a PR. label Jul 26, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow
Copy link
Member

@rluvaton the new tests seem to fail on windows https://ci.nodejs.org/job/node-test-binary-windows-js-suites/22188/RUN_SUBSET=1,nodes=win2012r2-COMPILED_BY-vs2019-x86/console

00:29:13 not ok 7 - test-runner/output/global_after_should_fail_the_test.js 00:29:13 --- 00:29:13 duration_ms: 780.562048 00:29:13 failureType: 'testCodeFailure' 00:29:13 error: |- 00:29:13 Expected values to be strictly equal: 00:29:13 + actual - expected ... Lines skipped 00:29:13 00:29:13 'this is a test\n' + 00:29:13 'TAP version 13\n' + 00:29:13 ... 00:29:13 ' duration_ms: *\n' + 00:29:13 ' ...\n' + 00:29:13 + 'not ok 2 - C:\\\\workspace\\\\node-test-binary-windows-js-suites\\\\node\\\\test\\\\fixtures\\\\test-runner\\\\output\\\\global_after_should_fail_the_test.js\n' + 00:29:13 - 'not ok 2 - /test/fixtures/test-runner/output/global_after_should_fail_the_test.js\n' + 00:29:13 ' ---\n' + 00:29:13 ... 00:29:13 '# skipped 0\n' + 00:29:13 '# todo 0\n' + 00:29:13 '# duration_ms *\n' 

@rluvaton
Copy link
MemberAuthor

I pushed a fix, hope this would work

@MoLow
Copy link
Member

@rluvaton commits like this dont actually trigger the CI

@rluvaton
Copy link
MemberAuthor

What would you do to trigger a CI?

@nodejs-github-botnodejs-github-bot merged commit c58e8fc into nodejs:mainAug 2, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in c58e8fc

@rluvatonrluvaton deleted the fix-after-not-failing-the-root-test branch August 2, 2023 20:06
pluris pushed a commit to pluris/node that referenced this pull request Aug 6, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
pluris pushed a commit to pluris/node that referenced this pull request Aug 7, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Ceres6 pushed a commit to Ceres6/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
UlisesGascon pushed a commit to UlisesGascon/node that referenced this pull request Aug 14, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
RafaelGSS pushed a commit that referenced this pull request Aug 15, 2023
PR-URL: #48913Fixes: #48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
@UlisesGasconUlisesGascon mentioned this pull request Aug 15, 2023
RafaelGSS pushed a commit to RafaelGSS/node that referenced this pull request Aug 15, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
rluvaton added a commit to rluvaton/node that referenced this pull request Aug 15, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
@RafaelGSSRafaelGSS added the backport-requested-v20.x PRs awaiting manual backport to the v20.x-staging branch. label Aug 17, 2023
@RafaelGSS
Copy link
Member

Due to fact, #48877 didn't land cleanly on v20.x-staging. This PR somehow, depends on it. So we'll need a manual backport.

Reference: https://github.com/nodejs/node/blob/main/doc/contributing/backporting-to-release-lines.md

rluvaton added a commit to rluvaton/node that referenced this pull request Aug 18, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
@rluvatonrluvaton added backport-open-v20.x Indicate that the PR has an open backport and removed backport-requested-v20.x PRs awaiting manual backport to the v20.x-staging branch. labels Aug 18, 2023
@rluvaton
Copy link
MemberAuthor

rluvaton added a commit to rluvaton/node that referenced this pull request Sep 4, 2023
PR-URL: nodejs#48913Fixes: nodejs#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
UlisesGascon pushed a commit that referenced this pull request Sep 10, 2023
PR-URL: #48913 Backport-PR-URL: #49225Fixes: #48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
@UlisesGasconUlisesGascon mentioned this pull request Sep 10, 2023
@targostargos added backported-to-v20.x PRs backported to the v20.x-staging branch. and removed backport-open-v20.x Indicate that the PR has an open backport labels Nov 12, 2023
targos pushed a commit that referenced this pull request Nov 27, 2023
PR-URL: #48913 Backport-PR-URL: #49225Fixes: #48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
@targostargos mentioned this pull request Nov 28, 2023
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
PR-URL: nodejs/node#48913 Backport-PR-URL: nodejs/node#49225Fixes: nodejs/node#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
sercher added a commit to sercher/graaljs that referenced this pull request Apr 25, 2024
PR-URL: nodejs/node#48913 Backport-PR-URL: nodejs/node#49225Fixes: nodejs/node#48867 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Chemi Atlow <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.backported-to-v20.xPRs backported to the v20.x-staging branch.commit-queue-squashAdd this label to instruct the Commit Queue to squash all the PR commits into the first one.needs-ciPRs that need a full CI run.test_runnerIssues and PRs related to the test runner subsystem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

after not failing the root test

9 participants

@rluvaton@nodejs-github-bot@MoLow@atlowChemi@RafaelGSS@benjamingr@cjihrig@targos@debadree25