Search in sources :

Example 1 with FakeCellPathResolver

use of com.facebook.buck.rules.FakeCellPathResolver in project buck by facebook.

the class BuildTargetParserTest method testParseWithRepoName.

@Test
public void testParseWithRepoName() {
    final Path localRepoRoot = Paths.get("/opt/local/repo");
    CellPathResolver cellRoots = new FakeCellPathResolver(ImmutableMap.of("localreponame", localRepoRoot));
    String targetStr = "localreponame//foo/bar:baz";
    BuildTarget buildTarget = parser.parse(targetStr, fullyQualifiedParser, cellRoots);
    assertEquals("localreponame//foo/bar:baz", buildTarget.getFullyQualifiedName());
    assertTrue(buildTarget.getCell().isPresent());
    assertEquals(localRepoRoot, buildTarget.getCellPath());
}
Also used : Path(java.nio.file.Path) BuildTarget(com.facebook.buck.model.BuildTarget) FakeCellPathResolver(com.facebook.buck.rules.FakeCellPathResolver) CellPathResolver(com.facebook.buck.rules.CellPathResolver) FakeCellPathResolver(com.facebook.buck.rules.FakeCellPathResolver) Test(org.junit.Test)

Example 2 with FakeCellPathResolver

use of com.facebook.buck.rules.FakeCellPathResolver in project buck by facebook.

the class BuildTargetPatternParserTest method visibilityCanContainCrossCellReference.

@Test
public void visibilityCanContainCrossCellReference() {
    BuildTargetPatternParser<BuildTargetPattern> buildTargetPatternParser = BuildTargetPatternParser.forVisibilityArgument();
    final ProjectFilesystem filesystem = FakeProjectFilesystem.createJavaOnlyFilesystem();
    CellPathResolver cellNames = new FakeCellPathResolver(ImmutableMap.of("other", filesystem.getRootPath()));
    assertEquals(new SingletonBuildTargetPattern(filesystem.getRootPath(), "//:something"), buildTargetPatternParser.parse(cellNames, "other//:something"));
    assertEquals(new SubdirectoryBuildTargetPattern(filesystem.getRootPath(), filesystem.getPath("sub")), buildTargetPatternParser.parse(cellNames, "other//sub/..."));
}
Also used : SubdirectoryBuildTargetPattern(com.facebook.buck.model.SubdirectoryBuildTargetPattern) ImmediateDirectoryBuildTargetPattern(com.facebook.buck.model.ImmediateDirectoryBuildTargetPattern) BuildTargetPattern(com.facebook.buck.model.BuildTargetPattern) SingletonBuildTargetPattern(com.facebook.buck.model.SingletonBuildTargetPattern) SingletonBuildTargetPattern(com.facebook.buck.model.SingletonBuildTargetPattern) FakeCellPathResolver(com.facebook.buck.rules.FakeCellPathResolver) SubdirectoryBuildTargetPattern(com.facebook.buck.model.SubdirectoryBuildTargetPattern) CellPathResolver(com.facebook.buck.rules.CellPathResolver) FakeCellPathResolver(com.facebook.buck.rules.FakeCellPathResolver) FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) Test(org.junit.Test)

Example 3 with FakeCellPathResolver

use of com.facebook.buck.rules.FakeCellPathResolver in project buck by facebook.

the class SourcePathTypeCoercerTest method coerceCrossRepoBuildTarget.

@Test
public void coerceCrossRepoBuildTarget() throws CoerceFailedException, IOException {
    Path helloRoot = Paths.get("/opt/src/hello");
    cellRoots = new FakeCellPathResolver(projectFilesystem, ImmutableMap.of("hello", helloRoot));
    SourcePath sourcePath = sourcePathTypeCoercer.coerce(cellRoots, projectFilesystem, pathRelativeToProjectRoot, "hello//:hello");
    // Note that the important thing is that the root of the target has been set to `helloRoot` so
    // the cell name should be absent (otherwise, we'd look for a cell named `@hello` from the
    // `@hello` cell. Yeah. My head hurts a little too.
    assertEquals(new DefaultBuildTargetSourcePath(BuildTarget.of(UnflavoredBuildTarget.of(helloRoot, Optional.of("hello"), "//", "hello"), ImmutableSortedSet.of())), sourcePath);
}
Also used : SourcePath(com.facebook.buck.rules.SourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) Path(java.nio.file.Path) SourcePath(com.facebook.buck.rules.SourcePath) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) PathSourcePath(com.facebook.buck.rules.PathSourcePath) FakeCellPathResolver(com.facebook.buck.rules.FakeCellPathResolver) DefaultBuildTargetSourcePath(com.facebook.buck.rules.DefaultBuildTargetSourcePath) Test(org.junit.Test)

Example 4 with FakeCellPathResolver

use of com.facebook.buck.rules.FakeCellPathResolver in project buck by facebook.

the class SourcePathTypeCoercerTest method setUp.

@Before
public void setUp() {
    projectFilesystem = new FakeProjectFilesystem();
    cellRoots = new FakeCellPathResolver(projectFilesystem);
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeCellPathResolver(com.facebook.buck.rules.FakeCellPathResolver) Before(org.junit.Before)

Aggregations

FakeCellPathResolver (com.facebook.buck.rules.FakeCellPathResolver)4 Test (org.junit.Test)3 CellPathResolver (com.facebook.buck.rules.CellPathResolver)2 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)2 Path (java.nio.file.Path)2 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)1 BuildTarget (com.facebook.buck.model.BuildTarget)1 BuildTargetPattern (com.facebook.buck.model.BuildTargetPattern)1 ImmediateDirectoryBuildTargetPattern (com.facebook.buck.model.ImmediateDirectoryBuildTargetPattern)1 SingletonBuildTargetPattern (com.facebook.buck.model.SingletonBuildTargetPattern)1 SubdirectoryBuildTargetPattern (com.facebook.buck.model.SubdirectoryBuildTargetPattern)1 DefaultBuildTargetSourcePath (com.facebook.buck.rules.DefaultBuildTargetSourcePath)1 PathSourcePath (com.facebook.buck.rules.PathSourcePath)1 SourcePath (com.facebook.buck.rules.SourcePath)1 Before (org.junit.Before)1