diff options
author | 2015-04-27 09:52:33 +0000 | |
---|---|---|
committer | 2015-04-27 18:51:44 +0000 | |
commit | 01f1b465b67b3d623be9a851bbf10782b40e277e (patch) | |
tree | d8625a7959b10f3e23eb3dd6fb396e71ff5c5190 /src/test | |
parent | 7a9721440a1adfa6757b946e87d9865a55b26368 (diff) |
Inline FoundationTestCase.scratchFile.
--
MOS_MIGRATED_REVID=92128998
Diffstat (limited to 'src/test')
11 files changed, 55 insertions, 64 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java index c8fcf964fc..4861ace11d 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/AspectTest.java @@ -60,7 +60,7 @@ public class AspectTest extends AnalysisTestCase { } private void pkg(String name, String... contents) throws Exception { - scratchFile("" + name + "/BUILD", contents); + scratch.file("" + name + "/BUILD", contents); } @Test diff --git a/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java b/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java index 1f24cf40af..78e9ce1cfc 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/DependencyResolverTest.java @@ -87,7 +87,7 @@ public class DependencyResolverTest extends AnalysisTestCase { } private void pkg(String name, String... contents) throws Exception { - scratchFile("" + name + "/BUILD", contents); + scratch.file("" + name + "/BUILD", contents); } @SafeVarargs diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java index ba119a784f..47e2f576a9 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SpawnActionTest.java @@ -102,7 +102,7 @@ public class SpawnActionTest extends BuildViewTestCase { Action[] actions = builder() .addInput(input) .addOutput(output) - .setExecutable(scratchFile("/bin/xxx").asFragment()) + .setExecutable(scratch.file("/bin/xxx").asFragment()) .setProgressMessage("Test") .build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig); collectingAnalysisEnvironment.registerAction(actions); @@ -130,7 +130,7 @@ public class SpawnActionTest extends BuildViewTestCase { public void testBuilderWithJavaExecutable() throws Exception { Action[] actions = builder() .addOutput(destinationArtifact) - .setJavaExecutable(scratchFile("/bin/java").asFragment(), + .setJavaExecutable(scratch.file("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) .build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig); collectingAnalysisEnvironment.registerAction(actions); @@ -148,7 +148,7 @@ public class SpawnActionTest extends BuildViewTestCase { Action[] actions = builder() .addOutput(output) .setJavaExecutable( - scratchFile("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) + scratch.file("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) .addArgument("-X") .useParameterFile(ParameterFileType.UNQUOTED) .build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig); @@ -180,7 +180,7 @@ public class SpawnActionTest extends BuildViewTestCase { Action[] actions = builder() .addOutput(output) .setJavaExecutable( - scratchFile("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) + scratch.file("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) .addArgument("-X") .useParameterFile(ParameterFileType.UNQUOTED, ISO_8859_1, "--flagfile=") .build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig); @@ -205,7 +205,7 @@ public class SpawnActionTest extends BuildViewTestCase { Action[] actions = builder() .addOutput(destinationArtifact) .setJavaExecutable( - scratchFile("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) + scratch.file("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) .addExecutableArguments("execArg1", "execArg2") .addArguments("arg1") .build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig); @@ -225,7 +225,7 @@ public class SpawnActionTest extends BuildViewTestCase { Action[] actions = builder() .addOutput(output) .setJavaExecutable( - scratchFile("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) + scratch.file("/bin/java").asFragment(), jarArtifact, "MyMainClass", asList("-jvmarg")) .addExecutableArguments("execArg1", "execArg2") .addArguments("arg1", "arg2", "arg3") .useParameterFile(ParameterFileType.UNQUOTED) @@ -308,7 +308,7 @@ public class SpawnActionTest extends BuildViewTestCase { .addInput(manifest) .addInputManifest(manifest, new PathFragment("/destination/")) .addOutput(getBinArtifactWithNoOwner("output")) - .setExecutable(scratchFile("/bin/xxx").asFragment()) + .setExecutable(scratch.file("/bin/xxx").asFragment()) .setProgressMessage("Test") .build(ActionsTestUtil.NULL_ACTION_OWNER, collectingAnalysisEnvironment, targetConfig); collectingAnalysisEnvironment.registerAction(actions); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java index d2607aa5d8..ae1a4af504 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/SymlinkActionTest.java @@ -40,7 +40,7 @@ public class SymlinkActionTest extends BuildViewTestCase { @Override public void setUp() throws Exception { super.setUp(); - input = scratchFile("input.txt", "Hello, world."); + input = scratch.file("input.txt", "Hello, world."); inputArtifact = getSourceArtifact("input.txt"); Path linkedInput = directories.getExecRoot().getRelative("input.txt"); FileSystemUtils.createDirectoryAndParents(linkedInput.getParentDirectory()); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java index 112e4b17d2..500c35fe48 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java @@ -56,7 +56,7 @@ public class TemplateExpansionActionTest extends FoundationTestCase { super.setUp(); Root workspace = Root.asSourceRoot(scratch.dir("/workspace")); outputRoot = Root.asDerivedRoot(scratch.dir("/workspace"), scratch.dir("/workspace/out")); - Path input = scratchFile("/workspace/input.txt", TEMPLATE); + Path input = scratch.file("/workspace/input.txt", TEMPLATE); inputArtifact = new Artifact(input, workspace); output = scratch.resolve("/workspace/out/destination.txt"); outputArtifact = new Artifact(output, outputRoot); @@ -158,7 +158,7 @@ public class TemplateExpansionActionTest extends FoundationTestCase { Executor executor = new TestExecutorBuilder(directories, binTools).build(); createWithArtifact().execute(createContext(executor)); String content = new String(FileSystemUtils.readContentAsLatin1(output)); - // The trailing "" is needed because scratchFile implicitly appends "\n". + // The trailing "" is needed because scratch.file implicitly appends "\n". String expected = Joiner.on('\n').join("key=foo", "value=bar", ""); assertEquals(expected, content); } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java index e9e89f20b9..fc05e741fa 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/config/ConfigSettingTest.java @@ -22,7 +22,7 @@ import com.google.devtools.build.lib.syntax.Label; public class ConfigSettingTest extends BuildViewTestCase { private void writeSimpleExample() throws Exception { - scratchFile("pkg/BUILD", + scratch.file("pkg/BUILD", "config_setting(", " name = 'foo',", " values = {", @@ -123,7 +123,7 @@ public class ConfigSettingTest extends BuildViewTestCase { * com.google.devtools.common.options.Option#defaultValue}). */ public void testLateBoundOptionDefaults() throws Exception { - scratchFile("test/BUILD", + scratch.file("test/BUILD", "config_setting(", " name = 'match',", " values = {", @@ -137,7 +137,7 @@ public class ConfigSettingTest extends BuildViewTestCase { * Tests matching on multi-value attributes with key=value entries (e.g. --define). */ public void testMultiValueDict() throws Exception { - scratchFile("test/BUILD", + scratch.file("test/BUILD", "config_setting(", " name = 'match',", " values = {", @@ -162,7 +162,7 @@ public class ConfigSettingTest extends BuildViewTestCase { * Tests matching on multi-value attributes with primitive values. */ public void testMultiValueList() throws Exception { - scratchFile("test/BUILD", + scratch.file("test/BUILD", "config_setting(", " name = 'match',", " values = {", diff --git a/src/test/java/com/google/devtools/build/lib/analysis/constraints/AbstractConstraintsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/constraints/AbstractConstraintsTest.java index dfa14e561e..7b493fdbe7 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/constraints/AbstractConstraintsTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/constraints/AbstractConstraintsTest.java @@ -73,7 +73,7 @@ public abstract class AbstractConstraintsTest extends BuildViewTestCase { .append(getAttrDef("environments", environments.toArray(new String[0])) + ",\n") .append(getAttrDef("defaults", defaults.toArray(new String[0])) + ",\n") .append(")"); - scratchFile("" + name + "/BUILD", builder.toString()); + scratch.file("" + name + "/BUILD", builder.toString()); } } diff --git a/src/test/java/com/google/devtools/build/lib/analysis/constraints/ConstraintsTest.java b/src/test/java/com/google/devtools/build/lib/analysis/constraints/ConstraintsTest.java index 18f30223a5..bba396f444 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/constraints/ConstraintsTest.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/constraints/ConstraintsTest.java @@ -40,7 +40,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void setUp() throws Exception { super.setUp(); // Support files for RuleClassWithImplicitAndLateBoundDefaults: - scratchFile("helpers/BUILD", + scratch.file("helpers/BUILD", "sh_library(name = 'implicit', srcs = ['implicit.sh'])", "sh_library(name = 'latebound', srcs = ['latebound.sh'])"); } @@ -280,7 +280,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testAllDefaults() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule()); assertNotNull(getConfiguredTarget("//hello:main")); @@ -292,7 +292,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testSameConstraintsDeclaredExplicitly() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:b")), getDependingRule(constrainedTo("//foo_env:b"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -305,7 +305,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testValidConstraintsDeclaredExplicitly() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:a", "//foo_env:b")), getDependingRule(constrainedTo("//foo_env:b"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -318,7 +318,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testInvalidConstraintsDeclaredExplicitly() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:b")), getDependingRule(constrainedTo("//foo_env:a", "//foo_env:b"))); reporter.removeHandler(failFastHandler); @@ -332,7 +332,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testSameCompatibilityConstraints() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(compatibleWith("//foo_env:b", "//foo_env:c")), getDependingRule(compatibleWith("//foo_env:b", "//foo_env:c"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -345,7 +345,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testValidCompatibilityConstraints() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(compatibleWith("//foo_env:b", "//foo_env:c")), getDependingRule(compatibleWith("//foo_env:c"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -358,7 +358,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testInvalidCompatibilityConstraints() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(compatibleWith("//foo_env:c")), getDependingRule(compatibleWith("//foo_env:b", "//foo_env:c"))); reporter.removeHandler(failFastHandler); @@ -371,7 +371,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testMultipleMissingEnvironments() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule(compatibleWith("//foo_env:b", "//foo_env:c"))); reporter.removeHandler(failFastHandler); @@ -386,7 +386,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testValidMultigroupConstraints() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); new EnvironmentGroupMaker("bar_env").setEnvironments("d", "e", "f").setDefaults("d").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:b", "//foo_env:c"), compatibleWith("//bar_env:e")), getDependingRule(constrainedTo("//foo_env:c"), compatibleWith("//bar_env:e"))); @@ -400,7 +400,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testInvalidMultigroupConstraints() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); new EnvironmentGroupMaker("bar_env").setEnvironments("d", "e", "f").setDefaults("d").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:c"), compatibleWith("//bar_env:e")), getDependingRule(constrainedTo("//foo_env:b", "//foo_env:c"), compatibleWith("//bar_env:e"))); @@ -416,7 +416,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testValidConstraintsUnknownEnvironmentToDependency() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a", "b") .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule(constrainedTo("//foo_env:b"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -430,7 +430,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testInvalidConstraintsUnknownEnvironmentToDependency() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a", "b") .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule(constrainedTo("//foo_env:c"))); reporter.removeHandler(failFastHandler); @@ -445,7 +445,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testValidConstraintsUnknownEnvironmentToDependender() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:a", "//foo_env:b")), getDependingRule()); assertNotNull(getConfiguredTarget("//hello:main")); @@ -459,7 +459,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testInvalidConstraintsUnknownEnvironmentToDependender() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:b")), getDependingRule()); reporter.removeHandler(failFastHandler); @@ -472,7 +472,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testOneDependencyIsInvalid() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getRuleDef("sh_library", "bad_dep", constrainedTo("//foo_env:b")), getRuleDef("sh_library", "good_dep", compatibleWith("//foo_env:b")), getRuleDef("sh_library", "depender", @@ -487,7 +487,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testConstraintEnforcementDisabled() throws Exception { useConfiguration("--experimental_enforce_constraints=0"); new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b", "c").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule(compatibleWith("//foo_env:b", "//foo_env:c"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -500,7 +500,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testCompatibilityPackageDefaults() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "package(default_compatible_with = ['//foo_env:b'])", getDependencyRule(), getDependingRule(compatibleWith("//foo_env:b"))); @@ -516,7 +516,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { // We intentionally create an invalid dependency structure vs. a valid one. If we tested on // a valid one, this test wouldn't be able to distinguish between rule declarations overriding // package defaults and package defaults overriding rule declarations. - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "package(default_compatible_with = ['//foo_env:b'])", getDependencyRule(compatibleWith("//foo_env:a")), getDependingRule(compatibleWith("//foo_env:a", "//foo_env:b"))); @@ -531,7 +531,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testRestrictionPackageDefaults() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a", "b").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "package(default_restricted_to = ['//foo_env:b'])", getDependencyRule(constrainedTo("//foo_env:b")), getDependingRule()); @@ -547,7 +547,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { // We intentionally create an invalid dependency structure vs. a valid one. If we tested on // a valid one, this test wouldn't be able to distinguish between rule declarations overriding // package defaults and package defaults overriding rule declarations. - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "package(default_restricted_to = ['//foo_env:b'])", getDependencyRule(constrainedTo("//foo_env:a")), getDependingRule(constrainedTo("//foo_env:a", "//foo_env:b"))); @@ -564,7 +564,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { */ public void testPackageDefaultsDirectlyFillRuleAttributes() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults().make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "package(default_restricted_to = ['//foo_env:b'])", getDependencyRule(compatibleWith("//foo_env:a"))); reporter.removeHandler(failFastHandler); @@ -575,7 +575,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testHostDependenciesAreNotChecked() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "sh_binary(name = 'host_tool', srcs = ['host_tool.sh'], restricted_to = ['//foo_env:b'])", "genrule(", " name = 'hello',", @@ -590,7 +590,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testImplicitAndLateBoundDependenciesAreNotChecked() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults("a").make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "rule_with_implicit_and_latebound_deps(name = 'hi', compatible_with = ['//foo_env:b'])"); assertNotNull(getConfiguredTarget("//hello:hi")); // Note that the event "cannot build rule_with_implicit_and_latebound_deps" *does* occur @@ -601,7 +601,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testOutputFilesAreChecked() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults().make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "genrule(name = 'gen', srcs = [], outs = ['shlib.sh'], cmd = '')", "sh_library(", " name = 'shlib',", @@ -615,7 +615,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { public void testConfigSettingRulesAreNotChecked() throws Exception { new EnvironmentGroupMaker("foo_env").setEnvironments("a", "b").setDefaults().make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", "config_setting(name = 'setting', values = {'compilation_mode': 'fastbuild'})", "sh_library(", " name = 'shlib',", @@ -633,7 +633,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { .setFulfills("a", "b") .setDefaults() .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:a")), getDependingRule(constrainedTo("//foo_env:b"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -646,7 +646,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { .setFulfills("a", "b") .setDefaults() .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:b")), getDependingRule(constrainedTo("//foo_env:a"))); reporter.removeHandler(failFastHandler); @@ -661,7 +661,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { .setFulfills("b", "c") .setDefaults() .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:a")), getDependingRule(constrainedTo("//foo_env:c"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -674,7 +674,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { .setFulfills("a", "b") .setDefaults("a") .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule(constrainedTo("//foo_env:b"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -688,7 +688,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { .setFulfills("b", "c") .setDefaults("a") .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(), getDependingRule(constrainedTo("//foo_env:c"))); assertNotNull(getConfiguredTarget("//hello:main")); @@ -701,7 +701,7 @@ public class ConstraintsTest extends AbstractConstraintsTest { .setFulfills("a", "b") .setDefaults("b") .make(); - scratchFile("hello/BUILD", + scratch.file("hello/BUILD", getDependencyRule(constrainedTo("//foo_env:a")), getDependingRule()); assertNotNull(getConfiguredTarget("//hello:main")); diff --git a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java index 13332501b9..0bc8e87a4d 100644 --- a/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java @@ -611,7 +611,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase { */ protected Rule scratchRule(String packageName, String ruleName, String... lines) throws Exception { - scratchFile(packageName + "/BUILD", lines); + scratch.file(packageName + "/BUILD", lines); return (Rule) getTarget("//" + packageName + ":" + ruleName); } diff --git a/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java b/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java index dad012bf7b..96ad98f0ed 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java @@ -75,7 +75,7 @@ public abstract class FoundationTestCase extends TestCase { scratch = new Scratch(createFileSystem(), "/workspace"); outputBase = scratch.dir("/usr/local/google/_blaze_jrluser/FAKEMD5/"); rootDirectory = scratch.dir("/workspace"); - scratchFile(rootDirectory.getRelative("WORKSPACE").getPathString(), + scratch.file(rootDirectory.getRelative("WORKSPACE").getPathString(), "bind(", " name = 'objc_proto_lib',", " actual = '//objcproto:ProtocolBuffers_lib',", @@ -99,8 +99,8 @@ public abstract class FoundationTestCase extends TestCase { } private void copySkylarkFilesIfExist() throws IOException { - scratchFile(rootDirectory.getRelative("devtools/blaze/rules/BUILD").getPathString()); - scratchFile(rootDirectory.getRelative("rules/BUILD").getPathString()); + scratch.file(rootDirectory.getRelative("devtools/blaze/rules/BUILD").getPathString()); + scratch.file(rootDirectory.getRelative("rules/BUILD").getPathString()); copySkylarkFilesIfExist("devtools/blaze/rules/staging", "devtools/blaze/rules/staging"); copySkylarkFilesIfExist("third_party/bazel/tools/build_rules", "rules"); } @@ -116,7 +116,7 @@ public abstract class FoundationTestCase extends TestCase { if (path.exists()) { scratch.overwriteFile(path.getPathString(), context); } else { - scratchFile(path.getPathString(), context); + scratch.file(path.getPathString(), context); } } } @@ -140,15 +140,6 @@ public abstract class FoundationTestCase extends TestCase { return scratch.getFileSystem(); } - /** - * Create a scratch file in the scratch filesystem, with the given pathName, - * consisting of a set of lines. The method returns a Path instance for the - * scratch file. - */ - protected Path scratchFile(String pathName, String... lines) throws IOException { - return scratch.file(pathName, lines); - } - // Mix-in assertions: protected void assertNoEvents() { diff --git a/src/test/java/com/google/devtools/build/lib/testutil/Scratch.java b/src/test/java/com/google/devtools/build/lib/testutil/Scratch.java index 0d1f0818df..dda097959c 100644 --- a/src/test/java/com/google/devtools/build/lib/testutil/Scratch.java +++ b/src/test/java/com/google/devtools/build/lib/testutil/Scratch.java @@ -124,7 +124,7 @@ public final class Scratch { } /** - * Like {@code scratchFile}, but the file is first deleted if it already + * Like {@code scratch.file}, but the file is first deleted if it already * exists. */ public Path overwriteFile(String pathName, String... lines) throws IOException { |