Accept marker-only changes in RewriteTest instead of failing with empty diff#7350
Closed
Accept marker-only changes in RewriteTest instead of failing with empty diff#7350
Conversation
…ty diff After #7202, `ChangeDependencyGroupIdAndArtifactId` updates `JavaSourceSet` markers on Java files when dependency coordinates change. These marker-only changes produce Results with identical before/after text, which `RewriteTest` previously treated as errors ("An empty diff was generated"). Instead of failing, silently accept Results where the printed text is unchanged. This allows recipes to update markers (e.g. classpath metadata) without requiring downstream tests to add explicit `after` text for every Java source spec. The `afterRecipe` callback still fires with the updated tree, so tests that need to verify marker changes (like `updatesJavaSourceSetMarkerOnJavaFiles`) continue to work. Fixes #7349
Member
Author
|
Ok getting ticked off here about the wrong changes being made; THis and the downstream PRs are rubbish; the actual problems are likely to do with |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ScanningRecipeupdates only markers (e.g.JavaSourceSet) without changing source text,RewriteTestnow accepts the result silently instead of failing with "An empty diff was generated"afterRecipecallback still fires with the updated tree so marker assertions continue to workContext
JavaSourceSetUpdatertoChangeDependencyGroupIdAndArtifactId, which correctly updates classpath markers on Java files when dependency coordinates change. However, this caused downstream test failures in repos that assert on Maven dependency changes alongside Java source files — the Java files produce aResult(because the marker changed the object identity) but have identical printed text, triggering the "empty diff" guard inRewriteTest.Affected repos:
rewrite-hibernate,rewrite-migrate-java,rewrite-dropwizard(all broke on scheduled CI April 11).What changed
In
RewriteTest.java, when aResulthas identical before/after text, instead of callingfail()we now:allResults(so no spurious diff is reported)afterRecipeconsumer withresult.getAfter()(preserving marker assertions)This does not affect:
RecipeRunCycleper-cycle change tracking (marker changes still count for recipe scheduling)InMemoryLargeSourceSet.getChangeset()(Results are still generated correctly)Test plan
ChangeDependencyGroupIdAndArtifactIdTest.updatesJavaSourceSetMarkerOnJavaFilespasses (verifiesafterRecipestill receives updated markers)ChangeDependencyGroupIdAndArtifactIdTest.javaSourceSetUnchangedWhenModuleDoesNotHaveDependencypassesrewrite-testmodule tests passrewrite-mavenmodule tests passrewrite-hibernateMigrateToHibernate61Test.groupIdHibernateOrmRenamedpasses onmainwith this SNAPSHOT