Skip to content

Commit

Permalink
Does Groovy parser trim final line terminator?
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Oct 22, 2023
1 parent 867f626 commit bb04cd1
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,7 @@ default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs)
if ((result.getBefore() == null && source == null) ||
(result.getBefore() != null && result.getBefore().getId().equals(source.getId()))) {
if (result.getAfter() != null) {
String before = result.getBefore() == null ? null : result.getBefore().printAll(out.clone());
String actualAfter = result.getAfter().printAll(out.clone());
String expectedAfter = sourceSpec.after == null ? null :
sourceSpec.after.apply(actualAfter);
Expand All @@ -466,7 +467,8 @@ default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs)
sourceSpec.eachResult.accept(result.getAfter(), testMethodSpec, testClassSpec);
} else {
boolean isRemote = result.getAfter() instanceof Remote;
if (!isRemote && Objects.equals(sourceSpec.before, actualAfter)) {
if (!isRemote && Objects.equals(result.getBefore().getSourcePath(), result.getAfter().getSourcePath()) &&
Objects.equals(before, actualAfter)) {
fail("An empty diff was generated. The recipe incorrectly changed a reference without changing its contents.");
}

Expand All @@ -476,7 +478,7 @@ default void rewriteRun(Consumer<RecipeSpec> spec, SourceSpec<?>... sourceSpecs)
} else {
assertThat(actualAfter)
.as("The recipe must not make changes to \"" + result.getBefore().getSourcePath() + "\"")
.isEqualTo(result.getBefore().printAll(out.clone()));
.isEqualTo(before);
}
}
} else {
Expand Down

0 comments on commit bb04cd1

Please sign in to comment.