Exemplo n.º 1
0
 @Test
 public void testNotEquals() {
   BuildTarget utilTarget =
       BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
   BuildTarget ioTarget = BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "io").build();
   assertFalse(utilTarget.equals(ioTarget));
 }
Exemplo n.º 2
0
  @Test
  public void testEqualsOtherBuildTarget() {
    BuildTarget utilTarget1 =
        BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
    assertEquals(utilTarget1, utilTarget1);

    BuildTarget utilTarget2 =
        BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
    assertEquals(utilTarget1, utilTarget2);
  }
Exemplo n.º 3
0
 @Test
 public void testBuildTargetWithoutFlavor() {
   BuildTarget target = BuildTarget.builder(ROOT, "//foo/bar", "baz").build();
   assertEquals(target.getShortNameAndFlavorPostfix(), "baz");
   assertEquals(ImmutableSortedSet.<Flavor>of(), target.getFlavors());
   assertFalse(target.isFlavored());
 }
Exemplo n.º 4
0
 @Test
 public void testBuildTargetWithFlavor() {
   BuildTarget target =
       BuildTarget.builder(ROOT, "//foo/bar", "baz").addFlavors(ImmutableFlavor.of("dex")).build();
   assertEquals("baz#dex", target.getShortNameAndFlavorPostfix());
   assertEquals(ImmutableSortedSet.of(ImmutableFlavor.of("dex")), target.getFlavors());
   assertTrue(target.isFlavored());
 }
Exemplo n.º 5
0
  @Test
  public void testGetUnflavoredTarget() {
    UnflavoredBuildTarget unflavoredTarget =
        UnflavoredBuildTarget.builder("//foo/bar", "baz").setCellPath(ROOT).build();

    BuildTarget flavoredTarget =
        BuildTarget.builder(ROOT, "//foo/bar", "baz").addFlavors(ImmutableFlavor.of("biz")).build();
    assertEquals(unflavoredTarget, flavoredTarget.getUnflavoredBuildTarget());
  }
Exemplo n.º 6
0
 @Test
 public void testFlavorIsValid() {
   try {
     BuildTarget.builder(ROOT, "//foo/bar", "baz").addFlavors(ImmutableFlavor.of("d!x")).build();
     fail("Should have thrown IllegalArgumentException.");
   } catch (IllegalArgumentException e) {
     assertEquals("Invalid characters in flavor name: d!x", e.getMessage());
   }
 }
Exemplo n.º 7
0
 @Test
 public void testBuildTargetTwoLevelsDeep() {
   BuildTarget rootTarget = BuildTarget.builder(ROOT, "//java/com/facebook", "fb4a").build();
   assertEquals("fb4a", rootTarget.getShortNameAndFlavorPostfix());
   assertEquals("//java/com/facebook", rootTarget.getBaseName());
   assertEquals("//java/com/facebook/", rootTarget.getBaseNameWithSlash());
   assertEquals(Paths.get("java/com/facebook"), rootTarget.getBasePath());
   assertEquals("java/com/facebook/", rootTarget.getBasePathWithSlash());
   assertEquals("//java/com/facebook:fb4a", rootTarget.getFullyQualifiedName());
   assertEquals("//java/com/facebook:fb4a", rootTarget.toString());
 }
Exemplo n.º 8
0
 @Test
 public void testRootBuildTarget() {
   BuildTarget rootTarget = BuildTarget.builder(ROOT, "//", "fb4a").build();
   assertEquals("fb4a", rootTarget.getShortNameAndFlavorPostfix());
   assertEquals("//", rootTarget.getBaseName());
   assertEquals("//", rootTarget.getBaseNameWithSlash());
   assertEquals(Paths.get(""), rootTarget.getBasePath());
   assertEquals("", rootTarget.getBasePathWithSlash());
   assertEquals("//:fb4a", rootTarget.getFullyQualifiedName());
   assertEquals("//:fb4a", rootTarget.toString());
 }
Exemplo n.º 9
0
 @Test
 public void testShortNameCannotContainHashWhenFlavorSet() {
   try {
     BuildTarget.builder(ROOT, "//foo/bar", "baz#dex")
         .addFlavors(ImmutableFlavor.of("src-jar"))
         .build();
     fail("Should have thrown IllegalArgumentException.");
   } catch (IllegalArgumentException e) {
     assertEquals("Build target name cannot contain '#' but was: baz#dex.", e.getMessage());
   }
 }
Exemplo n.º 10
0
 @Test
 public void testEqualsNullReturnsFalse() {
   BuildTarget utilTarget =
       BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
   assertNotNull(utilTarget);
 }
Exemplo n.º 11
0
 @Test
 public void testNumbersAreValidFlavors() {
   BuildTarget.builder(ROOT, "//foo", "bar").addFlavors(ImmutableFlavor.of("1234")).build();
 }
Exemplo n.º 12
0
 @Test
 public void testFlavorDefaultsToNoneIfNotSet() {
   assertEquals(
       ImmutableSet.<Flavor>of(),
       BuildTarget.builder(ROOT, "//foo/bar", "baz").build().getFlavors());
 }
Exemplo n.º 13
0
 @Test(expected = IllegalArgumentException.class)
 public void testShortNamesMustNotContainTheFlavorSeparator() {
   BuildTarget.builder(ROOT, "//foo/bar", "baz#dex").build();
 }