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

test_runner: fix afterEach not running on test failures #45204

Merged
merged 5 commits into from Nov 7, 2022

Conversation

MrJithil
Copy link
Contributor

@MrJithil MrJithil commented Oct 27, 2022

test_runner: fix afterEach not running on test failures

Fixes: #45192

Copy link
Member

@MoLow MoLow left a comment

Choose a reason for hiding this comment

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

In general LGTM, a few comments:

  • describe should be adjusted as well and moved to finally:
    await this[kRunHook]('after', hookArgs);
    if (this.parent?.hooks.afterEach.length > 0) {
    await this.parent[kRunHook]('afterEach', hookArgs);
    }
  • tests need to be added/adjusted

@MrJithil
Copy link
Contributor Author

MrJithil commented Oct 27, 2022

In general LGTM, a few comments:

  • describe should be adjusted as well and moved to finally:
    await this[kRunHook]('after', hookArgs);
    if (this.parent?.hooks.afterEach.length > 0) {
    await this.parent[kRunHook]('afterEach', hookArgs);
    }
  • tests need to be added/adjusted

Could you please provide a test snippet or some more details?

@MoLow
Copy link
Member

MoLow commented Oct 27, 2022

Could you please provide a test snippet or some more details?

checkout the failing tests

@MrJithil
Copy link
Contributor Author

Working on it.

@MrJithil
Copy link
Contributor Author

MrJithil commented Nov 5, 2022

help needed to fix the test case. I can see the test file is failing with the latest release as well.

I am confused, how to clean up or adjust the test case. Please provide some samples or feel free to commit to the PR.

@MoLow
Copy link
Member

MoLow commented Nov 5, 2022

@MrJithil I took a look.
prior to this PR, tests was marked as passed only in case the afterEach hook passed,


after this PR, if the afterEach hook failed there is no indication besides the parent test failing:
see the output for these tests:
describe('afterEach throws', () => {
afterEach(() => { throw new Error('afterEach'); });
it('1', () => {});
it('2', () => {});
});

image

@MoLow
Copy link
Member

MoLow commented Nov 5, 2022

@MrJithil I pushed a fix;
@nodejs/test_runner I would appreciate a review

@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 5, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 5, 2022
@nodejs-github-bot
Copy link
Collaborator

lib/internal/test_runner/test.js Outdated Show resolved Hide resolved
lib/internal/test_runner/test.js Outdated Show resolved Hide resolved
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Nov 6, 2022
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Nov 6, 2022
@nodejs-github-bot
Copy link
Collaborator

@MoLow
Copy link
Member

MoLow commented Nov 6, 2022

Do we need the out files?

yeah, tools/test.py compares the output with the actual result

@MoLow MoLow added the commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. label Nov 6, 2022
@MrJithil
Copy link
Contributor Author

MrJithil commented Nov 6, 2022

@MrJithil I pushed a fix;
@nodejs/test_runner I would appreciate a review

Thank you so much for the help and it's a really great work. Do we need the out files?

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

MrJithil and others added 5 commits November 6, 2022 22:30
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 7, 2022
@nodejs-github-bot nodejs-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 Nov 7, 2022
@nodejs-github-bot
Copy link
Collaborator

Commit Queue failed
- Loading data for nodejs/node/pull/45204
✔  Done loading data for nodejs/node/pull/45204
----------------------------------- PR info ------------------------------------
Title      test_runner: fix afterEach not running on test failures (#45204)
   ⚠  Could not retrieve the email or name of the PR author's from user's GitHub profile!
Branch     MrJithil:fix-45192 -> nodejs:main
Labels     needs-ci, dont-land-on-v14.x, commit-queue-squash, test_runner
Commits    5
 - test_runner: fix afterEach not running on test failures
 - fix
 - CR
 - CR
 - CR
Committers 1
 - Moshe Atlow 
PR-URL: https://github.com/nodejs/node/pull/45204
Fixes: https://github.com/nodejs/node/issues/45192
Reviewed-By: Benjamin Gruenbaum 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/45204
Fixes: https://github.com/nodejs/node/issues/45192
Reviewed-By: Benjamin Gruenbaum 
--------------------------------------------------------------------------------
   ⚠  Commits were pushed since the last review:
   ⚠  - test_runner: fix afterEach not running on test failures
   ⚠  - fix
   ⚠  - CR
   ⚠  - CR
   ⚠  - CR
   ℹ  This PR was created on Thu, 27 Oct 2022 09:31:19 GMT
   ✔  Approvals: 1
   ✔  - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/45204#pullrequestreview-1169503033
   ✔  Last GitHub CI successful
   ℹ  Last Full PR CI on 2022-11-07T03:50:10Z: https://ci.nodejs.org/job/node-test-pull-request/47755/
- Querying data for job/node-test-pull-request/47755/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/3407846700

@MoLow MoLow 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 Nov 7, 2022
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Nov 7, 2022
@nodejs-github-bot nodejs-github-bot merged commit 3759935 into nodejs:main Nov 7, 2022
@nodejs-github-bot
Copy link
Collaborator

Landed in 3759935

lucshi pushed a commit to lucshi/node that referenced this pull request Nov 9, 2022
test_runner: fix afterEach not running on test failures

PR-URL: nodejs#45204
Fixes: nodejs#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
RafaelGSS pushed a commit that referenced this pull request Nov 10, 2022
test_runner: fix afterEach not running on test failures

PR-URL: #45204
Fixes: #45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
@RafaelGSS RafaelGSS mentioned this pull request Nov 10, 2022
MoLow pushed a commit to MoLow/node that referenced this pull request Nov 23, 2022
test_runner: fix afterEach not running on test failures

PR-URL: nodejs#45204
Fixes: nodejs#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
MoLow pushed a commit to MoLow/node that referenced this pull request Nov 23, 2022
test_runner: fix afterEach not running on test failures

PR-URL: nodejs#45204
Fixes: nodejs#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
MoLow pushed a commit to MoLow/node that referenced this pull request Dec 9, 2022
test_runner: fix afterEach not running on test failures

PR-URL: nodejs#45204
Fixes: nodejs#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
test_runner: fix afterEach not running on test failures

PR-URL: #45204
Fixes: #45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Dec 30, 2022
test_runner: fix afterEach not running on test failures

PR-URL: #45204
Fixes: #45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Jan 3, 2023
test_runner: fix afterEach not running on test failures

PR-URL: #45204
Fixes: #45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
danielleadams pushed a commit that referenced this pull request Jan 4, 2023
test_runner: fix afterEach not running on test failures

PR-URL: #45204
Fixes: #45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
MoLow pushed a commit to MoLow/node-core-test that referenced this pull request Feb 2, 2023
test_runner: fix afterEach not running on test failures

PR-URL: nodejs/node#45204
Fixes: nodejs/node#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
(cherry picked from commit 3759935ee29d8042d917d3ceaa768521c14413ff)
MoLow pushed a commit to MoLow/node-core-test that referenced this pull request Feb 2, 2023
PR-URL: nodejs/node#45204
Fixes: nodejs/node#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
(cherry picked from commit 3759935ee29d8042d917d3ceaa768521c14413ff)
MoLow pushed a commit to MoLow/node-core-test that referenced this pull request Feb 2, 2023
PR-URL: nodejs/node#45204
Fixes: nodejs/node#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
(cherry picked from commit 3759935ee29d8042d917d3ceaa768521c14413ff)
MoLow pushed a commit to MoLow/node-core-test that referenced this pull request Feb 2, 2023
PR-URL: nodejs/node#45204
Fixes: nodejs/node#45192
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
(cherry picked from commit 3759935ee29d8042d917d3ceaa768521c14413ff)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
commit-queue-squash Add this label to instruct the Commit Queue to squash all the PR commits into the first one. needs-ci PRs that need a full CI run. test_runner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

afterEach hook not executed when test fails
6 participants