|
13 | 13 | # limitations under the License.
|
14 | 14 | """Tests common to py_binary and py_test (executable rules)."""
|
15 | 15 |
|
| 16 | +load("@rules_python_internal//:rules_python_config.bzl", rp_config = "config") |
16 | 17 | load("@rules_testing//lib:analysis_test.bzl", "analysis_test")
|
17 | 18 | load("@rules_testing//lib:truth.bzl", "matching")
|
18 | 19 | load("@rules_testing//lib:util.bzl", rt_util = "util")
|
19 | 20 | load("//tests/base_rules:base_tests.bzl", "create_base_tests")
|
20 | 21 | load("//tests/base_rules:util.bzl", "WINDOWS_ATTR", pt_util = "util")
|
| 22 | +load("//tests/support:test_platforms.bzl", "WINDOWS") |
21 | 23 |
|
22 | 24 | _tests = []
|
23 | 25 |
|
| 26 | +def _test_basic_windows(name, config): |
| 27 | + if rp_config.enable_pystar: |
| 28 | + target_compatible_with = [] |
| 29 | + else: |
| 30 | + target_compatible_with = ["@platforms//:incompatible"] |
| 31 | + rt_util.helper_target( |
| 32 | + config.rule, |
| 33 | + name = name + "_subject", |
| 34 | + srcs = ["main.py"], |
| 35 | + main = "main.py", |
| 36 | + ) |
| 37 | + analysis_test( |
| 38 | + name = name, |
| 39 | + impl = _test_basic_windows_impl, |
| 40 | + target = name + "_subject", |
| 41 | + config_settings = { |
| 42 | + "//command_line_option:cpu": "windows_x86_64", |
| 43 | + "//command_line_option:crosstool_top": Label("//tests/cc:cc_toolchain_suite"), |
| 44 | + "//command_line_option:extra_toolchains": [str(Label("//tests/cc:all"))], |
| 45 | + "//command_line_option:platforms": [WINDOWS], |
| 46 | + }, |
| 47 | + attr_values = {"target_compatible_with": target_compatible_with}, |
| 48 | + ) |
| 49 | + |
| 50 | +def _test_basic_windows_impl(env, target): |
| 51 | + target = env.expect.that_target(target) |
| 52 | + target.executable().path().contains(".exe") |
| 53 | + target.runfiles().contains_predicate(matching.str_endswith( |
| 54 | + target.meta.format_str("/{name}"), |
| 55 | + )) |
| 56 | + target.runfiles().contains_predicate(matching.str_endswith( |
| 57 | + target.meta.format_str("/{name}.exe"), |
| 58 | + )) |
| 59 | + |
| 60 | +_tests.append(_test_basic_windows) |
| 61 | + |
24 | 62 | def _test_executable_in_runfiles(name, config):
|
25 | 63 | rt_util.helper_target(
|
26 | 64 | config.rule,
|
|
0 commit comments