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

target_compatible_with failing with analysis_test #12366

Closed
keith opened this issue Oct 28, 2020 · 2 comments
Closed

target_compatible_with failing with analysis_test #12366

keith opened this issue Oct 28, 2020 · 2 comments

Comments

@keith
Copy link
Member

keith commented Oct 28, 2020

Using the new target_compatible_with feature with an analysis_test fails with this error on incompatible platforms:

ERROR: /workdir/test/BUILD:13:29: in coverage_xcode_prefix_map_test rule //test:coverage_settings_xcode_prefix_map: rules with analysis_test=true must return an instance of AnalysisTestResultInfo
ERROR: Analysis of target '//test:coverage_settings_xcode_prefix_map' failed; build aborted: Analysis of target '//test:coverage_settings_xcode_prefix_map' failed

https://buildkite.com/bazel/rules-swift-swift/builds/1980#af8b4f17-01b9-4e2d-99d0-93ef5abc6203

Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.

Example failure here for a test that is only compatible with macOS, and therefore fails with the above error on Linux bazelbuild/rules_swift#514

Flipping the target_compatible_with condition to only support Linux also makes it fail the same way on macOS.

What operating system are you running Bazel on?

macOS / Linux

What's the output of bazel info release?

2020/10/27 17:39:36 Using unreleased version at commit f3604a6c9c433c42f3adfa2bc1551150482aa73e
development version

If bazel info release returns "development version" or "(@non-git)", tell us how you built Bazel.

USE_BAZEL_VERSION=last_green with bazelisk

@philsc
Copy link
Contributor

philsc commented Oct 28, 2020

/cc @AustinSchuh @gregestren

@philsc
Copy link
Contributor

philsc commented Oct 28, 2020

Looking at this now.

philsc added a commit to philsc/bazel that referenced this issue Oct 28, 2020
In bazelbuild#12366, Keith Smiley (@keith) reported that he was having trouble
using the new `target_compatible_with` attribute in `rules_swift`.
Specifically, setting it on an `analysistest` test target was giving
him the following error:

    ERROR: /workdir/test/BUILD:13:29: in coverage_xcode_prefix_map_test rule //test:coverage_settings_xcode_prefix_map: rules with analysis_test=true must return an instance of AnalysisTestResultInfo
    ERROR: Analysis of target '//test:coverage_settings_xcode_prefix_map' failed; build aborted: Analysis of target '//test:coverage_settings_xcode_prefix_map' failed

This was caused by the fact that for incompatible targets we create a
dummy `ConfiguredTarget` that only provides the bare minimum to make
the rest of bazel happy before it gets skipped. It turns out that
`analysistest` rules have additional checks that need to be satisfied.
This patch aims to satisfy those additional checks without impacting
functionality.
philsc added a commit to philsc/bazel that referenced this issue Oct 28, 2020
In bazelbuild#12366, Keith Smiley (@keith) reported that he was having trouble
using the new `target_compatible_with` attribute in `rules_swift`.
Specifically, setting it on an `analysistest` test target was giving
him the following error:

    ERROR: /workdir/test/BUILD:13:29: in coverage_xcode_prefix_map_test rule //test:coverage_settings_xcode_prefix_map: rules with analysis_test=true must return an instance of AnalysisTestResultInfo
    ERROR: Analysis of target '//test:coverage_settings_xcode_prefix_map' failed; build aborted: Analysis of target '//test:coverage_settings_xcode_prefix_map' failed

This was caused by the fact that for incompatible targets we create a
dummy `ConfiguredTarget` that only provides the bare minimum to make
the rest of bazel happy before it gets skipped. It turns out that
`analysistest` rules have additional checks that need to be satisfied.
This patch aims to satisfy those additional checks without impacting
functionality.

Fixes bazelbuild#12366
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 a pull request may close this issue.

2 participants