From de7732d53ea1ef240d10c65eeb9f554d96ece826 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 3 Apr 2024 16:02:52 -0700 Subject: [PATCH 1/6] Everything that gets passed to StepHarness now gets round-tripped. --- .../com/diffplug/spotless/StepHarness.java | 2 +- .../diffplug/spotless/StepHarnessBase.java | 50 ++----------------- .../spotless/StepHarnessWithFile.java | 2 +- 3 files changed, 6 insertions(+), 48 deletions(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarness.java b/testlib/src/main/java/com/diffplug/spotless/StepHarness.java index 0f6ddc9ad9..43ff60f7a8 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarness.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarness.java @@ -26,7 +26,7 @@ import org.assertj.core.api.Assertions; /** An api for testing a {@code FormatterStep} that doesn't depend on the File path. DO NOT ADD FILE SUPPORT TO THIS, use {@link StepHarnessWithFile} if you need that. */ -public class StepHarness extends StepHarnessBase { +public class StepHarness extends StepHarnessBase { private StepHarness(Formatter formatter) { super(formatter); } diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java b/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java index 29b253872f..a9b7cda734 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java @@ -15,67 +15,25 @@ */ package com.diffplug.spotless; -import java.util.Locale; import java.util.Objects; -import java.util.Set; import org.assertj.core.api.Assertions; -class StepHarnessBase> implements AutoCloseable { +class StepHarnessBase implements AutoCloseable { private final Formatter formatter; - private Formatter roundTripped; - private boolean supportsRoundTrip = false; protected StepHarnessBase(Formatter formatter) { this.formatter = Objects.requireNonNull(formatter); - if (formatter.getSteps().size() == 1) { - // our goal is for everything to be roundtrip serializable - // the steps to get there are - // - make every individual step round-trippable - // - make the other machinery (Formatter, LineEnding, etc) round-trippable - // - done! - // - // Right now, we're still trying to get each and every single step to be round-trippable. - // You can help by add a test below, make sure that the test for that step fails, and then - // make the test pass. `FormatterStepEqualityOnStateSerialization` is a good base class for - // easily converting a step to round-trip serialization while maintaining easy and concise - // equality code. - String onlyStepName = formatter.getSteps().get(0).getName(); - if (onlyStepName.startsWith("indentWith")) { - supportsRoundTrip = true; - } else if (onlyStepName.equals("diktat")) { - supportsRoundTrip = true; - } else if (onlyStepName.toLowerCase(Locale.ROOT).contains("eclipse")) { - supportsRoundTrip = true; - } else if (onlyStepName.equals("fence")) { - supportsRoundTrip = true; - } else if (Set.of("black", "buf", "clang", "ktlint", "ktfmt", "scalafmt", "palantir-java-format", "google-java-format", - "removeUnusedImports", "cleanthat", "No line break between type annotation and type", "antlr4Formatter", - "gson", "jacksonJson", "apply-json-patch", "jsonSimple", "sortPom", "jacksonYaml", "gherkinUtils", - "flexmark-java", "freshmark", - "importOrder", "Remove unnecessary semicolons").contains(onlyStepName)) { - supportsRoundTrip = true; - } - } + Formatter roundTripped = SerializableEqualityTester.reserialize(formatter); + Assertions.assertThat(roundTripped).isEqualTo(formatter); } protected Formatter formatter() { - if (!supportsRoundTrip) { - return formatter; - } else { - if (roundTripped == null) { - roundTripped = SerializableEqualityTester.reserialize(formatter); - Assertions.assertThat(roundTripped).isEqualTo(formatter); - } - return roundTripped; - } + return formatter; } @Override public void close() { formatter.close(); - if (roundTripped != null) { - roundTripped.close(); - } } } diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java b/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java index ae2f22db1e..d09cc62668 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java @@ -26,7 +26,7 @@ import org.assertj.core.api.Assertions; /** An api for testing a {@code FormatterStep} that depends on the File path. */ -public class StepHarnessWithFile extends StepHarnessBase { +public class StepHarnessWithFile extends StepHarnessBase { private final ResourceHarness harness; private StepHarnessWithFile(ResourceHarness harness, Formatter formatter) { From a4f8e2b2cf598119778747aadc726760a562ad09 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 3 Apr 2024 22:57:26 -0700 Subject: [PATCH 2/6] FenceStep can't use serialization for equality on its delegate steps anymore, it has to use "real" equality now. --- .../java/com/diffplug/spotless/Formatter.java | 4 ++ .../diffplug/spotless/generic/FenceStep.java | 65 ++++++++++++++----- 2 files changed, 54 insertions(+), 15 deletions(-) diff --git a/lib/src/main/java/com/diffplug/spotless/Formatter.java b/lib/src/main/java/com/diffplug/spotless/Formatter.java index fc6fe32afd..0732ab4592 100644 --- a/lib/src/main/java/com/diffplug/spotless/Formatter.java +++ b/lib/src/main/java/com/diffplug/spotless/Formatter.java @@ -35,6 +35,8 @@ import javax.annotation.Nullable; +import com.diffplug.spotless.generic.FenceStep; + /** Formatter which performs the full formatting. */ public final class Formatter implements Serializable, AutoCloseable { private static final long serialVersionUID = 1L; @@ -306,6 +308,8 @@ public void close() { ((FormatterStepImpl.Standard) step).cleanupFormatterFunc(); } else if (step instanceof FormatterStepEqualityOnStateSerialization) { ((FormatterStepEqualityOnStateSerialization) step).cleanupFormatterFunc(); + } else if (step instanceof FenceStep.Apply) { + ((FenceStep.Apply) step).cleanup(); } } } diff --git a/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java b/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java index cbfe016679..9adabc5a4b 100644 --- a/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java +++ b/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java @@ -25,11 +25,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; +import javax.annotation.Nullable; + import com.diffplug.spotless.Formatter; import com.diffplug.spotless.FormatterFunc; import com.diffplug.spotless.FormatterStep; import com.diffplug.spotless.LineEnding; -import com.diffplug.spotless.SerializedFunction; import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; @@ -81,10 +82,7 @@ private void assertRegexSet() { /** Returns a step which will apply the given steps but preserve the content selected by the regex / openClose pair. */ public FormatterStep preserveWithin(List steps) { assertRegexSet(); - return FormatterStep.createLazy(name, - () -> new PreserveWithin(regex, steps), - SerializedFunction.identity(), - state -> FormatterFunc.Closeable.of(state.buildFormatter(), state)); + return new PreserveWithin(name, regex, steps); } /** @@ -93,17 +91,14 @@ public FormatterStep preserveWithin(List steps) { */ public FormatterStep applyWithin(List steps) { assertRegexSet(); - return FormatterStep.createLazy(name, - () -> new ApplyWithin(regex, steps), - SerializedFunction.identity(), - state -> FormatterFunc.Closeable.of(state.buildFormatter(), state)); + return new ApplyWithin(name, regex, steps); } static class ApplyWithin extends Apply implements FormatterFunc.Closeable.ResourceFuncNeedsFile { private static final long serialVersionUID = 17061466531957339L; - ApplyWithin(Pattern regex, List steps) { - super(regex, steps); + ApplyWithin(String name, Pattern regex, List steps) { + super(name, regex, steps); } @Override @@ -122,8 +117,8 @@ public String apply(Formatter formatter, String unix, File file) throws Exceptio static class PreserveWithin extends Apply implements FormatterFunc.Closeable.ResourceFuncNeedsFile { private static final long serialVersionUID = -8676786492305178343L; - PreserveWithin(Pattern regex, List steps) { - super(regex, steps); + PreserveWithin(String name, Pattern regex, List steps) { + super(name, regex, steps); } private void storeGroups(String unix) { @@ -144,7 +139,8 @@ public String apply(Formatter formatter, String unix, File file) throws Exceptio } @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") - static class Apply implements Serializable { + public static abstract class Apply implements Serializable, FormatterStep, FormatterFunc.Closeable.ResourceFuncNeedsFile { + final String name; private static final long serialVersionUID = -2301848328356559915L; final Pattern regex; final List steps; @@ -152,7 +148,8 @@ static class Apply implements Serializable { transient ArrayList groups = new ArrayList<>(); transient StringBuilder builderInternal; - public Apply(Pattern regex, List steps) { + public Apply(String name, Pattern regex, List steps) { + this.name = name; this.regex = regex; this.steps = steps; } @@ -218,5 +215,43 @@ protected String assembleGroups(String unix) { throw new Error("An intermediate step removed a match of " + pattern); } } + + @Override + public String getName() { + return name; + } + + private transient Formatter formatter; + + @Nullable + @Override + public String format(String rawUnix, File file) throws Exception { + if (formatter == null) { + formatter = buildFormatter(); + } + return this.apply(formatter, rawUnix, file); + } + + @Override + public boolean equals(Object o) { + if (this == o) + return true; + if (o == null || getClass() != o.getClass()) + return false; + Apply step = (Apply) o; + return name.equals(step.name) && regex.pattern().equals(step.regex.pattern()) && regex.flags() == step.regex.flags() && steps.equals(step.steps); + } + + @Override + public int hashCode() { + return Objects.hash(name, regex.pattern(), regex.flags(), steps); + } + + public void cleanup() { + if (formatter != null) { + formatter.close(); + formatter = null; + } + } } } From 532078b8cd5b8d5a5e88f0bb14d0236e7e001944 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 3 Apr 2024 22:59:01 -0700 Subject: [PATCH 3/6] Fix a long-standing bug where delegate steps (which are created by filename filters) weren't getting cleaned-up. --- lib/src/main/java/com/diffplug/spotless/Formatter.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/src/main/java/com/diffplug/spotless/Formatter.java b/lib/src/main/java/com/diffplug/spotless/Formatter.java index 0732ab4592..72016c353d 100644 --- a/lib/src/main/java/com/diffplug/spotless/Formatter.java +++ b/lib/src/main/java/com/diffplug/spotless/Formatter.java @@ -304,6 +304,9 @@ public boolean equals(Object obj) { @Override public void close() { for (FormatterStep step : steps) { + if (step instanceof DelegateFormatterStep) { + step = ((DelegateFormatterStep) step).delegateStep; + } if (step instanceof FormatterStepImpl.Standard) { ((FormatterStepImpl.Standard) step).cleanupFormatterFunc(); } else if (step instanceof FormatterStepEqualityOnStateSerialization) { From cee7cad08fa9520f90583d083ed7fe56b2bd8683 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 3 Apr 2024 23:09:40 -0700 Subject: [PATCH 4/6] Fix spotbugs. --- lib/src/main/java/com/diffplug/spotless/Formatter.java | 4 ++-- .../java/com/diffplug/spotless/generic/FenceStep.java | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/src/main/java/com/diffplug/spotless/Formatter.java b/lib/src/main/java/com/diffplug/spotless/Formatter.java index 72016c353d..05b27c1cf0 100644 --- a/lib/src/main/java/com/diffplug/spotless/Formatter.java +++ b/lib/src/main/java/com/diffplug/spotless/Formatter.java @@ -311,8 +311,8 @@ public void close() { ((FormatterStepImpl.Standard) step).cleanupFormatterFunc(); } else if (step instanceof FormatterStepEqualityOnStateSerialization) { ((FormatterStepEqualityOnStateSerialization) step).cleanupFormatterFunc(); - } else if (step instanceof FenceStep.Apply) { - ((FenceStep.Apply) step).cleanup(); + } else if (step instanceof FenceStep.BaseStep) { + ((FenceStep.BaseStep) step).cleanup(); } } } diff --git a/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java b/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java index 9adabc5a4b..e1b486bc22 100644 --- a/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java +++ b/lib/src/main/java/com/diffplug/spotless/generic/FenceStep.java @@ -94,7 +94,7 @@ public FormatterStep applyWithin(List steps) { return new ApplyWithin(name, regex, steps); } - static class ApplyWithin extends Apply implements FormatterFunc.Closeable.ResourceFuncNeedsFile { + static class ApplyWithin extends BaseStep { private static final long serialVersionUID = 17061466531957339L; ApplyWithin(String name, Pattern regex, List steps) { @@ -114,7 +114,7 @@ public String apply(Formatter formatter, String unix, File file) throws Exceptio } } - static class PreserveWithin extends Apply implements FormatterFunc.Closeable.ResourceFuncNeedsFile { + static class PreserveWithin extends BaseStep { private static final long serialVersionUID = -8676786492305178343L; PreserveWithin(String name, Pattern regex, List steps) { @@ -139,7 +139,7 @@ public String apply(Formatter formatter, String unix, File file) throws Exceptio } @SuppressFBWarnings("SE_TRANSIENT_FIELD_NOT_RESTORED") - public static abstract class Apply implements Serializable, FormatterStep, FormatterFunc.Closeable.ResourceFuncNeedsFile { + public static abstract class BaseStep implements Serializable, FormatterStep, FormatterFunc.Closeable.ResourceFuncNeedsFile { final String name; private static final long serialVersionUID = -2301848328356559915L; final Pattern regex; @@ -148,7 +148,7 @@ public static abstract class Apply implements Serializable, FormatterStep, Forma transient ArrayList groups = new ArrayList<>(); transient StringBuilder builderInternal; - public Apply(String name, Pattern regex, List steps) { + public BaseStep(String name, Pattern regex, List steps) { this.name = name; this.regex = regex; this.steps = steps; @@ -238,7 +238,7 @@ public boolean equals(Object o) { return true; if (o == null || getClass() != o.getClass()) return false; - Apply step = (Apply) o; + BaseStep step = (BaseStep) o; return name.equals(step.name) && regex.pattern().equals(step.regex.pattern()) && regex.flags() == step.regex.flags() && steps.equals(step.steps); } From 63414a748e55782275602ae648f463604aa20db0 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 3 Apr 2024 23:41:16 -0700 Subject: [PATCH 5/6] Make roundtripping optional-ish. --- .../java/com/diffplug/spotless/StepHarness.java | 6 +++--- .../java/com/diffplug/spotless/StepHarnessBase.java | 13 +++++++++++-- .../com/diffplug/spotless/StepHarnessWithFile.java | 8 ++++---- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarness.java b/testlib/src/main/java/com/diffplug/spotless/StepHarness.java index 43ff60f7a8..6c55165251 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarness.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarness.java @@ -27,8 +27,8 @@ /** An api for testing a {@code FormatterStep} that doesn't depend on the File path. DO NOT ADD FILE SUPPORT TO THIS, use {@link StepHarnessWithFile} if you need that. */ public class StepHarness extends StepHarnessBase { - private StepHarness(Formatter formatter) { - super(formatter); + private StepHarness(Formatter formatter, RoundTrip roundTrip) { + super(formatter, roundTrip); } /** Creates a harness for testing steps which don't depend on the file. */ @@ -49,7 +49,7 @@ public static StepHarness forSteps(FormatterStep... steps) { /** Creates a harness for testing a formatter whose steps don't depend on the file. */ public static StepHarness forFormatter(Formatter formatter) { - return new StepHarness(formatter); + return new StepHarness(formatter, RoundTrip.ASSERT_EQUAL); } /** Asserts that the given element is transformed as expected, and that the result is idempotent. */ diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java b/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java index a9b7cda734..656057cd4e 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarnessBase.java @@ -20,12 +20,21 @@ import org.assertj.core.api.Assertions; class StepHarnessBase implements AutoCloseable { + enum RoundTrip { + ASSERT_EQUAL, DONT_ASSERT_EQUAL, DONT_ROUNDTRIP + } + private final Formatter formatter; - protected StepHarnessBase(Formatter formatter) { + protected StepHarnessBase(Formatter formatter, RoundTrip roundTrip) { this.formatter = Objects.requireNonNull(formatter); + if (roundTrip == RoundTrip.DONT_ROUNDTRIP) { + return; + } Formatter roundTripped = SerializableEqualityTester.reserialize(formatter); - Assertions.assertThat(roundTripped).isEqualTo(formatter); + if (roundTrip == RoundTrip.ASSERT_EQUAL) { + Assertions.assertThat(roundTripped).isEqualTo(formatter); + } } protected Formatter formatter() { diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java b/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java index d09cc62668..871da6f385 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarnessWithFile.java @@ -29,14 +29,14 @@ public class StepHarnessWithFile extends StepHarnessBase { private final ResourceHarness harness; - private StepHarnessWithFile(ResourceHarness harness, Formatter formatter) { - super(formatter); + private StepHarnessWithFile(ResourceHarness harness, Formatter formatter, RoundTrip roundTrip) { + super(formatter, roundTrip); this.harness = Objects.requireNonNull(harness); } /** Creates a harness for testing steps which do depend on the file. */ public static StepHarnessWithFile forStep(ResourceHarness harness, FormatterStep step) { - return new StepHarnessWithFile(harness, Formatter.builder() + return forFormatter(harness, Formatter.builder() .name(step.getName()) .encoding(StandardCharsets.UTF_8) .lineEndingsPolicy(LineEnding.UNIX.createPolicy()) @@ -48,7 +48,7 @@ public static StepHarnessWithFile forStep(ResourceHarness harness, FormatterStep /** Creates a harness for testing a formatter whose steps do depend on the file. */ public static StepHarnessWithFile forFormatter(ResourceHarness harness, Formatter formatter) { - return new StepHarnessWithFile(harness, formatter); + return new StepHarnessWithFile(harness, formatter, RoundTrip.ASSERT_EQUAL); } /** Asserts that the given element is transformed as expected, and that the result is idempotent. */ From 9f016c8aaf1870cd2545ab7f3e0f5b3f9764a9b8 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 3 Apr 2024 23:46:44 -0700 Subject: [PATCH 6/6] Because there are a few legitimate reasons to not roundtrip. --- .../main/java/com/diffplug/spotless/StepHarness.java | 10 ++++++++++ .../com/diffplug/spotless/generic/FenceStepTest.java | 11 +++++------ .../spotless/java/GoogleJavaFormatStepTest.java | 6 +++--- 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/testlib/src/main/java/com/diffplug/spotless/StepHarness.java b/testlib/src/main/java/com/diffplug/spotless/StepHarness.java index 6c55165251..735dedb80c 100644 --- a/testlib/src/main/java/com/diffplug/spotless/StepHarness.java +++ b/testlib/src/main/java/com/diffplug/spotless/StepHarness.java @@ -52,6 +52,16 @@ public static StepHarness forFormatter(Formatter formatter) { return new StepHarness(formatter, RoundTrip.ASSERT_EQUAL); } + public static StepHarness forStepNoRoundtrip(FormatterStep step) { + return new StepHarness(Formatter.builder() + .steps(Arrays.asList(step)) + .lineEndingsPolicy(LineEnding.UNIX.createPolicy()) + .encoding(StandardCharsets.UTF_8) + .rootDir(Paths.get("")) + .exceptionPolicy(new FormatExceptionPolicyStrict()) + .build(), RoundTrip.DONT_ROUNDTRIP); + } + /** Asserts that the given element is transformed as expected, and that the result is idempotent. */ public StepHarness test(String before, String after) { String actual = formatter().compute(LineEnding.toUnix(before), new File("")); diff --git a/testlib/src/test/java/com/diffplug/spotless/generic/FenceStepTest.java b/testlib/src/test/java/com/diffplug/spotless/generic/FenceStepTest.java index 17159ae5a4..2f64dac0f5 100644 --- a/testlib/src/test/java/com/diffplug/spotless/generic/FenceStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/generic/FenceStepTest.java @@ -29,14 +29,13 @@ import com.diffplug.spotless.FormatterStep; import com.diffplug.spotless.ResourceHarness; import com.diffplug.spotless.StepHarness; -import com.diffplug.spotless.StepHarnessWithFile; class FenceStepTest extends ResourceHarness { @Test void single() { FormatterStep fence = FenceStep.named("fence").openClose("spotless:off", "spotless:on") .preserveWithin(Arrays.asList(createNeverUpToDateSerializable("lowercase", String::toLowerCase))); - StepHarness harness = StepHarness.forSteps(fence); + StepHarness harness = StepHarness.forStepNoRoundtrip(fence); harness.test( StringPrinter.buildStringFromLines( "A B C", @@ -56,7 +55,7 @@ void single() { void multiple() { FormatterStep fence = FenceStep.named("fence").openClose("spotless:off", "spotless:on") .preserveWithin(Arrays.asList(createNeverUpToDateSerializable("lowercase", String::toLowerCase))); - StepHarness harness = StepHarness.forSteps(fence); + StepHarness harness = StepHarness.forStepNoRoundtrip(fence); harness.test( StringPrinter.buildStringFromLines( "A B C", @@ -90,9 +89,8 @@ void multiple() { void broken() { FormatterStep fence = FenceStep.named("fence").openClose("spotless:off", "spotless:on") .preserveWithin(Arrays.asList(createNeverUpToDateSerializable("uppercase", String::toUpperCase))); - StepHarnessWithFile harness = StepHarnessWithFile.forStep(this, fence); // this fails because uppercase turns spotless:off into SPOTLESS:OFF, etc - harness.testExceptionMsg(newFile("test"), StringPrinter.buildStringFromLines("A B C", + StepHarness.forStepNoRoundtrip(fence).testExceptionMsg(StringPrinter.buildStringFromLines("A B C", "spotless:off", "D E F", "spotless:on", @@ -103,7 +101,7 @@ void broken() { void andApply() { FormatterStep fence = FenceStep.named("fence").openClose("", "") .applyWithin(Arrays.asList(createNeverUpToDateSerializable("lowercase", String::toLowerCase))); - StepHarness.forSteps(fence).test( + StepHarness.forStepNoRoundtrip(fence).test( StringPrinter.buildStringFromLines( "A B C", "", @@ -152,5 +150,6 @@ public String getName() { public String format(String rawUnix, File file) throws Exception { return formatterFunc.apply(rawUnix, file); } + } } diff --git a/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java b/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java index c2ec5b5d7f..4b157c536a 100644 --- a/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2016-2023 DiffPlug + * Copyright 2016-2024 DiffPlug * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,7 +64,7 @@ void behavior() throws Exception { @Test void versionBelowMinimumRequiredVersionIsNotAllowed() throws Exception { FormatterStep step = GoogleJavaFormatStep.create("1.2", "AOSP", TestProvisioner.mavenCentral()); - StepHarness.forStep(step) + StepHarness.forStepNoRoundtrip(step) .testResourceExceptionMsg("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test") .contains("you are using 1.2"); } @@ -73,7 +73,7 @@ void versionBelowMinimumRequiredVersionIsNotAllowed() throws Exception { @EnabledForJreRange(min = JAVA_16) void versionBelowOneDotTenIsNotAllowed() throws Exception { FormatterStep step = GoogleJavaFormatStep.create("1.9", "AOSP", TestProvisioner.mavenCentral()); - StepHarness.forStep(step) + StepHarness.forStepNoRoundtrip(step) .testResourceExceptionMsg("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test") .contains("you are using 1.9"); }