From b43aaa3d0a87824a1cd2e7ad018e483ddd5bc7ad Mon Sep 17 00:00:00 2001 From: Marharyta Date: Fri, 17 Nov 2023 17:23:07 +0100 Subject: [PATCH] [NO JIRA] Improve SanityTest to not build another time (#4554) --- .cirrus.yml | 2 +- .../java/org/sonar/plugins/java/SanityTest.java | 14 ++------------ 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 615ddfb2c66..ab1b5e88db8 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -143,7 +143,7 @@ sanity_task: sanity_script: - source cirrus-env QA - source set_maven_build_version $BUILD_NUMBER - - mvn clean install -DskipTests=true + - mvn clean compile --projects java-checks-test-sources --also-make-dependents - mvn verify -f sonar-java-plugin/pom.xml -Psanity -Dtest=SanityTest cleanup_before_cache_script: cleanup_maven_repository diff --git a/sonar-java-plugin/src/test/java/org/sonar/plugins/java/SanityTest.java b/sonar-java-plugin/src/test/java/org/sonar/plugins/java/SanityTest.java index 32b2b7acb99..e2f0747480b 100644 --- a/sonar-java-plugin/src/test/java/org/sonar/plugins/java/SanityTest.java +++ b/sonar-java-plugin/src/test/java/org/sonar/plugins/java/SanityTest.java @@ -65,13 +65,11 @@ class SanityTest { private static final Logger LOG = LoggerFactory.getLogger(SanityTest.class); + public static final String DEFAULT_MODULE = "default"; @RegisterExtension public final LogTesterJUnit5 logTester = new LogTesterJUnit5().setLevel(Level.DEBUG); - private static final String TARGET_CLASSES = "../java-checks/target/test-classes"; - private static final String TEST_FILES_EXTRA_CLASSES = "../java-checks/src/test/resources/"; - private static final String AWS_MODULE = "aws"; private static final String[] FILE_DIRECTORIES = { @@ -117,7 +115,7 @@ void test() throws Exception { List inputFiles = getJavaInputFiles(moduleBaseDir); assertThat(inputFiles).hasSizeGreaterThanOrEqualTo(checks.size()); - List classpath = getClassPath(); + List classpath = getClassPathFromModule(DEFAULT_MODULE); classpath.addAll(getClassPathFromModule(AWS_MODULE)); assertThat(classpath).isNotEmpty(); @@ -248,14 +246,6 @@ private static boolean isNotParsingErrorFile(String filename) { return !(filename.contains("ParsingError") || filename.contains("ParseError")); } - private static List getClassPath() { - List classpath = new ArrayList<>(); - classpath.addAll(FilesUtils.getClassPath(FilesUtils.DEFAULT_TEST_JARS_DIRECTORY)); - classpath.add(new File(TARGET_CLASSES).getAbsoluteFile()); - classpath.add(new File(TEST_FILES_EXTRA_CLASSES).getAbsoluteFile()); - return classpath; - } - private static List getClassPathFromModule(String module) { List classpath = new ArrayList<>(); classpath.addAll(FilesUtils.getClassPath(FilesUtils.TEST_SOURCES_ROOT + module + FilesUtils.TARGET_TEST_JARS));