diff options
author | Matteo Mara <matteo.mara@sonarsource.com> | 2023-12-22 10:28:20 +0100 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-12-22 20:03:01 +0000 |
commit | 48705fd9366d3cfae6c4642084d0400ee73313ad (patch) | |
tree | 1932ef20c1ff00118d8b83a6879e16d62a788381 /sonar-scanner-engine/src/it | |
parent | b6367ef978efd8f342dd70c4427e7570320818a4 (diff) | |
download | sonarqube-48705fd9366d3cfae6c4642084d0400ee73313ad.tar.gz sonarqube-48705fd9366d3cfae6c4642084d0400ee73313ad.zip |
Revert "SONAR-21195 Refactor file indexing into two distinct steps"
This reverts commit 42d16dafde01b19bc7fcb99084e087fdc9b8e95e.
Diffstat (limited to 'sonar-scanner-engine/src/it')
-rw-r--r-- | sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java | 8 | ||||
-rw-r--r-- | sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java | 43 |
2 files changed, 5 insertions, 46 deletions
diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java index 1916d3e6d00..ebf0dc20efa 100644 --- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java +++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/ScannerMediumTester.java @@ -35,7 +35,6 @@ import java.util.List; import java.util.Map; import java.util.Optional; import java.util.Properties; -import java.util.Set; import javax.annotation.CheckForNull; import javax.annotation.Nullable; import javax.annotation.Priority; @@ -137,12 +136,11 @@ public class ScannerMediumTester extends ExternalResource { } public ScannerMediumTester registerPlugin(String pluginKey, Plugin instance) { - pluginInstaller.add(pluginKey, instance); - return this; + return registerPlugin(pluginKey, instance, 1L); } - public ScannerMediumTester registerOptionalPlugin(String pluginKey, Set<String> requiredForLanguages, Plugin instance) { - pluginInstaller.addOptional(pluginKey, requiredForLanguages, instance); + public ScannerMediumTester registerPlugin(String pluginKey, Plugin instance, long lastUpdatedAt) { + pluginInstaller.add(pluginKey, instance, lastUpdatedAt); return this; } diff --git a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java index 66f35f9cfa8..0bfef5a38ad 100644 --- a/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java +++ b/sonar-scanner-engine/src/it/java/org/sonar/scanner/mediumtest/fs/FileSystemMediumIT.java @@ -29,7 +29,6 @@ import java.nio.file.LinkOption; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Random; -import java.util.Set; import org.apache.commons.io.FileUtils; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.SystemUtils; @@ -40,10 +39,8 @@ import org.junit.Test; import org.junit.rules.TemporaryFolder; import org.slf4j.event.Level; import org.sonar.api.CoreProperties; -import org.sonar.api.Plugin; import org.sonar.api.SonarEdition; import org.sonar.api.batch.fs.InputFile; -import org.sonar.api.batch.fs.InputFileFilter; import org.sonar.api.batch.fs.internal.DefaultInputFile; import org.sonar.api.testfixtures.log.LogTester; import org.sonar.api.utils.MessageException; @@ -77,7 +74,6 @@ public class FileSystemMediumIT { public ScannerMediumTester tester = new ScannerMediumTester() .setEdition(SonarEdition.COMMUNITY) .registerPlugin("xoo", new XooPlugin()) - .registerOptionalPlugin("optional-xoo", Set.of("xoo"), new OptionalXooPlugin()) .addDefaultQProfile("xoo", "Sonar Way") .addDefaultQProfile("xoo2", "Sonar Way"); @@ -1185,7 +1181,7 @@ public class FileSystemMediumIT { assertThatThrownBy(result::execute) .isExactlyInstanceOf(IllegalStateException.class) - .hasMessageEndingWith(format("Failed to preprocess files")); + .hasMessageEndingWith(format("Failed to index files")); } @Test @@ -1256,42 +1252,7 @@ public class FileSystemMediumIT { assertThatThrownBy(result::execute) .isExactlyInstanceOf(IllegalStateException.class) - .hasMessageEndingWith(format("Failed to preprocess files")); - } - - @Test - public void should_load_input_file_filters_for_required_and_optional_plugins() throws IOException { - File projectDir = new File("test-resources/mediumtest/xoo/sample-with-input-file-filters"); - AnalysisResult result = tester - .newAnalysis(new File(projectDir, "sonar-project.properties")) - .execute(); - - assertThat(result.inputFiles()).hasSize(1); - - assertThat(logTester.logs()).contains("'xources/hello/xoo_exclude2.xoo' excluded by org.sonar.scanner.mediumtest.fs" + - ".FileSystemMediumIT$OptionalXooPlugin$OptionalXooFileFilter"); - assertThat(logTester.logs()).contains("'xources/hello/xoo_exclude.xoo' excluded by org.sonar.xoo.extensions.XooExcludeFileFilter"); - assertThat(logTester.logs()).contains("'xources/hello/HelloJava.xoo' indexed with language 'xoo'"); - - assertThat(result.inputFile("xources/hello/xoo_exclude.xoo")).isNull(); - assertThat(result.inputFile("xources/hello/xoo_exclude2.xoo")).isNull(); - assertThat(result.inputFile("xources/hello/HelloJava.xoo")).isNotNull(); - } - - public static class OptionalXooPlugin implements Plugin { - - @Override - public void define(Context context) { - context.addExtension(OptionalXooFileFilter.class); - } - - public static class OptionalXooFileFilter implements InputFileFilter { - - @Override - public boolean accept(InputFile f) { - return !f.filename().endsWith("_exclude2.xoo"); - } - } + .hasMessageEndingWith(format("Failed to index files")); } private static void assertAnalysedFiles(AnalysisResult result, String... files) { |