aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build/lib/skyframe
diff options
context:
space:
mode:
authorGravatar shreyax <shreyax@google.com>2018-01-29 07:32:40 -0800
committerGravatar Copybara-Service <copybara-piper@google.com>2018-01-29 07:34:31 -0800
commit9f2a855be500f6a3bc11f1129600b07265a91f7e (patch)
tree2ce2727bd286a9a4a09a59cd7d7c5c0f50471e32 /src/test/java/com/google/devtools/build/lib/skyframe
parentf7f37be17506d41c7436807791611c31e216c45c (diff)
Remove hard coded prelude names from some unit tests.
PiperOrigin-RevId: 183662908
Diffstat (limited to 'src/test/java/com/google/devtools/build/lib/skyframe')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java18
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java8
2 files changed, 14 insertions, 12 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
index 68437dbdb3..5395b90a8c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ASTFileLookupFunctionTest.java
@@ -23,7 +23,6 @@ import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils;
import com.google.devtools.build.lib.syntax.SkylarkImport;
-import com.google.devtools.build.lib.testutil.TestConstants;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.Path;
@@ -42,16 +41,13 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class ASTFileLookupFunctionTest extends BuildViewTestCase {
- private static class MockFileSystem extends InMemoryFileSystem {
-
+ private class MockFileSystem extends InMemoryFileSystem {
boolean statThrowsIoException;
@Override
public FileStatus stat(Path path, boolean followSymlinks) throws IOException {
if (statThrowsIoException
- && path.asFragment()
- .getPathString()
- .equals("/workspace/tools/build_rules/prelude_" + TestConstants.PRODUCT_NAME)) {
+ && path.asFragment().getPathString().equals("/workspace/" + preludeLabelRelativePath)) {
throw new IOException("bork");
}
return super.stat(path, followSymlinks);
@@ -59,6 +55,8 @@ public class ASTFileLookupFunctionTest extends BuildViewTestCase {
}
private MockFileSystem mockFS;
+ String preludeLabelRelativePath =
+ getRuleClassProvider().getPreludeLabel().toPathFragment().toString();
@Override
protected FileSystem createFileSystem() {
@@ -66,12 +64,12 @@ public class ASTFileLookupFunctionTest extends BuildViewTestCase {
return mockFS;
}
- @Test
+ @Test
public void testPreludeASTFileIsNotMandatory() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file(
"foo/BUILD", "genrule(name = 'foo',", " outs = ['out.txt'],", " cmd = 'echo hello >@')");
- scratch.deleteFile("tools/build_rules/prelude_blaze");
+ scratch.deleteFile(preludeLabelRelativePath);
invalidatePackages();
SkyKey skyKey = PackageValue.key(PackageIdentifier.parse("@//foo"));
@@ -105,7 +103,7 @@ public class ASTFileLookupFunctionTest extends BuildViewTestCase {
@Test
public void testLoadFromBuildFileInRemoteRepo() throws Exception {
- scratch.deleteFile("tools/build_rules/prelude_blaze");
+ scratch.deleteFile(preludeLabelRelativePath);
scratch.overwriteFile("WORKSPACE",
"local_repository(",
" name = 'a_remote_repo',",
@@ -130,7 +128,7 @@ public class ASTFileLookupFunctionTest extends BuildViewTestCase {
@Test
public void testLoadFromSkylarkFileInRemoteRepo() throws Exception {
- scratch.deleteFile("tools/build_rules/prelude_blaze");
+ scratch.deleteFile(preludeLabelRelativePath);
scratch.overwriteFile("WORKSPACE",
"local_repository(",
" name = 'a_remote_repo',",
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java
index 03ec708273..cee3c4cebc 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java
@@ -45,6 +45,8 @@ import org.junit.runners.JUnit4;
@RunWith(JUnit4.class)
public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
+ String preludeLabelRelativePath;
+
@Before
public final void preparePackageLoading() throws Exception {
Path alternativeRoot = scratch.dir("/root_2");
@@ -65,6 +67,8 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
ImmutableMap.<String, String>of(),
ImmutableMap.<String, String>of(),
new TimestampGranularityMonitor(BlazeClock.instance()));
+ this.preludeLabelRelativePath =
+ getRuleClassProvider().getPreludeLabel().toPathFragment().toString();
}
@Test
@@ -99,7 +103,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
@Test
public void testLoadFromSkylarkFileInRemoteRepo() throws Exception {
- scratch.deleteFile("tools/build_rules/prelude_blaze");
+ scratch.deleteFile(preludeLabelRelativePath);
scratch.overwriteFile("WORKSPACE",
"local_repository(",
" name = 'a_remote_repo',",
@@ -238,7 +242,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
@Test
public void testLoadFromExternalRepoInWorkspaceFileAllowed() throws Exception {
- scratch.deleteFile("tools/build_rules/prelude_blaze");
+ scratch.deleteFile(preludeLabelRelativePath);
scratch.overwriteFile("WORKSPACE",
"local_repository(",
" name = 'a_remote_repo',",