use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testSimpleBuildWithProgress.
@Test
public void testSimpleBuildWithProgress() throws IOException {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
BuildTarget fakeTarget = BuildTargetFactory.newInstance("//banana:stand");
BuildTarget cachedTarget = BuildTargetFactory.newInstance("//chicken:dance");
ImmutableSet<BuildTarget> buildTargets = ImmutableSet.of(fakeTarget, cachedTarget);
Iterable<String> buildArgs = Iterables.transform(buildTargets, Object::toString);
FakeBuildRule fakeRule = new FakeBuildRule(fakeTarget, pathResolver, ImmutableSortedSet.of());
FakeBuildRule cachedRule = new FakeBuildRule(cachedTarget, pathResolver, ImmutableSortedSet.of());
ProgressEstimator e = new ProgressEstimator(getStorageForTest(), eventBus, ObjectMappers.newDefaultInstance());
listener.setProgressEstimator(e);
eventBus.register(listener);
BuildEvent.RuleCountCalculated ruleCountCalculated = BuildEvent.ruleCountCalculated(ImmutableSet.of(), 10);
eventBus.post(ruleCountCalculated);
BuildEvent.Started buildEventStarted = BuildEvent.started(buildArgs);
eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ParseEvent.Started parseStarted = ParseEvent.started(buildTargets);
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 300L, ImmutableList.of("[+] PROCESSING BUCK FILES...0.1s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ActionGraphEvent.Started actionGraphStarted = ActionGraphEvent.started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(actionGraphStarted, 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ActionGraphEvent.finished(actionGraphStarted), 400L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String parsingLine = "[-] PROCESSING BUCK FILES...FINISHED 0.2s";
validateConsole(listener, 540L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.1s" + " [0%] (0/10 JOBS, 0 UPDATED, " + "0 [0.0%] CACHE MISS)"));
BuildRuleEvent.Started started = BuildRuleEvent.started(fakeRule, durationTracker);
eventBus.postWithoutConfiguring(configureTestEventAtTime(started, 600L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 800L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.4s" + " [0%] (0/10 JOBS, 0 UPDATED, " + "0 [0.0%] CACHE MISS)", " |=> //banana:stand... 0.2s (checking_cache)"));
String stepShortName = "doing_something";
String stepDescription = "working hard";
UUID stepUuid = UUID.randomUUID();
StepEvent.Started stepEventStarted = StepEvent.started(stepShortName, stepDescription, stepUuid);
eventBus.postWithoutConfiguring(configureTestEventAtTime(stepEventStarted, 800L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 900L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.5s" + " [0%] (0/10 JOBS, 0 UPDATED, " + "0 [0.0%] CACHE MISS)", " |=> //banana:stand... 0.3s (running doing_something[0.1s])"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(StepEvent.finished(stepEventStarted, 0), 900L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildRuleEvent.finished(started, BuildRuleKeys.of(new RuleKey("aaaa")), BuildRuleStatus.SUCCESS, CacheResult.miss(), Optional.of(BuildRuleSuccessType.BUILT_LOCALLY), Optional.empty(), Optional.empty()), 1000L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 1000L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.6s [10%] (1/10 JOBS, 1 UPDATED, 1 [10.0%] CACHE MISS)", " |=> IDLE"));
BuildRuleEvent.Started startedCached = BuildRuleEvent.started(cachedRule, durationTracker);
eventBus.postWithoutConfiguring(configureTestEventAtTime(startedCached, 1010L, TimeUnit.MILLISECONDS, /* threadId */
2L));
validateConsole(listener, 1100L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.7s [10%] (1/10 JOBS, 1 UPDATED, 1 [10.0%] CACHE MISS)", " |=> IDLE", " |=> //chicken:dance... 0.1s (checking_cache)"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildRuleEvent.finished(startedCached, BuildRuleKeys.of(new RuleKey("aaaa")), BuildRuleStatus.SUCCESS, CacheResult.miss(), Optional.of(BuildRuleSuccessType.BUILT_LOCALLY), Optional.empty(), Optional.empty()), 1120L, TimeUnit.MILLISECONDS, /* threadId */
2L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildEvent.finished(buildEventStarted, 0), 1234L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String buildingLine = "[-] BUILDING...FINISHED 0.8s" + " [100%] (2/10 JOBS, 2 UPDATED, 2 [20.0%] CACHE MISS)";
validateConsole(listener, 1300L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testSkippedTest.
@Test
public void testSkippedTest() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
BuildTarget testTarget = BuildTargetFactory.newInstance("//:test");
ImmutableSet<BuildTarget> testTargets = ImmutableSet.of(testTarget);
Iterable<String> testArgs = Iterables.transform(testTargets, Object::toString);
FakeBuildRule testBuildRule = new FakeBuildRule(testTarget, pathResolver, ImmutableSortedSet.of());
ProjectBuildFileParseEvents.Started parseEventStarted = new ProjectBuildFileParseEvents.Started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseEventStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 0L, ImmutableList.of("[+] PARSING BUCK FILES...0.0s"));
validateConsole(listener, 100L, ImmutableList.of("[+] PARSING BUCK FILES...0.1s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(new ProjectBuildFileParseEvents.Finished(parseEventStarted), 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 200L, ImmutableList.of("[-] PARSING BUCK FILES...FINISHED 0.2s"));
BuildEvent.Started buildEventStarted = BuildEvent.started(testArgs);
eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ParseEvent.Started parseStarted = ParseEvent.started(testTargets);
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 200L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 300L, ImmutableList.of("[+] PROCESSING BUCK FILES...0.1s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
ActionGraphEvent.Started actionGraphStarted = ActionGraphEvent.started();
eventBus.postWithoutConfiguring(configureTestEventAtTime(actionGraphStarted, 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ActionGraphEvent.finished(actionGraphStarted), 400L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String parsingLine = "[-] PROCESSING BUCK FILES...FINISHED 0.2s";
validateConsole(listener, 540L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.1s"));
BuildRuleEvent.Started started = BuildRuleEvent.started(testBuildRule, durationTracker);
eventBus.postWithoutConfiguring(configureTestEventAtTime(started, 600L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 800L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.4s", " |=> //:test... 0.2s (checking_cache)"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildRuleEvent.finished(started, BuildRuleKeys.of(new RuleKey("aaaa")), BuildRuleStatus.SUCCESS, CacheResult.miss(), Optional.of(BuildRuleSuccessType.BUILT_LOCALLY), Optional.empty(), Optional.empty()), 1000L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildEvent.finished(buildEventStarted, 0), 1234L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String buildingLine = "[-] BUILDING...FINISHED 0.8s";
validateConsole(listener, 1300L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine));
eventBus.postWithoutConfiguring(configureTestEventAtTime(TestRunEvent.started(// isRunAllTests
true, TestSelectorList.empty(), // shouldExplainTestSelectorList
false, ImmutableSet.copyOf(testArgs)), 2500L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 3000L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...0.5s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(TestRuleEvent.started(testTarget), 3100L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 3200L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...0.7s", " |=> //:test... 0.1s"));
UUID stepUuid = new UUID(0, 1);
StepEvent.Started stepEventStarted = StepEvent.started("step_name", "step_desc", stepUuid);
eventBus.postWithoutConfiguring(configureTestEventAtTime(stepEventStarted, 3300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 3400L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...0.9s", " |=> //:test... 0.3s (running step_name[0.1s])"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(StepEvent.finished(stepEventStarted, 0), 3500L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 3600L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...1.1s", " |=> //:test... 0.5s"));
UUID testUUID = new UUID(2, 3);
eventBus.postWithoutConfiguring(configureTestEventAtTime(TestSummaryEvent.started(testUUID, "TestClass", "Foo"), 3700L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 3800L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...1.3s", " |=> //:test... 0.7s (running Foo[0.1s])"));
TestResultSummary testResultSummary = new TestResultSummary("TestClass", "Foo", ResultType.ASSUMPTION_VIOLATION, // time
0L, // message
null, // stacktrace
null, // stdOut
null, // stdErr
null);
eventBus.postWithoutConfiguring(configureTestEventAtTime(TestSummaryEvent.finished(testUUID, testResultSummary), 3900L, TimeUnit.MILLISECONDS, /* threadId */
0L));
validateConsole(listener, 4000L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...1.5s (0 PASS/1 SKIP/0 FAIL)", " |=> //:test... 0.9s"));
eventBus.postWithoutConfiguring(configureTestEventAtTime(TestRunEvent.finished(ImmutableSet.copyOf(testArgs), ImmutableList.of(TestResults.of(testTarget, ImmutableList.of(new TestCaseSummary("TestClass", ImmutableList.of(testResultSummary))), // contacts
ImmutableSet.of(), // labels
ImmutableSet.of()))), 4100L, TimeUnit.MILLISECONDS, /* threadId */
0L));
final String testingLine = "[-] TESTING...FINISHED 1.6s (0 PASS/1 SKIP/0 FAIL)";
validateConsoleWithStdOutAndErr(listener, 4200L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, testingLine), ImmutableList.of(), Optional.of(Joiner.on('\n').join("RESULTS FOR ALL TESTS", "ASSUME <100ms 0 Passed 1 Skipped 0 Failed TestClass", "NO TESTS RAN (assumption violations)", "")), // We don't care about stderr, since the last frame will be flushed there.
Optional.empty());
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class SuperConsoleEventBusListenerTest method testBuildRuleSuspendResumeEvents.
@Test
public void testBuildRuleSuspendResumeEvents() {
Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
SuperConsoleEventBusListener listener = createSuperConsole(fakeClock, eventBus);
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
BuildTarget fakeTarget = BuildTargetFactory.newInstance("//banana:stand");
ImmutableSet<BuildTarget> buildTargets = ImmutableSet.of(fakeTarget);
Iterable<String> buildArgs = Iterables.transform(buildTargets, Object::toString);
FakeBuildRule fakeRule = new FakeBuildRule(fakeTarget, pathResolver, ImmutableSortedSet.of());
String stepShortName = "doing_something";
String stepDescription = "working hard";
UUID stepUuid = UUID.randomUUID();
FakeRuleKeyFactory ruleKeyFactory = new FakeRuleKeyFactory(ImmutableMap.of(fakeTarget, new RuleKey("aaaa")));
// Start the build.
BuildEvent.Started buildEventStarted = BuildEvent.started(buildArgs);
eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Start and stop parsing.
String parsingLine = "[-] PROCESSING BUCK FILES...FINISHED 0.0s";
ParseEvent.Started parseStarted = ParseEvent.started(buildTargets);
eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(ActionGraphEvent.finished(ActionGraphEvent.started()), 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Start the rule.
BuildRuleEvent.Started started = BuildRuleEvent.started(fakeRule, durationTracker);
eventBus.postWithoutConfiguring(configureTestEventAtTime(started, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Post events that run a step for 100ms.
StepEvent.Started stepEventStarted = StepEvent.started(stepShortName, stepDescription, stepUuid);
eventBus.postWithoutConfiguring(configureTestEventAtTime(stepEventStarted, 0L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(StepEvent.finished(stepEventStarted, /* exitCode */
0), 100L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Suspend the rule.
BuildRuleEvent.Suspended suspended = BuildRuleEvent.suspended(started, ruleKeyFactory);
eventBus.postWithoutConfiguring(configureTestEventAtTime(suspended, 100L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Verify that the rule isn't printed now that it's suspended.
validateConsole(listener, 200L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.2s", " |=> IDLE"));
// Resume the rule.
BuildRuleEvent.Resumed resumed = BuildRuleEvent.resumed(fakeRule, durationTracker, ruleKeyFactory);
eventBus.postWithoutConfiguring(configureTestEventAtTime(resumed, 300L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Verify that we print "checking local..." now that we've resumed, and that we're accounting
// for previous running time.
validateConsole(listener, 300L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.3s", " |=> //banana:stand... 0.1s (checking_cache)"));
// Post events that run another step.
StepEvent.Started step2EventStarted = StepEvent.started(stepShortName, stepDescription, stepUuid);
eventBus.postWithoutConfiguring(configureTestEventAtTime(step2EventStarted, 400L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Verify the current console now accounts for the step.
validateConsole(listener, 500L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.5s", " |=> //banana:stand... 0.3s (running doing_something[0.1s])"));
// Finish the step and rule.
eventBus.postWithoutConfiguring(configureTestEventAtTime(StepEvent.finished(step2EventStarted, /* exitCode */
0), 600L, TimeUnit.MILLISECONDS, /* threadId */
0L));
eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildRuleEvent.finished(resumed, BuildRuleKeys.of(new RuleKey("aaaa")), BuildRuleStatus.SUCCESS, CacheResult.miss(), Optional.of(BuildRuleSuccessType.BUILT_LOCALLY), Optional.empty(), Optional.empty()), 600L, TimeUnit.MILLISECONDS, /* threadId */
0L));
// Verify that the rule isn't printed now that it's finally finished..
validateConsole(listener, 700L, ImmutableList.of(parsingLine, DOWNLOAD_STRING, "[+] BUILDING...0.7s", " |=> IDLE"));
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class WorkerToolTest method testCreateWorkerToolWithBadExeValue.
@Test
public void testCreateWorkerToolWithBadExeValue() throws NoSuchBuildTargetException {
BuildRuleResolver resolver = new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer());
BuildRule nonBinaryBuildRule = new FakeBuildRule(BuildTargetFactory.newInstance("//:fake"), new SourcePathResolver(new SourcePathRuleFinder(resolver)));
resolver.addToIndex(nonBinaryBuildRule);
BuildTarget workerTarget = BuildTargetFactory.newInstance("//:worker_rule");
try {
WorkerToolBuilder.newWorkerToolBuilder(workerTarget).setExe(nonBinaryBuildRule.getBuildTarget()).build(resolver);
} catch (HumanReadableException e) {
assertThat(e.getHumanReadableErrorMessage(), Matchers.containsString("needs to correspond to a binary rule"));
}
}
use of com.facebook.buck.rules.FakeBuildRule in project buck by facebook.
the class CxxLibraryTest method cxxLibraryInterfaces.
@Test
public void cxxLibraryInterfaces() {
SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
BuildTarget target = BuildTargetFactory.newInstance("//foo:bar");
BuildRuleParams params = new FakeBuildRuleParamsBuilder(target).build();
CxxPlatform cxxPlatform = CxxPlatformUtils.build(new CxxBuckConfig(FakeBuckConfig.builder().build()));
// Setup some dummy values for the header info.
final BuildTarget publicHeaderTarget = BuildTargetFactory.newInstance("//:header");
final BuildTarget publicHeaderSymlinkTreeTarget = BuildTargetFactory.newInstance("//:symlink");
final BuildTarget privateHeaderTarget = BuildTargetFactory.newInstance("//:privateheader");
final BuildTarget privateHeaderSymlinkTreeTarget = BuildTargetFactory.newInstance("//:privatesymlink");
// Setup some dummy values for the library archive info.
final BuildRule archive = new FakeBuildRule("//:archive", pathResolver).setOutputFile("libarchive.a");
// Setup some dummy values for the library archive info.
final BuildRule sharedLibrary = new FakeBuildRule("//:shared", pathResolver).setOutputFile("libshared.so");
final Path sharedLibraryOutput = Paths.get("output/path/lib.so");
final String sharedLibrarySoname = "lib.so";
// Construct a CxxLibrary object to test.
FakeCxxLibrary cxxLibrary = new FakeCxxLibrary(params, publicHeaderTarget, publicHeaderSymlinkTreeTarget, privateHeaderTarget, privateHeaderSymlinkTreeTarget, archive, sharedLibrary, sharedLibraryOutput, sharedLibrarySoname, ImmutableSortedSet.of());
// Verify that we get the header/symlink targets and root via the CxxPreprocessorDep
// interface.
CxxPreprocessorInput expectedPublicCxxPreprocessorInput = CxxPreprocessorInput.builder().addIncludes(CxxSymlinkTreeHeaders.builder().setIncludeType(CxxPreprocessables.IncludeType.LOCAL).putNameToPathMap(Paths.get("header.h"), new DefaultBuildTargetSourcePath(publicHeaderTarget)).setRoot(new DefaultBuildTargetSourcePath(publicHeaderSymlinkTreeTarget)).build()).build();
assertEquals(expectedPublicCxxPreprocessorInput, cxxLibrary.getCxxPreprocessorInput(cxxPlatform, HeaderVisibility.PUBLIC));
CxxPreprocessorInput expectedPrivateCxxPreprocessorInput = CxxPreprocessorInput.builder().addIncludes(CxxSymlinkTreeHeaders.builder().setIncludeType(CxxPreprocessables.IncludeType.LOCAL).setRoot(new DefaultBuildTargetSourcePath(privateHeaderSymlinkTreeTarget)).putNameToPathMap(Paths.get("header.h"), new DefaultBuildTargetSourcePath(privateHeaderTarget)).build()).build();
assertEquals(expectedPrivateCxxPreprocessorInput, cxxLibrary.getCxxPreprocessorInput(cxxPlatform, HeaderVisibility.PRIVATE));
// Verify that we get the static archive and its build target via the NativeLinkable
// interface.
NativeLinkableInput expectedStaticNativeLinkableInput = NativeLinkableInput.of(ImmutableList.of(SourcePathArg.of(archive.getSourcePathToOutput())), ImmutableSet.of(), ImmutableSet.of());
assertEquals(expectedStaticNativeLinkableInput, cxxLibrary.getNativeLinkableInput(cxxPlatform, Linker.LinkableDepType.STATIC));
// Verify that we get the static archive and its build target via the NativeLinkable
// interface.
NativeLinkableInput expectedSharedNativeLinkableInput = NativeLinkableInput.of(ImmutableList.of(SourcePathArg.of(sharedLibrary.getSourcePathToOutput())), ImmutableSet.of(), ImmutableSet.of());
assertEquals(expectedSharedNativeLinkableInput, cxxLibrary.getNativeLinkableInput(cxxPlatform, Linker.LinkableDepType.SHARED));
// Verify that the implemented BuildRule methods are effectively unused.
assertEquals(ImmutableList.<Step>of(), cxxLibrary.getBuildSteps(null, null));
assertNull(cxxLibrary.getSourcePathToOutput());
}
Aggregations