@Test
  public void canCompressTraces() throws IOException {
    ProjectFilesystem projectFilesystem = new ProjectFilesystem(tmpDir.getRoot().toPath());

    ChromeTraceBuildListener listener =
        new ChromeTraceBuildListener(
            projectFilesystem,
            new FakeClock(1409702151000000000L),
            new ObjectMapper(),
            Locale.US,
            TimeZone.getTimeZone("America/Los_Angeles"),
            /* tracesToKeep */ 1,
            true);
    listener.outputTrace(new BuildId("BUILD_ID"));

    Path tracePath = Paths.get("buck-out/log/traces/build.2014-09-02.16-55-51.BUILD_ID.trace.gz");

    assertTrue(projectFilesystem.exists(tracePath));

    BufferedReader reader =
        new BufferedReader(
            new InputStreamReader(
                new GZIPInputStream(projectFilesystem.newFileInputStream(tracePath))));

    List<?> elements = new Gson().fromJson(reader, List.class);
    assertThat(elements, notNullValue());
  }
예제 #2
0
 public Optional<Path> checkPathExists(String pathString, String errorMsg) {
   Path path = Paths.get(pathString);
   if (projectFilesystem.exists(path)) {
     return Optional.of(projectFilesystem.getPathForRelativePath(path));
   }
   throw new HumanReadableException(errorMsg + path);
 }
  @Test
  public void outputFileUsesCurrentTime() throws IOException {
    ProjectFilesystem projectFilesystem = new ProjectFilesystem(tmpDir.getRoot().toPath());

    ChromeTraceBuildListener listener =
        new ChromeTraceBuildListener(
            projectFilesystem,
            new FakeClock(1409702151000000000L),
            new ObjectMapper(),
            Locale.US,
            TimeZone.getTimeZone("America/Los_Angeles"),
            /* tracesToKeep */ 1,
            false);
    listener.outputTrace(new BuildId("BUILD_ID"));
    assertTrue(
        projectFilesystem.exists(
            Paths.get("buck-out/log/traces/build.2014-09-02.16-55-51.BUILD_ID.trace")));
  }