Skip to content

test_runner: avoid running twice tests in describe - #46888

Closed
MoLow wants to merge 1 commit into
nodejs:mainfrom
MoLow:fix-test-in-describe
Closed

test_runner: avoid running twice tests in describe#46888
MoLow wants to merge 1 commit into
nodejs:mainfrom
MoLow:fix-test-in-describe

Conversation

@MoLow

Copy link
Copy Markdown
Member

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
Copy Markdown
Collaborator

Review requested:

  • @nodejs/test_runner

@nodejs-github-botnodejs-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
MoLowforce-pushed the fix-test-in-describe branch from d9021c1 to e3c44e3CompareFebruary 28, 2023 20:32
@MoLowMoLow changed the title test_runner: avoid running tests nedted under describetest_runner: avoid running twice tests in describeFeb 28, 2023
Comment threadlib/internal/test_runner/harness.js Outdated

@aduh95aduh95 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.

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
Copy Markdown
MemberAuthor

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
Copy Markdown
Member

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".

Comment threaddoc/api/test.md Outdated
@MoLow
MoLowforce-pushed the fix-test-in-describe branch from 2c235f2 to 95d8d57CompareMarch 2, 2023 18:44
@MoLow

MoLow commented Mar 2, 2023

Copy link
Copy Markdown
MemberAuthor

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 aduh95March 2, 2023 18:52
@MoLow

MoLow commented Mar 2, 2023

Copy link
Copy Markdown
MemberAuthor

@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
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
functionrun(name,options,fn,overrides){
asyncfunctionrun(name,options,fn,overrides){

doing this instead would ensure it always returns a promise

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.

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

Comment threadlib/internal/test_runner/harness.js
@MoLowMoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Mar 2, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 2, 2023
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@MoLow
MoLowforce-pushed the fix-test-in-describe branch from fec80e6 to 95d8d57CompareMarch 2, 2023 20:02
@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 Mar 2, 2023
@github-actionsgithub-actionsBot removed the request-ci Add this label to start a Jenkins CI on a PR. label Mar 2, 2023
@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 Mar 3, 2023
@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 Mar 3, 2023
@nodejs-github-bot

Copy link
Copy Markdown
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 <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@MoLow

MoLow commented Mar 3, 2023

Copy link
Copy Markdown
MemberAuthor

Landed in a37b72d

@MoLowMoLow closed this Mar 3, 2023
@MoLow
MoLow deleted the fix-test-in-describe branch March 3, 2023 05:27
@MoLowMoLow mentioned this pull request Mar 3, 2023
targos pushed a commit that referenced this pull request Mar 13, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
targos pushed a commit that referenced this pull request Mar 14, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@targostargos mentioned this pull request Mar 14, 2023
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
PR-URL: #46888
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
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.commit-queue-failedAn error occurred while landing this pull request using GitHub Actions.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.

test within describe runs twice

6 participants

@MoLow@nodejs-github-bot@ljharb@jasnell@benjamingr@aduh95