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: don't await the same promise for each test #52185

Closed
wants to merge 2 commits into from

Conversation

cjihrig
Copy link
Contributor

@cjihrig cjihrig commented Mar 22, 2024

test: fix incorrect test fixture

This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164

test_runner: don't await the same promise for each test

Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

cjihrig added 2 commits March 21, 2024 20:54
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: nodejs#47164
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.
@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Mar 22, 2024
@cjihrig cjihrig requested review from MoLow and atlowChemi March 22, 2024 12:05
@cjihrig cjihrig added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 23, 2024
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 23, 2024
@nodejs-github-bot
Copy link
Collaborator

@cjihrig cjihrig added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed needs-ci PRs that need a full CI run. labels Mar 24, 2024
Comment on lines +228 to +232
if (reportersSetup) {
// Only incur the overhead of awaiting the Promise once.
await reportersSetup;
reportersSetup = undefined;
}
Copy link
Member

Choose a reason for hiding this comment

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

Do you happen to have any benchmarking for this change?
Did anything specific raise this change?

Copy link
Member

Choose a reason for hiding this comment

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

@cjihrig I am curious as well what impact this has. is it that expensive to await the same promise multiple times?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MoLow see my comment in #52185 (comment). The issue is just that even after the promise is settled, awaiting it costs another tick. Quoting MDN:

Even when the used promise is already fulfilled, the async function's execution still pauses until the next tick.

It just seemed like a simple way to eliminate some overhead.

@atlowChemi atlowChemi added the commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. label Mar 24, 2024
@cjihrig cjihrig added the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 25, 2024
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Mar 25, 2024
@nodejs-github-bot
Copy link
Collaborator

Landed in bae14b7...4648c83

nodejs-github-bot pushed a commit that referenced this pull request Mar 25, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164
PR-URL: #52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
nodejs-github-bot pushed a commit that referenced this pull request Mar 25, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: #52185
Refs: #47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
anonrig pushed a commit to anonrig/node that referenced this pull request Mar 25, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: nodejs#47164
PR-URL: nodejs#52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
anonrig pushed a commit to anonrig/node that referenced this pull request Mar 25, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: nodejs#52185
Refs: nodejs#47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
@cjihrig cjihrig deleted the extra-await branch March 25, 2024 23:19
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: nodejs#47164
PR-URL: nodejs#52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
rdw-msft pushed a commit to rdw-msft/node that referenced this pull request Mar 26, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: nodejs#52185
Refs: nodejs#47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164
PR-URL: #52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 2, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: #52185
Refs: #47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 3, 2024
This commit updates a test runner fixture that includes a failing
child test. However, the nested test is created using the top
level test() function instead t.test(). This commit updates the
fixture to use t.test(), while preserving the expected failure.

Refs: #47164
PR-URL: #52185
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
marco-ippolito pushed a commit that referenced this pull request May 23, 2024
Prior to this commit, each top level test awaited the same
global promise for setting up test reporters. This commit
updates the logic to only await the promise the first time
it is encountered.

PR-URL: #52185
Refs: #47164
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chemi Atlow <chemi@atlow.co.il>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. commit-queue-rebase Add this label to allow the Commit Queue to land a PR in several commits. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants