Esempio n. 1
0
  @Override
  public List<Term> getKComponents() {
    DataStructureSort sort = global.getDefinition().dataStructureSortOf(sort());

    ArrayList<Term> components = Lists.newArrayList();
    elements
        .stream()
        .forEach(
            element ->
                components.add(
                    KItem.of(
                        KLabelConstant.of(sort.elementLabel(), global.getDefinition()),
                        KList.singleton(element),
                        global,
                        element.getSource(),
                        element.getLocation())));

    for (Term term : baseTerms()) {
      if (term instanceof BuiltinSet) {
        components.addAll(((BuiltinSet) term).getKComponents());
      } else {
        components.add(term);
      }
    }

    return components;
  }
Esempio n. 2
0
  @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();
    };
  }
Esempio n. 3
0
  public ObjectMapper getObjectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
    mapper.setPropertyNamingStrategy(
        PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);

    ImmutableSet<SimpleModule> modules = getModules();
    if (getModules() != null) {
      modules.stream().forEach(mapper::registerModule);
    }

    mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, true);
    mapper.configure(SerializationFeature.INDENT_OUTPUT, true);

    mapper.registerModule(new GuavaModule());
    return mapper;
  }
Esempio n. 4
0
 @Override
 public Callable<TestResults> interpretTestResults(
     final ExecutionContext executionContext,
     boolean isUsingTestSelectors,
     final boolean isDryRun) {
   return () -> {
     ImmutableList.Builder<TestCaseSummary> summaries = ImmutableList.builder();
     if (!isDryRun) {
       ImmutableList<TestResultSummary> resultSummaries =
           parseResults(getPathToTestExitCode(), getPathToTestOutput(), getPathToTestResults());
       TestCaseSummary summary =
           new TestCaseSummary(getBuildTarget().getFullyQualifiedName(), resultSummaries);
       summaries.add(summary);
     }
     return TestResults.of(
         getBuildTarget(),
         summaries.build(),
         contacts,
         labels.stream().map(Object::toString).collect(MoreCollectors.toImmutableSet()));
   };
 }
 @Override
 public int hashCode() {
   return builtFrom.stream().mapToInt(AlgorithmResults::hashCode).sum();
 }