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

rules_python is broken with Bazel@HEAD #1185

Closed
sgowroji opened this issue Apr 28, 2023 · 3 comments · Fixed by #1183
Closed

rules_python is broken with Bazel@HEAD #1185

sgowroji opened this issue Apr 28, 2023 · 3 comments · Fixed by #1183
Assignees

Comments

@sgowroji
Copy link
Member

https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2984#0187c5a7-8c82-4bf4-8edc-bc61496edab0

Platform : macOS

Logs:

ERROR: /Users/buildkite/builds/bk-imacpro-8/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/BUILD.bazel:18:19: in test_non_mac_doesnt_require_darwin_for_execution_test rule //tools/build_defs/python/tests/py_test:test_non_mac_doesnt_require_darwin_for_execution:
--
  | Traceback (most recent call last):
  | File "/private/var/tmp/_bazel_buildkite/423e4bd8d06d193ec99dc7a74423eafe/external/rules_testing/lib/analysis_test.bzl", line 200, column 13, in wrapped_impl
  | impl(env, target)
  | File "/Users/buildkite/builds/bk-imacpro-8/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/py_test_tests.bzl", line 89, column 28, in _test_non_mac_doesnt_require_darwin_for_execution_impl
  | ).requirements().keys().not_contains("requires-darwin")
  | Error: 'struct' value has no field or method 'not_contains'
  | Available attributes: actual, contains, contains_at_least, contains_at_least_predicates, contains_exactly, contains_exactly_predicates, contains_none_of, contains_predicate, has_size, not_contains_predicate
  | (04:20:02) ERROR: /Users/buildkite/builds/bk-imacpro-8/bazel-downstream-projects/rules_python/tools/build_defs/python/tests/py_test/BUILD.bazel:18:19: Analysis of target '//tools/build_defs/python/tests/py_test:test_non_mac_doesnt_require_darwin_for_execution' failed

Reference : bazelbuild/bazel#18170
Unable to reproduce in local setup.

CC @meteorcloudy, @rickeylev

@rickeylev
Copy link
Collaborator

Reproducing this requires the host to be a mac.

What's happening is...

  • The test expects the target-under-test to be configured for not-mac, but isn't forcing it to be not-mac.
  • When a linux host builds, the TUT is not mac, so it passes.
  • When a mac host builds, the TUT is mac, so it fails.

The error is a bit confusing because it also reveals a bug in rules_testing -- the missing not_contains method. That code path is only being taken, though, because the test is seeing the unexpected value, so it tries to assert on its contents.

#1183 is out to fix.

@meteorcloudy
Copy link
Member

A bisect points to bazelbuild/bazel@1895585

BTW, I'm adding bisect feature to Bazelisk, which should help identifying Bazel breaking changes much easier: bazelbuild/bazelisk#451

@rickeylev
Copy link
Collaborator

My guess as to why enabling the Starlark impl caused this is the Starlark impl uses platforms, while the Java one uses the --cpu string.

Since platforms are the intended way to identify the platform over --cpu, I'll document this as a behavior change in bazelbuild/bazel#15897

rickeylev added a commit that referenced this issue Apr 28, 2023
…execution (#1183)

This is the inverse test of the one testing for the mac platform. As
before, the line forcing the platform to a non-mac platform was
commented out, which meant, when a mac host built it, it would build the
underlying target for Mac, which violated the test's assumptions.

Work towards bazelbuild/bazel/issues/18170

Fixes #1185
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants