aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib
diff options
context:
space:
mode:
authorGravatar Ulf Adams <ulfjack@google.com>2015-04-24 16:10:16 +0000
committerGravatar Han-Wen Nienhuys <hanwen@google.com>2015-04-27 18:48:26 +0000
commit4ce0d8800f1aaabe82f7a61faf1d5609b69c38cf (patch)
treef606c000cd8345a748d25562932fbd394f61da84 /src/test/java/com/google/devtools/build/lib
parent8e38d8d3aa427ba59ab5e8e7521d5c934166e862 (diff)
Inline/remove some calls to FoundationTestCase.scratchFS().
-- MOS_MIGRATED_REVID=91987064
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib')
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java10
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/actions/TemplateExpansionActionTest.java16
-rw-r--r--src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/testutil/Scratch.java10
4 files changed, 24 insertions, 14 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
index 107b6fcbca..ca521ea8d5 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/RunfilesTest.java
@@ -41,7 +41,7 @@ public class RunfilesTest extends FoundationTestCase {
public void testFilterListForObscuringSymlinksCatchesBadObscurer() throws Exception {
Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
PathFragment pathA = new PathFragment("a");
- Root root = Root.asSourceRoot(scratchFS().getPath("/workspace"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"), root);
obscuringMap.put(pathA, artifactA);
obscuringMap.put(new PathFragment("a/b"), new Artifact(new PathFragment("c/b"),
@@ -54,7 +54,7 @@ public class RunfilesTest extends FoundationTestCase {
public void testFilterListForObscuringSymlinksCatchesBadGrandParentObscurer() throws Exception {
Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
PathFragment pathA = new PathFragment("a");
- Root root = Root.asSourceRoot(scratchFS().getPath("/workspace"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
obscuringMap.put(pathA, artifactA);
@@ -68,7 +68,7 @@ public class RunfilesTest extends FoundationTestCase {
public void testFilterListForObscuringSymlinksCatchesBadObscurerNoListener() throws Exception {
Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
PathFragment pathA = new PathFragment("a");
- Root root = Root.asSourceRoot(scratchFS().getPath("/workspace"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
obscuringMap.put(pathA, artifactA);
@@ -81,7 +81,7 @@ public class RunfilesTest extends FoundationTestCase {
public void testFilterListForObscuringSymlinksIgnoresOkObscurer() throws Exception {
Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
PathFragment pathA = new PathFragment("a");
- Root root = Root.asSourceRoot(scratchFS().getPath("/workspace"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
obscuringMap.put(pathA, artifactA);
@@ -96,7 +96,7 @@ public class RunfilesTest extends FoundationTestCase {
public void testFilterListForObscuringSymlinksNoObscurers() throws Exception {
Map<PathFragment, Artifact> obscuringMap = new HashMap<>();
PathFragment pathA = new PathFragment("a");
- Root root = Root.asSourceRoot(scratchFS().getPath("/workspace"));
+ Root root = Root.asSourceRoot(scratch.resolve("/workspace"));
Artifact artifactA = new Artifact(new PathFragment("a"),
root);
obscuringMap.put(pathA, artifactA);
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 0dd7fff710..112e4b17d2 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
@@ -58,15 +58,15 @@ public class TemplateExpansionActionTest extends FoundationTestCase {
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");
+ output = scratch.resolve("/workspace/out/destination.txt");
outputArtifact = new Artifact(output, outputRoot);
substitutions = Lists.newArrayList();
substitutions.add(Substitution.of("%key%", "foo"));
substitutions.add(Substitution.of("%value%", "bar"));
directories = new BlazeDirectories(
- scratchFS().getPath("/install"),
- scratchFS().getPath("/base"),
- scratchFS().getPath("/workspace"));
+ scratch.resolve("/install"),
+ scratch.resolve("/base"),
+ scratch.resolve("/workspace"));
binTools = BinTools.empty(directories);
}
@@ -93,7 +93,7 @@ public class TemplateExpansionActionTest extends FoundationTestCase {
}
public void testKeySameIfSame() throws Exception {
- Artifact outputArtifact2 = new Artifact(scratchFS().getPath("/workspace/out/destination.txt"),
+ Artifact outputArtifact2 = new Artifact(scratch.resolve("/workspace/out/destination.txt"),
outputRoot);
TemplateExpansionAction a = new TemplateExpansionAction(NULL_ACTION_OWNER,
outputArtifact, Template.forString(TEMPLATE),
@@ -105,7 +105,7 @@ public class TemplateExpansionActionTest extends FoundationTestCase {
}
public void testKeyDiffersForSubstitution() throws Exception {
- Artifact outputArtifact2 = new Artifact(scratchFS().getPath("/workspace/out/destination.txt"),
+ Artifact outputArtifact2 = new Artifact(scratch.resolve("/workspace/out/destination.txt"),
outputRoot);
TemplateExpansionAction a = new TemplateExpansionAction(NULL_ACTION_OWNER,
outputArtifact, Template.forString(TEMPLATE),
@@ -117,7 +117,7 @@ public class TemplateExpansionActionTest extends FoundationTestCase {
}
public void testKeyDiffersForExecutable() throws Exception {
- Artifact outputArtifact2 = new Artifact(scratchFS().getPath("/workspace/out/destination.txt"),
+ Artifact outputArtifact2 = new Artifact(scratch.resolve("/workspace/out/destination.txt"),
outputRoot);
TemplateExpansionAction a = new TemplateExpansionAction(NULL_ACTION_OWNER,
outputArtifact, Template.forString(TEMPLATE),
@@ -129,7 +129,7 @@ public class TemplateExpansionActionTest extends FoundationTestCase {
}
public void testKeyDiffersForTemplates() throws Exception {
- Artifact outputArtifact2 = new Artifact(scratchFS().getPath("/workspace/out/destination.txt"),
+ Artifact outputArtifact2 = new Artifact(scratch.resolve("/workspace/out/destination.txt"),
outputRoot);
TemplateExpansionAction a = new TemplateExpansionAction(NULL_ACTION_OWNER,
outputArtifact, Template.forString(TEMPLATE),
diff --git a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java
index ebe3fa3819..46c7009b51 100644
--- a/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/analysis/config/BuildConfigurationTest.java
@@ -283,7 +283,7 @@ public class BuildConfigurationTest extends ConfigurationTestCase {
public void testSerialization() throws Exception {
FileSystem oldFileSystem = Path.getFileSystemForSerialization();
try {
- Path.setFileSystemForSerialization(scratchFS());
+ Path.setFileSystemForSerialization(scratch.getFileSystem());
TestUtils.serializeObject(createCollection());
} finally {
Path.setFileSystemForSerialization(oldFileSystem);
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 f5785a342f..0d1f0818df 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
@@ -18,6 +18,7 @@ import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
+import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
import java.io.IOException;
@@ -88,6 +89,15 @@ public final class Scratch {
}
/**
+ * Resolves {@code pathName} relative to the working directory. Note that this will not create any
+ * entity in the filesystem; i.e., the file that the object is describing may not exist in the
+ * filesystem.
+ */
+ public Path resolve(PathFragment pathName) {
+ return workingDir.getRelative(pathName);
+ }
+
+ /**
* Create a directory in the scratch filesystem, with the given path name.
*/
public Path dir(String pathName) throws IOException {