Skip to content

Add a --negative-filter option (#1108)#1114

Merged
martin-schulze-vireso merged 1 commit intobats-core:masterfrom
AdamWill:add-negative-filter
Oct 11, 2025
Merged

Add a --negative-filter option (#1108)#1114
martin-schulze-vireso merged 1 commit intobats-core:masterfrom
AdamWill:add-negative-filter

Conversation

@AdamWill
Copy link
Copy Markdown
Contributor

See https://pagure.io/fedora-qa/os-autoinst-distri-fedora/pull-request/389 . The FAQ claimed "So you could try to invert the regex", but as far as I can tell, there's no practical way to do this with bash regexes, if you want to express "run all tests except foo_in_a" or something like that. You can do it in some regex flavors using negative lookahead matches, but bash's regex flavor does not seem to support that, and you can't just stick a ! on the front of the regex or anything like that.

So, this adds --negative-filter which just does the opposite of --filter. The implementation is intentionally 'dumb' because handling 'what if one or both is not defined?' gets a bit awkward if you try to handle both in one function.

@AdamWill AdamWill requested a review from a team as a code owner July 16, 2025 17:36
@AdamWill
Copy link
Copy Markdown
Contributor Author

If there's a way to negate regexes that neither me nor @Luap99 could find, please let us know! I'd happily change this to just make the FAQ note more specific, in that case.

@Luap99
Copy link
Copy Markdown

Luap99 commented Jul 16, 2025

Thanks @AdamWill

@AdamWill
Copy link
Copy Markdown
Contributor Author

The same test failures are happening on other PRs and don't seem related to the changes in this PR. I can add a changelog note, though.

@AdamWill AdamWill force-pushed the add-negative-filter branch from dde4e63 to db826de Compare July 28, 2025 15:57
AdamWill added a commit to AdamWill/os-autoinst-distri-fedora-ai-test that referenced this pull request Jul 30, 2025
Until bats-core/bats-core#1114 we can't
easily filter out specific tests in a bats run. So let's hack it
up with a sed that just negates the behavior of --filter - we
don't need to use its default behavior. Then we can use --filter
to filter out specific tests, like this. Use it to filter out
the test that's known to fail with recent kernels.

Signed-off-by: Adam Williamson <[email protected]>
See https://pagure.io/fedora-qa/os-autoinst-distri-fedora/pull-request/389 .
The FAQ claimed "So you could try to invert the regex", but as
far as I can tell, there's no practical way to do this with bash
regexes, if you want to express "run all tests except foo_in_a"
or something like that. You can do it in some regex flavors using
negative lookahead matches, but bash's regex flavor does not seem
to support that, and you can't just stick a `!` on the front of
the regex or anything like that.

So, this adds --negative-filter which just does the opposite of
--filter. The implementation is intentionally 'dumb' because
handling 'what if one or both is not defined?' gets a bit awkward
if you try to handle both in one function.

Signed-off-by: Adam Williamson <[email protected]>
@martin-schulze-vireso martin-schulze-vireso merged commit b535b94 into bats-core:master Oct 11, 2025
61 checks passed
@martin-schulze-vireso
Copy link
Copy Markdown
Member

Thanks for your contribution! I am sorry for taking so long to merge this.

@AdamWill
Copy link
Copy Markdown
Contributor Author

No problem! Thanks for the merge.

@AdamWill
Copy link
Copy Markdown
Contributor Author

Are you planning a release soon, btw?

@martin-schulze-vireso
Copy link
Copy Markdown
Member

martin-schulze-vireso commented Nov 7, 2025

Are you planning a release soon, btw?

The new Version was just released @AdamWill . Sorry about the delay and late reply. I could not tell how long it would take and did not want to commit to any schedule.

@AdamWill
Copy link
Copy Markdown
Contributor Author

awesome news, thanks!

truffle-dev added a commit to truffle-dev/bats-core that referenced this pull request Apr 20, 2026
The bats(1) man page is missing OPTIONS entries for four flags
that exist in `bats --help` and have working implementations in
`libexec/bats-core/bats`:

  * `--abort`                  (added 2025-10-12, commit 2153e6a)
  * `--errexit`                (added 2025-07-26, commit 185f268)
  * `--negative-filter`        (added 2025-07-16, commit 9e6627e, bats-core#1114)
  * `--parallel-binary-name`   (added 2023-05-28, commit 2c31eb3)

`bats.1.ronn` was last touched in November 2022, before any of
these landed. The descriptions added here mirror the wording of
`bats --help` so the two stay in sync.

Verified with `comm -23` of help-flags vs man-flags before and
after; the gap is now empty in both directions.

Only `bats.1.ronn` is touched. `bats.1` was not regenerated
because the toolchain version available locally would have
introduced unrelated header noise; happy to regen with a specific
Ronn-NG version if a maintainer prefers.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants