Fix iterating over depsets

Iterating over depsets will be prohibited soon, they need to be converted to lists explicitly using the `to_list()` method.

RELNOTES: None.
PiperOrigin-RevId: 251199631
diff --git a/src/test/java/com/google/devtools/build/lib/query2/aquery/ActionGraphProtoOutputFormatterCallbackTest.java b/src/test/java/com/google/devtools/build/lib/query2/aquery/ActionGraphProtoOutputFormatterCallbackTest.java
index 3409273..d54fa75 100644
--- a/src/test/java/com/google/devtools/build/lib/query2/aquery/ActionGraphProtoOutputFormatterCallbackTest.java
+++ b/src/test/java/com/google/devtools/build/lib/query2/aquery/ActionGraphProtoOutputFormatterCallbackTest.java
@@ -536,7 +536,7 @@
         "  if hasattr(ctx.rule.attr, 'srcs'):",
         "    out = ctx.actions.declare_file('out_jpl_{}'.format(target))",
         "    ctx.actions.run(",
-        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],",
+        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],",
         "      outputs = [out],",
         "      executable = 'dummy',",
         "      mnemonic = 'MyJplAspect'",
@@ -561,7 +561,7 @@
         "  if hasattr(ctx.rule.attr, 'srcs'):",
         "    out = ctx.actions.declare_file('out{}'.format(target))",
         "    ctx.actions.run(",
-        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],",
+        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],",
         "      outputs = [out],",
         "      executable = 'dummy',",
         "      mnemonic = 'MyAspect'",
@@ -651,7 +651,7 @@
         "  if hasattr(ctx.rule.attr, 'srcs'):",
         "    out = ctx.actions.declare_file('out_jpl_{}'.format(target))",
         "    ctx.actions.run(",
-        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],",
+        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],",
         "      outputs = [out],",
         "      executable = 'dummy',",
         "      mnemonic = 'MyJplAspect'",
@@ -736,7 +736,7 @@
         "  if hasattr(ctx.rule.attr, 'srcs'):",
         "    out = ctx.actions.declare_file(outfilename)",
         "    ctx.actions.run(",
-        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],",
+        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],",
         "      outputs = [out],",
         "      executable = 'dummy',",
         "      mnemonic = mnemonic",
@@ -845,7 +845,7 @@
         "  if hasattr(ctx.rule.attr, 'srcs'):",
         "    out = ctx.actions.declare_file('out_jpl_{}'.format(target))",
         "    ctx.actions.run(",
-        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],",
+        "      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],",
         "      outputs = [out],",
         "      executable = 'dummy',",
         "      mnemonic = 'MyJplAspect'",
diff --git a/src/test/shell/integration/aquery_test.sh b/src/test/shell/integration/aquery_test.sh
index 5e66e7d..24afc26 100755
--- a/src/test/shell/integration/aquery_test.sh
+++ b/src/test/shell/integration/aquery_test.sh
@@ -879,7 +879,7 @@
   if hasattr(ctx.rule.attr, 'srcs'):
     out = ctx.actions.declare_file('out_jpl_{}'.format(target))
     ctx.actions.run(
-      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],
+      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],
       outputs = [out],
       executable = 'dummy',
       mnemonic = 'MyIntermediateAspect'
@@ -909,7 +909,7 @@
   if hasattr(ctx.rule.attr, 'srcs'):
     out = ctx.actions.declare_file('out{}'.format(target))
     ctx.actions.run(
-      inputs = [f for src in ctx.rule.attr.srcs for f in src.files],
+      inputs = [f for src in ctx.rule.attr.srcs for f in src.files.to_list()],
       outputs = [out],
       executable = 'dummy',
       mnemonic = 'MyAspect'
diff --git a/src/test/shell/integration/build_event_stream_test.sh b/src/test/shell/integration/build_event_stream_test.sh
index f9a5219..f1a41a5 100755
--- a/src/test/shell/integration/build_event_stream_test.sh
+++ b/src/test/shell/integration/build_event_stream_test.sh
@@ -125,7 +125,7 @@
 EOF
 cat > failingaspect.bzl <<'EOF'
 def _failing_aspect_impl(target, ctx):
-    for orig_out in ctx.rule.attr.outs:
+    for orig_out in ctx.rule.attr.outs.to_list():
         aspect_out = ctx.actions.declare_file(orig_out.name + ".aspect")
         ctx.actions.run_shell(
             inputs = [],
diff --git a/src/test/shell/integration/discard_analysis_cache_test.sh b/src/test/shell/integration/discard_analysis_cache_test.sh
index 02f7f5c..ab9aff1 100755
--- a/src/test/shell/integration/discard_analysis_cache_test.sh
+++ b/src/test/shell/integration/discard_analysis_cache_test.sh
@@ -111,7 +111,7 @@
   cat > foo/simpleaspect.bzl <<'EOF' || fail "Couldn't write bzl file"
 def _simple_aspect_impl(target, ctx):
   result=[]
-  for orig_out in target.files:
+  for orig_out in target.files.to_list():
     aspect_out = ctx.actions.declare_file(orig_out.basename + ".aspect")
     ctx.actions.write(
         output=aspect_out,
diff --git a/src/test/shell/integration/discard_graph_edges_test.sh b/src/test/shell/integration/discard_graph_edges_test.sh
index 892d2e4..32bd972 100755
--- a/src/test/shell/integration/discard_graph_edges_test.sh
+++ b/src/test/shell/integration/discard_graph_edges_test.sh
@@ -130,7 +130,7 @@
   cat > foo/simpleaspect.bzl <<'EOF' || fail "Couldn't write bzl file"
 def _simple_aspect_impl(target, ctx):
   result=[]
-  for orig_out in target.files:
+  for orig_out in target.files.to_list():
     aspect_out = ctx.actions.declare_file(orig_out.basename + ".aspect")
     ctx.actions.write(
         output=aspect_out,
@@ -303,11 +303,11 @@
   files_to_build = depset(ctx.outputs.outs)
   intemediate_outputs = [ctx.actions.declare_file("bar")]
   intermediate_cmd = "cat %s > %s" % (ctx.attr.name, intemediate_outputs[0].path)
-  action_cmd = "touch " + list(files_to_build)[0].path
+  action_cmd = "touch " + files_to_build.to_list()[0].path
   ctx.actions.run_shell(outputs=list(intemediate_outputs),
                         command=intermediate_cmd)
   ctx.actions.run_shell(inputs=list(intemediate_outputs),
-                        outputs=list(files_to_build),
+                        outputs=files_to_build.to_list(),
                         command=action_cmd)
   struct(files=files_to_build,
          data_runfiles=ctx.runfiles(transitive_files=files_to_build))
diff --git a/src/test/shell/integration/skylark_dependency_pruning_test.sh b/src/test/shell/integration/skylark_dependency_pruning_test.sh
index e8a29e6..996589e 100755
--- a/src/test/shell/integration/skylark_dependency_pruning_test.sh
+++ b/src/test/shell/integration/skylark_dependency_pruning_test.sh
@@ -55,7 +55,7 @@
     arguments = []
     arguments += [output.path]
     arguments += [unused_inputs_list.path]
-    for input in inputs:
+    for input in inputs.to_list():
         arguments += [input.path]
     ctx.actions.run(
         inputs = inputs,