bazel-contrib / bazel-contrib/rules_ruby
binary.sh.tpl doesn't check that arguments are passed when used as a test
- Dominant language
- Starlark
- Stars
- 50
- Forks
- 22
- Avg merge
- 9d 23h
- Merged PRs (30d)
- 5
Description
It is possible to end up in a situation where an `rb_test` rule produces a shell script from `binary.sh.tpl` that never receives arguments. In this case, executing the rule results in a false negative - in other words, `bazel test` will pass even though the Ruby test has never been executed because the only thing that runs is `bundle exec ruby` which returns successfully.
I'm still trying to determine what I've done in my local setup to misconfigure the `rb_test` in this way, but having defense in depth could help others avoid losing the same time that I have tracking this down.
Something like:
```bash
if [[ -n "${TEST_BINARY:-}" && $# -le 0 ]]; then
echo "Error! No arguments provided to test binary"
exit -1
fi
```
This approach would rely on `TEST_BINARY` (set by `test-setup.sh`) to be present so that the check for missing arguments doesn't apply to vanilla `rb_binary` rules.
WDYT, @p0deje ?
Contributor guide
Assessment
This issue has not been assessed yet.