use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxTestStepTest method setUp.
@Before
public void setUp() throws IOException {
exitCode = tmpDir.newFile("exitCode").toPath();
output = tmpDir.newFile("output").toPath();
context = TestExecutionContext.newInstance();
filesystem = new FakeProjectFilesystem();
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class CxxTestTest method runTests.
@Test
public void runTests() {
final ImmutableList<String> command = ImmutableList.of("hello", "world");
FakeCxxTest cxxTest = new FakeCxxTest() {
@Override
public SourcePath getSourcePathToOutput() {
return new ExplicitBuildTargetSourcePath(getBuildTarget(), Paths.get("output"));
}
@Override
protected ImmutableList<String> getShellCommand(SourcePathResolver resolver, Path output) {
return command;
}
@Override
public Tool getExecutableCommand() {
CommandTool.Builder builder = new CommandTool.Builder();
command.forEach(builder::addArg);
return builder.build();
}
};
ExecutionContext executionContext = TestExecutionContext.newInstance();
TestRunningOptions options = TestRunningOptions.builder().setTestSelectorList(TestSelectorList.empty()).build();
ImmutableList<Step> actualSteps = cxxTest.runTests(executionContext, options, createMock(SourcePathResolver.class), FakeTestRule.NOOP_REPORTING_CALLBACK);
CxxTestStep cxxTestStep = new CxxTestStep(new FakeProjectFilesystem(), command, ImmutableMap.of(), cxxTest.getPathToTestExitCode(), cxxTest.getPathToTestOutput(), TEST_TIMEOUT_MS);
assertEquals(cxxTestStep, Iterables.getLast(actualSteps));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class DirectHeaderMapTest method setUp.
@Before
public void setUp() throws Exception {
projectFilesystem = new FakeProjectFilesystem(tmpDir.getRoot());
// Create a build target to use when building the symlink tree.
buildTarget = BuildTargetFactory.newInstance("//test:test");
// Get the first file we're symlinking
Path link1 = Paths.get("file");
file1 = tmpDir.newFile();
Files.write(file1, "hello world".getBytes(Charsets.UTF_8));
// Get the second file we're symlinking
Path link2 = Paths.get("directory", "then", "file");
file2 = tmpDir.newFile();
Files.write(file2, "hello world".getBytes(Charsets.UTF_8));
// Setup the map representing the link tree.
links = ImmutableMap.of(link1, new PathSourcePath(projectFilesystem, MorePaths.relativize(tmpDir.getRoot(), file1)), link2, new PathSourcePath(projectFilesystem, MorePaths.relativize(tmpDir.getRoot(), file2)));
// The output path used by the buildable for the link tree.
symlinkTreeRoot = BuildTargets.getGenPath(projectFilesystem, buildTarget, "%s/symlink-tree-root");
// Setup the symlink tree buildable.
ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
ruleFinder = new SourcePathRuleFinder(ruleResolver);
pathResolver = new SourcePathResolver(ruleFinder);
buildRule = new DirectHeaderMap(buildTarget, projectFilesystem, symlinkTreeRoot, links, ruleFinder);
ruleResolver.addToIndex(buildRule);
headerMapPath = pathResolver.getRelativePath(buildRule.getSourcePathToOutput());
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class HeaderSymlinkTreeWithHeaderMapTest method testSymlinkTreeBuildSteps.
@Test
public void testSymlinkTreeBuildSteps() throws IOException {
BuildContext buildContext = FakeBuildContext.withSourcePathResolver(resolver);
ProjectFilesystem filesystem = new FakeProjectFilesystem();
FakeBuildableContext buildableContext = new FakeBuildableContext();
ImmutableList<Step> expectedBuildSteps = ImmutableList.of(new MakeCleanDirectoryStep(filesystem, symlinkTreeRoot), new SymlinkTreeStep(filesystem, symlinkTreeRoot, resolver.getMappedPaths(links)), new HeaderMapStep(filesystem, HeaderSymlinkTreeWithHeaderMap.getPath(filesystem, buildTarget), ImmutableMap.of(Paths.get("file"), filesystem.getBuckPaths().getBuckOut().relativize(symlinkTreeRoot).resolve("file"), Paths.get("directory/then/file"), filesystem.getBuckPaths().getBuckOut().relativize(symlinkTreeRoot).resolve("directory/then/file"))));
ImmutableList<Step> actualBuildSteps = symlinkTreeBuildRule.getBuildSteps(buildContext, buildableContext);
assertEquals(expectedBuildSteps, actualBuildSteps.subList(1, actualBuildSteps.size()));
}
use of com.facebook.buck.testutil.FakeProjectFilesystem in project buck by facebook.
the class HeaderSymlinkTreeWithHeaderMapTest method setUp.
@Before
public void setUp() throws Exception {
projectFilesystem = new FakeProjectFilesystem(tmpDir.getRoot());
// Create a build target to use when building the symlink tree.
buildTarget = BuildTargetFactory.newInstance("//test:test");
// Get the first file we're symlinking
Path link1 = Paths.get("file");
Path file1 = tmpDir.newFile();
Files.write(file1, "hello world".getBytes(Charsets.UTF_8));
// Get the second file we're symlinking
Path link2 = Paths.get("directory", "then", "file");
Path file2 = tmpDir.newFile();
Files.write(file2, "hello world".getBytes(Charsets.UTF_8));
// Setup the map representing the link tree.
links = ImmutableMap.of(link1, new PathSourcePath(projectFilesystem, MorePaths.relativize(tmpDir.getRoot(), file1)), link2, new PathSourcePath(projectFilesystem, MorePaths.relativize(tmpDir.getRoot(), file2)));
// The output path used by the buildable for the link tree.
symlinkTreeRoot = BuildTargets.getGenPath(projectFilesystem, buildTarget, "%s/symlink-tree-root");
ruleResolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
ruleFinder = new SourcePathRuleFinder(ruleResolver);
resolver = new SourcePathResolver(ruleFinder);
// Setup the symlink tree buildable.
symlinkTreeBuildRule = HeaderSymlinkTreeWithHeaderMap.create(buildTarget, projectFilesystem, symlinkTreeRoot, links, ruleFinder);
}
Aggregations