Skip to content

Commit c6561ff

Browse files
committed
Refactor output formatting; enhance module header display and adjust indentation settings
1 parent edd6c6c commit c6561ff

File tree

3 files changed

+24
-23
lines changed

3 files changed

+24
-23
lines changed

src/main/java/io/github/clojang/sophodromos/OutputPatternMatcher.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ protected String tryMatchMethodExecution(final String line, final TestOutputForm
125125
final String methodWithParens = methodName + "()";
126126
result =
127127
formatter.formatTestResult(
128-
className, methodWithParens, "SUCCESS", (long) (timeElapsed * 1000));
128+
" " + className, methodWithParens, "SUCCESS", (long) (timeElapsed * 1000));
129129
}
130130
return result;
131131
}
@@ -179,15 +179,15 @@ protected String tryMatchTestResults(
179179
*/
180180
protected String formatModuleHeader(
181181
final String artifactId, final TestOutputFormatter formatter) {
182-
final String moduleHeader = colors.colorize(
183-
artifactId, AnsiColors.BOLD + AnsiColors.BRIGHT_YELLOW);
184-
return formatter.formatProgressLine(moduleHeader);
182+
return colors.colorize(artifactId, AnsiColors.BOLD + AnsiColors.BRIGHT_YELLOW);
185183
}
186184

187185
private String getSimpleClassName(final String testClass) {
188186
return testClass.substring(testClass.lastIndexOf('.') + 1);
189187
}
190188

189+
@SuppressWarnings("PMD.UnusedFormalParameter")
190+
// Parameters intentionally unused in current implementation
191191
private String formatTestResults(
192192
final int testsRun,
193193
final int failures,
@@ -197,27 +197,27 @@ private String formatTestResults(
197197
final TestOutputFormatter formatter) {
198198
final StringBuilder result = new StringBuilder();
199199

200-
// if (failures == 0 && errors == 0) {
201-
// result.append("✅ ");
202-
// } else {
203-
// result.append("❌ ");
204-
// }
200+
// if (failures == 0 && errors == 0) {
201+
// result.append("✅ ");
202+
// } else {
203+
// result.append("❌ ");
204+
// }
205205

206-
//result.append(String.format("Tests: %d", testsRun));
206+
// result.append(String.format("Tests: %d", testsRun));
207207

208-
//if (failures > 0) {
209-
// result.append(String.format(", Failures: %d", failures));
210-
//}
208+
// if (failures > 0) {
209+
// result.append(String.format(", Failures: %d", failures));
210+
// }
211211

212-
//if (errors > 0) {
213-
// result.append(String.format(", Errors: %d", errors));
214-
//}
212+
// if (errors > 0) {
213+
// result.append(String.format(", Errors: %d", errors));
214+
// }
215215

216-
//if (skipped > 0) {
217-
// result.append(String.format(", Skipped: %d", skipped));
218-
//}
216+
// if (skipped > 0) {
217+
// result.append(String.format(", Skipped: %d", skipped));
218+
// }
219219

220-
//result.append(String.format(" (%.3fs)", timeElapsed));
220+
// result.append(String.format(" (%.3fs)", timeElapsed));
221221

222222
return formatter.formatProgressLine(result.toString());
223223
}

src/main/java/io/github/clojang/sophodromos/SophoDromosTestMojo.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ private void displayHeader() {
121121
@SuppressWarnings("PMD.SystemPrintln") // Intentional console output for clean formatting
122122
private void displayModuleHeader() {
123123
final String artifactId = project.getArtifactId();
124-
final String moduleHeader = ":" + artifactId + ":test";
124+
final OutputPatternMatcher patternMatcher = new OutputPatternMatcher(formatter.getColors());
125+
final String moduleHeader = patternMatcher.formatModuleHeader(artifactId, formatter);
125126
System.out.println(moduleHeader);
126127
}
127128

src/main/java/io/github/clojang/sophodromos/TestResultFormatter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
/** Handles individual test result formatting. */
88
@SuppressWarnings("PMD.TestClassWithoutTestCases") // This is not a test class
99
class TestResultFormatter {
10-
private static final String INDENT = " ";
11-
private static final int DOTS_BASE = 76;
10+
private static final String INDENT = "";
11+
private static final int DOTS_BASE = 78;
1212

1313
private final AnsiColors colors;
1414
private final GradlDromusExtension extension;

0 commit comments

Comments
 (0)