diff options
Diffstat (limited to 'src/test/java/com')
6 files changed, 38 insertions, 13 deletions
diff --git a/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java b/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java index 875c449d2f..72fc7e9d25 100644 --- a/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java +++ b/src/test/java/com/google/devtools/build/lib/actions/BaseSpawnTest.java @@ -38,7 +38,7 @@ public class BaseSpawnTest { private Root rootDir; @Before - public void setup() throws IOException { + public final void setup() throws IOException { Scratch scratch = new Scratch(); rootDir = Root.asDerivedRoot(scratch.dir("/fake/root/dont/matter")); } diff --git a/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java b/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java index 0735a0528f..2998460a76 100644 --- a/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java +++ b/src/test/java/com/google/devtools/build/lib/bazel/repository/StripPrefixedPathTest.java @@ -14,14 +14,23 @@ package com.google.devtools.build.lib.bazel.repository; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + import com.google.common.base.Optional; import com.google.devtools.build.lib.vfs.PathFragment; -import junit.framework.TestCase; + +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; /** * Tests {@link StripPrefixedPath}. */ -public class StripPrefixedPathTest extends TestCase { +@RunWith(JUnit4.class) +public class StripPrefixedPathTest { + @Test public void testStrip() { StripPrefixedPath result = StripPrefixedPath.maybeDeprefix("foo/bar", Optional.of("foo")); assertEquals(result.getPathFragment(), new PathFragment("bar")); diff --git a/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java b/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java index aaf9d4c3db..1e8c6044e2 100644 --- a/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java +++ b/src/test/java/com/google/devtools/build/lib/graph/DigraphTest.java @@ -28,7 +28,9 @@ import com.google.devtools.build.lib.packages.Rule; import com.google.devtools.build.lib.packages.RuleVisibility; import com.google.devtools.build.lib.packages.Target; -import junit.framework.TestCase; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.JUnit4; import java.util.Comparator; import java.util.List; @@ -37,7 +39,8 @@ import java.util.Set; /** * Test for {@link Digraph}. */ -public class DigraphTest extends TestCase { +@RunWith(JUnit4.class) +public class DigraphTest { class FakeTarget implements Target { @@ -98,6 +101,7 @@ public class DigraphTest extends TestCase { } } + @Test public void testStableOrdering() throws Exception { Digraph<Target> digraph = new Digraph<>(); FakeTarget a = new FakeTarget(Label.create("pkg", "a")); diff --git a/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java b/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java index b2f5c550ca..8f7b9a7ef9 100644 --- a/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java +++ b/src/test/java/com/google/devtools/build/lib/sandbox/LinuxSandboxedStrategyTestCase.java @@ -66,7 +66,7 @@ public class LinuxSandboxedStrategyTestCase { } @Before - public void setUp() throws Exception { + public final void createDirectoriesAndExecutor() throws Exception { Path testRoot = createTestRoot(); workspaceDir = testRoot.getRelative("workspace"); diff --git a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java index 715b7920b4..6e4bfd24ed 100644 --- a/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java +++ b/src/test/java/com/google/devtools/build/lib/standalone/StandaloneSpawnStrategyTest.java @@ -14,6 +14,9 @@ package com.google.devtools.build.lib.standalone; 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.ImmutableMap; @@ -46,7 +49,10 @@ import com.google.devtools.build.lib.vfs.Path; import com.google.devtools.build.lib.vfs.util.FileSystems; import com.google.devtools.common.options.OptionsParser; -import junit.framework.TestCase; +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.Arrays; @@ -54,7 +60,8 @@ import java.util.Arrays; /** * Test StandaloneSpawnStrategy. */ -public class StandaloneSpawnStrategyTest extends TestCase { +@RunWith(JUnit4.class) +public class StandaloneSpawnStrategyTest { private Reporter reporter = new Reporter(PrintingEventHandler.ERRORS_AND_WARNINGS_TO_STDERR); private BlazeExecutor executor; @@ -72,9 +79,8 @@ public class StandaloneSpawnStrategyTest extends TestCase { return testRoot; } - @Override - protected void setUp() throws Exception { - super.setUp(); + @Before + public final void setUp() throws Exception { Path testRoot = createTestRoot(); Path workspaceDir = testRoot.getRelative(TestConstants.WORKSPACE_NAME); workspaceDir.createDirectory(); @@ -120,6 +126,7 @@ public class StandaloneSpawnStrategyTest extends TestCase { return outErr.errAsLatin1(); } + @Test public void testBinTrueExecutesFine() throws Exception { Spawn spawn = createSpawn(getTrueCommand()); executor.getSpawnActionContext(spawn.getMnemonic()).exec(spawn, createContext()); @@ -141,6 +148,7 @@ public class StandaloneSpawnStrategyTest extends TestCase { null); } + @Test public void testBinFalseYieldsException() throws Exception { try { run(createSpawn(getFalseCommand())); @@ -159,7 +167,7 @@ public class StandaloneSpawnStrategyTest extends TestCase { return OS.getCurrent() == OS.DARWIN ? "/usr/bin/true" : "/bin/true"; } - + @Test public void testBinEchoPrintsArguments() throws Exception { Spawn spawn = createSpawn("/bin/echo", "Hello,", "world."); run(spawn); @@ -167,12 +175,14 @@ public class StandaloneSpawnStrategyTest extends TestCase { assertThat(err()).isEmpty(); } + @Test public void testCommandRunsInWorkingDir() throws Exception { Spawn spawn = createSpawn("/bin/pwd"); run(spawn); assertEquals(executor.getExecRoot() + "\n", out()); } + @Test public void testCommandHonorsEnvironment() throws Exception { Spawn spawn = new BaseSpawn.Local(Arrays.asList("/usr/bin/env"), ImmutableMap.of("foo", "bar", "baz", "boo"), @@ -181,6 +191,7 @@ public class StandaloneSpawnStrategyTest extends TestCase { assertEquals(Sets.newHashSet("foo=bar", "baz=boo"), Sets.newHashSet(out().split("\n"))); } + @Test public void testStandardError() throws Exception { Spawn spawn = createSpawn("/bin/sh", "-c", "echo Oops! >&2"); run(spawn); @@ -191,6 +202,7 @@ public class StandaloneSpawnStrategyTest extends TestCase { // Test an action with environment variables set indicating an action running on a darwin host // system. Such actions should fail given the fact that these tests run on a non darwin // architecture. + @Test public void testIOSEnvironmentOnNonDarwin() throws Exception { if (OS.getCurrent() == OS.DARWIN) { return; diff --git a/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java b/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java index f915304277..dafcb1c030 100644 --- a/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java +++ b/src/test/java/com/google/devtools/build/lib/unix/FilesystemUtilsTest.java @@ -42,7 +42,7 @@ public class FilesystemUtilsTest { private Path testFile; @Before - public void setUp() throws Exception { + public final void createFileSystem() throws Exception { testFS = new UnixFileSystem(); workingDir = testFS.getPath(new File(TestUtils.tmpDir()).getCanonicalPath()); testFile = workingDir.getRelative("test"); |