aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/java/com/google/devtools/build
diff options
context:
space:
mode:
authorGravatar Florian Weikert <fwe@google.com>2015-12-03 10:17:18 +0000
committerGravatar Kristina Chodorow <kchodorow@google.com>2015-12-03 18:37:43 +0000
commit92b22366a6a7bace048b48e56931c8c1ea111045 (patch)
tree9cc8797b8f3ac5267870db5df86690c9dc19af02 /src/test/java/com/google/devtools/build
parent2dbe1baf752339c9c4dc6baee929507ce4007e33 (diff)
Migrated tests in devtools/build/lib/skyframe to JUnit 4.
-- MOS_MIGRATED_REVID=109286530
Diffstat (limited to 'src/test/java/com/google/devtools/build')
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ActionDataTest.java10
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java23
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManagerTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java4
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java53
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java2
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java3
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java29
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java32
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderMediumTest.java7
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java31
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java15
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java21
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java21
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java35
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java22
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java13
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeAwareActionTest.java24
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java27
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java49
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java25
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/SkylarkImportLookupFunctionTest.java31
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java21
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderMediumTest.java25
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTest.java20
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java11
-rw-r--r--src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java25
28 files changed, 468 insertions, 122 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ActionDataTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ActionDataTest.java
index be903de440..74c987a4b8 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ActionDataTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ActionDataTest.java
@@ -13,6 +13,9 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Sets;
import com.google.devtools.build.lib.actions.AbstractAction;
@@ -28,6 +31,10 @@ import com.google.devtools.build.lib.actions.util.ActionsTestUtil;
import com.google.devtools.build.lib.actions.util.DummyExecutor;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
import java.util.Collection;
import java.util.Set;
@@ -36,8 +43,10 @@ import java.util.Set;
* Tests that the data passed from the application to the Builder is passed
* down to each Action executed.
*/
+@RunWith(JUnit4.class)
public class ActionDataTest extends TimestampBuilderTestCase {
+ @Test
public void testArgumentToBuildArtifactsIsPassedDownToAction() throws Exception {
class MyAction extends AbstractAction {
@@ -156,6 +165,7 @@ public class ActionDataTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testActionSharabilityAndDiscoveredInputs() throws Exception {
Artifact output =
new Artifact(
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
index f808432e44..e05464299f 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ArtifactFunctionTest.java
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
-
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.skyframe.FileArtifactValue.create;
import static org.junit.Assert.assertArrayEquals;
@@ -89,8 +88,7 @@ public class ArtifactFunctionTest {
private TimestampGranularityMonitor tsgm = new TimestampGranularityMonitor(BlazeClock.instance());
@Before
- public void setUp() throws Exception {
-
+ public final void setUp() throws Exception {
setupRoot(new CustomInMemoryFs());
AtomicReference<PathPackageLocator> pkgLocator =
new AtomicReference<>(PathPackageLocator.EMPTY);
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java
index 72a47a5067..45d6996d27 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ContainingPackageLookupFunctionTest.java
@@ -13,13 +13,17 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
-import com.google.devtools.build.lib.testutil.FoundationTestCase;
+import com.google.devtools.build.lib.testutil.FoundationTestCaseForJunit4;
import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -31,6 +35,11 @@ import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -39,15 +48,15 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* Tests for {@link ContainingPackageLookupFunction}.
*/
-public class ContainingPackageLookupFunctionTest extends FoundationTestCase {
+@RunWith(JUnit4.class)
+public class ContainingPackageLookupFunctionTest extends FoundationTestCaseForJunit4 {
private AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages;
private MemoizingEvaluator evaluator;
private SequentialBuildDriver driver;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void setUp() throws Exception {
AtomicReference<PathPackageLocator> pkgLocator =
new AtomicReference<>(new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
deletedPackages = new AtomicReference<>(ImmutableSet.<PackageIdentifier>of());
@@ -83,11 +92,13 @@ public class ContainingPackageLookupFunctionTest extends FoundationTestCase {
.get(key);
}
+ @Test
public void testNoContainingPackage() throws Exception {
ContainingPackageLookupValue value = lookupContainingPackage("a/b");
assertFalse(value.hasContainingPackage());
}
+ @Test
public void testContainingPackageIsParent() throws Exception {
scratch.file("a/BUILD");
ContainingPackageLookupValue value = lookupContainingPackage("a/b");
@@ -96,6 +107,7 @@ public class ContainingPackageLookupFunctionTest extends FoundationTestCase {
assertEquals(rootDirectory, value.getContainingPackageRoot());
}
+ @Test
public void testContainingPackageIsSelf() throws Exception {
scratch.file("a/b/BUILD");
ContainingPackageLookupValue value = lookupContainingPackage("a/b");
@@ -104,6 +116,7 @@ public class ContainingPackageLookupFunctionTest extends FoundationTestCase {
assertEquals(rootDirectory, value.getContainingPackageRoot());
}
+ @Test
public void testEqualsAndHashCodeContract() throws Exception {
ContainingPackageLookupValue valueA1 = ContainingPackageLookupValue.NONE;
ContainingPackageLookupValue valueA2 = ContainingPackageLookupValue.NONE;
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManagerTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManagerTest.java
index 1ade3d4383..90d53fb5ad 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManagerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/DiffAwarenessManagerTest.java
@@ -51,10 +51,13 @@ public class DiffAwarenessManagerTest {
protected EventCollectionApparatus events;
@Before
- public void setUp() throws Exception {
-
+ public final void createFileSystem() throws Exception {
fs = new InMemoryFileSystem();
root = fs.getRootDirectory();
+ }
+
+ @Before
+ public final void initializeEventCollectionApparatus() {
events = new EventCollectionApparatus();
events.setFailFast(false);
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
index deb2b9e0b6..ae5de2782b 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FileFunctionTest.java
@@ -12,7 +12,6 @@
// See the License for the specific language governing permissions and
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
-
import static com.google.common.truth.Truth.assertThat;
import static com.google.devtools.build.lib.skyframe.SkyframeExecutor.DEFAULT_THREAD_COUNT;
import static org.junit.Assert.assertArrayEquals;
@@ -96,8 +95,7 @@ public class FileFunctionTest {
private RecordingDifferencer differencer;
@Before
- public void setUp() throws Exception {
-
+ public final void createMonitor() throws Exception {
fastMd5 = true;
manualClock = new ManualClock();
createFsAndRoot(new CustomInMemoryFs(manualClock));
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java
index 40405fe561..abb006c829 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesetEntryFunctionTest.java
@@ -36,7 +36,7 @@ import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.packages.FilesetEntry.SymlinkBehavior;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
-import com.google.devtools.build.lib.testutil.FoundationTestCase;
+import com.google.devtools.build.lib.testutil.FoundationTestCaseForJunit4;
import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.Fingerprint;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
@@ -53,6 +53,11 @@ import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
@@ -65,7 +70,8 @@ import java.util.concurrent.atomic.AtomicReference;
import javax.annotation.Nullable;
/** Tests for {@link FilesetEntryFunction}. */
-public final class FilesetEntryFunctionTest extends FoundationTestCase {
+@RunWith(JUnit4.class)
+public final class FilesetEntryFunctionTest extends FoundationTestCaseForJunit4 {
private TimestampGranularityMonitor tsgm = new TimestampGranularityMonitor(BlazeClock.instance());
private MemoizingEvaluator evaluator;
@@ -73,10 +79,8 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
private RecordingDifferencer differencer;
private AtomicReference<PathPackageLocator> pkgLocator;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public final void setUp() throws Exception {
pkgLocator = new AtomicReference<>(
new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages =
@@ -195,6 +199,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
return Label.parseAbsolute(label);
}
+ @Test
public void testFileTraversalForFile() throws Exception {
Artifact file = createSourceArtifact("foo/file.real");
FilesetTraversalParams params =
@@ -231,14 +236,17 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testFileTraversalForFileSymlinkNoFollow() throws Exception {
assertFileTraversalForFileSymlink(SymlinkBehavior.COPY);
}
+ @Test
public void testFileTraversalForFileSymlinkFollow() throws Exception {
assertFileTraversalForFileSymlink(SymlinkBehavior.DEREFERENCE);
}
+ @Test
public void testFileTraversalForDirectory() throws Exception {
Artifact dir = getSourceArtifact("foo/dir_real");
RootedPath fileA = createFile(childOf(dir, "file.a"), "hello");
@@ -281,10 +289,12 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testFileTraversalForDirectorySymlinkFollow() throws Exception {
assertFileTraversalForDirectorySymlink(SymlinkBehavior.COPY);
}
+ @Test
public void testFileTraversalForDirectorySymlinkNoFollow() throws Exception {
assertFileTraversalForDirectorySymlink(SymlinkBehavior.DEREFERENCE);
}
@@ -341,26 +351,32 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testRecursiveTraversalForDirectoryCrossNoFollow() throws Exception {
assertRecursiveTraversalForDirectory(SymlinkBehavior.COPY, CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectoryDontCrossNoFollow() throws Exception {
assertRecursiveTraversalForDirectory(SymlinkBehavior.COPY, DONT_CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectoryReportErrorNoFollow() throws Exception {
assertRecursiveTraversalForDirectory(SymlinkBehavior.COPY, REPORT_ERROR);
}
+ @Test
public void testRecursiveTraversalForDirectoryCrossFollow() throws Exception {
assertRecursiveTraversalForDirectory(SymlinkBehavior.DEREFERENCE, CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectoryDontCrossFollow() throws Exception {
assertRecursiveTraversalForDirectory(SymlinkBehavior.DEREFERENCE, DONT_CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectoryReportErrorFollow() throws Exception {
assertRecursiveTraversalForDirectory(SymlinkBehavior.DEREFERENCE, REPORT_ERROR);
}
@@ -422,26 +438,32 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testRecursiveTraversalForDirectorySymlinkNoFollowCross() throws Exception {
assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior.COPY, CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectorySymlinkNoFollowDontCross() throws Exception {
assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior.COPY, DONT_CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectorySymlinkNoFollowReportError() throws Exception {
assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior.COPY, REPORT_ERROR);
}
+ @Test
public void testRecursiveTraversalForDirectorySymlinkFollowCross() throws Exception {
assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior.DEREFERENCE, CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectorySymlinkFollowDontCross() throws Exception {
assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior.DEREFERENCE, DONT_CROSS);
}
+ @Test
public void testRecursiveTraversalForDirectorySymlinkFollowReportError() throws Exception {
assertRecursiveTraversalForDirectorySymlink(SymlinkBehavior.DEREFERENCE, REPORT_ERROR);
}
@@ -507,30 +529,37 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testRecursiveTraversalForPackageNoFollowCross() throws Exception {
assertRecursiveTraversalForPackage(SymlinkBehavior.COPY, CROSS);
}
+ @Test
public void testRecursiveTraversalForPackageNoFollowDontCross() throws Exception {
assertRecursiveTraversalForPackage(SymlinkBehavior.COPY, DONT_CROSS);
}
+ @Test
public void testRecursiveTraversalForPackageNoFollowReportError() throws Exception {
assertRecursiveTraversalForPackage(SymlinkBehavior.COPY, REPORT_ERROR);
}
+ @Test
public void testRecursiveTraversalForPackageFollowCross() throws Exception {
assertRecursiveTraversalForPackage(SymlinkBehavior.DEREFERENCE, CROSS);
}
+ @Test
public void testRecursiveTraversalForPackageFollowDontCross() throws Exception {
assertRecursiveTraversalForPackage(SymlinkBehavior.DEREFERENCE, DONT_CROSS);
}
+ @Test
public void testRecursiveTraversalForPackageFollowReportError() throws Exception {
assertRecursiveTraversalForPackage(SymlinkBehavior.DEREFERENCE, REPORT_ERROR);
}
+ @Test
public void testNestedFileFilesetTraversal() throws Exception {
Artifact path = getSourceArtifact("foo/bar.file");
createFile(path, "blah");
@@ -587,14 +616,17 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testNestedRecursiveFilesetTraversalWithInnerDestDir() throws Exception {
assertNestedRecursiveFilesetTraversal(true);
}
+ @Test
public void testNestedRecursiveFilesetTraversalWithoutInnerDestDir() throws Exception {
assertNestedRecursiveFilesetTraversal(false);
}
+ @Test
public void testFileTraversalForDanglingSymlink() throws Exception {
Artifact linkName = getSourceArtifact("foo/dangling.sym");
RootedPath linkTarget = createFile(siblingOf(linkName, "target.file"), "blah");
@@ -630,14 +662,17 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
assertSymlinksInOrder(paramsWithSymlinkCopy, symlink("output-name/BUILD", buildFile));
}
+ @Test
public void testExclusionOfDanglingSymlinkWithSymlinkModeCopy() throws Exception {
assertExclusionOfDanglingSymlink(SymlinkBehavior.COPY);
}
+ @Test
public void testExclusionOfDanglingSymlinkWithSymlinkModeDereference() throws Exception {
assertExclusionOfDanglingSymlink(SymlinkBehavior.DEREFERENCE);
}
+ @Test
public void testFileTraversalForNonExistentFile() throws Exception {
Artifact path = getSourceArtifact("foo/non-existent");
FilesetTraversalParams params =
@@ -650,6 +685,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
assertSymlinksInOrder(params); // expect empty results
}
+ @Test
public void testRecursiveTraversalForDanglingSymlink() throws Exception {
Artifact linkName = getSourceArtifact("foo/dangling.sym");
RootedPath linkTarget = createFile(siblingOf(linkName, "target.file"), "blah");
@@ -667,6 +703,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
assertSymlinksInOrder(params); // expect empty results
}
+ @Test
public void testRecursiveTraversalForNonExistentFile() throws Exception {
Artifact path = getSourceArtifact("foo/non-existent");
@@ -770,6 +807,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
return new Domain(false, valueA, valueB);
}
+ @Test
public void testFingerprintOfFileTraversal() throws Exception {
new FingerprintTester(
ImmutableMap.<String, Domain>of(
@@ -791,6 +829,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}.doTest();
}
+ @Test
public void testFingerprintOfDirectoryTraversal() throws Exception {
new FingerprintTester(
ImmutableMap.<String, Domain>builder()
@@ -819,6 +858,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}.doTest();
}
+ @Test
public void testFingerprintOfPackageTraversal() throws Exception {
new FingerprintTester(
ImmutableMap.<String, Domain>builder()
@@ -847,6 +887,7 @@ public final class FilesetEntryFunctionTest extends FoundationTestCase {
}.doTest();
}
+ @Test
public void testFingerprintOfNestedTraversal() throws Exception {
FilesetTraversalParams n1 =
FilesetTraversalParamsFactory.fileTraversal(
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
index d1d2018eaf..69a267b582 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/FilesystemValueCheckerTest.java
@@ -86,7 +86,7 @@ public class FilesystemValueCheckerTest {
private TimestampGranularityMonitor tsgm;
@Before
- public void setUp() throws Exception {
+ public final void setUp() throws Exception {
ImmutableMap.Builder<SkyFunctionName, SkyFunction> skyFunctions = ImmutableMap.builder();
fs = new MockFileSystem();
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
index a03a107e08..a5c9614c04 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/GlobFunctionTest.java
@@ -99,8 +99,7 @@ public abstract class GlobFunctionTest {
private static final PackageIdentifier PKG_PATH_ID = PackageIdentifier.createInDefaultRepo("pkg");
@Before
- public void setUp() throws Exception {
-
+ public final void setUp() throws Exception {
fs = new CustomInMemoryFs(new ManualClock());
root = fs.getRootDirectory().getRelative("root/workspace");
writableRoot = fs.getRootDirectory().getRelative("writableRoot/workspace");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
index 8fe6c9dfbf..ec3ed2489e 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageFunctionTest.java
@@ -15,13 +15,17 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import com.google.common.base.Predicates;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.ConstantRuleVisibility;
@@ -45,6 +49,10 @@ import com.google.devtools.build.skyframe.RecordingDifferencer;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
import java.util.Collection;
import java.util.Map;
@@ -57,7 +65,8 @@ import javax.annotation.Nullable;
* Unit tests of specific functionality of PackageFunction. Note that it's already tested
* indirectly in several other places.
*/
-public class PackageFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class PackageFunctionTest extends BuildViewTestCaseForJunit4 {
private CustomInMemoryFs fs = new CustomInMemoryFs(new ManualClock());
@@ -82,6 +91,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
return value;
}
+ @Test
public void testInconsistentNewPackage() throws Exception {
scratch.file("pkg/BUILD", "subinclude('//foo:sub')");
scratch.file("foo/sub");
@@ -108,6 +118,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
assertThat(exception.getMessage()).contains("Unexpected package");
}
+ @Test
public void testInconsistentMissingPackage() throws Exception {
reporter.removeHandler(failFastHandler);
Path root1 = fs.getPath("/root1");
@@ -142,6 +153,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
assertThat(exception.getMessage()).contains("Inconsistent package location");
}
+ @Test
public void testPropagatesFilesystemInconsistencies() throws Exception {
reporter.removeHandler(failFastHandler);
RecordingDifferencer differencer = getSkyframeExecutor().getDifferencerForTesting();
@@ -208,6 +220,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
assertThat(errorMessage).contains(expectedMessage);
}
+ @Test
public void testPropagatesFilesystemInconsistencies_Globbing() throws Exception {
reporter.removeHandler(failFastHandler);
RecordingDifferencer differencer = getSkyframeExecutor().getDifferencerForTesting();
@@ -248,6 +261,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
}
/** Regression test for unexpected exception type from PackageValue. */
+ @Test
public void testDiscrepancyBetweenLegacyAndSkyframePackageLoadingErrors() throws Exception {
reporter.removeHandler(failFastHandler);
Path fooBuildFile = scratch.file("foo/BUILD",
@@ -268,6 +282,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
assertThat(errorMessage).contains(expectedMessage);
}
+ @Test
public void testMultipleSubincludesFromSamePackage() throws Exception {
scratch.file("foo/BUILD",
"subinclude('//bar:a')",
@@ -286,6 +301,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
validPackage(skyKey);
}
+ @Test
public void testTransitiveSubincludesStoredInPackage() throws Exception {
scratch.file("foo/BUILD",
"subinclude('//bar:a')");
@@ -318,6 +334,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
Label.parseAbsolute("//bar:a"), Label.parseAbsolute("//baz:c"));
}
+ @Test
public void testTransitiveSkylarkDepsStoredInPackage() throws Exception {
scratch.file("foo/BUILD",
"load('/bar/ext', 'a')");
@@ -353,6 +370,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
Label.parseAbsolute("//bar:ext.bzl"), Label.parseAbsolute("//qux:ext.bzl"));
}
+ @Test
public void testNonExistingSkylarkExtension() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("test/skylark/BUILD",
@@ -373,6 +391,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
+ "file doesn't exist or isn't a file");
}
+ @Test
public void testNonExistingSkylarkExtensionWithPythonPreprocessing() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("foo/BUILD",
@@ -392,6 +411,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
+ "file doesn't exist or isn't a file");
}
+ @Test
public void testNonExistingSkylarkExtensionFromExtension() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("test/skylark/extension.bzl",
@@ -415,6 +435,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
+ "file doesn't exist or isn't a file");
}
+ @Test
public void testSymlinkCycleWithSkylarkExtension() throws Exception {
reporter.removeHandler(failFastHandler);
Path extensionFilePath = scratch.resolve("/workspace/test/skylark/extension.bzl");
@@ -438,6 +459,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
+ "file 'test/skylark/extension.bzl': Symlink cycle");
}
+ @Test
public void testIOErrorLookingForSubpackageForLabelIsHandled() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("foo/BUILD",
@@ -451,12 +473,14 @@ public class PackageFunctionTest extends BuildViewTestCase {
assertContainsEvent("nope");
}
+ @Test
public void testLoadRelativePath() throws Exception {
scratch.file("pkg/BUILD", "load('ext', 'a')");
scratch.file("pkg/ext.bzl", "a = 1");
validPackage(PackageValue.key(PackageIdentifier.parse("pkg")));
}
+ @Test
public void testLoadAbsolutePath() throws Exception {
scratch.file("pkg1/BUILD");
scratch.file("pkg2/BUILD",
@@ -465,6 +489,7 @@ public class PackageFunctionTest extends BuildViewTestCase {
validPackage(PackageValue.key(PackageIdentifier.parse("pkg2")));
}
+ @Test
public void testBadWorkspaceFile() throws Exception {
Path workspacePath = scratch.overwriteFile("WORKSPACE", "junk");
SkyKey skyKey = PackageValue.key(PackageIdentifier.createInDefaultRepo("external"));
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
index dfc1c4450b..554bd3308b 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PackageLookupFunctionTest.java
@@ -14,6 +14,11 @@
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.testing.EqualsTester;
@@ -25,7 +30,7 @@ import com.google.devtools.build.lib.packages.PackageFactory;
import com.google.devtools.build.lib.packages.RuleClassProvider;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.skyframe.PackageLookupValue.ErrorReason;
-import com.google.devtools.build.lib.testutil.FoundationTestCase;
+import com.google.devtools.build.lib.testutil.FoundationTestCaseForJunit4;
import com.google.devtools.build.lib.testutil.TestRuleClassProvider;
import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
@@ -40,6 +45,11 @@ import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
@@ -48,16 +58,15 @@ import java.util.concurrent.atomic.AtomicReference;
/**
* Tests for {@link PackageLookupFunction}.
*/
-public class PackageLookupFunctionTest extends FoundationTestCase {
+@RunWith(JUnit4.class)
+public class PackageLookupFunctionTest extends FoundationTestCaseForJunit4 {
private AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages;
private MemoizingEvaluator evaluator;
private SequentialBuildDriver driver;
private RecordingDifferencer differencer;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public final void setUp() throws Exception {
Path emptyPackagePath = rootDirectory.getRelative("somewhere/else");
scratch.file("parentpackage/BUILD");
@@ -107,6 +116,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
NullEventHandler.INSTANCE).get(key);
}
+ @Test
public void testNoBuildFile() throws Exception {
scratch.file("parentpackage/nobuildfile/foo.txt");
PackageLookupValue packageLookupValue = lookupPackage("parentpackage/nobuildfile");
@@ -115,6 +125,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertNotNull(packageLookupValue.getErrorMsg());
}
+ @Test
public void testNoBuildFileAndNoParentPackage() throws Exception {
scratch.file("noparentpackage/foo.txt");
PackageLookupValue packageLookupValue = lookupPackage("noparentpackage");
@@ -123,6 +134,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertNotNull(packageLookupValue.getErrorMsg());
}
+ @Test
public void testDeletedPackage() throws Exception {
scratch.file("parentpackage/deletedpackage/BUILD");
deletedPackages.set(ImmutableSet.of(
@@ -134,6 +146,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
}
+ @Test
public void testBlacklistedPackage() throws Exception {
scratch.file("blacklisted/subdir/BUILD");
scratch.file("blacklisted/BUILD");
@@ -160,6 +173,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
}
}
+ @Test
public void testInvalidPackageName() throws Exception {
scratch.file("parentpackage/invalidpackagename%42/BUILD");
PackageLookupValue packageLookupValue = lookupPackage("parentpackage/invalidpackagename%42");
@@ -169,6 +183,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertNotNull(packageLookupValue.getErrorMsg());
}
+ @Test
public void testDirectoryNamedBuild() throws Exception {
scratch.dir("parentpackage/isdirectory/BUILD");
PackageLookupValue packageLookupValue = lookupPackage("parentpackage/isdirectory");
@@ -178,6 +193,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertNotNull(packageLookupValue.getErrorMsg());
}
+ @Test
public void testEverythingIsGood() throws Exception {
scratch.file("parentpackage/everythinggood/BUILD");
PackageLookupValue packageLookupValue = lookupPackage("parentpackage/everythinggood");
@@ -185,6 +201,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertEquals(rootDirectory, packageLookupValue.getRoot());
}
+ @Test
public void testEmptyPackageName() throws Exception {
scratch.file("BUILD");
PackageLookupValue packageLookupValue = lookupPackage("");
@@ -192,6 +209,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertEquals(rootDirectory, packageLookupValue.getRoot());
}
+ @Test
public void testWorkspaceLookup() throws Exception {
scratch.overwriteFile("WORKSPACE");
PackageLookupValue packageLookupValue = lookupPackage("external");
@@ -200,6 +218,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
}
// TODO(kchodorow): Clean this up (see TODOs in PackageLookupValue).
+ @Test
public void testExternalPackageLookupSemantics() {
PackageLookupValue existing = PackageLookupValue.workspace(rootDirectory);
assertTrue(existing.isExternalPackage());
@@ -209,6 +228,7 @@ public class PackageLookupFunctionTest extends FoundationTestCase {
assertFalse(nonExistent.packageExists());
}
+ @Test
public void testPackageLookupValueHashCodeAndEqualsContract() throws Exception {
Path root1 = rootDirectory.getRelative("root1");
Path root2 = rootDirectory.getRelative("root2");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderMediumTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderMediumTest.java
index 1d923d7dd1..7884ab9598 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderMediumTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderMediumTest.java
@@ -17,15 +17,21 @@ package com.google.devtools.build.lib.skyframe;
import com.google.devtools.build.lib.testutil.Suite;
import com.google.devtools.build.lib.testutil.TestSpec;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
/**
* Stress tests for the parallel builder.
*/
@TestSpec(size = Suite.MEDIUM_TESTS)
+@RunWith(JUnit4.class)
public class ParallelBuilderMediumTest extends ParallelBuilderTest {
/**
* A larger set of tests using randomly-generated complex dependency graphs.
*/
+ @Test
public void testRandomStressTest1() throws Exception {
final int numTrials = 2;
final int numArtifacts = 100;
@@ -34,6 +40,7 @@ public class ParallelBuilderMediumTest extends ParallelBuilderTest {
test.runStressTest();
}
+ @Test
public void testRandomStressTest2() throws Exception {
final int numTrials = 10;
final int numArtifacts = 10;
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
index b1637b2b5c..449168270f 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/ParallelBuilderTest.java
@@ -15,6 +15,9 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -51,6 +54,11 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.inmemoryfs.InMemoryFileSystem;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
@@ -70,6 +78,7 @@ import java.util.logging.Logger;
*
*/
@TestSpec(size = Suite.MEDIUM_TESTS)
+@RunWith(JUnit4.class)
public class ParallelBuilderTest extends TimestampBuilderTestCase {
private static final Logger LOG =
@@ -79,9 +88,8 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
protected static final int DEFAULT_NUM_JOBS = 100;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void setUp() throws Exception {
this.cache = new InMemoryActionCache();
ResourceManager.instance().setAvailableResources(LocalHostCapacity.getLocalHostCapacity());
ResourceManager.instance().setRamUtilizationPercentage(
@@ -188,6 +196,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testReportsActionExecutedEvent() throws Exception {
Artifact pear = createDerivedArtifact("pear");
ActionEventRecorder recorder = new ActionEventRecorder();
@@ -202,6 +211,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
assertEquals(action, recorder.actionExecutedEvents.get(0).getAction());
}
+ @Test
public void testRunsInParallel() throws Exception {
runsInParallelWithBuilder(createBuilder(DEFAULT_NUM_JOBS, false));
}
@@ -209,6 +219,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
/**
* Test that we can recover properly after a failed build.
*/
+ @Test
public void testFailureRecovery() throws Exception {
// [action] -> foo
@@ -243,6 +254,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
buildArtifacts(bar);
}
+ @Test
public void testUpdateCacheError() throws Exception {
FileSystem fs = new InMemoryFileSystem() {
@Override
@@ -307,6 +319,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testNullBuild() throws Exception {
// BuildTool.setupLogging(Level.FINEST);
LOG.fine("Testing null build...");
@@ -316,6 +329,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
/**
* Test a randomly-generated complex dependency graph.
*/
+ @Test
public void testSmallRandomStressTest() throws Exception {
final int numTrials = 1;
final int numArtifacts = 30;
@@ -508,6 +522,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
// Regression test for bug fixed in CL 3548332: builder was not waiting for
// all its subprocesses to terminate.
+ @Test
public void testWaitsForSubprocesses() throws Exception {
final Semaphore semaphore = new Semaphore(1);
final boolean[] finished = { false };
@@ -561,6 +576,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
finished[0]);
}
+ @Test
public void testSchedulingOfMemoryResources() throws Exception {
// The action graph consists of 100 independent actions, but execution is
// memory limited: only 6 TestActions can run concurrently:
@@ -606,6 +622,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
assertEquals(6, counter.maxConcurrent);
}
+ @Test
public void testEstimateExceedsAvailableRam() throws Exception {
// Pretend that the machine has only 1MB of RAM available,
// then test running an action that we estimate requires 2MB of RAM.
@@ -632,6 +649,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
assertTrue(finished[0]);
}
+ @Test
public void testCyclicActionGraph() throws Exception {
// foo -> [action] -> bar
// bar -> [action] -> baz
@@ -650,6 +668,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testSelfCyclicActionGraph() throws Exception {
// foo -> [action] -> foo
Artifact foo = createDerivedArtifact("foo");
@@ -662,6 +681,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testCycleInActionGraphBelowTwoActions() throws Exception {
// bar -> [action] -> foo1
// bar -> [action] -> foo2
@@ -684,6 +704,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
+ @Test
public void testCyclicActionGraphWithTail() throws Exception {
// bar -> [action] -> foo
// baz -> [action] -> bar
@@ -704,6 +725,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testDuplicatedInput() throws Exception {
// <null> -> [action] -> foo
// (foo, foo) -> [action] -> bar
@@ -784,10 +806,12 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testNoNewJobsAreRunAfterFirstFailure() throws Exception {
assertNoNewJobsAreRunAfterFirstFailure(false, false);
}
+ @Test
public void testNoNewJobsAreRunAfterCatastrophe() throws Exception {
assertNoNewJobsAreRunAfterFirstFailure(true, true);
}
@@ -800,6 +824,7 @@ public class ParallelBuilderTest extends TimestampBuilderTestCase {
return artifact;
}
+ @Test
public void testProgressReporting() throws Exception {
// Build three artifacts in 3 separate actions (baz depends on bar and bar
// depends on foo. Make sure progress is reported at the beginning of all
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java
index a1e5e9ae93..107f577552 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionSmartNegationTest.java
@@ -14,10 +14,12 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -26,10 +28,15 @@ import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
import com.google.devtools.build.skyframe.WalkableGraph;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
/** Tests for {@link PrepareDepsOfPatternsFunction}. */
-public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTestCaseForJunit4 {
private static SkyKey getKeyForLabel(Label label) {
// Note that these tests used to look for TargetMarker SkyKeys before TargetMarker was
@@ -38,6 +45,7 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes
return TransitiveTraversalValue.key(label);
}
+ @Test
public void testRecursiveEvaluationFailsOnBadBuildFile() throws Exception {
// Given a well-formed package "//foo" and a malformed package "//foo/foo",
createFooAndFooFoo();
@@ -59,6 +67,7 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes
assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("foo/foo", "foofoo"))));
}
+ @Test
public void testNegativePatternBlocksPatternEvaluation() throws Exception {
// Given a well-formed package "//foo" and a malformed package "//foo/foo",
createFooAndFooFoo();
@@ -70,6 +79,7 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes
assertSkipsFoo(patternSequence);
}
+ @Test
public void testBlacklistPatternBlocksPatternEvaluation() throws Exception {
// Given a well-formed package "//foo" and a malformed package "//foo/foo",
createFooAndFooFoo();
@@ -104,6 +114,7 @@ public class PrepareDepsOfPatternsFunctionSmartNegationTest extends BuildViewTes
assertFalse(walkableGraph.exists(getKeyForLabel(label)));
}
+ @Test
public void testNegativeNonTBDPatternsAreSkippedWithWarnings() throws Exception {
// Given a target pattern sequence with a negative non-TBD pattern,
ImmutableList<String> patternSequence = ImmutableList.of("-//foo/bar");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java
index d7b9e5fefb..9c872cf26e 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfPatternsFunctionTest.java
@@ -14,10 +14,14 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.NoSuchPackageException;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
@@ -26,10 +30,15 @@ import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
import com.google.devtools.build.skyframe.WalkableGraph;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
/** Tests for {@link com.google.devtools.build.lib.skyframe.PrepareDepsOfPatternsFunction}. */
-public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCaseForJunit4 {
private static SkyKey getKeyForLabel(Label label) {
// Note that these tests used to look for TargetMarker SkyKeys before TargetMarker was
@@ -38,6 +47,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
return TransitiveTraversalValue.key(label);
}
+ @Test
public void testFunctionLoadsTargetAndNotUnspecifiedTargets() throws Exception {
// Given a package "//foo" with independent target rules ":foo" and ":foo2",
createFooAndFoo2(/*dependent=*/ false);
@@ -56,6 +66,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("foo", "foo2"))));
}
+ @Test
public void testFunctionLoadsTargetDependencies() throws Exception {
// Given a package "//foo" with target rules ":foo" and ":foo2",
// And given ":foo" depends on ":foo2",
@@ -72,6 +83,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
assertValidValue(walkableGraph, getKeyForLabel(Label.create("foo", "foo2")));
}
+ @Test
public void testFunctionExpandsTargetPatterns() throws Exception {
// Given a package "//foo" with independent target rules ":foo" and ":foo2",
createFooAndFoo2(/*dependent=*/ false);
@@ -88,6 +100,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
assertValidValue(walkableGraph, getKeyForLabel(Label.create("foo", "foo2")));
}
+ @Test
public void testTargetParsingException() throws Exception {
// Given no packages, and a target pattern sequence referring to a non-existent target,
String nonexistentTarget = "//foo:foo";
@@ -101,6 +114,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
assertFalse(walkableGraph.exists(getKeyForLabel(Label.create("foo", "foo"))));
}
+ @Test
public void testDependencyTraversalNoSuchPackageException() throws Exception {
// Given a package "//foo" with a target ":foo" that has a dependency on a non-existent target
// "//bar:bar" in a non-existent package "//bar",
@@ -124,6 +138,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
assertThat(e).isInstanceOf(NoSuchPackageException.class);
}
+ @Test
public void testDependencyTraversalNoSuchTargetException() throws Exception {
// Given a package "//foo" with a target ":foo" that has a dependency on a non-existent target
// "//bar:bar" in an existing package "//bar",
@@ -147,6 +162,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
assertThat(e).isInstanceOf(NoSuchTargetException.class);
}
+ @Test
public void testParsingProblemsKeepGoing() throws Exception {
parsingProblem(/*keepGoing=*/ true);
}
@@ -157,6 +173,7 @@ public class PrepareDepsOfPatternsFunctionTest extends BuildViewTestCase {
* always used {@code keepGoing=true} during target pattern parsing because it was responsible
* for ensuring that queries had a complete graph to work on.
*/
+ @Test
public void testParsingProblemsNoKeepGoing() throws Exception {
parsingProblem(/*keepGoing=*/ false);
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java
index 757495102b..0fbb4ecbc3 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/PrepareDepsOfTargetsUnderDirectoryFunctionTest.java
@@ -15,12 +15,14 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.pkgcache.FilteringPolicies;
@@ -33,18 +35,23 @@ import com.google.devtools.build.skyframe.EvaluationResult;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.WalkableGraph;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
/**
* Tests for {@link PrepareDepsOfTargetsUnderDirectoryFunction}. Insert excuses here.
*/
-public class PrepareDepsOfTargetsUnderDirectoryFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class PrepareDepsOfTargetsUnderDirectoryFunctionTest extends BuildViewTestCaseForJunit4 {
private SkyframeExecutor skyframeExecutor;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void setSkyframeExecutor() throws Exception {
skyframeExecutor = getSkyframeExecutor();
}
@@ -76,6 +83,7 @@ public class PrepareDepsOfTargetsUnderDirectoryFunctionTest extends BuildViewTes
return evaluationResult;
}
+ @Test
public void testTransitiveLoading() throws Exception {
// Given a package "a" with a genrule "a" that depends on a target in package "b",
createPackages();
@@ -100,6 +108,7 @@ public class PrepareDepsOfTargetsUnderDirectoryFunctionTest extends BuildViewTes
assertThat(graph.exists(bTxtKey)).isTrue();
}
+ @Test
public void testTargetFilterSensitivity() throws Exception {
// Given a package "a" with a genrule "a" that depends on a target in package "b", and a test
// rule "aTest",
@@ -133,6 +142,7 @@ public class PrepareDepsOfTargetsUnderDirectoryFunctionTest extends BuildViewTes
"exports_files(['b.txt'])");
}
+ @Test
public void testSubdirectoryExclusion() throws Exception {
// Given a package "a" with two packages below it, "a/b" and "a/c",
scratch.file("a/BUILD");
@@ -170,6 +180,7 @@ public class PrepareDepsOfTargetsUnderDirectoryFunctionTest extends BuildViewTes
ImmutableSet.<PathFragment>of())));
}
+ @Test
public void testExcludedSubdirectoryGettingPassedDown() throws Exception {
// Given a package "a", and a package below it in "a/b/c", and a non-BUILD file below it in
// "a/b/d",
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java
index a4367e0ad9..d94b8dd06c 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursiveFilesystemTraversalFunctionTest.java
@@ -31,7 +31,7 @@ import com.google.devtools.build.lib.events.NullEventHandler;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.skyframe.RecursiveFilesystemTraversalValue.ResolvedFile;
import com.google.devtools.build.lib.skyframe.RecursiveFilesystemTraversalValue.TraversalRequest;
-import com.google.devtools.build.lib.testutil.FoundationTestCase;
+import com.google.devtools.build.lib.testutil.FoundationTestCaseForJunit4;
import com.google.devtools.build.lib.util.BlazeClock;
import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.Path;
@@ -49,6 +49,11 @@ import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
@@ -60,7 +65,8 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.regex.Pattern;
/** Tests for {@link RecursiveFilesystemTraversalFunction}. */
-public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTestCase {
+@RunWith(JUnit4.class)
+public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTestCaseForJunit4 {
private TimestampGranularityMonitor tsgm = new TimestampGranularityMonitor(BlazeClock.instance());
private RecordingEvaluationProgressReceiver progressReceiver;
@@ -69,10 +75,8 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
private RecordingDifferencer differencer;
private AtomicReference<PathPackageLocator> pkgLocator;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
-
+ @Before
+ public final void setUp() throws Exception {
pkgLocator = new AtomicReference<>(
new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)));
AtomicReference<ImmutableSet<PackageIdentifier>> deletedPackages =
@@ -334,14 +338,17 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
progressReceiver.clear();
}
+ @Test
public void testTraversalOfSourceFile() throws Exception {
assertTraversalOfFile(sourceArtifact("foo/bar.txt"));
}
+ @Test
public void testTraversalOfGeneratedFile() throws Exception {
assertTraversalOfFile(derivedArtifact("foo/bar.txt"));
}
+ @Test
public void testTraversalOfSymlinkToFile() throws Exception {
Artifact linkNameArtifact = sourceArtifact("foo/baz/qux.sym");
Artifact linkTargetArtifact = sourceArtifact("foo/bar/baz.txt");
@@ -368,6 +375,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
assertThat(v2).isNotEqualTo(v1);
}
+ @Test
public void testTraversalOfTransitiveSymlinkToFile() throws Exception {
Artifact directLinkArtifact = sourceArtifact("direct/file.sym");
Artifact transitiveLinkArtifact = sourceArtifact("transitive/sym.sym");
@@ -443,14 +451,17 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
assertThat(progressReceiver.invalidations).doesNotContain(rftvSkyKey(traversalRoot));
}
+ @Test
public void testTraversalOfSourceDirectory() throws Exception {
assertTraversalOfDirectory(sourceArtifact("dir"));
}
+ @Test
public void testTraversalOfGeneratedDirectory() throws Exception {
assertTraversalOfDirectory(derivedArtifact("dir"));
}
+ @Test
public void testTraversalOfTransitiveSymlinkToDirectory() throws Exception {
Artifact directLinkArtifact = sourceArtifact("direct/dir.sym");
Artifact transitiveLinkArtifact = sourceArtifact("transitive/sym.sym");
@@ -478,6 +489,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
resolvedFile(childOf(transitiveLinkArtifact, "file.a")));
}
+ @Test
public void testTraversePackage() throws Exception {
Artifact buildFile = sourceArtifact("pkg/BUILD");
RootedPath buildFilePath = createFile(rootedPath(buildFile));
@@ -489,6 +501,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
resolvedFile(file1));
}
+ @Test
public void testTraversalOfSymlinkToDirectory() throws Exception {
Artifact linkNameArtifact = sourceArtifact("link/foo.sym");
Artifact linkTargetArtifact = sourceArtifact("dir");
@@ -543,6 +556,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
assertThat(progressReceiver.invalidations).doesNotContain(rftvSkyKey(traversalRoot));
}
+ @Test
public void testTraversalOfDanglingSymlink() throws Exception {
Artifact linkArtifact = sourceArtifact("a/dangling.sym");
RootedPath link = rootedPath(linkArtifact);
@@ -553,6 +567,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
fileLikeRoot(linkArtifact, DONT_CROSS), resolvedDanglingSymlink(link, linkTarget));
}
+ @Test
public void testTraversalOfDanglingSymlinkInADirectory() throws Exception {
Artifact dirArtifact = sourceArtifact("a");
RootedPath file = createFile(childOf(dirArtifact, "file.txt"));
@@ -599,18 +614,22 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
}
}
+ @Test
public void testTraverseSubpackages() throws Exception {
assertTraverseSubpackages(CROSS);
}
+ @Test
public void testDoNotTraverseSubpackages() throws Exception {
assertTraverseSubpackages(DONT_CROSS);
}
+ @Test
public void testReportErrorWhenTraversingSubpackages() throws Exception {
assertTraverseSubpackages(REPORT_ERROR);
}
+ @Test
public void testSwitchPackageRootsWhenUsingMultiplePackagePaths() throws Exception {
// Layout:
// pp1://a/BUILD
@@ -688,6 +707,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
resolvedFile(pp1aSubdirFileB));
}
+ @Test
public void testFileDigestChangeCausesRebuild() throws Exception {
Artifact artifact = sourceArtifact("foo/bar.txt");
RootedPath path = rootedPath(artifact);
@@ -707,6 +727,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
assertThat(v2).isNotEqualTo(v1);
}
+ @Test
public void testFileMtimeChangeDoesNotCauseRebuildIfDigestIsUnchanged() throws Exception {
Artifact artifact = sourceArtifact("foo/bar.txt");
RootedPath path = rootedPath(artifact);
@@ -727,6 +748,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
assertThat(v2).isEqualTo(v1);
}
+ @Test
public void testRegexp() throws Exception {
Artifact wantedArtifact = sourceArtifact("foo/bar/baz.txt");
Artifact unwantedArtifact = sourceArtifact("foo/boo/baztxt.bak");
@@ -745,6 +767,7 @@ public final class RecursiveFilesystemTraversalFunctionTest extends FoundationTe
traverseAndAssertFiles(traversalRoot, expected);
}
+ @Test
public void testGeneratedDirectoryConflictsWithPackage() throws Exception {
Artifact genDir = derivedArtifact("a/b");
createFile(rootedPath(sourceArtifact("a/b/c/file.real")));
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java
index ce2b84d402..8b0cc1bf59 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgFunctionTest.java
@@ -14,12 +14,15 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Iterables;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
@@ -29,6 +32,11 @@ import com.google.devtools.build.skyframe.EvaluationResult;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.WalkableGraph;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
/**
* Tests for {@link RecursivePkgFunction}. Unfortunately, we can't directly test
* RecursivePkgFunction as it uses PackageValues, and PackageFunction uses legacy stuff that
@@ -38,13 +46,13 @@ import com.google.devtools.build.skyframe.WalkableGraph;
* <p>Target parsing tests already cover most of the behavior of RecursivePkgFunction, but there
* are a couple of corner cases we need to test directly.
*/
-public class RecursivePkgFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class RecursivePkgFunctionTest extends BuildViewTestCaseForJunit4 {
private SkyframeExecutor skyframeExecutor;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void createSkyframeExecutor() throws Exception {
skyframeExecutor = getSkyframeExecutor();
}
@@ -80,6 +88,7 @@ public class RecursivePkgFunctionTest extends BuildViewTestCase {
return evaluationResult;
}
+ @Test
public void testStartingAtBuildFile() throws Exception {
scratch.file("a/b/c/BUILD");
RecursivePkgValue value =
@@ -87,6 +96,7 @@ public class RecursivePkgFunctionTest extends BuildViewTestCase {
assertTrue(value.getPackages().isEmpty());
}
+ @Test
public void testPackagesUnderMultipleRoots() throws Exception {
Path root1 = rootDirectory.getRelative("root1");
Path root2 = rootDirectory.getRelative("root2");
@@ -105,6 +115,7 @@ public class RecursivePkgFunctionTest extends BuildViewTestCase {
assertEquals(root2Pkg, "a/b");
}
+ @Test
public void testSubdirectoryExclusion() throws Exception {
// Given a package "a" with two packages below it, "a/b" and "a/c",
scratch.file("a/BUILD");
@@ -141,6 +152,7 @@ public class RecursivePkgFunctionTest extends BuildViewTestCase {
rootDirectory, new PathFragment("a/c"), ImmutableSet.<PathFragment>of())));
}
+ @Test
public void testExcludedSubdirectoryGettingPassedDown() throws Exception {
// Given a package "a" with two packages below a directory below it, "a/b/c" and "a/b/d",
scratch.file("a/BUILD");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java
index 4c312db139..2e5df9e9a1 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/RecursivePkgKeyTest.java
@@ -13,8 +13,10 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.fail;
+
import com.google.common.collect.ImmutableSet;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.cmdline.PackageIdentifier.RepositoryName;
import com.google.devtools.build.lib.skyframe.RecursivePkgValue.RecursivePkgKey;
@@ -22,8 +24,13 @@ import com.google.devtools.build.lib.vfs.PathFragment;
import com.google.devtools.build.lib.vfs.RootedPath;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
/** Tests for {@link RecursivePkgKey}. */
-public class RecursivePkgKeyTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class RecursivePkgKeyTest extends BuildViewTestCaseForJunit4 {
private SkyKey buildRecursivePkgKey(
RepositoryName repository,
@@ -43,6 +50,7 @@ public class RecursivePkgKeyTest extends BuildViewTestCase {
}
}
+ @Test
public void testValidRecursivePkgKeys() throws Exception {
buildRecursivePkgKey(
PackageIdentifier.DEFAULT_REPOSITORY_NAME,
@@ -72,6 +80,7 @@ public class RecursivePkgKeyTest extends BuildViewTestCase {
ImmutableSet.of(new PathFragment("a/b/c")));
}
+ @Test
public void testInvalidRecursivePkgKeys() throws Exception {
invalidHelper(new PathFragment(""), ImmutableSet.of(new PathFragment("")));
invalidHelper(new PathFragment("a"), ImmutableSet.of(new PathFragment("a")));
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeAwareActionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeAwareActionTest.java
index 282bb51afb..219b6e283f 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeAwareActionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeAwareActionTest.java
@@ -41,6 +41,11 @@ import com.google.devtools.build.skyframe.SkyFunction.Environment;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -52,16 +57,20 @@ import java.util.concurrent.atomic.AtomicInteger;
import javax.annotation.Nullable;
/** Tests for {@link SkyframeAwareAction}. */
+@RunWith(JUnit4.class)
public class SkyframeAwareActionTest extends TimestampBuilderTestCase {
private Builder builder;
private Executor executor;
private TrackingEvaluationProgressReceiver invalidationReceiver;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void createBuilder() throws Exception {
invalidationReceiver = new TrackingEvaluationProgressReceiver();
builder = createBuilder(inMemoryCache, 1, /*keepGoing=*/ false, invalidationReceiver);
+ }
+
+ @Before
+ public final void createExecutor() throws Exception {
executor = new DummyExecutor(rootDirectory);
}
@@ -454,10 +463,12 @@ public class SkyframeAwareActionTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testCacheCheckingActionWithContentChangingInput() throws Exception {
assertActionWithContentChangingInput(/* unconditionalExecution */ false);
}
+ @Test
public void testCacheBypassingActionWithContentChangingInput() throws Exception {
assertActionWithContentChangingInput(/* unconditionalExecution */ true);
}
@@ -481,10 +492,12 @@ public class SkyframeAwareActionTest extends TimestampBuilderTestCase {
ExpectActionIs.REEXECUTED);
}
+ @Test
public void testCacheCheckingActionWithMtimeChangingInput() throws Exception {
assertActionWithMtimeChangingInput(/* unconditionalExecution */ false);
}
+ @Test
public void testCacheBypassingActionWithMtimeChangingInput() throws Exception {
assertActionWithMtimeChangingInput(/* unconditionalExecution */ true);
}
@@ -558,19 +571,23 @@ public class SkyframeAwareActionTest extends TimestampBuilderTestCase {
ExpectActionIs.REEXECUTED);
}
+ @Test
public void testActionWithNonChangingInputButChangingSkyframeDeps() throws Exception {
assertActionWithMaybeChangingInputAndChangingSkyframeDeps(ChangeArtifact.DONT_CHANGE);
}
+ @Test
public void testActionWithChangingInputMtimeAndChangingSkyframeDeps() throws Exception {
assertActionWithMaybeChangingInputAndChangingSkyframeDeps(ChangeArtifact.CHANGE_MTIME);
}
+ @Test
public void testActionWithChangingInputAndChangingSkyframeDeps() throws Exception {
assertActionWithMaybeChangingInputAndChangingSkyframeDeps(
ChangeArtifact.CHANGE_MTIME_AND_CONTENT);
}
+ @Test
public void testActionWithNonChangingInputAndNonChangingSkyframeDeps() throws Exception {
final SkyKey skyframeDep = FileStateValue.key(createSkyframeDepOfAction());
@@ -688,6 +705,7 @@ public class SkyframeAwareActionTest extends TimestampBuilderTestCase {
* are missing, request also the skyframe-dependencies. The race is described in this method's
* body.
*/
+ @Test
public void testRaceConditionBetweenInputAcquisitionAndSkyframeDeps() throws Exception {
// Sequence of events on threads A and B, showing SkyFunctions and requested SkyKeys, leading
// to an InconsistentFilesystemException:
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
index a145b075e6..7c7fc4b953 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTest.java
@@ -14,6 +14,8 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;
@@ -31,16 +33,23 @@ import com.google.devtools.build.lib.vfs.ModifiedFileSet;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.PathFragment;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
import java.util.Collection;
import java.util.UUID;
+@RunWith(JUnit4.class)
public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
+ @Override
public PackageFactory.EnvironmentExtension getPackageEnvironmentExtension() {
return new PackageFactory.EmptyEnvironmentExtension();
}
+ @Test
public void testLabelVisitorDetectsMissingPackages() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
@@ -56,6 +65,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
* Tests that Blaze is resilient to changing symlinks between builds. This test is a more
* "integrated" version of FilesystemValueCheckerTest#testDirtySymlink.
*/
+ @Test
public void testChangingSymlink() throws Exception {
Path path = scratch.file("foo/BUILD", "sh_library(name = 'foo')");
Path sym1 = scratch.resolve(rootDirectory + "/sym1/BUILD");
@@ -84,6 +94,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
ImmutableSet.of("//bar:bar"), ImmutableSet.of("//bar:bar"), !EXPECT_ERROR, !KEEP_GOING);
}
+ @Test
public void testFailFastLoading() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
@@ -118,6 +129,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
!KEEP_GOING);
}
+ @Test
public void testNewFailure() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
@@ -140,6 +152,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
ImmutableSet.of("//pkg:x"), ImmutableSet.of("//pkg:x"), EXPECT_ERROR, !KEEP_GOING);
}
+ @Test
public void testNewTransitiveFailure() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
@@ -172,6 +185,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
KEEP_GOING);
}
+ @Test
public void testAddDepInNewPkg() throws Exception {
Path buildFile =
scratch.file("pkg/BUILD", "sh_library(name = 'x', deps = ['z'])", "sh_library(name = 'z')");
@@ -203,6 +217,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
// Regression test for: "IllegalArgumentException thrown during build." This happened if "."
// occurred in a label name segment.
+ @Test
public void testDotLabelName() throws Exception {
scratch.file("pkg/BUILD", "exports_files(srcs = ['.', 'x/.'])");
@@ -221,6 +236,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
!KEEP_GOING);
}
+ @Test
public void testLabelVisitorPlural() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
@@ -237,6 +253,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
}
// Indirectly tests that there are dependencies between packages and their subpackages.
+ @Test
public void testSubpackageBoundaryAdd() throws Exception {
scratch.file(
"x/BUILD", "sh_library(name = 'x', deps = ['//x:y/z'])", "sh_library(name = 'y/z')");
@@ -257,6 +274,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
}
// Indirectly tests that there are dependencies between packages and their subpackages.
+ @Test
public void testSubpackageBoundaryDelete() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
scratch.file(
@@ -273,6 +291,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
ImmutableSet.of("//x:x", "//x:y/z"), ImmutableSet.of("//x:x"), !EXPECT_ERROR, !KEEP_GOING);
}
+ @Test
public void testInterruptPending() throws Exception {
scratch.file("x/BUILD");
Thread.currentThread().interrupt();
@@ -286,6 +305,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
}
// Regression test for "crash when // encountered in package name".
+ @Test
public void testDoubleSlashInPackageName() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
scratch.file("x/BUILD", "sh_library(name='x', deps=['//x//y'])");
@@ -297,6 +317,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
}
// Regression test for "Bazel hangs on input of illegal rule".
+ @Test
public void testCrashInLoadPackageIsReportedEffectively() throws Exception {
reporter.removeHandler(failFastHandler);
// Inject a NullPointerException into loadPackage(). This is triggered by
@@ -337,6 +358,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
// Regression test for: "Need better context for missing build file error due to
// use in visibility rule".
+ @Test
public void testErrorMessageContainsTarget() throws Exception {
reporter.removeHandler(failFastHandler); // expect errors
@@ -352,6 +374,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
+ "such package 'not/a/package'");
}
+ @Test
public void testKeepGoing() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file(
@@ -370,6 +393,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
* In the case of Skyframe we print a warning inside SkyframeLabelVisitor because the existing
* interfaces forces us to do the keep_going + show warning logic there.
*/
+ @Test
public void testNewBuildFileConflict() throws Exception {
Collection<Event> warnings = assertNewBuildFileConflict();
assertThat(warnings).hasSize(1);
@@ -377,6 +401,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
.contains("errors encountered while analyzing target '//pkg:x': it will not be built");
}
+ @Test
public void testWithNoSubincludes() throws Exception {
// This test uses the preprocessor.
preprocessorFactorySupplier.inject(
@@ -417,6 +442,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
//
// Indirectly tests that there are dependencies between a package and other packages that could
// potentially cutoff its subincludes.
+ @Test
public void testSubpackageBoundarySubincludes() throws Exception {
// This test uses the python preprocessor.
preprocessorFactorySupplier.inject(
@@ -451,6 +477,7 @@ public class SkyframeLabelVisitorTest extends SkyframeLabelVisitorTestCase {
}
// Regression test for: "ClassCastException in SkyframeLabelVisitor.sync()"
+ @Test
public void testRootCauseOnInconsistentFilesystem() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("foo/BUILD", "sh_library(name = 'foo', deps = ['//bar:baz/fizz'])");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
index ed27884a0f..45d8cd8087 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkyframeLabelVisitorTestCase.java
@@ -13,13 +13,14 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
-import com.google.common.base.Predicates;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotSame;
+import static org.junit.Assert.assertTrue;
+
import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
-import com.google.devtools.build.lib.analysis.BlazeDirectories;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.LabelSyntaxException;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
@@ -31,32 +32,28 @@ import com.google.devtools.build.lib.packages.NoSuchThingException;
import com.google.devtools.build.lib.packages.Package;
import com.google.devtools.build.lib.packages.PackageFactory;
import com.google.devtools.build.lib.packages.Target;
-import com.google.devtools.build.lib.packages.util.PackageLoadingTestCase;
+import com.google.devtools.build.lib.packages.util.PackageLoadingTestCaseForJunit4;
import com.google.devtools.build.lib.packages.util.PreprocessorUtils;
-import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
import com.google.devtools.build.lib.pkgcache.TransitivePackageLoader;
import com.google.devtools.build.lib.testutil.ManualClock;
-import com.google.devtools.build.lib.util.BlazeClock;
-import com.google.devtools.build.lib.util.io.TimestampGranularityMonitor;
import com.google.devtools.build.lib.vfs.FileStatus;
import com.google.devtools.build.lib.vfs.FileSystem;
import com.google.devtools.build.lib.vfs.ModifiedFileSet;
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 com.google.devtools.build.skyframe.SkyFunction;
-import com.google.devtools.build.skyframe.SkyFunctionName;
+
+import org.junit.Before;
import java.io.IOException;
import java.util.Collection;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.UUID;
import javax.annotation.Nullable;
-abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCase {
+abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCaseForJunit4 {
// Convenience constants, so test args are readable vs true/false
protected static final boolean KEEP_GOING = true;
protected static final boolean EXPECT_ERROR = true;
@@ -239,31 +236,11 @@ abstract public class SkyframeLabelVisitorTestCase extends PackageLoadingTestCas
return builder.build();
}
- @Override
- protected void setUp() throws Exception {
- super.setUp();
- this.skyframeExecutor =
- SequencedSkyframeExecutor.create(
- new PackageFactory(ruleClassProvider, getPackageEnvironmentExtension()),
- new TimestampGranularityMonitor(BlazeClock.instance()),
- new BlazeDirectories(outputBase, outputBase, rootDirectory),
- null, /* BinTools -- not used */
- null, /* workspaceStatusActionFactory -- not used */
- ruleClassProvider.getBuildInfoFactories(),
- ImmutableSet.<Path>of(),
- ImmutableList.<DiffAwareness.Factory>of(),
- Predicates.<PathFragment>alwaysFalse(),
- preprocessorFactorySupplier,
- ImmutableMap.<SkyFunctionName, SkyFunction>of(),
- ImmutableList.<PrecomputedValue.Injected>of(),
- ImmutableList.<SkyValueDirtinessChecker>of());
- skyframeExecutor.preparePackageLoading(
- new PathPackageLocator(outputBase, ImmutableList.of(rootDirectory)),
- ConstantRuleVisibility.PRIVATE,
- true,
- 7,
- ruleClassProvider.getDefaultsPackageContent(),
- UUID.randomUUID());
+ @Before
+ public final void initializeVisitor() throws Exception {
+ skyframeExecutor = super.createSkyframeExecutor(
+ ImmutableList.of(getPackageEnvironmentExtension()), preprocessorFactorySupplier,
+ ConstantRuleVisibility.PRIVATE, ruleClassProvider.getDefaultsPackageContent());
this.visitor = skyframeExecutor.pkgLoader();
}
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java b/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java
index 18c0d359c6..8c2087f323 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/SkylarkFileContentHashTests.java
@@ -13,8 +13,11 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.ConstantRuleVisibility;
import com.google.devtools.build.lib.packages.Rule;
@@ -24,6 +27,11 @@ import com.google.devtools.build.lib.skyframe.util.SkyframeExecutorTestUtils;
import com.google.devtools.build.skyframe.EvaluationResult;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.Collection;
import java.util.UUID;
@@ -31,11 +39,11 @@ import java.util.UUID;
* Tests for the hash code calculated for Skylark RuleClasses based on the transitive closure
* of the imports of their respective definition SkylarkEnvironments.
*/
-public class SkylarkFileContentHashTests extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class SkylarkFileContentHashTests extends BuildViewTestCaseForJunit4 {
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void createFiles() throws Exception {
scratch.file("foo/BUILD");
scratch.file("bar/BUILD");
scratch.file("helper/BUILD");
@@ -66,10 +74,12 @@ public class SkylarkFileContentHashTests extends BuildViewTestCase {
"bar1(name = 'bar1')");
}
+ @Test
public void testHashInvariance() throws Exception {
assertEquals(getHash("pkg", "foo1"), getHash("pkg", "foo1"));
}
+ @Test
public void testHashInvarianceAfterOverwritingFileWithSameContents() throws Exception {
String bar1 = getHash("pkg", "bar1");
scratch.overwriteFile(
@@ -81,14 +91,17 @@ public class SkylarkFileContentHashTests extends BuildViewTestCase {
assertEquals(bar1, getHash("pkg", "bar1"));
}
+ @Test
public void testHashSameForRulesDefinedInSameFile() throws Exception {
assertEquals(getHash("pkg", "foo1"), getHash("pkg", "foo2"));
}
+ @Test
public void testHashNotSameForRulesDefinedInDifferentFiles() throws Exception {
assertNotEquals(getHash("pkg", "foo1"), getHash("pkg", "bar1"));
}
+ @Test
public void testImmediateFileChangeChangesHash() throws Exception {
String bar1 = getHash("pkg", "bar1");
scratch.overwriteFile(
@@ -101,6 +114,7 @@ public class SkylarkFileContentHashTests extends BuildViewTestCase {
assertNotEquals(bar1, getHash("pkg", "bar1"));
}
+ @Test
public void testTransitiveFileChangeChangesHash() throws Exception {
String bar1 = getHash("pkg", "bar1");
String foo1 = getHash("pkg", "foo1");
@@ -116,6 +130,7 @@ public class SkylarkFileContentHashTests extends BuildViewTestCase {
assertNotEquals(foo2, getHash("pkg", "foo2"));
}
+ @Test
public void testFileChangeDoesNotAffectRulesDefinedOutsideOfTransitiveClosure() throws Exception {
String foo1 = getHash("pkg", "foo1");
String foo2 = getHash("pkg", "foo2");
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 99999be0d1..0682d79156 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
@@ -13,8 +13,12 @@
// limitations under the License.
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
import com.google.common.collect.ImmutableList;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.ConstantRuleVisibility;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
@@ -24,16 +28,21 @@ import com.google.devtools.build.skyframe.ErrorInfo;
import com.google.devtools.build.skyframe.EvaluationResult;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.UUID;
/**
* Tests for SkylarkImportLookupFunction.
*/
-public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class SkylarkImportLookupFunctionTest extends BuildViewTestCaseForJunit4 {
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void preparePackageLoading() throws Exception {
Path alternativeRoot = scratch.dir("/root_2");
getSkyframeExecutor()
.preparePackageLoading(
@@ -45,6 +54,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
UUID.randomUUID());
}
+ @Test
public void testSkylarkImportLabels() throws Exception {
scratch.file("pkg1/BUILD");
scratch.file("pkg1/ext.bzl");
@@ -59,12 +69,14 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
checkLabel("//dir/pkg3:dir/ext.bzl", "//dir/pkg3:dir/ext.bzl");
}
+ @Test
public void testSkylarkImportLabelsAlternativeRoot() throws Exception {
scratch.file("/root_2/pkg4/BUILD");
scratch.file("/root_2/pkg4/ext.bzl");
checkLabel("//pkg4:ext.bzl", "//pkg4:ext.bzl");
}
+ @Test
public void testSkylarkImportLabelsMultipleBuildFiles() throws Exception {
scratch.file("dir1/BUILD");
scratch.file("dir1/dir2/BUILD");
@@ -72,6 +84,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
checkLabel("//dir1/dir2:ext.bzl", "//dir1/dir2:ext.bzl");
}
+ @Test
public void testLoadRelativePath() throws Exception {
scratch.file("pkg/BUILD");
scratch.file("pkg/ext1.bzl", "a = 1");
@@ -79,6 +92,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
get(key("//pkg:ext2.bzl"));
}
+ @Test
public void testLoadAbsolutePath() throws Exception {
scratch.file("pkg2/BUILD");
scratch.file("pkg3/BUILD");
@@ -87,6 +101,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
get(key("//pkg3:ext.bzl"));
}
+ @Test
public void testLoadFromSameAbsolutePathTwice() throws Exception {
scratch.file("pkg1/BUILD");
scratch.file("pkg2/BUILD");
@@ -95,6 +110,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
get(key("//pkg2:ext.bzl"));
}
+ @Test
public void testLoadFromSameRelativePathTwice() throws Exception {
scratch.file("pkg/BUILD");
scratch.file("pkg/ext1.bzl", "a = 1", "b = 2");
@@ -102,6 +118,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
get(key("//pkg:ext2.bzl"));
}
+ @Test
public void testLoadFromRelativePathInSubdir() throws Exception {
scratch.file("pkg/BUILD");
scratch.file("pkg/subdir/ext1.bzl", "a = 1");
@@ -131,6 +148,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
result.get(skylarkImportLookupKey).getDependency().getLabel().toString());
}
+ @Test
public void testSkylarkImportLookupNoBuildFile() throws Exception {
scratch.file("pkg/ext.bzl", "");
SkyKey skylarkImportLookupKey =
@@ -145,6 +163,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
+ "BUILD file not found on package path", errorMessage);
}
+ @Test
public void testSkylarkImportLookupNoBuildFileForLoad() throws Exception {
scratch.file("pkg2/BUILD");
scratch.file("pkg1/ext.bzl", "a = 1");
@@ -161,6 +180,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
+ "BUILD file not found on package path", errorMessage);
}
+ @Test
public void testSkylarkAbsoluteImportFilenameWithControlChars() throws Exception {
scratch.file("pkg/BUILD", "");
scratch.file("pkg/ext.bzl", "load('/pkg/oops\u0000', 'a')");
@@ -176,6 +196,7 @@ public class SkylarkImportLookupFunctionTest extends BuildViewTestCase {
+ "target names may not contain non-printable characters: '\\x00'", errorMessage);
}
+ @Test
public void testSkylarkRelativeImportFilenameWithControlChars() throws Exception {
scratch.file("pkg/BUILD", "");
scratch.file("pkg/ext.bzl", "load('oops\u0000', 'a')");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java
index 8ac667f2cb..6a8fbccf06 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TargetMarkerFunctionTest.java
@@ -14,11 +14,13 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import com.google.common.base.Preconditions;
import com.google.common.collect.Iterables;
import com.google.common.collect.Maps;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.cmdline.PackageIdentifier;
import com.google.devtools.build.lib.packages.BuildFileNotFoundException;
@@ -35,6 +37,11 @@ import com.google.devtools.build.skyframe.ErrorInfo;
import com.google.devtools.build.skyframe.EvaluationResult;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
import java.util.Map;
@@ -43,14 +50,14 @@ import java.util.Map;
* TargetMarkerFunction as it uses PackageValues, and PackageFunction uses legacy stuff
* that isn't easily mockable. So our testing strategy is to make hacky calls to SkyframeExecutor.
*/
-public class TargetMarkerFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class TargetMarkerFunctionTest extends BuildViewTestCaseForJunit4 {
private SkyframeExecutor skyframeExecutor;
private CustomInMemoryFs fs = new CustomInMemoryFs();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void setSkyframExecutor() throws Exception {
skyframeExecutor = getSkyframeExecutor();
}
@@ -78,6 +85,7 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase {
}
/** Regression test for b/12545745 */
+ @Test
public void testLabelCrossingSubpackageBoundary() throws Exception {
scratch.file("a/b/c/foo.sh", "echo 'FOO'");
scratch.file("a/BUILD", "sh_library(name = 'foo', srcs = ['b/c/foo.sh'])");
@@ -96,6 +104,7 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase {
.contains("Label '//a:b/c/foo.sh' crosses boundary of subpackage 'a/b'");
}
+ @Test
public void testNoBuildFileForTargetWithSlash() throws Exception {
String labelName = "//no/such/package:target/withslash";
BuildFileNotFoundException exn =
@@ -107,6 +116,7 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase {
assertThat(exn).hasMessage(expectedMessage);
}
+ @Test
public void testRuleWithError() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file(
@@ -121,6 +131,7 @@ public class TargetMarkerFunctionTest extends BuildViewTestCase {
assertTrue(exn.hasTarget());
}
+ @Test
public void testTargetFunctionRethrowsExceptions() throws Exception {
reporter.removeHandler(failFastHandler);
scratch.file("a/BUILD", "sh_library(name = 'b/c')");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderMediumTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderMediumTest.java
index 7ecc956d9a..131d413109 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderMediumTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderMediumTest.java
@@ -14,6 +14,9 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterables;
@@ -28,6 +31,11 @@ import com.google.devtools.build.lib.vfs.FileSystemUtils;
import com.google.devtools.build.lib.vfs.Path;
import com.google.devtools.build.lib.vfs.UnixGlob;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.io.IOException;
/**
@@ -35,13 +43,13 @@ import java.io.IOException;
* separate class for now because they are a little slower.
*/
@TestSpec(size = Suite.MEDIUM_TESTS)
+@RunWith(JUnit4.class)
public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
private Path cacheRoot;
private CompactPersistentActionCache cache;
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void setCache() throws Exception {
// BlazeRuntime.setupLogging(Level.FINEST); // Uncomment this for debugging.
cacheRoot = scratch.dir("cacheRoot");
@@ -63,6 +71,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
// - test timestamp monotonicity is not required (i.e. set mtime backwards)
// - test change of key causes rebuild
+ @Test
public void testUnneededInputs() throws Exception {
Artifact hello = createSourceArtifact("hello");
BlazeTestUtils.makeEmptyFile(hello.getPath());
@@ -109,6 +118,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testPersistentCache_ModifyingInputCausesActionReexecution() throws Exception {
// /hello -> [action] -> /goodbye
Artifact hello = createSourceArtifact("hello");
@@ -140,6 +150,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testModifyingInputCausesActionReexecution() throws Exception {
// /hello -> [action] -> /goodbye
Artifact hello = createSourceArtifact("hello");
@@ -176,6 +187,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testArtifactOrderingDoesNotMatter() throws Exception {
// (/hello,/there) -> [action] -> /goodbye
@@ -209,6 +221,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertFalse(button2.pressed); // still not rebuilt
}
+ @Test
public void testOldCacheKeysAreCleanedUp() throws Exception {
// [action1] -> (/goodbye), cache key will be /goodbye
Artifact goodbye = createDerivedArtifact("goodbye");
@@ -241,6 +254,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertThat(cache.get(goodbye.getExecPathString())).isNull();
}
+ @Test
public void testArtifactNamesMatter() throws Exception {
// /hello -> [action] -> /goodbye
@@ -271,6 +285,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertTrue(button2.pressed); // name changed. must rebuild.
}
+ @Test
public void testDuplicateInputs() throws Exception {
// (/hello,/hello) -> [action] -> /goodbye
@@ -310,6 +325,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
* does not cause action reexecution when metadata cache uses file digests in
* addition to the timestamp.
*/
+ @Test
public void testModifyingTimestampOnlyDoesNotCauseActionReexecution() throws Exception {
// /hello -> [action] -> /goodbye
Artifact hello = createSourceArtifact("hello");
@@ -334,6 +350,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testPersistentCache_ModifyingOutputCausesActionReexecution() throws Exception {
// [action] -> /hello
Artifact hello = createDerivedArtifact("hello");
@@ -363,6 +380,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testPersistentCache_missingFilenameIndexCausesActionReexecution() throws Exception {
// [action] -> /hello
Artifact hello = createDerivedArtifact("hello");
@@ -408,6 +426,7 @@ public class TimestampBuilderMediumTest extends TimestampBuilderTestCase {
assertTrue(button.pressed); // rebuilt due to the missing filename index
}
+ @Test
public void testPersistentCache_failedIntegrityCheckCausesActionReexecution() throws Exception {
// [action] -> /hello
Artifact hello = createDerivedArtifact("hello");
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTest.java
index 5359fe9b39..55f1784c01 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTest.java
@@ -15,6 +15,9 @@
package com.google.devtools.build.lib.skyframe;
import static com.google.common.truth.Truth.assertThat;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.collect.Sets;
@@ -24,6 +27,10 @@ import com.google.devtools.build.lib.actions.util.TestAction;
import com.google.devtools.build.lib.testutil.BlazeTestUtils;
import com.google.devtools.build.lib.vfs.FileSystemUtils;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
import java.util.Collection;
import java.util.Collections;
@@ -31,8 +38,10 @@ import java.util.Collections;
* Test suite for TimestampBuilder.
*
*/
+@RunWith(JUnit4.class)
public class TimestampBuilderTest extends TimestampBuilderTestCase {
+ @Test
public void testAmnesiacBuilderAlwaysRebuilds() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
@@ -54,6 +63,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
// That is, Builders conflate traversal and dependency analysis, and don't
// revisit a node (traversal) even if it needs to be rebuilt (dependency
// analysis). We might want to separate these aspects.
+ @Test
public void testBuilderDoesntRevisitActions() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
@@ -66,12 +76,14 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertEquals(counter.count, 1); // built only once
}
+ @Test
public void testBuildingExistingSourcefileSuceeds() throws Exception {
Artifact hello = createSourceArtifact("hello");
BlazeTestUtils.makeEmptyFile(hello.getPath());
buildArtifacts(cachingBuilder(), hello);
}
+ @Test
public void testBuildingNonexistentSourcefileFails() throws Exception {
reporter.removeHandler(failFastHandler);
Artifact hello = createSourceArtifact("hello");
@@ -83,6 +95,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
}
}
+ @Test
public void testCachingBuilderCachesUntilReset() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
@@ -103,6 +116,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertTrue(button.pressed); // rebuilt
}
+ @Test
public void testUnneededInputs() throws Exception {
Artifact hello = createSourceArtifact("hello");
BlazeTestUtils.makeEmptyFile(hello.getPath());
@@ -139,6 +153,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testModifyingInputCausesActionReexecution() throws Exception {
// hello -> [action] -> goodbye
Artifact hello = createSourceArtifact("hello");
@@ -166,6 +181,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testOnlyModifyingInputContentCausesReexecution() throws Exception {
// hello -> [action] -> goodbye
Artifact hello = createSourceArtifact("hello");
@@ -201,6 +217,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testModifyingOutputCausesActionReexecution() throws Exception {
// [action] -> hello
Artifact hello = createDerivedArtifact("hello");
@@ -228,6 +245,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertFalse(button.pressed); // not rebuilt
}
+ @Test
public void testBuildingTransitivePrerequisites() throws Exception {
// hello -> [action1] -> wazuup -> [action2] -> goodbye
Artifact hello = createSourceArtifact("hello");
@@ -265,6 +283,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertTrue(button2.pressed); // goodbye rebuilt
}
+ @Test
public void testWillNotRebuildActionsWithEmptyListOfInputsSpuriously()
throws Exception {
@@ -289,6 +308,7 @@ public class TimestampBuilderTest extends TimestampBuilderTestCase {
assertFalse(anotherButton.pressed);
}
+ @Test
public void testMissingSourceFileIsAnError() throws Exception {
// A missing input to an action must be treated as an error because there's
// a risk that the action that consumes it will succeed, but with a
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
index 5c52a90ae7..ef8fc9964f 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/TimestampBuilderTestCase.java
@@ -43,7 +43,7 @@ import com.google.devtools.build.lib.buildtool.SkyframeBuilder;
import com.google.devtools.build.lib.events.Reporter;
import com.google.devtools.build.lib.events.StoredEventHandler;
import com.google.devtools.build.lib.pkgcache.PathPackageLocator;
-import com.google.devtools.build.lib.testutil.FoundationTestCase;
+import com.google.devtools.build.lib.testutil.FoundationTestCaseForJunit4;
import com.google.devtools.build.lib.testutil.TestUtils;
import com.google.devtools.build.lib.util.AbruptExitException;
import com.google.devtools.build.lib.util.BlazeClock;
@@ -63,6 +63,8 @@ import com.google.devtools.build.skyframe.SkyFunctionName;
import com.google.devtools.build.skyframe.SkyKey;
import com.google.devtools.build.skyframe.SkyValue;
+import org.junit.Before;
+
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collection;
@@ -80,7 +82,7 @@ import javax.annotation.Nullable;
/**
* The common code that's shared between various builder tests.
*/
-public abstract class TimestampBuilderTestCase extends FoundationTestCase {
+public abstract class TimestampBuilderTestCase extends FoundationTestCaseForJunit4 {
private static final SkyKey OWNER_KEY = new SkyKey(SkyFunctions.ACTION_LOOKUP, "OWNER");
protected static final ActionLookupValue.ActionLookupKey ALL_OWNER =
@@ -95,9 +97,8 @@ public abstract class TimestampBuilderTestCase extends FoundationTestCase {
protected AtomicReference<EventBus> eventBusRef = new AtomicReference<>();
- @Override
- protected void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void initialize() throws Exception {
inMemoryCache = new InMemoryActionCache();
tsgm = new TimestampGranularityMonitor(clock);
ResourceManager.instance().setAvailableResources(ResourceSet.createWithRamCpuIo(100, 1, 1));
diff --git a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java
index da7eadc049..66630c837e 100644
--- a/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java
+++ b/src/test/java/com/google/devtools/build/lib/skyframe/WorkspaceFileFunctionTest.java
@@ -14,8 +14,12 @@
package com.google.devtools.build.lib.skyframe;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
import com.google.devtools.build.lib.analysis.ConfiguredRuleClassProvider;
-import com.google.devtools.build.lib.analysis.util.BuildViewTestCase;
+import com.google.devtools.build.lib.analysis.util.BuildViewTestCaseForJunit4;
import com.google.devtools.build.lib.bazel.rules.BazelRulesModule;
import com.google.devtools.build.lib.cmdline.Label;
import com.google.devtools.build.lib.packages.NoSuchTargetException;
@@ -30,6 +34,10 @@ import com.google.devtools.build.lib.vfs.RootedPath;
import com.google.devtools.build.skyframe.SkyFunction;
import com.google.devtools.build.skyframe.SkyKey;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
import org.mockito.Matchers;
import org.mockito.Mockito;
@@ -38,7 +46,8 @@ import java.io.IOException;
/**
* Test for {@link WorkspaceFileFunction}.
*/
-public class WorkspaceFileFunctionTest extends BuildViewTestCase {
+@RunWith(JUnit4.class)
+public class WorkspaceFileFunctionTest extends BuildViewTestCaseForJunit4 {
private WorkspaceFileFunction skyFunc;
private FakeFileValue fakeWorkspaceFileValue;
@@ -82,9 +91,8 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
}
}
- @Override
- public void setUp() throws Exception {
- super.setUp();
+ @Before
+ public final void setUp() throws Exception {
ConfiguredRuleClassProvider ruleClassProvider = TestRuleClassProvider.getRuleClassProvider();
skyFunc =
new WorkspaceFileFunction(
@@ -113,6 +121,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
return env;
}
+ @Test
public void testInvalidRepo() throws Exception {
RootedPath workspacePath = createWorkspaceFile("workspace(name = 'foo$')");
PackageValue value =
@@ -122,6 +131,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
MoreAsserts.assertContainsEvent(pkg.getEvents(), "target names may not contain '$'");
}
+ @Test
public void testBindFunction() throws Exception {
String lines[] = {"bind(name = 'foo/bar',", "actual = '//foo:bar')"};
RootedPath workspacePath = createWorkspaceFile(lines);
@@ -133,6 +143,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
MoreAsserts.assertNoEvents(pkg.getEvents());
}
+ @Test
public void testBindArgsReversed() throws Exception {
String lines[] = {"bind(actual = '//foo:bar', name = 'foo/bar')"};
RootedPath workspacePath = createWorkspaceFile(lines);
@@ -144,6 +155,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
MoreAsserts.assertNoEvents(pkg.getEvents());
}
+ @Test
public void testNonExternalBinding() throws Exception {
// name must be a valid label name.
String lines[] = {"bind(name = 'foo:bar', actual = '//bar/baz')"};
@@ -156,6 +168,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
MoreAsserts.assertContainsEvent(pkg.getEvents(), "target names may not contain ':'");
}
+ @Test
public void testWorkspaceFileParsingError() throws Exception {
// //external:bar:baz is not a legal package.
String lines[] = {"bind(name = 'foo/bar', actual = '//external:bar:baz')"};
@@ -168,6 +181,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
MoreAsserts.assertContainsEvent(pkg.getEvents(), "target names may not contain ':'");
}
+ @Test
public void testNoWorkspaceFile() throws Exception {
// Even though the WORKSPACE exists, Skyframe thinks it doesn't, so it doesn't.
String lines[] = {"bind(name = 'foo/bar', actual = '//foo:bar')"};
@@ -181,6 +195,7 @@ public class WorkspaceFileFunctionTest extends BuildViewTestCase {
MoreAsserts.assertNoEvents(pkg.getEvents());
}
+ @Test
public void testListBindFunction() throws Exception {
String lines[] = {
"L = ['foo', 'bar']", "bind(name = '%s/%s' % (L[0], L[1]),", "actual = '//foo:bar')"};