bazel-contrib / bazel-contrib/rules_ruby

binary.sh.tpl doesn't check that arguments are passed when used as a test

Open
#233 3 comments 0 reactions 0 assignees View on GitHub
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

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.