Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Flamefire
Copy link
Contributor

As discussed in #197 the PR #172 introduced a change which broke the test runner when the test consumed stdin (containing remaining tests) by

  • Iterating over the all_tests array previously created and split at the last TAB found. By construction of the test lines this should work in all cases (test function names cannot contain a TAB)

  • count number of executed tests and fail if it doesn't match number of tests that were scheduled

    • avoid silent failure as on current master
  • show number of not-run tests in the pretty-printer summary by counting passed tests

  • I have reviewed the Contributor Guidelines.

  • I have reviewed the Code of Conduct and agree to abide by it

@Flamefire
Copy link
Contributor Author

Alternative would be e.g. redirecting /dev/null do stdin for the test commands, see e.g. https://stackoverflow.com/questions/13800225/shell-script-while-read-line-loop-stops-after-the-first-line

But I think this solution is better as it only relies on "simply" bashisms like iterating over a previously filled array. It also avoids an issue if the path to the test file contains a TAB

@Flamefire Flamefire force-pushed the stdin_fix branch 2 times, most recently from c5d200d to 003f3d4 Compare June 13, 2019 06:37
@sublimino
Copy link
Member

Thanks @Flamefire, this LGTM. Agreed on "simply Bashisms".

Anybody else from @bats-core/bats-core or @cyphar want to have a look?

@cyphar
Copy link
Contributor

cyphar commented Jun 23, 2019

LGTM from me. Thanks @Flamefire!

Flamefire added 4 commits July 3, 2019 09:53
Can happen e.g. when test code reads stdin which consumes remaining
tests and was silently ignored (OK returned)
This now makes the test run fail if not all tests were executed
Use an array to iterate over to avoid using stdin for test orchestration
Fixes bats-core#197
Move to bats folder as it is a single test
Extracting into an own command file required to use `bash -c`
@sublimino sublimino merged commit c92480b into bats-core:master Jul 4, 2019
@sublimino
Copy link
Member

Awesome! Fast and clean. Cheers @Flamefire : ] I'll keep on with your changes in other PRs, sorry it's a bit slow -- we'll get there 🙏

@Flamefire Flamefire deleted the stdin_fix branch July 4, 2019 09:15
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