-
Couldn't load subscription status.
- Fork 450
Don't truncate skip message when ')' is included. #48
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
Conversation
Addresses sstephenson/bats#240. When outputting a 'pretty' formatted output stream, the 'skip' message was being processed with a character class of [^)]. I couldn't find a reason for this to be the case, so I've swapped it out to check instead of printable characters, spaces included ([:print:]). Please advise if there is a problem with this approach. Tested using Bash 4.3.11(1)-release.
|
This is a delayed response, but if you're still game, could you add a test case? |
This test case checks whether skipped tests with closing parentheses are formatted correctly when passed throguh the pretty formatter.
|
Odd that the only failure was in the Alpine container... Try this to debug it:
|
|
I agree that it's strange that it's failing on Alpine and nowhere else. I was planning to test it on Docker locally to figure out why it failed. |
|
Ah. Alpine apparently handles output from the pretty formatter very differently. This brings to light the question of whether the TAP vs pretty formatter output comparison (bats.bats test "pretty and tap formats") is currently a valid test on the Alpine container, since it's just an equality check. Alpine, for a single line test redrawn with carriage returns, outputs this for On other systems, only the last line (with a single space after 'skipped:') is returned. I have an augmented test to fix this, but it's kind of hack-ish, and seems like it'd be awfully prone to breakage with future changes: @test "skipped test with parens (pretty formatter)" {
run bats --pretty "$FIXTURE_ROOT/skipped_with_parens.bats"
[ $status -eq 0 ]
- [[ "${lines[@]}" =~ "- a skipped test with parentheses in the reason (skipped: a reason (with parentheses))" ]]
+ [[ "${lines[@]}" =~ "- a skipped test with parentheses in the reason (skipped: "+"a reason (with parentheses))" ]]
} |
The Alpine container handles 'pretty' output from BATS very differently from other platforms. This is a somewhat hack-ish fix to account for that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heh, wow, interesting. I don't think the updated pattern is too hackish or fragile, but before I approve, would you mind adding an explanatory comment, something like:
# Some systems (e.g. Alpine) add an extra whitespace when the formatter emits
# a carriage return, hence the `+` to match one or more whitespace characters.Also, any reason not to use $output instead of ${lines[@]}?
I also see how you'd think the pretty and tap formats test case seems to provide little useful information. One thing it does provide, however, is confirmation that the --pretty and --tap switches indeed dispatch to different formatters.
We could replace that case with two different cases checking the output directly, which'd require including the unicode ✓ in the test string. If you want to take a stab at it, feel free!
|
No specific reason not to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No worries about the rust. Thanks for picking the PR up again and submitting a great change!
Addresses sstephenson/bats#240. When outputting a 'pretty' formatted
output stream, the 'skip' message was being processed with a character
class of [^)]. I couldn't find a reason for this to be the case, so
I've swapped it out to check instead for printable characters, spaces
included ([:print:]). Please advise if there is a problem with this
approach.
Tested using Bash 4.3.11(1)-release.