aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2015-03-03 11:11:43 +0000
committerGravatar Ulf Adams <ulfjack@google.com>2015-03-05 14:27:18 +0000
commit4e86f275ffd650a4a5a51f78e1de96422e0f2cd6 (patch)
treefbd428c2892bac6695227f9d898a3fed7bf930be /src/test/java
parent1e79b96be40d4a31d2da89ff7320ddf077494a77 (diff)
Inline a couple of methods from FoundationTestCase. Having these convenience
methods available doesn't seem to carry its weight, and this makes it easier for us to migrate to JUnit 4. -- MOS_MIGRATED_REVID=87597162
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/util/BuildViewTestCase.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/FoundationTestCase.java40
3 files changed, 7 insertions, 39 deletions
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 ec8935eabe..65df114a08 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
@@ -54,8 +54,8 @@ public class TemplateExpansionActionTest extends FoundationTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
- Root workspace = Root.asSourceRoot(scratchDir("/workspace"));
- outputRoot = Root.asDerivedRoot(scratchDir("/workspace"), scratchDir("/workspace/out"));
+ Root workspace = Root.asSourceRoot(scratch.dir("/workspace"));
+ outputRoot = Root.asDerivedRoot(scratch.dir("/workspace"), scratch.dir("/workspace/out"));
Path input = scratchFile("/workspace/input.txt", TEMPLATE);
inputArtifact = new Artifact(input, workspace);
output = scratchFS().getPath("/workspace/out/destination.txt");
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 d1b99e7067..ee6904de3f 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
@@ -745,7 +745,7 @@ public abstract class BuildViewTestCase extends FoundationTestCase {
protected Artifact getSourceArtifact(String name) throws IOException {
return getSourceArtifact(new PathFragment(name),
- Root.asSourceRoot(scratchDir("/" + TestConstants.TEST_WORKSPACE_DIRECTORY)));
+ Root.asSourceRoot(scratch.dir("/" + TestConstants.TEST_WORKSPACE_DIRECTORY)));
}
/**
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 d6642e8dac..ec3c20e93e 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
@@ -13,8 +13,6 @@
// limitations under the License.
package com.google.devtools.build.lib.testutil;
-import static com.google.common.truth.Truth.assertThat;
-
import com.google.common.io.Files;
import com.google.devtools.build.lib.events.Event;
import com.google.devtools.build.lib.events.EventCollector;
@@ -50,7 +48,7 @@ public abstract class FoundationTestCase extends TestCase {
protected Reporter reporter;
protected EventCollector eventCollector;
- private Scratch scratch;
+ protected Scratch scratch;
// Individual tests can opt-out of this handler if they expect an error, by
@@ -75,11 +73,11 @@ public abstract class FoundationTestCase extends TestCase {
protected void setUp() throws Exception {
super.setUp();
scratch = new Scratch(createFileSystem());
- outputBase = scratchDir("/usr/local/google/_blaze_jrluser/FAKEMD5/");
- rootDirectory = scratchDir("/" + TestConstants.TEST_WORKSPACE_DIRECTORY);
+ outputBase = scratch.dir("/usr/local/google/_blaze_jrluser/FAKEMD5/");
+ rootDirectory = scratch.dir("/" + TestConstants.TEST_WORKSPACE_DIRECTORY);
scratchFile(rootDirectory.getRelative("WORKSPACE").getPathString());
copySkylarkFilesIfExist();
- actionOutputBase = scratchDir("/usr/local/google/_blaze_jrluser/FAKEMD5/action_out/");
+ actionOutputBase = scratch.dir("/usr/local/google/_blaze_jrluser/FAKEMD5/action_out/");
eventCollector = new EventCollector(EventKind.ERRORS_AND_WARNINGS);
reporter = new Reporter(eventCollector);
reporter.addHandler(failFastHandler);
@@ -153,13 +151,6 @@ public abstract class FoundationTestCase extends TestCase {
}
/**
- * Deletes the specified scratch file, using the same specification as {@link Path#delete}.
- */
- protected boolean deleteScratchFile(String pathName) throws IOException {
- return scratch.deleteFile(pathName);
- }
-
- /**
* Create a scratch file in the given filesystem, with the given pathName,
* consisting of a set of lines. The method returns a Path instance for the
* scratch file.
@@ -179,29 +170,6 @@ public abstract class FoundationTestCase extends TestCase {
return scratch.file(fs, pathName, content);
}
- /**
- * Create a directory in the scratch filesystem, with the given path name.
- */
- public Path scratchDir(String pathName) throws IOException {
- return scratch.dir(pathName);
- }
-
- /**
- * If "expectedSuffix" is not a suffix of "actual", fails with an informative
- * assertion.
- */
- protected void assertEndsWith(String expectedSuffix, String actual) {
- assertThat(actual).endsWith(expectedSuffix);
- }
-
- /**
- * If "expectedPrefix" is not a prefix of "actual", fails with an informative
- * assertion.
- */
- protected void assertStartsWith(String expectedPrefix, String actual) {
- assertThat(actual).startsWith(expectedPrefix);
- }
-
// Mix-in assertions:
protected void assertNoEvents() {