@@ -24,7 +24,7 @@ load("//python/private:util.bzl", "IS_BAZEL_7_OR_HIGHER") # buildifier: disable
2424load ("//tests/base_rules:base_tests.bzl" , "create_base_tests" )
2525load ("//tests/base_rules:util.bzl" , "WINDOWS_ATTR" , pt_util = "util" )
2626load ("//tests/support:py_executable_info_subject.bzl" , "PyExecutableInfoSubject" )
27- load ("//tests/support:support.bzl" , "CC_TOOLCHAIN" , "CROSSTOOL_TOP" , "LINUX_X86_64" , "WINDOWS_X86_64" )
27+ load ("//tests/support:support.bzl" , "BOOTSTRAP_IMPL" , " CC_TOOLCHAIN" , "CROSSTOOL_TOP" , "LINUX_X86_64" , "WINDOWS_X86_64" )
2828
2929_tests = []
3030
@@ -342,6 +342,53 @@ def _test_name_cannot_end_in_py_impl(env, target):
342342 matching .str_matches ("name must not end in*.py" ),
343343 )
344344
345+ def _test_main_module_bootstrap_system_python (name , config ):
346+ rt_util .helper_target (
347+ config .rule ,
348+ name = name + "_subject" ,
349+ main_module = "dummy" ,
350+ )
351+ analysis_test (
352+ name = name ,
353+ impl = _test_main_module_bootstrap_system_python_impl ,
354+ target = name + "_subject" ,
355+ config_settings = {
356+ BOOTSTRAP_IMPL : "system_python" ,
357+ "//command_line_option:platforms" : [LINUX_X86_64 ],
358+ },
359+ expect_failure = True ,
360+ )
361+
362+ def _test_main_module_bootstrap_system_python_impl (env , target ):
363+ env .expect .that_target (target ).failures ().contains_predicate (
364+ matching .str_matches ("mandatory*srcs" ),
365+ )
366+
367+ _tests .append (_test_main_module_bootstrap_system_python )
368+
369+ def _test_main_module_bootstrap_script (name , config ):
370+ rt_util .helper_target (
371+ config .rule ,
372+ name = name + "_subject" ,
373+ main_module = "dummy" ,
374+ )
375+ analysis_test (
376+ name = name ,
377+ impl = _test_main_module_bootstrap_script_impl ,
378+ target = name + "_subject" ,
379+ config_settings = {
380+ BOOTSTRAP_IMPL : "script" ,
381+ "//command_line_option:platforms" : [LINUX_X86_64 ],
382+ },
383+ )
384+
385+ def _test_main_module_bootstrap_script_impl (env , target ):
386+ env .expect .that_target (target ).default_outputs ().contains (
387+ "{package}/{test_name}_subject" ,
388+ )
389+
390+ _tests .append (_test_main_module_bootstrap_script )
391+
345392def _test_py_runtime_info_provided (name , config ):
346393 rt_util .helper_target (
347394 config .rule ,
@@ -365,29 +412,6 @@ def _test_py_runtime_info_provided_impl(env, target):
365412
366413_tests .append (_test_py_runtime_info_provided )
367414
368- # Can't test this -- mandatory validation happens before analysis test
369- # can intercept it
370- # TODO(#1069): Once re-implemented in Starlark, modify rule logic to make this
371- # testable.
372- # def _test_srcs_is_mandatory(name, config):
373- # rt_util.helper_target(
374- # config.rule,
375- # name = name + "_subject",
376- # )
377- # analysis_test(
378- # name = name,
379- # impl = _test_srcs_is_mandatory,
380- # target = name + "_subject",
381- # expect_failure = True,
382- # )
383- #
384- # _tests.append(_test_srcs_is_mandatory)
385- #
386- # def _test_srcs_is_mandatory_impl(env, target):
387- # env.expect.that_target(target).failures().contains_predicate(
388- # matching.str_matches("mandatory*srcs"),
389- # )
390-
391415# =====
392416# You were gonna add a test at the end, weren't you?
393417# Nope. Please keep them sorted; put it in its alphabetical location.
0 commit comments