Skip to content

Commit 07d530b

Browse files
authored
test(pystar): run pystar under Windows and Mac (#1547)
This is to have better test coverage. Only workspace for them is used because of limited CI slots. This also fixes the test_basic_windows test. The `--build_python_zip` flag built into Bazel has a different default depending on the host OS (not target platform): true for windows, and false otherwise. Updated the test to force the flag value for reliable behavior between platforms. Work towards #1069
1 parent b347a29 commit 07d530b

File tree

2 files changed

+31
-23
lines changed

2 files changed

+31
-23
lines changed

.bazelci/presubmit.yml

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,17 @@ buildifier:
6363
- //tests:version_3_8_test
6464
- //tests:version_3_9_test
6565
- //tests:version_default_test
66+
.pystar_base: &pystar_base
67+
# TODO: Change to "7.x" once Bazel 7 is available
68+
# https://github.com/bazelbuild/bazel/commit/f3aafea59ae021c6a12086cb2cd34c5fa782faf1
69+
# is available in rolling.
70+
bazel: "last_rc"
71+
environment:
72+
RULES_PYTHON_ENABLE_PYSTAR: "1"
73+
test_flags:
74+
# The doc check tests fail because the Starlark implementation makes the
75+
# PyInfo and PyRuntimeInfo symbols become documented.
76+
- "--test_tag_filters=-integration-test,-doc_check_test"
6677
tasks:
6778
gazelle_extension_min:
6879
<<: *minimum_supported_version
@@ -94,35 +105,27 @@ tasks:
94105
<<: *reusable_config
95106
name: Default test on Ubuntu
96107
platform: ubuntu2004
97-
ubuntu_bazel_rolling:
108+
ubuntu_pystar_workspace:
98109
<<: *reusable_config
110+
<<: *pystar_base
99111
name: "Default test: Ubuntu, Pystar, workspace"
100112
platform: ubuntu2004
101-
# TODO: Change to "rolling" once
102-
# https://github.com/bazelbuild/bazel/commit/f3aafea59ae021c6a12086cb2cd34c5fa782faf1
103-
# is available in rolling.
104-
bazel: "last_green"
105-
environment:
106-
RULES_PYTHON_ENABLE_PYSTAR: "1"
107-
test_flags:
108-
# The doc check tests fail because the Starlark implementation makes the
109-
# PyInfo and PyRuntimeInfo symbols become documented.
110-
- "--test_tag_filters=-integration-test,-doc_check_test"
111-
ubuntu_bazel_rolling_bzlmod:
113+
ubuntu_pystar_bzlmod:
112114
<<: *reusable_config
113115
<<: *common_bzlmod_flags
116+
<<: *pystar_base
114117
name: "Default test: Ubuntu, Pystar, bzlmod"
115118
platform: ubuntu2004
116-
# TODO: Change to "rolling" once
117-
# https://github.com/bazelbuild/bazel/commit/f3aafea59ae021c6a12086cb2cd34c5fa782faf1
118-
# is available in rolling.
119-
bazel: "last_green"
120-
environment:
121-
RULES_PYTHON_ENABLE_PYSTAR: "1"
122-
test_flags:
123-
# The doc check tests fail because the Starlark implementation makes the
124-
# PyInfo and PyRuntimeInfo symbols become documented.
125-
- "--test_tag_filters=-integration-test,-doc_check_test"
119+
mac_pystar_workspace:
120+
<<: *reusable_config
121+
<<: *pystar_base
122+
name: "Default test: Mac, Pystar, workspace"
123+
platform: macos
124+
windows_pystar_workspace:
125+
<<: *reusable_config
126+
<<: *pystar_base
127+
name: "Default test: Mac, Pystar, workspace"
128+
platform: windows
126129

127130
debian:
128131
<<: *reusable_config

tests/base_rules/py_executable_base_tests.bzl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@ def _test_basic_windows(name, config):
3939
impl = _test_basic_windows_impl,
4040
target = name + "_subject",
4141
config_settings = {
42+
# NOTE: The default for this flag is based on the Bazel host OS, not
43+
# the target platform. For windows, it defaults to true, so force
44+
# it to that to match behavior when this test runs on other
45+
# platforms.
46+
"//command_line_option:build_python_zip": "true",
4247
"//command_line_option:cpu": "windows_x86_64",
4348
"//command_line_option:crosstool_top": Label("//tests/cc:cc_toolchain_suite"),
4449
"//command_line_option:extra_toolchains": [str(Label("//tests/cc:all"))],
@@ -51,7 +56,7 @@ def _test_basic_windows_impl(env, target):
5156
target = env.expect.that_target(target)
5257
target.executable().path().contains(".exe")
5358
target.runfiles().contains_predicate(matching.str_endswith(
54-
target.meta.format_str("/{name}"),
59+
target.meta.format_str("/{name}.zip"),
5560
))
5661
target.runfiles().contains_predicate(matching.str_endswith(
5762
target.meta.format_str("/{name}.exe"),

0 commit comments

Comments
 (0)