Skip to content

test_runner: better error handing for test hook - #52401

Merged
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
himself65:himself65/20240407/better-error-handler
Apr 15, 2024
Merged

test_runner: better error handing for test hook#52401
nodejs-github-bot merged 1 commit into
nodejs:mainfrom
himself65:himself65/20240407/better-error-handler

Conversation

@himself65

Copy link
Copy Markdown
Member

Fixes: #52399

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@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 Apr 7, 2024
@himself65
himself65 marked this pull request as ready for review April 7, 2024 09:18
Comment threadlib/internal/test_runner/harness.js Outdated
Comment threadtest/parallel/test-runner-extraneous-async-activity.js Outdated
Comment threadtest/fixtures/test-runner/async-error-in-test-hook.mjs Outdated
Comment threadlib/internal/test_runner/harness.js Outdated
@himself65
himself65 requested a review from MoLowApril 8, 2024 19:42
@himself65
himself65force-pushed the himself65/20240407/better-error-handler branch 2 times, most recently from be37e0d to 0e35b75CompareApril 9, 2024 00:45

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Probably should also have the replaceTestLocationLine transformer?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am ok with these being a number. it shouldn't change much

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

same

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
assert.match(stdout,/^#Warning:Test"extraneousasyncactivitytest"at.+extraneous_set_immediate_async\.mjs:3:1generatedasynchronousactivityafterthetestended/m);
assert.match(stdout,/^#Warning:Test"extraneousasyncactivitytest"at.+extraneous_set_immediate_async\.mjs:\d+:\d+generatedasynchronousactivityafterthetestended/m);

(same for rest of the file)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am ok with this being a number. it shouldn't change much

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

We can leave col/row number here, because fixtures are won't change too much, it's good to keep it here

@MoLowMoLow left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice improvement

Comment threadlib/internal/test_runner/harness.js Outdated
Comment threadlib/internal/test_runner/harness.js Outdated
Comment threadlib/internal/test_runner/harness.js Outdated
Comment threadlib/internal/test_runner/harness.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

There is another warning on line 70 that we should change to an error. We should also remove the part that says "after the test ended" since we have seen that it can happen before a test even starts.

@himself65himself65Apr 9, 2024

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

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

We should also remove the part that says "after the test ended" since we have seen that it can happen before a test even starts.

I will keep this comment because it seems out of the context of this PR. And perhaps we can open another PR and add such test case

Comment threadlib/internal/test_runner/harness.js Outdated
@himself65
himself65 requested a review from cjihrigApril 9, 2024 21:27
@himself65himself65 changed the title test_runner: better warning inside test hooktest_runner: better error handing for test hookApr 9, 2024
@MoLowMoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 10, 2024

@cjihrigcjihrig left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. Thanks, I think this is a nice change.

@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 10, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@himself65himself65 added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 11, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 11, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@atlowChemi

Copy link
Copy Markdown
Member

@himself65 CI seems to have failures related to the snapshots

@himself65

Copy link
Copy Markdown
MemberAuthor

@himself65 CI seems to have failures related to the snapshots

How to fix it?

@MoLow

Copy link
Copy Markdown
Member

see https://ci.nodejs.org/job/node-test-binary-windows-js-suites/27045/RUN_SUBSET=1,nodes=win11-COMPILED_BY-vs2022/console for example:

07:37:37 + ' Error: Test "unhandled rejection - passes but warns" at test\\fixtures\\test-runner\\output\\output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.\n' +
07:37:37 + ' Error: Test "async unhandled rejection - passes but warns" at test\\fixtures\\test-runner\\output\\output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.\n' +
07:37:37 - ' Error: Test "unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:72:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.\n' +
07:37:37 - ' Error: Test "async unhandled rejection - passes but warns" at test/fixtures/test-runner/output/output.js:76:1 generated asynchronous activity after the test ended. This activity created the error "Error: rejected from async unhandled rejection fail" and would have caused the test to fail, but instead triggered an unhandledRejection event.\n' +

snapshot.replaceWindowsPaths needs to be added to junitTransform and to specTransform. if you need help LMK and I will push that to this branch

@atlowChemi

Copy link
Copy Markdown
Member

@himself65 CI seems to have failures related to the snapshots

How to fix it?

Once you fix the transfrormers @MoLow mentioned, run the following command to update the snapshots:
NODE_REGENERATE_SNAPSHOTS=1 out/Release/node test/parallel/test-runner-output.mjs. see: https://github.com/nodejs/node/blob/5b33f9dd88c4a9592dfdfdc03ad01e103287c144/test/common/README.md#L690-L694

@himself65

Copy link
Copy Markdown
MemberAuthor

working on this now

@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 14, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@himself65
himself65force-pushed the himself65/20240407/better-error-handler branch from 074683d to 16f2eefCompareApril 14, 2024 23:02
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
@himself65
himself65force-pushed the himself65/20240407/better-error-handler branch from 16f2eef to ebaa222CompareApril 14, 2024 23:02
@himself65himself65 added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 14, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 14, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@himself65himself65 added the request-ci Add this label to start a Jenkins CI on a PR. label Apr 15, 2024
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Apr 15, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@MoLowMoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 15, 2024
@nodejs-github-botnodejs-github-bot added commit-queue-failed An error occurred while landing this pull request using GitHub Actions. and removed commit-queue Add this label to land a pull request using GitHub Actions. labels Apr 15, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator
Commit Queue failed
- Loading data for nodejs/node/pull/52401
✔ Done loading data for nodejs/node/pull/52401
----------------------------------- PR info ------------------------------------
Title test_runner: better error handing for test hook (#52401)
Author Alex Yang (@himself65)
Branch himself65:himself65/20240407/better-error-handler -> nodejs:main
Labels needs-ci, test_runner
Commits 1
- test_runner: better error handing for test hook
Committers 1
- Alex Yang PR-URL: https://github.com/nodejs/node/pull/52401
Fixes: https://github.com/nodejs/node/issues/52399
Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig ------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/52401
Fixes: https://github.com/nodejs/node/issues/52399
Reviewed-By: Moshe Atlow Reviewed-By: Chemi Atlow Reviewed-By: Benjamin Gruenbaum Reviewed-By: Colin Ihrig --------------------------------------------------------------------------------
⚠ Commits were pushed since the last approving review:
⚠ - test_runner: better error handing for test hook
ℹ This PR was created on Sun, 07 Apr 2024 07:56:26 GMT
✔ Approvals: 4
✔ - Moshe Atlow (@MoLow) (TSC): https://github.com/nodejs/node/pull/52401#pullrequestreview-1990080998
✔ - Chemi Atlow (@atlowChemi): https://github.com/nodejs/node/pull/52401#pullrequestreview-1990786703
✔ - Benjamin Gruenbaum (@benjamingr) (TSC): https://github.com/nodejs/node/pull/52401#pullrequestreview-1990921524
✔ - Colin Ihrig (@cjihrig): https://github.com/nodejs/node/pull/52401#pullrequestreview-1991730905
✔ Last GitHub CI successful
ℹ Last Full PR CI on 2024-04-15T07:42:58Z: https://ci.nodejs.org/job/node-test-pull-request/58391/
- Querying data for job/node-test-pull-request/58391/
✔ Last Jenkins CI successful
--------------------------------------------------------------------------------
✔ Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/8687402947

@MoLowMoLow added commit-queue Add this label to land a pull request using GitHub Actions. and removed commit-queue-failed An error occurred while landing this pull request using GitHub Actions. labels Apr 15, 2024
@nodejs-github-botnodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Apr 15, 2024
@nodejs-github-bot
nodejs-github-bot merged commit f098b7a into nodejs:mainApr 15, 2024
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

Landed in f098b7a

@himself65
himself65 deleted the himself65/20240407/better-error-handler branch April 22, 2024 16:33
aduh95 pushed a commit that referenced this pull request Apr 29, 2024
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
PR-URL: #52401Fixes: #52399
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: Colin Ihrig <cjihrig@gmail.com>
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
PR-URL: #52401Fixes: #52399
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: Colin Ihrig <cjihrig@gmail.com>
@marco-ippolitomarco-ippolito mentioned this pull request May 2, 2024
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
Co-authored-by: Colin Ihrig <cjihrig@gmail.com>
PR-URL: #52401Fixes: #52399
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: Colin Ihrig <cjihrig@gmail.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

async error inside before won't cause test error

6 participants

@himself65@nodejs-github-bot@atlowChemi@MoLow@benjamingr@cjihrig