Skip to content
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

executable shadows files in DefaultInfo #6784

Closed
Profpatsch opened this issue Nov 27, 2018 · 4 comments
Closed

executable shadows files in DefaultInfo #6784

Profpatsch opened this issue Nov 27, 2018 · 4 comments
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug untriaged

Comments

@Profpatsch
Copy link
Contributor

Please take a look at the minimal repro: https://github.com/Profpatsch/repros/tree/02844d53cb21eee043795bfa735698d99da0aca4/bazel-DefaultInfo-defaults-to-executable

executable shadows files in DefaultInfo

This repro documents the fact that it’s impossible to create a test target for another test with a macro, because the required (and afaik outdated) executable field in DefaultInfo shadows files.

This issue is amplified by #6783, because in order to generate sh_test targets for a test rule, we need to wrap in sh_library, which is itself not a test rule. This is disallowed by a bazel restriction, which forbids non-test rules to depend on test rules.
A meta question would be whether this restriction is sensible for the general case.

$ bazel version
Build label: 0.18.0- (@non-git)
Build target: bazel-out/k8-opt/bin/src/main/java/com/google/devtools/build/lib/bazel/BazelServer_deploy.jar
Build time: Tue Jan 1 00:00:00 1980 (315532800)
Build timestamp: 315532800
Build timestamp as int: 315532800


$ bazel test --test_output=errors :example@test
INFO: Analysed target //:example@test (17 packages loaded).
INFO: Found 1 test target...
Target //:example@test up-to-date:
  bazel-bin/example@test
INFO: Elapsed time: 3.903s, Critical Path: 0.12s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed successfully, 3 total actions
//:example@test                                                          PASSED in 0.1s

Executed 1 out of 1 test: 1 test passes.
INFO: Build completed successfully, 3 total actions


$ bazel test --test_output=errors :example_test@test
INFO: Analysed target //:example_test@test (0 packages loaded).
INFO: Found 1 test target...
FAIL: //:example_test@test (see /home/philip/.cache/bazel/_bazel_philip/39225840e6b019295c1b0a6dcf31787a/execroot/__main__/bazel-out/k8-fastbuild/testlogs/example_test@test/test.log)
INFO: From Testing //:example_test@test:
==================== Test output for //:example_test@test:
+ echo files: ./empty
files: ./empty
+ '[' ./empty = ./a ']'
================================================================================
Target //:example_test@test up-to-date:
  bazel-bin/example_test@test
INFO: Elapsed time: 0.334s, Critical Path: 0.07s
INFO: 1 process: 1 processwrapper-sandbox.
INFO: Build completed, 1 test FAILED, 3 total actions
//:example_test@test                                                     FAILED in 0.0s
  /home/philip/.cache/bazel/_bazel_philip/39225840e6b019295c1b0a6dcf31787a/execroot/__main__/bazel-out/k8-fastbuild/testlogs/example_test@test/test.log

INFO: Build completed, 1 test FAILED, 3 total actions
@Profpatsch Profpatsch changed the title executable shadows files in DefaultInfo executable shadows files in DefaultInfo Nov 27, 2018
@jin jin added team-Local-Exec Issues and PRs for the Execution (Local) team and removed team-Execution labels Jan 14, 2019
@jmmv jmmv added team-Starlark and removed team-Local-Exec Issues and PRs for the Execution (Local) team labels Jan 24, 2019
@c-parsons
Copy link
Contributor

As a workaround, can you write your own test rule to customfit an appropriate test action? (That is, not use sh_test in macros for the tests but create the appropriate test action in starlark rule logic)

@c-parsons c-parsons added type: feature request P3 We're not considering working on this, but happy to review a PR. (No assignee) and removed untriaged labels Sep 3, 2019
@Profpatsch
Copy link
Contributor Author

I don’t know, it’s nearly been a year. We worked around it somehow back in the day.

I would consider it less of a feature request and more of a bug.

@c-parsons
Copy link
Contributor

Apologies that this fell through.

It's quite possible users have come to depend on this "quirk" of the API:
A "fix" here would likely warrant an overall API change and require some design (it would likely be an incompatible change).

@brandjon brandjon added P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) team-Build-Language and removed P3 We're not considering working on this, but happy to review a PR. (No assignee) team-Starlark labels Feb 16, 2021
@brandjon brandjon added untriaged team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts and removed team-Build-Language labels Nov 4, 2022
@sgowroji sgowroji added the stale Issues or PRs that are stale (no activity for 30 days) label Feb 16, 2023
@sgowroji
Copy link
Member

Hi there! We're doing a clean up of old issues and will be closing this one. Please reopen if you’d like to discuss anything further. We’ll respond as soon as we have the bandwidth/resources to do so.

@sgowroji sgowroji closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
P4 This is either out of scope or we don't have bandwidth to review a PR. (No assignee) stale Issues or PRs that are stale (no activity for 30 days) team-Rules-API API for writing rules/aspects: providers, runfiles, actions, artifacts type: bug untriaged
Projects
None yet
Development

No branches or pull requests

7 participants