Skip to content

Commit 4818acf

Browse files
committed
Sanitize system-dependent pieces of the maven log snapshots.
1 parent a7a1df7 commit 4818acf

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

plugin-maven/src/test/java/com/diffplug/spotless/maven/MavenIntegrationHarness.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ protected static String[] formats(String[]... formats) {
356356

357357
private static final String ERROR_PREFIX = "[ERROR] ";
358358

359-
protected static StringSelfie expectSelfieErrorMsg(ProcessRunner.Result result) {
359+
protected StringSelfie expectSelfieErrorMsg(ProcessRunner.Result result) {
360360
String concatenatedError = result.stdOutUtf8().lines()
361361
.map(line -> line.startsWith(ERROR_PREFIX) ? line.substring(ERROR_PREFIX.length()) : null)
362362
.filter(line -> line != null)
@@ -367,6 +367,8 @@ protected static StringSelfie expectSelfieErrorMsg(ProcessRunner.Result result)
367367
int help1 = sanitizedVersion.indexOf("-> [Help 1]");
368368
String trimTrailingString = sanitizedVersion.substring(0, help1);
369369

370-
return Selfie.expectSelfie(trimTrailingString);
370+
String sanitizeBiomeNative = trimTrailingString.replaceAll("spotless-data/biome/biome-(.+),", "biome-exe");
371+
String sanitizeFilePath = sanitizeBiomeNative.replaceAll(rootFolder().getAbsolutePath(), "PROJECT_DIR");
372+
return Selfie.expectSelfie(sanitizeFilePath);
371373
}
372374
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/biome/BiomeMavenTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ void failureWhenNotParseable() throws Exception {
249249
assertFile("biome_test.js").sameAsResource("biome/js/fileBefore.js");
250250
expectSelfieErrorMsg(result).toBe("""
251251
Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:VERSION:apply (default-cli) on project spotless-maven-plugin-tests: There were 1 lint error(s), they must be fixed or suppressed.
252-
biome_test.js:LINE_UNDEFINED biome(java.lang.RuntimeException) > arguments: [/Users/ntwigg/.m2/repository/com/diffplug/spotless/spotless-data/biome/biome-mac_os-arm64-1.2.0, format, --stdin-file-path, file.json] (...)
252+
biome_test.js:LINE_UNDEFINED biome(java.lang.RuntimeException) > arguments: [/Users/ntwigg/.m2/repository/com/diffplug/spotless/biome-exe file.json] (...)
253253
Resolve these lints or suppress with `<lintSuppressions>`
254254
""");
255255
}

plugin-maven/src/test/java/com/diffplug/spotless/maven/java/LintSuppressionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ void testNoSuppressionFailsOnWildcardImports() throws Exception {
3333
setFile(path).toResource("java/removewildcardimports/JavaCodeWildcardsUnformatted.test");
3434

3535
expectSelfieErrorMsg(mavenRunner().withArguments("spotless:check").runHasError()).toBe("""
36-
Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:VERSION:check (default-cli) on project spotless-maven-plugin-tests: Unable to format file /private/var/folders/8p/37qyn_6506sd85y1jbl91dbw0000gn/T/junit-7771631643861333109/src/main/java/TestFile.java
36+
Failed to execute goal com.diffplug.spotless:spotless-maven-plugin:VERSION:check (default-cli) on project spotless-maven-plugin-tests: Unable to format file PROJECT_DIR/src/main/java/TestFile.java
3737
Step 'removeWildcardImports' found problem in 'TestFile.java':
3838
TestFile.java:L1 removeWildcardImports(import java.util.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this
3939
TestFile.java:L2 removeWildcardImports(import static java.util.Collections.*;) Do not use wildcard imports (e.g. java.util.*) - replace with specific class imports (e.g. java.util.List) as 'spotlessApply' cannot auto-fix this

0 commit comments

Comments
 (0)