@@ -5,26 +5,49 @@ 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 ] == "external" :
16
+ return "(source) " + file .short_path
17
+ if segments [0 ] == "bazel-out" :
18
+ # not exactly reliable, but the current test rules perform several transitions making it
19
+ # difficult to validate if a file is actually where it should be.
20
+ if "exec" in segments [1 ]:
21
+ return "(exec) " + file .short_path
22
+ return "(target) " + file .short_path
23
+
8
24
def _action (env , got ):
9
25
got_target = env .expect .that_target (got )
10
26
11
- inputs = []
27
+ want_inputs = {}
12
28
for i in env .ctx .attr .exec_inputs :
13
29
if JavaInfo in i :
14
30
for jo in i [JavaInfo ].java_outputs :
15
- inputs . append (jo .compile_jar )
31
+ want_inputs [ _normalize_path_with_cfg (jo .compile_jar )] = True
16
32
else :
17
- inputs .extend (i [DefaultInfo ].files .to_list ())
33
+ for f in i [DefaultInfo ].files .to_list ():
34
+ want_inputs [_normalize_path_with_cfg (f )] = True
18
35
for i in env .ctx .attr .target_inputs :
19
36
if JavaInfo in i :
20
37
for jo in i [JavaInfo ].java_outputs :
21
- inputs . append (jo .compile_jar )
38
+ want_inputs [ _normalize_path_with_cfg (jo .compile_jar )] = True
22
39
else :
23
- inputs .extend (i [DefaultInfo ].files .to_list ())
40
+ for f in i [DefaultInfo ].files .to_list ():
41
+ want_inputs [_normalize_path_with_cfg (f )] = True
24
42
25
43
compile = got_target .action_named (env .ctx .attr .mnemonic )
26
44
27
- compile .contains_at_least_inputs (inputs )
45
+ got_inputs = {
46
+ _normalize_path_with_cfg (f ): True
47
+ for f in compile .actual .inputs .to_list ()
48
+ }
49
+
50
+ env .expect .that_collection (got_inputs .keys ()).contains_at_least (want_inputs .keys ())
28
51
29
52
got_target .runfiles ().contains_at_least ([
30
53
"/" .join ((env .ctx .workspace_name , f .short_path ))
0 commit comments