示例#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));
 }
示例#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);
  }
示例#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());
 }
示例#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());
 }
示例#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());
  }
示例#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());
   }
 }
示例#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());
 }
示例#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());
 }
示例#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());
   }
 }
示例#10
0
 @Test
 public void testEqualsNullReturnsFalse() {
   BuildTarget utilTarget =
       BuildTarget.builder(ROOT, "//src/com/facebook/buck/util", "util").build();
   assertNotNull(utilTarget);
 }
示例#11
0
 @Test
 public void testNumbersAreValidFlavors() {
   BuildTarget.builder(ROOT, "//foo", "bar").addFlavors(ImmutableFlavor.of("1234")).build();
 }
示例#12
0
 @Test
 public void testFlavorDefaultsToNoneIfNotSet() {
   assertEquals(
       ImmutableSet.<Flavor>of(),
       BuildTarget.builder(ROOT, "//foo/bar", "baz").build().getFlavors());
 }
示例#13
0
 @Test(expected = IllegalArgumentException.class)
 public void testShortNamesMustNotContainTheFlavorSeparator() {
   BuildTarget.builder(ROOT, "//foo/bar", "baz#dex").build();
 }