Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Updating the call to
ctx.runfiles()
in thebats_test()
impl function. Instead of settingtransitive_files
to thefiles
ofctx.attr.data
andctx.attr.dep
, this PR usesdefault_runfiles.files
fordeps
. The effect is that all runfiles (not only the immediate outputs) ofdeps
will be copied into thebats_test
target's runfiles.The existing issue can be shown when a
bats_test()
target'sdep
target containsdata
, it does not get copied over. Consider:In this example, the
bats_test
needs the:tool
target (to run tests against the binary). With the current implementation, it will only get the binary. Thedata
("tool_config.txt") will not be copied over into the test runfiles. This is not only inconsistent (since running:tool
would always have the file present), but it may (depending on the binary's functionality) cause the binary to no longer run correctly, as it depends on that file to be present.data
files are also missing from any further transitive dependencies further in the build DAG.This issue is also present with
sh_binary
for bothdata
anddeps
, due to both attributes being treated as the same. This causes any transitive scripts (i.e.deps
) to be missing in thebats_test
runfiles.This PR fixes this by gathering all runfiles (which includes
deps
anddata
+ transitives) for each dep defined. This PR does not modify howdata
is processed, asdata
is moreso intended to explicitly list files (orfilegroups
) instead of targets (which would have their owndeps
/data
). This distinction is merely a semantic one anddata
could also be processed in the same way in the future, if desired.