コード例 #1
0
ファイル: AppleTest.java プロジェクト: sdwilsh/buck
  @Override
  public Callable<TestResults> interpretTestResults(
      final ExecutionContext executionContext, boolean isUsingTestSelectors, boolean isDryRun) {
    return () -> {
      List<TestCaseSummary> testCaseSummaries;
      if (xctoolStdoutReader.isPresent()) {
        // We've already run the tests with 'xctool' and parsed
        // their output; no need to parse the same output again.
        testCaseSummaries = xctoolStdoutReader.get().getTestCaseSummaries();
      } else if (xctestOutputReader.isPresent()) {
        // We've already run the tests with 'xctest' and parsed
        // their output; no need to parse the same output again.
        testCaseSummaries = xctestOutputReader.get().getTestCaseSummaries();
      } else if (isUiTest()) {
        TestCaseSummary noTestsSummary =
            new TestCaseSummary(
                "XCUITest runs not supported with buck test", Collections.emptyList());
        testCaseSummaries = Collections.singletonList(noTestsSummary);
      } else {
        Path resolvedOutputPath = getProjectFilesystem().resolve(testOutputPath);
        try (BufferedReader reader =
            Files.newBufferedReader(resolvedOutputPath, StandardCharsets.UTF_8)) {
          if (useXctest) {
            TestCaseSummariesBuildingXctestEventHandler xctestEventHandler =
                new TestCaseSummariesBuildingXctestEventHandler(NOOP_REPORTING_CALLBACK);
            XctestOutputParsing.streamOutput(reader, xctestEventHandler);
            testCaseSummaries = xctestEventHandler.getTestCaseSummaries();
          } else {
            TestCaseSummariesBuildingXctoolEventHandler xctoolEventHandler =
                new TestCaseSummariesBuildingXctoolEventHandler(NOOP_REPORTING_CALLBACK);
            XctoolOutputParsing.streamOutputFromReader(reader, xctoolEventHandler);
            testCaseSummaries = xctoolEventHandler.getTestCaseSummaries();
          }
        }
      }
      TestResults.Builder testResultsBuilder =
          TestResults.builder()
              .setBuildTarget(getBuildTarget())
              .setTestCases(testCaseSummaries)
              .setContacts(contacts)
              .setLabels(
                  labels.stream().map(Object::toString).collect(MoreCollectors.toImmutableSet()));
      if (getProjectFilesystem().isDirectory(testLogsPath)) {
        for (Path testLogPath : getProjectFilesystem().getDirectoryContents(testLogsPath)) {
          testResultsBuilder.addTestLogPaths(testLogPath);
        }
      }

      return testResultsBuilder.build();
    };
  }
コード例 #2
0
ファイル: AppleTest.java プロジェクト: sdwilsh/buck
 public ImmutableList<TestCaseSummary> getTestCaseSummaries() {
   return xctestEventHandler.getTestCaseSummaries();
 }