Skip to content

Commit

Permalink
Add Maven formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
michalvavrik committed Feb 15, 2024
1 parent 04f404a commit d3f4662
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 23 deletions.
18 changes: 18 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
<maven-surefire-report-parser.version>3.2.5</maven-surefire-report-parser.version>
<plexus-containers.version>2.2.0</plexus-containers.version>
<jackson-databind.version>2.16.1</jackson-databind.version>
<formatter-maven-plugin.version>2.23.0</formatter-maven-plugin.version>
<!-- Format Settings -->
<src.format.goal>format</src.format.goal>
</properties>

<dependencies>
Expand Down Expand Up @@ -61,6 +64,21 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>net.revelc.code.formatter</groupId>
<artifactId>formatter-maven-plugin</artifactId>
<version>${formatter-maven-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>${src.format.goal}</goal>
</goals>
</execution>
</executions>
<configuration>
<lineEnding>LF</lineEnding>
</configuration>
</plugin>
</plugins>
</build>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ public static List<FlakyTest> parseFlakyTestsReport(String reportPathStr) {
return List.of();
}
try {
return OBJECT_MAPPER.readValue(reportPath.toFile(), new TypeReference<>() {});
return OBJECT_MAPPER.readValue(reportPath.toFile(), new TypeReference<>() {
});
} catch (IOException e) {
throw new RuntimeException(e);
}
Expand All @@ -50,9 +51,7 @@ public void createFlakyRunReport() {
}

private static List<FlakyTest> buildReportToFlakyTests(BuildReport buildReport) {
return buildReport
.getProjectReports()
.stream()
return buildReport.getProjectReports().stream()
.flatMap(projectReport -> testDirsToFlakyTests(toTestDirs(projectReport), projectReport)).toList();
}

Expand All @@ -79,24 +78,18 @@ private static BuildReport getBuildReporter() {
}

private static List<File> toTestDirs(ProjectReport projectReport) {
return Stream.of(Path.of(normalizeModuleName(projectReport.getBasedir())))
.flatMap(baseDir -> Stream.of(baseDir.resolve(MAVEN_FAILSAFE_REPORTS_PATH),
baseDir.resolve(MAVEN_SUREFIRE_REPORTS_PATH)))
.filter(Files::exists)
.map(Path::toFile)
.toList();
return Stream
.of(Path.of(normalizeModuleName(projectReport.getBasedir()))).flatMap(baseDir -> Stream
.of(baseDir.resolve(MAVEN_FAILSAFE_REPORTS_PATH), baseDir.resolve(MAVEN_SUREFIRE_REPORTS_PATH)))
.filter(Files::exists).map(Path::toFile).toList();
}

private static Stream<FlakyTest> testDirsToFlakyTests(List<File> testDirs, ProjectReport projectReport) {
if (testDirs.isEmpty()) {
return Stream.empty();
}
return new SurefireReportParser(testDirs, new NullConsoleLogger())
.parseXMLReportFiles()
.stream()
.filter(r -> r.getNumberOfFlakes() > 0)
.map(ReportTestSuite::getTestCases)
.flatMap(Collection::stream)
return new SurefireReportParser(testDirs, new NullConsoleLogger()).parseXMLReportFiles().stream()
.filter(r -> r.getNumberOfFlakes() > 0).map(ReportTestSuite::getTestCases).flatMap(Collection::stream)
.filter(ReportTestCase::hasFlakes)
.flatMap(reportTestCase -> FlakyTest.newInstances(reportTestCase, projectReport));
}
Expand Down
14 changes: 7 additions & 7 deletions src/main/java/io/quarkus/qe/reporter/flakyrun/FlakyTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@
import java.util.stream.Stream;

public record FlakyTest(String projectName, String projectBaseDir, String fullTestName, String failureMessage,
String failureType, String failureStackTrace, String dateTime) {
String failureType, String failureStackTrace, String dateTime) {

static Stream<FlakyTest> newInstances(ReportTestCase reportTestCase, ProjectReport projectReport) {
final String now = ZonedDateTime.now().toString();
Stream<FlakyTest> result = Stream.empty();
if (!reportTestCase.getFlakyFailures().isEmpty()) {
result = reportTestCase.getFlakyFailures()
.stream()
result = reportTestCase.getFlakyFailures().stream()
.map(s -> new FlakyTest(projectReport.getName(), projectReport.getBasedir(),
reportTestCase.getFullName(), s.getMessage(), s.getType(), s.getStackTrace(), now));
}
if (!reportTestCase.getFlakyErrors().isEmpty()) {
result = Stream.concat(result, reportTestCase.getFlakyErrors()
.stream()
.map(s -> new FlakyTest(projectReport.getName(), projectReport.getBasedir(),
reportTestCase.getFullName(), s.getMessage(), s.getType(), s.getStackTrace(), now)));
result = Stream.concat(result,
reportTestCase.getFlakyErrors().stream()
.map(s -> new FlakyTest(projectReport.getName(), projectReport.getBasedir(),
reportTestCase.getFullName(), s.getMessage(), s.getType(), s.getStackTrace(),
now)));
}
return result;
}
Expand Down

0 comments on commit d3f4662

Please sign in to comment.