Search in sources :

Example 6 with DefaultClock

use of com.facebook.buck.timing.DefaultClock in project buck by facebook.

the class InteractiveReportIntegrationTest method createDefectReport.

private static DefectSubmitResult createDefectReport(ProjectWorkspace workspace, ByteArrayInputStream inputStream) throws IOException, InterruptedException {
    ProjectFilesystem filesystem = workspace.asCell().getFilesystem();
    ObjectMapper objectMapper = ObjectMappers.newDefaultInstance();
    RageConfig rageConfig = RageConfig.of(workspace.asCell().getBuckConfig());
    Clock clock = new DefaultClock();
    ExtraInfoCollector extraInfoCollector = Optional::empty;
    TestConsole console = new TestConsole();
    DefectReporter defectReporter = new DefaultDefectReporter(filesystem, objectMapper, rageConfig, BuckEventBusFactory.newInstance(clock), clock);
    WatchmanDiagReportCollector watchmanDiagReportCollector = new WatchmanDiagReportCollector(filesystem, WATCHMAN_DIAG_COMMAND, createFakeWatchmanDiagProcessExecutor(console));
    InteractiveReport interactiveReport = new InteractiveReport(defectReporter, filesystem, objectMapper, console, inputStream, TestBuildEnvironmentDescription.INSTANCE, VcsInfoCollector.create(new NoOpCmdLineInterface()), rageConfig, extraInfoCollector, Optional.of(watchmanDiagReportCollector));
    return interactiveReport.collectAndSubmitResult().get();
}
Also used : DefaultClock(com.facebook.buck.timing.DefaultClock) NoOpCmdLineInterface(com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface) ProjectFilesystem(com.facebook.buck.io.ProjectFilesystem) DefaultClock(com.facebook.buck.timing.DefaultClock) Clock(com.facebook.buck.timing.Clock) TestConsole(com.facebook.buck.testutil.TestConsole) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper)

Example 7 with DefaultClock

use of com.facebook.buck.timing.DefaultClock in project buck by facebook.

the class RageConfigTest method setUp.

@BeforeClass
public static void setUp() {
    clock = new DefaultClock();
    eventBus = BuckEventBusFactory.newInstance(clock);
    threadFactory = new CommandThreadFactory("RageConfigTest.Unused");
}
Also used : DefaultClock(com.facebook.buck.timing.DefaultClock) CommandThreadFactory(com.facebook.buck.log.CommandThreadFactory) BeforeClass(org.junit.BeforeClass)

Example 8 with DefaultClock

use of com.facebook.buck.timing.DefaultClock in project buck by facebook.

the class FakeBuildEngineTest method buildRuleFutureHasResult.

@Test
public void buildRuleFutureHasResult() throws Exception {
    BuildTarget fakeBuildTarget = BuildTargetFactory.newInstance("//foo:bar");
    SourcePathResolver pathResolver = new SourcePathResolver(new SourcePathRuleFinder(new BuildRuleResolver(TargetGraph.EMPTY, new DefaultTargetNodeToBuildRuleTransformer())));
    FakeBuildRule fakeBuildRule = new FakeBuildRule(fakeBuildTarget, pathResolver);
    BuildResult fakeBuildResult = BuildResult.success(fakeBuildRule, BUILT_LOCALLY, CacheResult.miss());
    FakeBuildEngine fakeEngine = new FakeBuildEngine(ImmutableMap.of(fakeBuildTarget, fakeBuildResult), ImmutableMap.of(fakeBuildTarget, new RuleKey("00")));
    assertThat(fakeEngine.build(BuildEngineBuildContext.builder().setBuildContext(FakeBuildContext.NOOP_CONTEXT).setArtifactCache(new NoopArtifactCache()).setBuildId(new BuildId()).setObjectMapper(ObjectMappers.newDefaultInstance()).setClock(new DefaultClock()).build(), TestExecutionContext.newInstance(), fakeBuildRule).get(), equalTo(fakeBuildResult));
}
Also used : NoopArtifactCache(com.facebook.buck.artifact_cache.NoopArtifactCache) BuildId(com.facebook.buck.model.BuildId) BuildTarget(com.facebook.buck.model.BuildTarget) DefaultClock(com.facebook.buck.timing.DefaultClock) Test(org.junit.Test)

Example 9 with DefaultClock

use of com.facebook.buck.timing.DefaultClock in project buck by facebook.

the class WatchmanWatcherIntegrationTest method setUp.

@Before
public void setUp() throws InterruptedException, IOException {
    // Create an empty watchman config file.
    Files.write(tmp.getRoot().resolve(".watchmanconfig"), new byte[0]);
    watchman = Watchman.build(ImmutableSet.of(tmp.getRoot()), ImmutableMap.copyOf(System.getenv()), new Console(Verbosity.ALL, System.out, System.err, Ansi.withoutTty()), new DefaultClock(), Optional.empty());
    assumeTrue(watchman.getWatchmanClient().isPresent());
    eventBus = new EventBus();
    watchmanEventCollector = new WatchmanEventCollector();
    eventBus.register(watchmanEventCollector);
}
Also used : DefaultClock(com.facebook.buck.timing.DefaultClock) BuckEventBus(com.facebook.buck.event.BuckEventBus) EventBus(com.google.common.eventbus.EventBus) Before(org.junit.Before)

Example 10 with DefaultClock

use of com.facebook.buck.timing.DefaultClock in project buck by facebook.

the class MachineReadableLogJsonViewTest method setUp.

@Before
public void setUp() {
    Clock clock = new DefaultClock();
    timestamp = clock.currentTimeMillis();
    nanoTime = clock.nanoTime();
    // Not using real value as not all JVMs will support thread user time.
    threadUserNanoTime = new Random().nextLong();
    threadId = 0;
    buildId = new BuildId("Test");
    durationTracker = new BuildRuleDurationTracker();
}
Also used : Random(java.util.Random) BuildId(com.facebook.buck.model.BuildId) DefaultClock(com.facebook.buck.timing.DefaultClock) DefaultClock(com.facebook.buck.timing.DefaultClock) Clock(com.facebook.buck.timing.Clock) BuildRuleDurationTracker(com.facebook.buck.rules.BuildRuleDurationTracker) Before(org.junit.Before)

Aggregations

DefaultClock (com.facebook.buck.timing.DefaultClock)20 Test (org.junit.Test)12 Clock (com.facebook.buck.timing.Clock)10 ProjectFilesystem (com.facebook.buck.io.ProjectFilesystem)8 IOException (java.io.IOException)7 TestConsole (com.facebook.buck.testutil.TestConsole)6 BuckEventBus (com.facebook.buck.event.BuckEventBus)5 BuildId (com.facebook.buck.model.BuildId)5 Path (java.nio.file.Path)5 HttpdForTests (com.facebook.buck.testutil.integration.HttpdForTests)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 Optional (java.util.Optional)4 ProjectWorkspace (com.facebook.buck.testutil.integration.ProjectWorkspace)3 ZipInspector (com.facebook.buck.testutil.integration.ZipInspector)3 NoOpCmdLineInterface (com.facebook.buck.util.versioncontrol.NoOpCmdLineInterface)3 ServletException (javax.servlet.ServletException)3 HttpServletRequest (javax.servlet.http.HttpServletRequest)3 HttpServletResponse (javax.servlet.http.HttpServletResponse)3 Request (org.eclipse.jetty.server.Request)3 AbstractHandler (org.eclipse.jetty.server.handler.AbstractHandler)3