-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
file_test, rule_test: now as sh_test rules #8352
Conversation
All test rules in @bazel_tools//tools/build_rule:test_rules.bzl are now macros around sh_test. This allows running them on Windows with the Windows-native test wrapper. Fixes bazelbuild#8203 Unblocks bazelbuild#6622
all green |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a lot of Bash-specific code, how does it work on Windows?
@@ -14,83 +14,153 @@ | |||
# See the License for the specific language governing permissions and | |||
# limitations under the License. | |||
|
|||
_INIT_BASH_RUNFILES = "\n".join([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a comment? It's not obvious to see what it does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What should the comment say? The variable's name is descriptive and the first line of the code says what it does.
_INIT_BASH_RUNFILES = "\n".join([ | ||
"#!/bin/bash", | ||
"# --- begin runfiles.bash initialization ---", | ||
"# Copy-pasted from Bazel Bash runfiles library (tools/bash/runfiles/runfiles.bash).", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why copy-pasted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bazel/tools/bash/runfiles/runfiles.bash
Lines 34 to 36 in 616481a
# The runfiles library itself defines rlocation which you would need to look | |
# up the library's runtime location, thus we have a chicken-and-egg problem. | |
# Insert the following code snippet to the top of your main script: |
Via sh_test. Previously, the executable of these test rules was a naked Therefore these tests, while still depend on Bash, they don't depend on the Bash-based test wrapper, and that's what I wanted to achieve, see #8203 (comment) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thank you for the quick review! |
I need to roll this back, because it breaks some Google-internal tests. :( |
*** Reason for rollback *** Breaks some of Google's own tests *** Original change description *** file_test, rule_test: now as sh_test rules All test rules in @bazel_tools//tools/build_rule:test_rules.bzl are now macros around sh_test. This allows running them on Windows with the Windows-native test wrapper. Fixes #8203 Unblocks #6622 Closes #8352. PiperOrigin-RevId: 248682341
This commit rolls forward commit 76583ee, which was rolled back by commit 28f8af7. Differences: - test_rules.bzl:success_target and failure_target no longer dump 'msg' into a file and print that. Instead, they print it as a heredoc. - The same functions no longer need runfiles.bash. The breakage the original commit caused was that some Starlark rule used success_target but itself didn't depend on the Bash runfiles library, and success_target returns a DefaultInfo without the runfiles library in it. To keep existing success_target and failure_target calls intact, I opted to remove the dependency on runfiles.bash - marked all "_impl" rules as testonly=1 Original commit message follows. All test rules in @bazel_tools//tools/build_rule:test_rules.bzl are now macros around sh_test. This allows running them on Windows with the Windows-native test wrapper. Fixes #8203 Unblocks #6622 Closes #8352. PiperOrigin-RevId: 248691640
All test rules in @bazel_tools//tools/build_rule:test_rules.bzl are now macros around sh_test. This allows running them on Windows with the Windows-native test wrapper. Fixes bazelbuild#8203 Unblocks bazelbuild#6622 Closes bazelbuild#8352. PiperOrigin-RevId: 248680587
*** Reason for rollback *** Breaks some of Google's own tests *** Original change description *** file_test, rule_test: now as sh_test rules All test rules in @bazel_tools//tools/build_rule:test_rules.bzl are now macros around sh_test. This allows running them on Windows with the Windows-native test wrapper. Fixes bazelbuild#8203 Unblocks bazelbuild#6622 Closes bazelbuild#8352. PiperOrigin-RevId: 248682341
This commit rolls forward commit 76583ee, which was rolled back by commit 28f8af7. Differences: - test_rules.bzl:success_target and failure_target no longer dump 'msg' into a file and print that. Instead, they print it as a heredoc. - The same functions no longer need runfiles.bash. The breakage the original commit caused was that some Starlark rule used success_target but itself didn't depend on the Bash runfiles library, and success_target returns a DefaultInfo without the runfiles library in it. To keep existing success_target and failure_target calls intact, I opted to remove the dependency on runfiles.bash - marked all "_impl" rules as testonly=1 Original commit message follows. All test rules in @bazel_tools//tools/build_rule:test_rules.bzl are now macros around sh_test. This allows running them on Windows with the Windows-native test wrapper. Fixes bazelbuild#8203 Unblocks bazelbuild#6622 Closes bazelbuild#8352. PiperOrigin-RevId: 248691640
All test rules in
@bazel_tools//tools/build_rule:test_rules.bzl are
now macros around sh_test.
This allows running them on Windows with the
Windows-native test wrapper.
Fixes #8203
Unblocks #6622