11load ("@rules_testing//lib:analysis_test.bzl" , "analysis_test" )
2+ load ("@rules_testing//lib:truth.bzl" , "matching" )
23load ("//src/test/starlark:case.bzl" , "suite" )
34load (":arrangement.bzl" , "arrange" )
4- load (":util.bzl" , "abi_jar_of" , "values_for_flag_of" )
5+ load (":util.bzl" , "abi_jar_of" , "basename_of" , " values_for_flag_of" )
56
67def _classpath_assertions_ (env , target ):
78 action = env .expect .that_target (target ).action_named (env .ctx .attr .on_action_mnemonic )
8- action .inputs ().contains_at_least ([abi_jar_of (f .short_path ) for f in env .ctx .files .want_inputs if not f .short_path .endswith ("jdeps" )])
99
10- values_for_flag_of (action , "--classpath" ).contains_at_least ([abi_jar_of (f .path ) for f in env .ctx .files .want_classpath if not f .short_path .endswith ("jdeps" )])
11- values_for_flag_of (action , "--classpath" ).contains_none_of ([f .path for f in env .ctx .files .not_want_classpath ])
10+ # Use basename comparison to avoid configuration transition path issues
11+ # When config_settings is used, targets are built in a transitioned configuration
12+ # with a different output path (e.g., k8-fastbuild-ST-xxx instead of k8-fastbuild)
13+
14+ # For inputs (File objects), use file_basename_equals matcher
15+ want_input_matchers = [
16+ matching .file_basename_equals (abi_jar_of (f .basename ))
17+ for f in env .ctx .files .want_inputs
18+ if not f .basename .endswith ("jdeps" )
19+ ]
20+ action .inputs ().contains_at_least_predicates (want_input_matchers )
21+
22+ # For classpath (string paths), use str_endswith matcher to match by basename
23+ want_classpath_basenames = [abi_jar_of (f .basename ) for f in env .ctx .files .want_classpath if not f .basename .endswith ("jdeps" )]
24+ values_for_flag_of (action , "--classpath" ).transform (desc = "basenames" , map_each = basename_of ).contains_at_least (want_classpath_basenames )
25+
26+ not_want_basenames = [f .basename for f in env .ctx .files .not_want_classpath ]
27+ values_for_flag_of (action , "--classpath" ).transform (desc = "basenames" , map_each = basename_of ).contains_none_of (not_want_basenames )
1228
1329def _test_classpath_experimental_prune_transitive_deps_False (test ):
1430 (dependency_a_trans_dep_jar , dependency_a , main_target_library ) = arrange (test )
@@ -22,27 +38,27 @@ def _test_classpath_experimental_prune_transitive_deps_False(test):
2238 str (Label ("@rules_kotlin//kotlin/settings:experimental_strict_associate_dependencies" )): False ,
2339 },
2440 attr_values = {
41+ "not_want_classpath" : [],
2542 "on_action_mnemonic" : "KotlinCompile" ,
26- "want_inputs " : [
43+ "want_classpath " : [
2744 dependency_a ,
2845 dependency_a_trans_dep_jar ,
2946 ],
3047 "want_direct_dependencies" : [
3148 dependency_a ,
3249 dependency_a_trans_dep_jar ,
3350 ],
34- "want_classpath " : [
51+ "want_inputs " : [
3552 dependency_a ,
3653 dependency_a_trans_dep_jar ,
3754 ],
38- "not_want_classpath" : [],
3955 },
4056 attrs = {
57+ "not_want_classpath" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
4158 "on_action_mnemonic" : attr .string (),
42- "want_inputs" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
43- "want_direct_dependencies" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
4459 "want_classpath" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
45- "not_want_classpath" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
60+ "want_direct_dependencies" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
61+ "want_inputs" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
4662 },
4763 )
4864
@@ -58,26 +74,26 @@ def _test_classpath_experimental_prune_transitive_deps_True(test):
5874 str (Label ("@rules_kotlin//kotlin/settings:experimental_strict_associate_dependencies" )): False ,
5975 },
6076 attr_values = {
77+ "not_want_classpath" : [
78+ dependency_a_trans_dep_jar ,
79+ ],
6180 "on_action_mnemonic" : "KotlinCompile" ,
62- "want_inputs " : [
81+ "want_classpath " : [
6382 dependency_a ,
6483 ],
6584 "want_direct_dependencies" : [
6685 dependency_a ,
6786 ],
68- "want_classpath " : [
87+ "want_inputs " : [
6988 dependency_a ,
7089 ],
71- "not_want_classpath" : [
72- dependency_a_trans_dep_jar ,
73- ],
7490 },
7591 attrs = {
92+ "not_want_classpath" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
7693 "on_action_mnemonic" : attr .string (),
77- "want_inputs" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
78- "want_direct_dependencies" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
7994 "want_classpath" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
80- "not_want_classpath" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
95+ "want_direct_dependencies" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
96+ "want_inputs" : attr .label_list (providers = [DefaultInfo ], allow_files = True ),
8197 },
8298 )
8399
0 commit comments