Skip to content

feat: add assert_stderr, refute_stderr, assert_stderr_line #72

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

Merged
merged 10 commits into from
Mar 22, 2025

Conversation

mh182
Copy link

@mh182 mh182 commented Feb 16, 2025

This pull request closes #42. It addresses the shortcoming of PR #52 reducing the code duplication.

Refactor the assert_output function to improve clarity and maintainability. Introduce a new helper function __assert_stream to handle different stream types (output and stderr).

Introduce the assert_stderr function to validate that the standard error output matches the expected value.

Refactor the refute_output function to improve stream handling by introducing a new __refute_stream function. This change allows for more flexible handling of both output and stderr streams. This enhances the maintainability and usability of the code.

Introduce the refute_stderr function to allow verification that a command or function does not produce unexpected stderr. This function complements assert_stderr and supports matching via literal, partial, or regular expression. Update documentation to reflect this addition and clarify usage of assert_stderr with --separate-stderr for proper stderr handling.

Add a new assert_stderr_line function for checking expected lines in the stderr output. This improves the clarity and functionality of the assertion process.

Refactor the refute_line function to handle both output and stderr streams uniformly. Introduce a new helper function __refute_stream_line to streamline the logic and reduce code duplication.

Introduce the refute_stderr_line function to verify that an unexpected line does not appear in the stderr output. Update documentation to reflect usage and necessary conditions for correct operation, including the requirement to use --separate-stderr when running commands.

@mh182 mh182 marked this pull request as draft February 16, 2025 00:41
@mh182 mh182 marked this pull request as ready for review February 16, 2025 00:41
Refactor the `assert_output` function to improve clarity and
maintainability. Introduce a new helper function `__assert_stream`
to handle different stream types (output and stderr).
Introduce the `assert_stderr` function to validate that the
standard error output matches the expected value.
Refactor the `refute_output` function to improve stream handling by
introducing a new `__refute_stream` function. This change allows for
more flexible handling of both `output` and `stderr` streams. This
enhances the maintainability and usability of the code.
Introduce the `refute_stderr` function to allow verification that a command
or function does not produce unexpected stderr. This function complements
`assert_stderr` and supports matching via literal, partial, or regular
expression. Update documentation to reflect this addition and clarify
usage of `assert_stderr` with `--separate-stderr` for proper stderr
handling.
Refactor the `assert_line` function to improve clarity and
maintainability. Introduce a new helper function `__assert_stream_line`
to handle different stream types (output and stderr).
Add a new assert_stderr_line function for checking expected lines
in the stderr output. This improves the clarity and functionality
of the assertion process.
Introduce a new helper function
`__refute_stream_line` to streamline the logic and reduce
code duplication.
Refactor the `refute_line` function to handle both output and
stderr streams uniformly. Introduce a new helper function
`__refute_stream_line` to streamline the logic and reduce
code duplication.

Introduce the `refute_stderr_line` function to verify that an
unexpected line does not appear in the stderr output. Update
documentation to reflect usage and necessary conditions for correct
operation, including the requirement to use `--separate-stderr`
when running commands.
@brokenpip3
Copy link

it seems a great work, however I can't approve the workflow to see the tests @bats-core/bats-core can someone approve thew workflow? or give me the grants to do it for this repo as well, thanks!

mh182 added 2 commits March 21, 2025 21:36
Add tests for `__refute_stream_line`, `__assert_stream`, and 
`__assert_line` to ensure they produce appropriate error messages 
when called directly. Update the implementations to handle 
unexpected calls by providing clear guidance on correct usage. 
This improves user experience and debugging by preventing silent 
failures and clarifying intended function usage.
@martin-schulze-vireso martin-schulze-vireso merged commit b93143a into bats-core:master Mar 22, 2025
1 check passed
@martin-schulze-vireso
Copy link
Member

Thanks for your contribution.

@mh182
Copy link
Author

mh182 commented Mar 22, 2025

Thanks for your work you do with bats.

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.

Missing assert_stderr and similar assertions
3 participants