Use text blocks for test inputs (6/N)

PiperOrigin-RevId: 619607633
Change-Id: If3b4ccb90e26ff80dc22f31a9590e79c4f65698d
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java b/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java
index d8ac6c3..7866b61 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/CircularDependencyTest.java
@@ -146,7 +146,18 @@
   public void testTwoRuleCycle2() throws Exception {
     reporter.removeHandler(failFastHandler); // expect errors
     scratch.file(
-        "x/BUILD", "java_library(name='x', deps=['y'])", "java_library(name='y', deps=['x'])");
+        "x/BUILD",
+        """
+        java_library(
+            name = "x",
+            deps = ["y"],
+        )
+
+        java_library(
+            name = "y",
+            deps = ["x"],
+        )
+        """);
     getConfiguredTarget("//x");
     assertContainsEvent("in java_library rule //x:x: cycle in dependency graph");
   }
@@ -185,8 +196,22 @@
     reporter.removeHandler(failFastHandler); // expect errors
     scratch.file(
         "x/BUILD",
-        "genrule(name='b', srcs=['c'], tools=['c'], outs=['b.out'], cmd=':')",
-        "genrule(name='c', srcs=['b.out'], outs=[], cmd=':')");
+        """
+        genrule(
+            name = "b",
+            srcs = ["c"],
+            outs = ["b.out"],
+            cmd = ":",
+            tools = ["c"],
+        )
+
+        genrule(
+            name = "c",
+            srcs = ["b.out"],
+            outs = [],
+            cmd = ":",
+        )
+        """);
     getConfiguredTarget("//x:b"); // doesn't crash!
     assertContainsEvent("cycle in dependency graph");
   }
@@ -196,31 +221,51 @@
     reporter.removeHandler(failFastHandler);
     scratch.file(
         "x/BUILD",
-        "load('//x:x.bzl', 'aspected', 'plain')",
-        // Using data= makes the dependency graph clearer because then the aspect does not propagate
-        // from aspectdep through a to b (and c)
-        "plain(name = 'a', noaspect_deps = [':b'])",
-        "aspected(name = 'b', aspect_deps = ['c'])",
-        "plain(name = 'c')",
-        "plain(name = 'aspectdep', aspect_deps = ['a'])");
+        """
+        load("//x:x.bzl", "aspected", "plain")
+
+        # Using data= makes the dependency graph clearer because then the aspect does not propagate
+        # from aspectdep through a to b (and c)
+        plain(
+            name = "a",
+            noaspect_deps = [":b"],
+        )
+
+        aspected(
+            name = "b",
+            aspect_deps = ["c"],
+        )
+
+        plain(name = "c")
+
+        plain(
+            name = "aspectdep",
+            aspect_deps = ["a"],
+        )
+        """);
 
     scratch.file(
         "x/x.bzl",
-        "def _impl(ctx):",
-        "    return []",
-        "",
-        "rule_aspect = aspect(",
-        "    implementation = _impl,",
-        "    attr_aspects = ['aspect_deps'],",
-        "    attrs = { '_implicit': attr.label(default = Label('//x:aspectdep')) })",
-        "",
-        "plain = rule(",
-        "    implementation = _impl,",
-        "    attrs = { 'aspect_deps': attr.label_list(), 'noaspect_deps': attr.label_list() })",
-        "",
-        "aspected = rule(",
-        "    implementation = _impl,",
-        "    attrs = { 'aspect_deps': attr.label_list(aspects = [rule_aspect]) })");
+        """
+        def _impl(ctx):
+            return []
+
+        rule_aspect = aspect(
+            implementation = _impl,
+            attr_aspects = ["aspect_deps"],
+            attrs = {"_implicit": attr.label(default = Label("//x:aspectdep"))},
+        )
+
+        plain = rule(
+            implementation = _impl,
+            attrs = {"aspect_deps": attr.label_list(), "noaspect_deps": attr.label_list()},
+        )
+
+        aspected = rule(
+            implementation = _impl,
+            attrs = {"aspect_deps": attr.label_list(aspects = [rule_aspect])},
+        )
+        """);
 
     getConfiguredTarget("//x:a");
     assertContainsEvent("cycle in dependency graph");
@@ -324,9 +369,22 @@
     scratch.file("a/BUILD", "normal_dep(name = 'a', dep = '//b')");
     scratch.file(
         "b/BUILD",
-        "config_setting(name = 'cycle', define_values = {'CYCLE_ON': 'yes'})",
-        "normal_dep(name = 'stop')",
-        "normal_dep(name = 'b', dep = select({':cycle': '//c', '//conditions:default': ':stop'}))");
+        """
+        config_setting(
+            name = "cycle",
+            define_values = {"CYCLE_ON": "yes"},
+        )
+
+        normal_dep(name = "stop")
+
+        normal_dep(
+            name = "b",
+            dep = select({
+                ":cycle": "//c",
+                "//conditions:default": ":stop",
+            }),
+        )
+        """);
     scratch.file("c/BUILD", "define_clearer(name = 'c', dep = '//a', define = 'CYCLE_ON')");
 
     useConfiguration("--define=CYCLE_ON=yes");
@@ -338,9 +396,13 @@
   public void testInvalidVisibility() throws Exception {
     scratch.file(
         "a/BUILD",
-        "cc_library(name='rule1',",
-        "           deps=['//b:rule2'],",
-        "           visibility=['//b:rule2'])");
+        """
+        cc_library(
+            name = "rule1",
+            visibility = ["//b:rule2"],
+            deps = ["//b:rule2"],
+        )
+        """);
     scratch.file("b/BUILD", "cc_library(name='rule2')");
 
     AssertionError expected =
@@ -355,19 +417,33 @@
   public void testInvalidVisibilityWithSelect() throws Exception {
     scratch.file(
         "a/BUILD",
-        "cc_library(name='rule1',",
-        "           deps=['//b:rule2'],",
-        "           visibility=['//b:rule2'])");
+        """
+        cc_library(
+            name = "rule1",
+            visibility = ["//b:rule2"],
+            deps = ["//b:rule2"],
+        )
+        """);
     scratch.file(
         "b/BUILD",
-        "config_setting(name = 'fastbuild', values = {'compilation_mode': 'fastbuild'})",
-        "cc_library(name='rule2',",
-        "           hdrs = select({",
-        "              ':fastbuild': glob([",
-        "                   '*.h',",
-        "               ], allow_empty = True),",
-        "           }),",
-        ")");
+        """
+        config_setting(
+            name = "fastbuild",
+            values = {"compilation_mode": "fastbuild"},
+        )
+
+        cc_library(
+            name = "rule2",
+            hdrs = select({
+                ":fastbuild": glob(
+                    [
+                        "*.h",
+                    ],
+                    allow_empty = True,
+                ),
+            }),
+        )
+        """);
 
     AssertionError expected =
         assertThrows(AssertionError.class, () -> getConfiguredTarget("//a:rule1"));