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: avoid running twice tests in describe #46888

Closed
wants to merge 1 commit into from

Conversation

MoLow
Copy link
Member

@MoLow MoLow commented Feb 28, 2023

Fixes #46887

not the fix itself can be understood in the first commit, the second one just unifies the code,
wanted to make review easier so split into two commits

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-bot nodejs-github-bot added dont-land-on-v14.x needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem. labels Feb 28, 2023
@MoLow MoLow force-pushed the fix-test-in-describe branch from d9021c1 to e3c44e3 Compare February 28, 2023 20:32
@MoLow MoLow changed the title test_runner: avoid running tests nedted under describe test_runner: avoid running twice tests in describe Feb 28, 2023
Copy link
Contributor

@aduh95 aduh95 left a comment

Choose a reason for hiding this comment

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

I'm not too sure if returning undefined is the correct move (rather than a PromiseResolve()), is there some use case when it would be useful for the users to make the difference?

Other than that, I think I would word the commit as avoid running tests twice, but I'm not an English native speaker, so if the current order is correct, I'm fine with it :)

@MoLow
Copy link
Member Author

MoLow commented Feb 28, 2023

I'm not too sure if returning undefined is the correct move (rather than a PromiseResolve()), is there some use case when it would be useful for the users to make the difference?

returning a PromiseResolve() might be confusing, if the promise some times fulfilled immediately, and sometimes when the test completes

@ljharb
Copy link
Member

ljharb commented Feb 28, 2023

That sounds less confusing an API to me than one that only sometimes returns a Promise - the latter is literally what's referred to as "zalgo".

doc/api/test.md Outdated Show resolved Hide resolved
@MoLow MoLow force-pushed the fix-test-in-describe branch from 2c235f2 to 95d8d57 Compare March 2, 2023 18:44
@MoLow
Copy link
Member Author

MoLow commented Mar 2, 2023

Since I don't feel strongly about returning undefined vs returning a promise that resolve immediately, I have changed the code to return PromiseResolve,
CC @aduh95 @ljharb

@MoLow MoLow requested a review from aduh95 March 2, 2023 18:52
@MoLow
Copy link
Member Author

MoLow commented Mar 2, 2023

@nodejs/test_runner since this is a bug in main I'd like to land it, additional reviews/approvals will be appreciated

}

function runInParentContext(Factory) {
function runInParentContext(Factory, addShorthands = true) {
function run(name, options, fn, overrides) {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
function run(name, options, fn, overrides) {
async function run(name, options, fn, overrides) {

doing this instead would ensure it always returns a promise

Copy link
Member Author

Choose a reason for hiding this comment

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

@ljharb change has caused invalid arguments to reject instead of throw so I will revert this

lib/internal/test_runner/harness.js Show resolved Hide resolved
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 2, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 2, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow force-pushed the fix-test-in-describe branch from fec80e6 to 95d8d57 Compare March 2, 2023 20:02
@MoLow MoLow 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 Mar 2, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 2, 2023
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

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

Commit Queue failed
- Loading data for nodejs/node/pull/46888
✔  Done loading data for nodejs/node/pull/46888
----------------------------------- PR info ------------------------------------
Title      test_runner: avoid running twice tests in describe (#46888)
Author     Moshe Atlow  (@MoLow)
Branch     MoLow:fix-test-in-describe -> nodejs:main
Labels     author ready, needs-ci, dont-land-on-v14.x, test_runner
Commits    1
 - test_runner: avoid running twice tests in describe
Committers 1
 - Moshe Atlow 
PR-URL: https://github.com/nodejs/node/pull/46888
Reviewed-By: Benjamin Gruenbaum 
Reviewed-By: Antoine du Hamel 
------------------------------ Generated metadata ------------------------------
PR-URL: https://github.com/nodejs/node/pull/46888
Reviewed-By: Benjamin Gruenbaum 
Reviewed-By: Antoine du Hamel 
--------------------------------------------------------------------------------
   ℹ  This PR was created on Tue, 28 Feb 2023 20:30:39 GMT
   ✔  Approvals: 2
   ✔  - Benjamin Gruenbaum (@benjamingr): https://github.com/nodejs/node/pull/46888#pullrequestreview-1320288015
   ✔  - Antoine du Hamel (@aduh95) (TSC): https://github.com/nodejs/node/pull/46888#pullrequestreview-1322529537
   ✖  Last GitHub CI failed
   ℹ  Last Full PR CI on 2023-03-02T22:06:27Z: https://ci.nodejs.org/job/node-test-pull-request/50173/
- Querying data for job/node-test-pull-request/50173/
   ✔  Last Jenkins CI successful
--------------------------------------------------------------------------------
   ✔  Aborted `git node land` session in /home/runner/work/node/node/.ncu
https://github.com/nodejs/node/actions/runs/4320318363

MoLow added a commit that referenced this pull request Mar 3, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
@MoLow
Copy link
Member Author

MoLow commented Mar 3, 2023

Landed in a37b72d

@MoLow MoLow closed this Mar 3, 2023
@MoLow MoLow deleted the fix-test-in-describe branch March 3, 2023 05:27
targos pushed a commit that referenced this pull request Mar 13, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
targos pushed a commit that referenced this pull request Mar 14, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: Antoine du Hamel <[email protected]>
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-failed An error occurred while landing this pull request using GitHub Actions. needs-ci PRs that need a full CI run. test_runner Issues and PRs related to the test runner subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test within describe runs twice
6 participants