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: add describe.only and it.only shorthands #46604

Conversation

richiemccoll
Copy link
Contributor

@richiemccoll richiemccoll commented Feb 10, 2023

Fixes: #46562

This PR adds support for describe.only and it.only shorthands in the test_runner. It follows the existing semantics for how only works.

@nodejs-github-bot
Copy link
Collaborator

Review requested:

  • @nodejs/test_runner

@@ -808,6 +808,11 @@ Shorthand for skipping a suite, same as [`describe([name], { skip: true }[, fn])
Shorthand for marking a suite as `TODO`, same as
[`describe([name], { todo: true }[, fn])`][describe options].

## `describe.only([name][, options][, fn])`
Copy link
Member

Choose a reason for hiding this comment

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

If we do this, we should also support test.only

Copy link
Contributor

Choose a reason for hiding this comment

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

test does not currently support test.skip() or test.todo(), and I would prefer to keep it that way.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think there is definitely value in having shorthands for the test API - especially skip and only. However, for the scope of this commit, it's only about adding the extra shorthand to the describe/it API. This keeps the options consistent.

@cjihrig are there any issues in particular you see with adding a shorthand API for the test interface in a future PR?

Copy link
Contributor

Choose a reason for hiding this comment

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

There is no technical reason - just a desire to keep the API surface area smaller. The Test class in particular is important because everything else builds on top of it. And, it already supports skip, todo, and only functionality, so I would prefer to not implement another way of doing the same thing.

@richiemccoll richiemccoll force-pushed the test-runner/describe-it-only-shorthands branch from 9f9585a to e89d473 Compare February 13, 2023 08:36
@MoLow
Copy link
Member

MoLow commented Feb 13, 2023

@richiemccoll is this ready for review?

@richiemccoll richiemccoll force-pushed the test-runner/describe-it-only-shorthands branch from e89d473 to e32726d Compare February 13, 2023 08:55
@richiemccoll richiemccoll marked this pull request as ready for review February 13, 2023 09:14
@richiemccoll
Copy link
Contributor Author

@MoLow Yes I was just checking the tests locally this morning before marking it for review. It should be ready now.

@aduh95
Copy link
Contributor

aduh95 commented Feb 13, 2023

@richiemccoll can you amend the commit message to adhere to our guidelines? The first word should be an imperative word, which describe technically is, but is not used as such (IIUC), making the commit message hard to understand.

* be prefixed with the name of the changed [subsystem](#appendix-subsystems)
and start with an imperative verb. Check the output of `git log --oneline

May I suggest test_runner: add `describe.only` and `it.only` shorthands?

doc/api/test.md Show resolved Hide resolved
doc/api/test.md Show resolved Hide resolved
@richiemccoll richiemccoll force-pushed the test-runner/describe-it-only-shorthands branch from e32726d to 6c6a7dd Compare February 13, 2023 09:42
@richiemccoll
Copy link
Contributor Author

@aduh95 Thanks. Commit message updated and pushed the doc metadata changes.

@richiemccoll richiemccoll changed the title test_runner: describe it only shorthand test_runner: add describe.only and it.only shorthands Feb 13, 2023
MoLow
MoLow previously approved these changes Feb 13, 2023
@aduh95 aduh95 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 Feb 13, 2023
test/message/test_runner_only_tests.js Outdated Show resolved Hide resolved
duration_ms: *
...
# Subtest: subtest should run
ok 14 - subtest should run # SKIP 'only' option not set
Copy link
Contributor

Choose a reason for hiding this comment

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

The test title says this should run, but it is skipped.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah - yes, I left these ones in here as they should work after @MoLow's nesting describe/test PR #46544 is merged. Once that's landed I'll rebase this PR and re-run these tests/update the output.

At the moment they are skipped with both the shorthand and the explicit { only: true } passed.

Copy link
Member

Choose a reason for hiding this comment

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

@richiemccoll #46544 has landed, can you please rebase this PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've rebased after your PR landed and updated these tests which now run. Commit here 6f069ef.

test/message/test_runner_only_tests.out Outdated Show resolved Hide resolved
@richiemccoll richiemccoll force-pushed the test-runner/describe-it-only-shorthands branch 2 times, most recently from c7c895a to 73b66f0 Compare February 14, 2023 09:02
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 16, 2023
@nodejs-github-bot
Copy link
Collaborator

@richiemccoll richiemccoll force-pushed the test-runner/describe-it-only-shorthands branch from 73b66f0 to 6f069ef Compare February 20, 2023 09:46
@MoLow MoLow added the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2023
@github-actions github-actions bot removed the request-ci Add this label to start a Jenkins CI on a PR. label Feb 21, 2023
@nodejs-github-bot
Copy link
Collaborator

@MoLow MoLow added the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 21, 2023
@nodejs-github-bot nodejs-github-bot removed the commit-queue Add this label to land a pull request using GitHub Actions. label Feb 21, 2023
@nodejs-github-bot nodejs-github-bot merged commit 0093fd3 into nodejs:main Feb 21, 2023
@nodejs-github-bot
Copy link
Collaborator

Landed in 0093fd3

MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
PR-URL: nodejs#46604
Fixes: nodejs#46562
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
PR-URL: nodejs#46604
Fixes: nodejs#46562
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
@MoLow MoLow added the backport-open-v18.x Indicate that the PR has an open backport. label Feb 25, 2023
MoLow pushed a commit to MoLow/node that referenced this pull request Feb 25, 2023
PR-URL: nodejs#46604
Fixes: nodejs#46562
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
juanarbol pushed a commit that referenced this pull request Mar 3, 2023
PR-URL: #46604
Backport-PR-URL: #46839
Fixes: #46562
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
@juanarbol juanarbol mentioned this pull request Mar 3, 2023
juanarbol pushed a commit that referenced this pull request Mar 5, 2023
PR-URL: #46604
Backport-PR-URL: #46839
Fixes: #46562
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
targos pushed a commit that referenced this pull request Mar 13, 2023
PR-URL: #46604
Fixes: #46562
Reviewed-By: Moshe Atlow <moshe@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. backport-open-v18.x Indicate that the PR has an open backport. needs-ci PRs that need a full CI run. test_runner
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test_runner: support describe / it only shorthands
6 participants