Search in sources :

Example 6 with TraceAttributes

use of com.facebook.buck.util.trace.BuildTraces.TraceAttributes in project buck by facebook.

the class BuildTracesTest method testGetTraceAttributesForJsonWithoutCommandArgs.

@Test
public void testGetTraceAttributesForJsonWithoutCommandArgs() throws IOException {
    FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem(new FakeClock(TimeUnit.MILLISECONDS.toNanos(2000L)));
    projectFilesystem.writeContentsToPath("[" + "{" + "\"cat\":\"buck\"," + "\"ph\":\"B\"," + "\"pid\":0," + "\"tid\":1," + "\"ts\":5621911884918" + "}" + "]", projectFilesystem.getBuckPaths().getTraceDir().resolve("build.c.trace"));
    BuildTraces helper = new BuildTraces(projectFilesystem);
    TraceAttributes traceAttributes = helper.getTraceAttributesFor("c");
    assertEquals("BuildTraces should not be able to extract the command because there is no " + "command_args attribute.", Optional.empty(), traceAttributes.getCommand());
    assertEquals(2000L, traceAttributes.getLastModifiedTime());
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeClock(com.facebook.buck.timing.FakeClock) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) TraceAttributes(com.facebook.buck.util.trace.BuildTraces.TraceAttributes) Test(org.junit.Test)

Example 7 with TraceAttributes

use of com.facebook.buck.util.trace.BuildTraces.TraceAttributes in project buck by facebook.

the class BuildTracesTest method testGetTraceAttributesForJsonWithoutName.

@Test
public void testGetTraceAttributesForJsonWithoutName() throws IOException {
    FakeProjectFilesystem projectFilesystem = new FakeProjectFilesystem(new FakeClock(TimeUnit.MILLISECONDS.toNanos(2000L)));
    projectFilesystem.writeContentsToPath("[" + "{" + "\"cat\":\"buck\"," + "\"ph\":\"B\"," + "\"pid\":0," + "\"tid\":1," + "\"ts\":5621911884918," + "\"args\":{\"command_args\":\"buck\"}" + "}" + "]", projectFilesystem.getBuckPaths().getTraceDir().resolve("build.b.trace"));
    BuildTraces helper = new BuildTraces(projectFilesystem);
    TraceAttributes traceAttributes = helper.getTraceAttributesFor("b");
    assertEquals("BuildTraces should not be able to extract the command because there is no name " + "attribute.", Optional.empty(), traceAttributes.getCommand());
    assertEquals(2000L, traceAttributes.getLastModifiedTime());
}
Also used : FakeProjectFilesystem(com.facebook.buck.testutil.FakeProjectFilesystem) FakeClock(com.facebook.buck.timing.FakeClock) SettableFakeClock(com.facebook.buck.timing.SettableFakeClock) TraceAttributes(com.facebook.buck.util.trace.BuildTraces.TraceAttributes) Test(org.junit.Test)

Aggregations

TraceAttributes (com.facebook.buck.util.trace.BuildTraces.TraceAttributes)7 Test (org.junit.Test)5 FakeProjectFilesystem (com.facebook.buck.testutil.FakeProjectFilesystem)3 FakeClock (com.facebook.buck.timing.FakeClock)3 SettableFakeClock (com.facebook.buck.timing.SettableFakeClock)3 BuildTraces (com.facebook.buck.util.trace.BuildTraces)2 SoyMapData (com.google.template.soy.data.SoyMapData)2 Matcher (java.util.regex.Matcher)2 Request (org.eclipse.jetty.server.Request)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 SoyListData (com.google.template.soy.data.SoyListData)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 Path (java.nio.file.Path)1 Nullable (javax.annotation.Nullable)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 Handler (org.eclipse.jetty.server.Handler)1 Matchers.containsString (org.hamcrest.Matchers.containsString)1