From 65c30a5c1d5d03a959e27f7779ec7c766484be7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20Kr=C3=BCger?= Date: Thu, 19 Oct 2023 17:46:21 +0200 Subject: [PATCH] fixes #975 Fix ignore pattern and test --- .../org/springframework/sbm/parsers/ModuleParser.java | 2 +- .../resources/META-INF/sbm-support-rewrite.properties | 2 +- .../sbm/parsers/CompareParserRecipeRunTest.java | 8 +++----- .../springframework/sbm/parsers/ParserPropertiesTest.java | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ModuleParser.java b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ModuleParser.java index 0b1d4cc41..96f57dc0e 100644 --- a/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ModuleParser.java +++ b/sbm-support-rewrite/src/main/java/org/springframework/sbm/parsers/ModuleParser.java @@ -128,7 +128,7 @@ public List processMainSources( mainProjectProvenance.add(sourceSet("main", dependencies, typeCache)); // FIXME: 945 Why target and not all main? - List parsedJavaPaths = mainJavaSources.stream().map(ResourceUtil::getPath).toList(); + List parsedJavaPaths = javaSourcesInTarget.stream().map(ResourceUtil::getPath).toList(); Stream parsedJava = cus.map(addProvenance(baseDir, mainProjectProvenance, parsedJavaPaths)); log.debug("[%s] Scanned %d java source files in main scope.".formatted(currentProject, mainJavaSources.size())); diff --git a/sbm-support-rewrite/src/main/resources/META-INF/sbm-support-rewrite.properties b/sbm-support-rewrite/src/main/resources/META-INF/sbm-support-rewrite.properties index 0d564fd91..caaf7f4eb 100644 --- a/sbm-support-rewrite/src/main/resources/META-INF/sbm-support-rewrite.properties +++ b/sbm-support-rewrite/src/main/resources/META-INF/sbm-support-rewrite.properties @@ -27,4 +27,4 @@ parser.sizeThresholdMb=10 parser.runPerSubmodule=false parser.failOnInvalidActiveRecipes=true parser.activeProfiles=default -parser.ignoredPathPatterns=**.idea,**.git,**/target/**,target/** +parser.ignoredPathPatterns=**.idea/**,**.git,**/target/**,target/** diff --git a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java index 71ca8e05f..800e406fa 100644 --- a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java +++ b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/CompareParserRecipeRunTest.java @@ -45,7 +45,6 @@ * @author Fabian Krüger */ @SpringBootTest(classes = {SbmSupportRewriteConfiguration.class, SbmTestConfiguration.class}) -@Issue("https://github.com/spring-projects-experimental/spring-boot-migrator/issues/975") public class CompareParserRecipeRunTest { @Autowired @@ -58,9 +57,8 @@ public class CompareParserRecipeRunTest { private ExecutionContext executionContext; @Test - @DisplayName("runningRecipe") - @ExpectedToFail("FIXME: #975") - void runningRecipe() { + @DisplayName("Running a recipe with RewriteMavenParser should yield the same result as with RewriteProjectParser") + void runningARecipeWithRewriteMavenParserYieldsTheSameResultAsWithRewriteProjectParser() { Path baseDir = TestProjectHelper.getMavenProject("parser-recipe-run"); RewriteProjectParsingResult sutParsingResult = sut.parse(baseDir); RewriteProjectParsingResult compParsingResult = comparingParser.parse(baseDir); @@ -105,7 +103,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex // Run Parser independent from Maven counter.setRelease(0); RecipeRun sutRecipeRun = recipe.run(new InMemoryLargeSourceSet(sutParsingResult.sourceFiles()), executionContext); - assertThat(counter.get()).isEqualTo(3); // differs, should be 2 + assertThat(counter.get()).isEqualTo(2); // differs, should be 2 assertThat(sutRecipeRun.getChangeset().getAllResults()).hasSize(1); // is 0 } diff --git a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/ParserPropertiesTest.java b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/ParserPropertiesTest.java index a21b8df72..d76276720 100644 --- a/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/ParserPropertiesTest.java +++ b/sbm-support-rewrite/src/test/java/org/springframework/sbm/parsers/ParserPropertiesTest.java @@ -87,7 +87,7 @@ void defaultActiveProfiles() { @Test @DisplayName("parser.ignoredPathPatterns") void defaultIgnoredPathPatterns() { - assertThat(parserProperties.getIgnoredPathPatterns()).containsExactlyInAnyOrder("target/**", "**.git", "**/target/**", "**.idea"); + assertThat(parserProperties.getIgnoredPathPatterns()).containsExactlyInAnyOrder("**.idea/**", "**.git", "**/target/**", "target/**"); } }