Commit dff982e
committed
fix(test): make
Bazel 9 flipped `--incompatible_strict_action_env` to `true` by default
(bazelbuild/bazel#27670), which means tests no longer inherit `PATH`
from the host environment. This breaks subprocess calls that rely on
`PATH` lookup:
```
==================== Test output for //distro:packaging_test:
E.
======================================================================
ERROR: testBuild (__main__.PackagingTest.testBuild)
----------------------------------------------------------------------
Traceback (most recent call last):
[...]
build_result = subprocess.check_output(['bazel', 'build', '--enable_workspace', ':dummy_tar'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]
FileNotFoundError: [Errno 2] No such file or directory: 'bazel'
```
This change therefore adds `env_inherit = ["PATH"]` to that very test,
which matches the behavior of earlier Bazel versions and is consistent
with the presence of a "noci" tag.
Additionally, Bazel 9 removed `WORKSPACE` support entirely
(bazelbuild/bazel#26131), requiring `bzlmod` with `MODULE.bazel`:
```
==================== Test output for //distro:packaging_test:
[...]
WARNING: --enable_bzlmod is set, but no MODULE.bazel file was found at the workspace root. Bazel will create an empty MODULE.bazel file. Please consider migrating your external dependencies from WORKSPACE to MODULE.bazel. For more details, please refer to bazelbuild/bazel#18958.
[...]
ERROR: error loading package '': Unable to find package for @@[unknown repo 'not_named_rules_pkg' requested from @@]//pkg:tar.bzl: The repository '@@[unknown repo 'not_named_rules_pkg' requested from @@]' could not be resolved: No repository visible as '@not_named_rules_pkg' from main repository.
[...]
ERROR: Build did NOT complete successfully
E.
======================================================================
ERROR: testBuild (__main__.PackagingTest.testBuild)
----------------------------------------------------------------------
[...]
build_result = subprocess.check_output(['bazel', 'build'] + bazel_flags + [':dummy_tar'])
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[...]
subprocess.CalledProcessError: Command '['bazel', 'build', '--enable_workspace', ':dummy_tar']' returned non-zero exit status 1.
```
The test now detects the Bazel version at runtime and generates the
appropriate setup:
- Bazel 9+: `MODULE.bazel`, with `bazel_dep` and `archive_override`,
- earlier versions, as before: `WORKSPACE`, with `http_archive` and
`--enable_workspace` flag.
For good measure, the change also addresses a leftover TODO by replacing
the `tar` subprocess invocation with pure Python code.packaging_test work with Bazel 91 parent e93d65a commit dff982e
2 files changed
Lines changed: 37 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
101 | 102 | | |
102 | 103 | | |
103 | 104 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
| |||
57 | 58 | | |
58 | 59 | | |
59 | 60 | | |
60 | | - | |
| 61 | + | |
| 62 | + | |
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
64 | 66 | | |
65 | 67 | | |
66 | 68 | | |
67 | 69 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
72 | | - | |
73 | | - | |
74 | | - | |
75 | | - | |
76 | | - | |
| 70 | + | |
| 71 | + | |
77 | 72 | | |
78 | | - | |
79 | | - | |
| 73 | + | |
| 74 | + | |
80 | 75 | | |
81 | 76 | | |
82 | 77 | | |
| |||
91 | 86 | | |
92 | 87 | | |
93 | 88 | | |
94 | | - | |
| 89 | + | |
95 | 90 | | |
96 | 91 | | |
97 | 92 | | |
98 | 93 | | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
103 | 122 | | |
104 | 123 | | |
105 | 124 | | |
| |||
0 commit comments