forked from bazelbuild/rules_python
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(bzlmod): Make some tests bzlmod compatible
A few tests weren't compatible with bzlmod, so would fail when it was enabled. The various causes and fixes are: * Under bzlmod, `runfiles.CurrentRepository()` returns the empty string for the main repository. To fix, an environment variable is used to tell the test whether bzlmod is enabled or not. * Accessing data files through `TEST_SRCDIR` directly is error-prone under bzlmod because the directory name within runfiles changes from the workspace name to `_main`. To fix, use the runfiles libraries, which know how to map apparent repo names to the actual directory name. In the integration tests, the runfiles library isn't available, so just check for the `_main` directory instead. Work towards bazelbuild#1469
- Loading branch information
Showing
5 changed files
with
57 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,4 +323,7 @@ py_test( | |
":python_requires_in_a_package", | ||
":use_rule_with_dir_in_outs", | ||
], | ||
deps = [ | ||
"//python/runfiles", | ||
], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
load("@rules_python//python:defs.bzl", "py_test") | ||
load("@rules_python//python:py_test.bzl", "py_test") | ||
load("@rules_python//python/private:bzlmod_enabled.bzl", "BZLMOD_ENABLED") | ||
|
||
py_test( | ||
name = "runfiles_test", | ||
srcs = ["runfiles_test.py"], | ||
env = { | ||
"BZLMOD_ENABLED": "1" if BZLMOD_ENABLED else "0", | ||
}, | ||
deps = ["//python/runfiles"], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters