Search in sources :

Example 1 with DefaultExecutionEnvironment

use of com.facebook.buck.util.environment.DefaultExecutionEnvironment in project buck by facebook.

the class PublicAnnouncementManagerIntegrationTest method testAnnouncementsWork.

@Test
public void testAnnouncementsWork() throws Exception {
    final AtomicReference<byte[]> requestBody = new AtomicReference<>();
    try (HttpdForTests httpd = new HttpdForTests()) {
        httpd.addHandler(new AbstractHandler() {

            @Override
            public void handle(String s, Request request, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws IOException, ServletException {
                httpServletResponse.setStatus(200);
                request.setHandled(true);
                if (request.getUri().getPath().equals("/status.php")) {
                    return;
                }
                requestBody.set(ByteStreams.toByteArray(httpServletRequest.getInputStream()));
                FrontendRequest thriftRequest = new FrontendRequest();
                ThriftUtil.deserialize(ThriftProtocol.BINARY, requestBody.get(), thriftRequest);
                assertTrue("Request should contain the repository.", thriftRequest.getAnnouncementRequest().getRepository().equals(REPOSITORY));
                try (DataOutputStream out = new DataOutputStream(httpServletResponse.getOutputStream())) {
                    Announcement announcement = new Announcement();
                    announcement.setErrorMessage(ERROR_MSG);
                    announcement.setSolutionMessage(SOLUTION_MSG);
                    AnnouncementResponse announcementResponse = new AnnouncementResponse();
                    announcementResponse.setAnnouncements(ImmutableList.of(announcement));
                    FrontendResponse frontendResponse = new FrontendResponse();
                    frontendResponse.setType(FrontendRequestType.ANNOUNCEMENT);
                    frontendResponse.setAnnouncementResponse(announcementResponse);
                    out.write(ThriftUtil.serialize(ThriftProtocol.BINARY, frontendResponse));
                }
            }
        });
        httpd.start();
        Clock clock = new DefaultClock();
        BuckEventBus eventBus = BuckEventBusFactory.newInstance(clock);
        ExecutionEnvironment executionEnvironment = new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties());
        BuckConfig buckConfig = new FakeBuckConfig.Builder().setSections(ImmutableMap.of("log", ImmutableMap.of("slb_server_pool", "http://localhost:" + httpd.getRootUri().getPort()))).build();
        TestConsole console = new TestConsole();
        SuperConsoleEventBusListener listener = new SuperConsoleEventBusListener(new SuperConsoleConfig(FakeBuckConfig.builder().build()), console, clock, /* verbosity */
        TestResultSummaryVerbosity.of(false, false), executionEnvironment, Optional.empty(), Locale.US, logPath, TimeZone.getTimeZone("UTC"));
        eventBus.register(listener);
        PublicAnnouncementManager manager = new PublicAnnouncementManager(clock, eventBus, listener, REPOSITORY, new RemoteLogBuckConfig(buckConfig), MoreExecutors.newDirectExecutorService());
        manager.getAndPostAnnouncements();
        Optional<String> announcements = listener.getPublicAnnouncements();
        assertEquals("The header and the message", announcements.get(), "**-------------------------------**\n" + "**- Sticky Public Announcements -**\n" + "**-------------------------------**\n" + "** This is the error message. This is the solution message.");
    }
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) RemoteLogBuckConfig(com.facebook.buck.util.network.RemoteLogBuckConfig) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) ExecutionEnvironment(com.facebook.buck.util.environment.ExecutionEnvironment) Announcement(com.facebook.buck.distributed.thrift.Announcement) AnnouncementResponse(com.facebook.buck.distributed.thrift.AnnouncementResponse) DataOutputStream(java.io.DataOutputStream) DefaultClock(com.facebook.buck.timing.DefaultClock) Clock(com.facebook.buck.timing.Clock) AbstractHandler(org.eclipse.jetty.server.handler.AbstractHandler) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletException(javax.servlet.ServletException) RemoteLogBuckConfig(com.facebook.buck.util.network.RemoteLogBuckConfig) BuckConfig(com.facebook.buck.cli.BuckConfig) FakeBuckConfig(com.facebook.buck.cli.FakeBuckConfig) DefaultClock(com.facebook.buck.timing.DefaultClock) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) HttpdForTests(com.facebook.buck.testutil.integration.HttpdForTests) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) Request(org.eclipse.jetty.server.Request) FrontendRequest(com.facebook.buck.distributed.thrift.FrontendRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) HttpServletResponse(javax.servlet.http.HttpServletResponse) AtomicReference(java.util.concurrent.atomic.AtomicReference) IOException(java.io.IOException) FrontendResponse(com.facebook.buck.distributed.thrift.FrontendResponse) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 2 with DefaultExecutionEnvironment

use of com.facebook.buck.util.environment.DefaultExecutionEnvironment in project buck by facebook.

the class SimpleConsoleEventBusListenerTest method testSimpleBuild.

@Test
public void testSimpleBuild() {
    String expectedOutput = "";
    Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
    BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
    TestConsole console = new TestConsole();
    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, new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer()))), ImmutableSortedSet.of());
    SimpleConsoleEventBusListener listener = new SimpleConsoleEventBusListener(console, fakeClock, TestResultSummaryVerbosity.of(false, false), Locale.US, logPath, new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties()));
    eventBus.register(listener);
    final long threadId = 0;
    BuildEvent.Started buildEventStarted = BuildEvent.started(buildArgs);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(buildEventStarted, 0L, TimeUnit.MILLISECONDS, threadId));
    ParseEvent.Started parseStarted = ParseEvent.started(buildTargets);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(parseStarted, 0L, TimeUnit.MILLISECONDS, threadId));
    assertOutput("", console);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(ParseEvent.finished(parseStarted, Optional.empty()), 400L, TimeUnit.MILLISECONDS, threadId));
    expectedOutput += "[-] PARSING BUCK FILES...FINISHED 0.4s\n";
    assertOutput(expectedOutput, console);
    BuildRuleEvent.Started started = BuildRuleEvent.started(fakeRule, durationTracker);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(started, 600L, TimeUnit.MILLISECONDS, threadId));
    HttpArtifactCacheEvent.Scheduled storeScheduledOne = postStoreScheduled(eventBus, threadId, TARGET_ONE, 700L);
    HttpArtifactCacheEvent.Scheduled storeScheduledTwo = postStoreScheduled(eventBus, threadId, TARGET_TWO, 700L);
    HttpArtifactCacheEvent.Started storeStartedOne = postStoreStarted(eventBus, threadId, 710L, storeScheduledOne);
    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));
    eventBus.postWithoutConfiguring(configureTestEventAtTime(BuildEvent.finished(buildEventStarted, 0), 1234L, TimeUnit.MILLISECONDS, threadId));
    expectedOutput += "BUILT  0.4s //banana:stand\n" + "[-] BUILDING...FINISHED 0.8s\n" + "WAITING FOR HTTP CACHE UPLOADS 0.00 B (0 COMPLETE/0 FAILED/1 UPLOADING/1 PENDING)\n";
    assertOutput(expectedOutput, console);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(ConsoleEvent.severe(SEVERE_MESSAGE), 1500L, TimeUnit.MILLISECONDS, threadId));
    expectedOutput += SEVERE_MESSAGE + "\n";
    assertOutput(expectedOutput, console);
    InstallEvent.Started installEventStarted = configureTestEventAtTime(InstallEvent.started(fakeTarget), 2500L, TimeUnit.MILLISECONDS, threadId);
    eventBus.postWithoutConfiguring(installEventStarted);
    assertOutput(expectedOutput, console);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(InstallEvent.finished(installEventStarted, true, Optional.empty(), Optional.empty()), 4000L, TimeUnit.MILLISECONDS, threadId));
    expectedOutput += "[-] INSTALLING...FINISHED 1.5s\n";
    assertOutput(expectedOutput, console);
    long artifactSizeOne = SizeUnit.MEGABYTES.toBytes(1.5);
    postStoreFinished(eventBus, threadId, artifactSizeOne, 5015L, true, storeStartedOne);
    HttpArtifactCacheEvent.Started storeStartedTwo = postStoreStarted(eventBus, threadId, 5020L, storeScheduledTwo);
    long artifactSizeTwo = 600;
    postStoreFinished(eventBus, threadId, artifactSizeTwo, 5020L, false, storeStartedTwo);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(HttpArtifactCacheEvent.newShutdownEvent(), 6000L, TimeUnit.MILLISECONDS, threadId));
    expectedOutput += "[-] HTTP CACHE UPLOAD...FINISHED 1.50 MB (1 COMPLETE/1 FAILED/0 UPLOADING/0 PENDING)\n";
    assertOutput(expectedOutput, console);
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) Clock(com.facebook.buck.timing.Clock) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) BuildTarget(com.facebook.buck.model.BuildTarget) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) RuleKey(com.facebook.buck.rules.RuleKey) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) InstallEvent(com.facebook.buck.event.InstallEvent) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildEvent(com.facebook.buck.rules.BuildEvent) ParseEvent(com.facebook.buck.parser.ParseEvent) BuildRuleEvent(com.facebook.buck.rules.BuildRuleEvent) HttpArtifactCacheEvent(com.facebook.buck.artifact_cache.HttpArtifactCacheEvent) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 3 with DefaultExecutionEnvironment

use of com.facebook.buck.util.environment.DefaultExecutionEnvironment in project buck by facebook.

the class SuperConsoleEventBusListenerTest method createSuperConsole.

private SuperConsoleEventBusListener createSuperConsole(Clock clock, BuckEventBus eventBus) {
    SuperConsoleEventBusListener listener = new SuperConsoleEventBusListener(emptySuperConsoleConfig, new TestConsole(), clock, silentSummaryVerbosity, new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties()), Optional.empty(), Locale.US, logPath, timeZone);
    eventBus.register(listener);
    return listener;
}
Also used : DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) TestConsole(com.facebook.buck.testutil.TestConsole)

Example 4 with DefaultExecutionEnvironment

use of com.facebook.buck.util.environment.DefaultExecutionEnvironment in project buck by facebook.

the class SuperConsoleEventBusListenerTest method testFailingTest.

@Test
public void testFailingTest() {
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
    BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
    TestConsole console = new TestConsole();
    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());
    SuperConsoleEventBusListener listener = new SuperConsoleEventBusListener(emptySuperConsoleConfig, console, fakeClock, noisySummaryVerbosity, new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties()), Optional.empty(), Locale.US, logPath, timeZone);
    eventBus.register(listener);
    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.FAILURE, // time
    0L, // message
    "Foo.java:47: Assertion failure: 'foo' != 'bar'", // stacktrace
    null, // stdOut
    "Message on stdout", // stdErr
    "Message on stderr");
    eventBus.postWithoutConfiguring(configureTestEventAtTime(TestSummaryEvent.finished(testUUID, testResultSummary), 3900L, TimeUnit.MILLISECONDS, /* threadId */
    0L));
    validateConsoleWithLogLines(listener, 4000L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, "[+] TESTING...1.5s (0 PASS/1 FAIL)", " |=> //:test...  0.9s"), ImmutableList.of("FAILURE TestClass Foo: Foo.java:47: Assertion failure: 'foo' != 'bar'"));
    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 FAIL)";
    validateConsoleWithStdOutAndErr(listener, 4200L, ImmutableList.of(parsingLine, FINISHED_DOWNLOAD_STRING, buildingLine, testingLine), ImmutableList.of(), Optional.of(Joiner.on('\n').join("RESULTS FOR ALL TESTS", "FAIL    <100ms  0 Passed   0 Skipped   1 Failed   TestClass", "FAILURE TestClass Foo: Foo.java:47: Assertion failure: 'foo' != 'bar'", "====STANDARD OUT====", "Message on stdout", "====STANDARD ERR====", "Message on stderr", "TESTS FAILED: 1 FAILURE", "Failed target: //:test", "FAIL TestClass", "")), // We don't care about stderr, since the last frame will be flushed there.
    Optional.empty());
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) ConsoleTestUtils.postStoreStarted(com.facebook.buck.event.listener.ConsoleTestUtils.postStoreStarted) ProjectBuildFileParseEvents(com.facebook.buck.json.ProjectBuildFileParseEvents) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) Clock(com.facebook.buck.timing.Clock) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) BuildRuleResolver(com.facebook.buck.rules.BuildRuleResolver) BuildTarget(com.facebook.buck.model.BuildTarget) TestCaseSummary(com.facebook.buck.test.TestCaseSummary) DefaultTargetNodeToBuildRuleTransformer(com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer) UUID(java.util.UUID) ConsoleTestUtils.postStoreFinished(com.facebook.buck.event.listener.ConsoleTestUtils.postStoreFinished) StepEvent(com.facebook.buck.step.StepEvent) RuleKey(com.facebook.buck.rules.RuleKey) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) ActionGraphEvent(com.facebook.buck.event.ActionGraphEvent) TestResultSummary(com.facebook.buck.test.TestResultSummary) SourcePathResolver(com.facebook.buck.rules.SourcePathResolver) SourcePathRuleFinder(com.facebook.buck.rules.SourcePathRuleFinder) FakeBuildRule(com.facebook.buck.rules.FakeBuildRule) BuildEvent(com.facebook.buck.rules.BuildEvent) ParseEvent(com.facebook.buck.parser.ParseEvent) BuildRuleEvent(com.facebook.buck.rules.BuildRuleEvent) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Example 5 with DefaultExecutionEnvironment

use of com.facebook.buck.util.environment.DefaultExecutionEnvironment in project buck by facebook.

the class SuperConsoleEventBusListenerTest method timestampsInLocaleWithDecimalCommaFormatCorrectly.

@Test
public void timestampsInLocaleWithDecimalCommaFormatCorrectly() {
    Clock fakeClock = new IncrementingFakeClock(TimeUnit.SECONDS.toNanos(1));
    BuckEventBus eventBus = BuckEventBusFactory.newInstance(fakeClock);
    SuperConsoleEventBusListener listener = new SuperConsoleEventBusListener(new SuperConsoleConfig(FakeBuckConfig.builder().build()), new TestConsole(), fakeClock, silentSummaryVerbosity, new DefaultExecutionEnvironment(ImmutableMap.copyOf(System.getenv()), System.getProperties()), Optional.empty(), // Note we use de_DE to ensure we get a decimal comma in the output.
    Locale.GERMAN, logPath, timeZone);
    eventBus.register(listener);
    eventBus.postWithoutConfiguring(configureTestEventAtTime(ProjectGenerationEvent.started(), 0L, TimeUnit.MILLISECONDS, /* threadId */
    0L));
    validateConsole(listener, 0L, ImmutableList.of("[+] GENERATING PROJECT...0,0s"));
    eventBus.postWithoutConfiguring(configureTestEventAtTime(new ProjectGenerationEvent.Finished(), 0L, TimeUnit.MILLISECONDS, 0L));
    validateConsole(listener, 0L, ImmutableList.of("[-] GENERATING PROJECT...FINISHED 0,0s"));
}
Also used : BuckEventBus(com.facebook.buck.event.BuckEventBus) ConsoleTestUtils.postStoreFinished(com.facebook.buck.event.listener.ConsoleTestUtils.postStoreFinished) DefaultExecutionEnvironment(com.facebook.buck.util.environment.DefaultExecutionEnvironment) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) Clock(com.facebook.buck.timing.Clock) IncrementingFakeClock(com.facebook.buck.timing.IncrementingFakeClock) TestConsole(com.facebook.buck.testutil.TestConsole) Test(org.junit.Test)

Aggregations

DefaultExecutionEnvironment (com.facebook.buck.util.environment.DefaultExecutionEnvironment)8 BuckEventBus (com.facebook.buck.event.BuckEventBus)6 Clock (com.facebook.buck.timing.Clock)6 TestConsole (com.facebook.buck.testutil.TestConsole)5 Test (org.junit.Test)5 IncrementingFakeClock (com.facebook.buck.timing.IncrementingFakeClock)3 HttpArtifactCacheEvent (com.facebook.buck.artifact_cache.HttpArtifactCacheEvent)2 ActionGraphEvent (com.facebook.buck.event.ActionGraphEvent)2 ConsoleTestUtils.postStoreFinished (com.facebook.buck.event.listener.ConsoleTestUtils.postStoreFinished)2 BuildTarget (com.facebook.buck.model.BuildTarget)2 ParseEvent (com.facebook.buck.parser.ParseEvent)2 BuildEvent (com.facebook.buck.rules.BuildEvent)2 BuildRuleEvent (com.facebook.buck.rules.BuildRuleEvent)2 BuildRuleResolver (com.facebook.buck.rules.BuildRuleResolver)2 DefaultTargetNodeToBuildRuleTransformer (com.facebook.buck.rules.DefaultTargetNodeToBuildRuleTransformer)2 FakeBuildRule (com.facebook.buck.rules.FakeBuildRule)2 RuleKey (com.facebook.buck.rules.RuleKey)2 SourcePathResolver (com.facebook.buck.rules.SourcePathResolver)2 SourcePathRuleFinder (com.facebook.buck.rules.SourcePathRuleFinder)2 ExecutionEnvironment (com.facebook.buck.util.environment.ExecutionEnvironment)2