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());
}
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());
}
Aggregations