@@ -342,28 +342,28 @@ 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_py_runtime_info_provided (name , config ):
345+ def  _test_no_srcs (name , config ):
346346    rt_util .helper_target (
347347        config .rule ,
348348        name  =  name  +  "_subject" ,
349-         srcs  =  [ name   +   "_subject.py" ] ,
349+         main_module  =  "dummy" ,
350350    )
351351    analysis_test (
352352        name  =  name ,
353-         impl  =  _test_py_runtime_info_provided_impl ,
353+         impl  =  _test_no_srcs_impl ,
354354        target  =  name  +  "_subject" ,
355+         config_settings  =  {
356+             "//command_line_option:platforms" : [LINUX_X86_64 ],
357+         },
358+         expect_failure  =  True ,
355359    )
356360
357- def  _test_py_runtime_info_provided_impl (env , target ):
358-     # Make sure that the rules_python loaded symbol is provided. 
359-     env .expect .that_target (target ).has_provider (RulesPythonPyRuntimeInfo )
360- 
361-     if  BuiltinPyRuntimeInfo  !=  None :
362-         # For compatibility during the transition, the builtin PyRuntimeInfo should 
363-         # also be provided. 
364-         env .expect .that_target (target ).has_provider (BuiltinPyRuntimeInfo )
361+ def  _test_no_srcs_impl (env , target ):
362+     env .expect .that_target (target ).failures ().contains_predicate (
363+         matching .str_matches ("mandatory*srcs" ),
364+     )
365365
366- _tests .append (_test_py_runtime_info_provided )
366+ _tests .append (_test_no_srcs )
367367
368368def  _test_no_srcs_script_bootstrap (name , config ):
369369    rt_util .helper_target (
@@ -388,49 +388,28 @@ def _test_no_srcs_script_bootstrap_impl(env, target):
388388
389389_tests .append (_test_no_srcs_script_bootstrap )
390390
391- def  _test_no_srcs (name , config ):
391+ def  _test_py_runtime_info_provided (name , config ):
392392    rt_util .helper_target (
393393        config .rule ,
394394        name  =  name  +  "_subject" ,
395-         main_module  =  "dummy" ,
395+         srcs  =  [ name   +   "_subject.py" ] ,
396396    )
397397    analysis_test (
398398        name  =  name ,
399-         impl  =  _test_no_srcs_impl ,
399+         impl  =  _test_py_runtime_info_provided_impl ,
400400        target  =  name  +  "_subject" ,
401-         config_settings  =  {
402-             "//command_line_option:platforms" : [LINUX_X86_64 ],
403-         },
404-         expect_failure  =  True ,
405401    )
406402
407- def  _test_no_srcs_impl (_ , __ ):
408-     pass 
403+ def  _test_py_runtime_info_provided_impl (env , target ):
404+     # Make sure that the rules_python loaded symbol is provided. 
405+     env .expect .that_target (target ).has_provider (RulesPythonPyRuntimeInfo )
409406
410- _tests .append (_test_no_srcs )
407+     if  BuiltinPyRuntimeInfo  !=  None :
408+         # For compatibility during the transition, the builtin PyRuntimeInfo should 
409+         # also be provided. 
410+         env .expect .that_target (target ).has_provider (BuiltinPyRuntimeInfo )
411411
412- # Can't test this -- mandatory validation happens before analysis test 
413- # can intercept it 
414- # TODO(#1069): Once re-implemented in Starlark, modify rule logic to make this 
415- # testable. 
416- # def _test_srcs_is_mandatory(name, config): 
417- #     rt_util.helper_target( 
418- #         config.rule, 
419- #         name = name + "_subject", 
420- #     ) 
421- #     analysis_test( 
422- #         name = name, 
423- #         impl = _test_srcs_is_mandatory, 
424- #         target = name + "_subject", 
425- #         expect_failure = True, 
426- #     ) 
427- # 
428- # _tests.append(_test_srcs_is_mandatory) 
429- # 
430- # def _test_srcs_is_mandatory_impl(env, target): 
431- #     env.expect.that_target(target).failures().contains_predicate( 
432- #         matching.str_matches("mandatory*srcs"), 
433- #     ) 
412+ _tests .append (_test_py_runtime_info_provided )
434413
435414# ===== 
436415# You were gonna add a test at the end, weren't you? 
0 commit comments