@@ -5,26 +5,51 @@ load("//kotlin/compiler:kapt.bzl", "kapt_compiler_plugin")
5
5
load ("//src/test/starlark:case.bzl" , "Want" , "suite" )
6
6
load ("//src/test/starlark:truth.bzl" , "flags_and_values_of" )
7
7
8
+ def _normalize_path_with_cfg (file ):
9
+ """Attempts to normalize the file to standard configs.
10
+
11
+ This turns out to be necessary due to multiple transitions with testing.analysis_test.
12
+ """
13
+ prefix = file .path .removesuffix (file .short_path )
14
+ segments = prefix .split ("/" )
15
+ if segments [0 ] == "bazel-out" :
16
+ # not exactly reliable, but the current test rules perform several transitions making it
17
+ # difficult to validate if a file is actually where it should be.
18
+ if "exec" in segments [1 ]:
19
+ return "(exec) " + file .short_path
20
+ return "(target) " + file .short_path
21
+ if file .is_source ():
22
+ return "(source) " + file .short_path
23
+
24
+ return file .path
25
+
8
26
def _action (env , got ):
9
27
got_target = env .expect .that_target (got )
10
28
11
- inputs = []
29
+ want_inputs = {}
12
30
for i in env .ctx .attr .exec_inputs :
13
31
if JavaInfo in i :
14
32
for jo in i [JavaInfo ].java_outputs :
15
- inputs . append (jo .compile_jar )
33
+ want_inputs [ _normalize_path_with_cfg (jo .compile_jar )] = True
16
34
else :
17
- inputs .extend (i [DefaultInfo ].files .to_list ())
35
+ for f in i [DefaultInfo ].files .to_list ():
36
+ want_inputs [_normalize_path_with_cfg (f )] = True
18
37
for i in env .ctx .attr .target_inputs :
19
38
if JavaInfo in i :
20
39
for jo in i [JavaInfo ].java_outputs :
21
- inputs . append (jo .compile_jar )
40
+ want_inputs [ _normalize_path_with_cfg (jo .compile_jar )] = True
22
41
else :
23
- inputs .extend (i [DefaultInfo ].files .to_list ())
42
+ for f in i [DefaultInfo ].files .to_list ():
43
+ want_inputs [_normalize_path_with_cfg (f )] = True
24
44
25
45
compile = got_target .action_named (env .ctx .attr .mnemonic )
26
46
27
- compile .contains_at_least_inputs (inputs )
47
+ got_inputs = {
48
+ _normalize_path_with_cfg (f ): True
49
+ for f in compile .actual .inputs .to_list ()
50
+ }
51
+
52
+ env .expect .that_collection (got_inputs .keys ()).contains_at_least (want_inputs .keys ())
28
53
29
54
got_target .runfiles ().contains_at_least ([
30
55
"/" .join ((env .ctx .workspace_name , f .short_path ))
0 commit comments