diff --git a/.cirrus.default.yml b/.cirrus.default.yml index a4d58e589..6b9c0832e 100644 --- a/.cirrus.default.yml +++ b/.cirrus.default.yml @@ -235,7 +235,7 @@ qa_connectedModeSonarQube_task: cd its/ mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \ -s ${HOME}/.m2/settings-public-auth.xml \ - -P coverage,\!standaloneMode,\!connectedModeSc \ + -P coverage,\!standaloneMode,\!connectedModeSc,\!cdtIntegration \ -Declipse.p2.mirrors=false \ -Dtarget.platform=latest-java-17_e431 \ -Dtycho.localArtifacts=ignore \ @@ -310,7 +310,7 @@ qa_connectedModeSonarCloud_task: env SONARCLOUD_IT_PASSWORD=$SONARCLOUD_IT_PASSWORD \ mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \ -s ${HOME}/.m2/settings-public-auth.xml \ - -P coverage,\!standaloneMode,\!connectedModeSq \ + -P coverage,\!standaloneMode,\!connectedModeSq,\!cdtIntegration \ -Declipse.p2.mirrors=false \ -Dtarget.platform=latest-java-21 \ -Dtycho.localArtifacts=ignore \ @@ -389,7 +389,7 @@ qa_standaloneMode_task: cd its/ mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \ -s ${HOME}/.m2/settings-public-auth.xml \ - -P coverage,\!connectedModeSq,\!connectedModeSc \ + -P coverage,\!connectedModeSq,\!connectedModeSc,\!cdtIntegration \ -Declipse.p2.mirrors=false \ -Dtarget.platform=${TARGET_PLATFORM} \ -Dtycho.localArtifacts=ignore \ @@ -424,6 +424,85 @@ qa_standaloneMode_task: slack_notification_script: | source slack-failure-notification "Cirrus CI build failure on pipeline: $CIRRUS_PIPELINE_NAME" +qa_cdtIntegration_task: + # name: "Run ITs for CDT integration" + depends_on: + - build + <<: *ONLY_IF_EXCEPT_NIGHTLY + eks_container: + <<: *BUILDER_CONTAINER_DEFINITION + cpu: 4 + memory: 12G + type: m6a.large + env: + ARTIFACTORY_API_KEY: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-private-reader access_token] + GITHUB_TOKEN: VAULT[development/github/token/licenses-ro token] + DISPLAY: :10 + MAVEN_OPTS: -Xmx3072m + matrix: + - env: + TARGET_PLATFORM: 'oldest-java-11_e48' + - env: + TARGET_PLATFORM: 'latest-java-17_e431' + - env: + TARGET_PLATFORM: 'latest-java-21' + <<: *SETUP_MAVEN_CACHE_QA + download_staged_update_site_script: | + set -euo pipefail + source cirrus-env QA + source .cirrus/set_maven_build_version $BUILD_NUMBER + mvn -B -e -V dependency:unpack \ + -Declipse.p2.mirrors=false \ + -Dtycho.mode=maven \ + -Dartifact=org.sonarsource.sonarlint.eclipse:org.sonarlint.eclipse.site:${PROJECT_VERSION}:zip \ + -DoutputDirectory=${CIRRUS_WORKING_DIR}/staged-repository + prepare_background_script: | + set -euo pipefail + /etc/init.d/xvfb start + metacity --sm-disable --replace & + sleep 10 # give metacity some time to start + echo 'Recording tests on video' + ffmpeg -loglevel warning -f x11grab -video_size 1920x1080 -i ${DISPLAY} -codec:v libx264 -r 12 ${CIRRUS_WORKING_DIR}/recording_${TARGET_PLATFORM}.mp4 + run_its_script: | + echo "Run Maven ITs for CDT integration on Eclipse '${TARGET_PLATFORM}'" + cd its/ + mvn -B -e -V org.jacoco:jacoco-maven-plugin:prepare-agent verify \ + -s ${HOME}/.m2/settings-public-auth.xml \ + -P coverage,\!standaloneMode,\!connectedModeSq,\!connectedModeSc \ + -Declipse.p2.mirrors=false \ + -Dtarget.platform=${TARGET_PLATFORM} \ + -Dtycho.localArtifacts=ignore \ + -Dsonarlint-eclipse.p2.url="file://${CIRRUS_WORKING_DIR}/staged-repository" \ + -Djacoco.append=true \ + -Djacoco.destFile=${CIRRUS_WORKING_DIR}/it-coverage.exec + mv ${CIRRUS_WORKING_DIR}/it-coverage.exec ${CIRRUS_WORKING_DIR}/it-coverage-${TARGET_PLATFORM}.exec + cleanup_before_cache_script: cleanup_maven_repository + always: + stop_recording_script: | + pkill -SIGINT -f ffmpeg + while pgrep ffmpeg >/dev/null; do sleep 1; done + /etc/init.d/xvfb stop + test_recording_artifacts: + path: "${CIRRUS_WORKING_DIR}/recording_${TARGET_PLATFORM}.mp4" + jacoco_it_cdt_artifacts: + path: "${CIRRUS_WORKING_DIR}/it-coverage*.exec" + mvn_startTestLog_artifacts: + path: "${CIRRUS_WORKING_DIR}/its/**/target/work/configuration/*.log" + mvn_runTestLog_artifacts: + path: "${CIRRUS_WORKING_DIR}/its/**/target/work/data/.metadata/.log" + on_failure: + xvfb_log_artifacts: + path: "${CIRRUS_WORKING_DIR}/Xvfb.out" + reports_artifacts: + path: "**/reports/**/*" + junit_artifacts: + paths: + - "**/test-results/**/*.xml" + - "**/target/surefire-reports/TEST-*.xml" + format: junit + slack_notification_script: | + source slack-failure-notification "Cirrus CI build failure on pipeline: $CIRRUS_PIPELINE_NAME" + inspect_orchestrator_cache_task: <<: *ONLY_IF depends_on: qa_connectedModeSonarQube @@ -446,6 +525,7 @@ sonarqube_task: - qa_connectedModeSonarQube - qa_connectedModeSonarCloud - qa_standaloneMode + - qa_cdtIntegration <<: *ONLY_IF_EXCEPT_NIGHTLY eks_container: <<: *BUILDER_CONTAINER_DEFINITION @@ -468,10 +548,12 @@ sonarqube_task: curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it.zip -o jacoco_it.zip curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it_sq.zip -o jacoco_it_sq.zip curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it_sc.zip -o jacoco_it_sc.zip + curl --no-progress-meter https://api.cirrus-ci.com/v1/artifact/build/$CIRRUS_BUILD_ID/jacoco_it_cdt.zip -o jacoco_it_cdt.zip unzip jacoco_ut.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/ unzip jacoco_it.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/ unzip jacoco_it_sq.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/ unzip jacoco_it_sc.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/ + unzip jacoco_it_cdt.zip -d ${CIRRUS_WORKING_DIR}/org.sonarlint.eclipse.core.tests/target/ source cirrus-env QA .cirrus/regular_mvn_build_deploy_analyze \ -P-deploy-sonarsource,-release,-sign \ diff --git a/.cirrus.ibuilds.yml b/.cirrus.ibuilds.yml index bdaffe3dd..23a5b3525 100644 --- a/.cirrus.ibuilds.yml +++ b/.cirrus.ibuilds.yml @@ -72,7 +72,7 @@ qa_ibuilds_task: cd its/ mvn -B -e -V verify \ -s ${HOME}/.m2/settings-public-auth.xml \ - -P \!connectedModeSq,\!connectedModeSc \ + -P \!connectedModeSq,\!connectedModeSc,\!cdtIntegration \ -Declipse.p2.mirrors=false \ -Dtarget.platform=ibuilds \ -Dtycho.localArtifacts=ignore \ diff --git a/its/README.md b/its/README.md index aef2c0fe0..cea34a5d3 100644 --- a/its/README.md +++ b/its/README.md @@ -1,20 +1,20 @@ -# SonarLint for Eclipse: Integration tests +# SonarQube for Eclipse: Integration tests This project including its modules contains the integration tests (including compatibility against [iBuilds](https://download.eclipse.org/eclipse/downloads/), the in-development version of the Eclipse IDE) for -SonarLint that are relying on [Eclipse RedDeer](https://github.com/eclipse/reddeer) as the test framework connected +SonarQube that are relying on [Eclipse RedDeer](https://github.com/eclipse/reddeer) as the test framework connected to [Eclipse Tycho](https://github.com/eclipse-tycho/tycho). -The tests are split into separate modules for testing in Standalone Mode only, in Connected Mode with SonarQube and -SonarCloud. Additionally, one module is used for shared logic. This Maven/Tycho project is completely decoupled from -the main SonarLint for Eclipse project. +The tests are split into separate modules for testing in Standalone Mode only, with the integration into CDT (which is +also in Standalone Mode), in Connected Mode with SonarQube Server and SonarQube Cloud. Additionally, one module is used +for shared logic. This Maven/Tycho project is completely decoupled from the main SonarQube for Eclipse project. ## Building -In order to build the integration tests, the main SonarLint for Eclipse project must be build first to create the +In order to build the integration tests, the main SonarQube for Eclipse project must be build first to create the Eclipse Update Site. On the CI/CD pipeline this is not done in one step, but locally it has to be done. -The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarLint +The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube for Eclipse project directory. ``` @@ -25,7 +25,7 @@ mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ig ``` When all the projects are opened inside Eclipse and the target platform correctly configured, this is done in the -background (not for the main SonarLint for Eclipse project tho if not also imported into Eclipse, which is required). +background (not for the main SonarQube for Eclipse project tho if not also imported into Eclipse, which is required). ## Running the Tests @@ -37,48 +37,64 @@ instance. ### Standalone Mode / iBuilds compatibility To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the -Standalone Mode, the following command has to be run that excludes the tests for the Connected Mode with SonarQube and -SonarCloud. +Standalone Mode, the following command has to be run that excludes the tests for the Connected Mode with SonarQube +Server and SonarQube Cloud and the integration into CDT. -The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarLint +The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube for Eclipse project directory. For Standalone Mode all target platforms are useful, for the iBuilds compatibility the `ibuilds` target platform must be used. ``` -mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!connectedModeSc,\!connectedModeSq +mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!connectedModeSc,\!connectedModeSq,\!cdtIntegration ``` -### Connected Mode (SQ) +### Connected Mode (SonarQube Server) To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the -Connected Mode with SonarQube, the following command has to be run that excludes the tests for the Standalone Mode and -the Connected Mode with SonarCloud. With the additional command line option `-Dsonar.runtimeVersion={version alias}` -(see [Orchestrator documentation](https://github.com/SonarSource/orchestrator?tab=readme-ov-file#version-aliases)) the -specific SonarQube version can be configured, the default one is `LATEST_RELEASE`. +Connected Mode with SonarQube Server, the following command has to be run that excludes the tests for the Standalone +Mode and the Connected Mode with SonarQube Cloud and the integration into CDT. With the additional command line option +`-Dsonar.runtimeVersion={version alias}` (see +[Orchestrator documentation](https://github.com/SonarSource/orchestrator?tab=readme-ov-file#version-aliases)) the +specific SonarQube Server version can be configured, the default one is `LATEST_RELEASE`. The target platform provided should be run against the latest one linked to the Eclipse IDE that is shipped with Java 17 (Eclipse IDE 2024-03 / 4.31). This is also what the CI/CD pipeline is doing in order to provide the correct runtime -for the SonarQube instance provided via [Orchestrator](https://github.com/SonarSource/orchestrator) for the latest -supported LTA version, the latest supported version and the currently in-development version (of SonarQube). +for the SonarQube Server instance provided via [Orchestrator](https://github.com/SonarSource/orchestrator) for the +latest supported LTA version, the latest supported version and the currently in-development version (of SonarQube +Server). ``` -mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSc +mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSc,\!cdtIntegration ``` -### Connected Mode (SC) +### Connected Mode (SonarQube Cloud) To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the -Connected Mode with SonarCloud, the following command has to be run that excludes the tests for the Standalone Mode and -the Connected Mode with SonarQube. +Connected Mode with SonarQube Cloud, the following command has to be run that excludes the tests for the Standalone +Mode and the Connected Mode with SonarQube Server and the integration into CDT. -The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarLint -for Eclipse project directory. Compared to the integration tests for the Connected Mode with SonarCloud there is no -dependency on the Java version and the CI/CD pipeline will run against the latest one linked to the Eclipse IDE that is -shipped with Java 21 (the current Java runtime used for upcoming releases as well). +The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube +for Eclipse project directory. Compared to the integration tests for the Connected Mode with SonarQube Cloud there is +no dependency on the Java version and the CI/CD pipeline will run against the latest one linked to the Eclipse IDE that +is shipped with Java 21 (the current Java runtime used for upcoming releases as well). -Due to us requiring the password for the SonarCloud staging environment, we have to pass it directly to the command as -the Eclipse IDE runtime won't pick it up otherwise via `System.getenv("SONARCLOUD_IT_PASSWORD")`! +Due to us requiring the password for the SonarQube Cloud staging environment, we have to pass it directly to the +command as the Eclipse IDE runtime won't pick it up otherwise via `System.getenv("SONARCLOUD_IT_PASSWORD")`! ``` -env SONARCLOUD_IT_PASSWORD=$SONARCLOUD_IT_PASSWORD mvn clean verify -Dtarget.platform=latest-java-21 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSq +env SONARCLOUD_IT_PASSWORD=$SONARCLOUD_IT_PASSWORD mvn clean verify -Dtarget.platform=latest-java-21 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSq,\!cdtIntegration +``` + +### CDT integration + +To run all the tests, or a specific one with the additionally command line option `-Dtest={TestClassName}`, for the +integration into CDT, the following command has to be run that excludes the tests for the Standalone +Mode and the Connected Mode with SonarQube Server and the Connected Mode with SonarQube Cloud. + +The target platform provided must be one of the supported in the `target-platforms` folder inside the main SonarQube +for Eclipse project directory. For the integration into CDT, all target platforms are useful, for the iBuilds +compatibility the `ibuilds` target platform must be used. + +``` +mvn clean verify -Dtarget.platform=latest-java-17_e431 -Dtycho.localArtifacts=ignore -Dsonarlint-eclipse.p2.url="file://{path to repo}/org.sonarlint.eclipse.site/target/repository" -P \!standaloneMode,\!connectedModeSc,\!connectedModeSq ``` diff --git a/its/org.sonarlint.eclipse.its.cdt/META-INF/MANIFEST.MF b/its/org.sonarlint.eclipse.its.cdt/META-INF/MANIFEST.MF new file mode 100644 index 000000000..54d9ae706 --- /dev/null +++ b/its/org.sonarlint.eclipse.its.cdt/META-INF/MANIFEST.MF @@ -0,0 +1,47 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: SonarLint for Eclipse ITs (CDT integration) +Bundle-SymbolicName: org.sonarlint.eclipse.its.cdt;singleton:=true +Bundle-Version: 1.0.0.qualifier +Bundle-ClassPath: . +Bundle-Vendor: SonarSource +Require-Bundle: org.eclipse.jdt.core, + org.eclipse.jdt.ui, + org.eclipse.debug.core, + org.eclipse.jdt.launching, + org.eclipse.jface, + org.eclipse.jface.text, + org.eclipse.ui.workbench, + org.eclipse.ui, + org.eclipse.ui.ide, + org.eclipse.core.runtime, + org.eclipse.core.resources, + org.eclipse.swt, + org.eclipse.ui.forms, + org.eclipse.search, + org.eclipse.ui.editors, + org.junit;bundle-version="4.11.0", + org.eclipse.equinox.security, + org.eclipse.ui.console, + assertj-core, + org.eclipse.reddeer.junit, + org.eclipse.reddeer.requirements, + org.eclipse.reddeer.eclipse, + org.eclipse.reddeer.swt, + org.eclipse.reddeer.common, + org.eclipse.reddeer.workbench.core, + org.eclipse.reddeer.workbench, + org.eclipse.reddeer.jface, + org.eclipse.reddeer.core, + com.google.gson;bundle-version="2.9.1", + org.apache.commons.commons-io;bundle-version="2.16.1", + org.awaitility;bundle-version="4.2.2", + org.hamcrest;bundle-version="2.2.0", + minimal-json;bundle-version="0.9.5", + org.apache.commons.exec;bundle-version="1.3.0", + com.google.protobuf;bundle-version="3.25.1", + org.sonarlint.eclipse.its.shared +Import-Package: org.sonarlint.eclipse.ui.internal.views.issues +Bundle-RequiredExecutionEnvironment: JavaSE-11 +Bundle-ActivationPolicy: lazy +Export-Package: org.sonarlint.eclipse.its.cdt diff --git a/its/org.sonarlint.eclipse.its.cdt/build.properties b/its/org.sonarlint.eclipse.its.cdt/build.properties new file mode 100644 index 000000000..56d776555 --- /dev/null +++ b/its/org.sonarlint.eclipse.its.cdt/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = target/classes/ +bin.includes = META-INF/,\ + . diff --git a/its/org.sonarlint.eclipse.its.cdt/its.cdt.product b/its/org.sonarlint.eclipse.its.cdt/its.cdt.product new file mode 100644 index 000000000..5f7c614bd --- /dev/null +++ b/its/org.sonarlint.eclipse.its.cdt/its.cdt.product @@ -0,0 +1,49 @@ + + + + + + + + --launcher.defaultAction openFile --launcher.appendVmargs + + -Dosgi.requiredJavaVersion=17 -Dosgi.dataAreaRequiresExplicitInit=true -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true --add-modules=ALL-SYSTEM -Djava.security.manager=allow + + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/its/org.sonarlint.eclipse.its.cdt/pom.xml b/its/org.sonarlint.eclipse.its.cdt/pom.xml new file mode 100644 index 000000000..ad382c7b9 --- /dev/null +++ b/its/org.sonarlint.eclipse.its.cdt/pom.xml @@ -0,0 +1,48 @@ + + + 4.0.0 + + + org.sonarsource.sonarlint.eclipse.its + org.sonarlint.eclipse.its + 1.0.0-SNAPSHOT + ../pom.xml + + + org.sonarlint.eclipse.its.cdt + eclipse-test-plugin + + SonarLint for Eclipse ITs (CDT integration) + + + + + org.eclipse.tycho + tycho-p2-publisher-plugin + + + publish-products-for-tests + + publish-products + + pre-integration-test + + + + + + + org.eclipse.tycho + tycho-surefire-plugin + + + + org.sonarlint.eclipse.its.cdt.product + + + + + + + diff --git a/its/org.sonarlint.eclipse.its.cdt/src/org/sonarlint/eclipse/its/cdt/CdtIntegrationTest.java b/its/org.sonarlint.eclipse.its.cdt/src/org/sonarlint/eclipse/its/cdt/CdtIntegrationTest.java new file mode 100644 index 000000000..3b9e0b7eb --- /dev/null +++ b/its/org.sonarlint.eclipse.its.cdt/src/org/sonarlint/eclipse/its/cdt/CdtIntegrationTest.java @@ -0,0 +1,47 @@ +/* + * SonarLint for Eclipse ITs + * Copyright (C) 2009-2024 SonarSource SA + * sonarlint@sonarsource.com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +package org.sonarlint.eclipse.its.cdt; + +import org.junit.Test; +import org.sonarlint.eclipse.its.shared.AbstractSonarLintTest; +import org.sonarlint.eclipse.its.shared.reddeer.perspectives.CppPerspective; +import org.sonarlint.eclipse.its.shared.reddeer.views.OnTheFlyView; + +import static org.assertj.core.api.Assertions.tuple; + +/** + * These tests are for the CDT integration of the plug-in. It should work correctly with different kidns of C/C++ + * projects that are supported by CDT itself or other tools generating the Eclipse project files. + */ +public class CdtIntegrationTest extends AbstractSonarLintTest { + @Test + public void test_makefile_based_project() { + // i) Open C/C++ perspective and import project + new CppPerspective().open(); + var rootProject = importExistingProjectIntoWorkspace("cdt/MakefileProject", "MakefileProject"); + + // ii) Open file and await for the analysis to show issues + openFileAndWaitForAnalysisCompletion(rootProject.getResource("hello.c")); + var onTheFlyView = new OnTheFlyView(); + onTheFlyView.open(); + waitForSonarLintMarkers(onTheFlyView, + tuple("Complete the task associated to this \"TODO\" comment.", "hello.c", "few seconds ago")); + } +} diff --git a/its/org.sonarlint.eclipse.its.connected.sc/its.connected.sc.product b/its/org.sonarlint.eclipse.its.connected.sc/its.connected.sc.product index 8b73ad662..6bcda29bd 100644 --- a/its/org.sonarlint.eclipse.its.connected.sc/its.connected.sc.product +++ b/its/org.sonarlint.eclipse.its.connected.sc/its.connected.sc.product @@ -33,7 +33,6 @@ --> - diff --git a/its/org.sonarlint.eclipse.its.connected.sc/src/org/sonarlint/eclipse/its/connected/sc/SonarCloudConnectedModeTest.java b/its/org.sonarlint.eclipse.its.connected.sc/src/org/sonarlint/eclipse/its/connected/sc/SonarCloudConnectedModeTest.java index 5268e0bcb..8b325c643 100644 --- a/its/org.sonarlint.eclipse.its.connected.sc/src/org/sonarlint/eclipse/its/connected/sc/SonarCloudConnectedModeTest.java +++ b/its/org.sonarlint.eclipse.its.connected.sc/src/org/sonarlint/eclipse/its/connected/sc/SonarCloudConnectedModeTest.java @@ -36,15 +36,12 @@ import org.eclipse.reddeer.common.wait.WaitWhile; import org.eclipse.reddeer.eclipse.ui.perspectives.JavaPerspective; import org.eclipse.reddeer.swt.impl.link.DefaultLink; -import org.eclipse.reddeer.swt.impl.shell.DefaultShell; import org.eclipse.reddeer.workbench.core.condition.JobIsRunning; -import org.eclipse.reddeer.workbench.impl.editor.DefaultEditor; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.sonarlint.eclipse.its.shared.AbstractSonarLintTest; -import org.sonarlint.eclipse.its.shared.reddeer.conditions.CFamilyLoaded; import org.sonarlint.eclipse.its.shared.reddeer.conditions.ConfirmConnectionCreationDialogOpened; import org.sonarlint.eclipse.its.shared.reddeer.conditions.DialogMessageIsExpected; import org.sonarlint.eclipse.its.shared.reddeer.conditions.FixSuggestionAvailableDialogOpened; @@ -55,15 +52,11 @@ import org.sonarlint.eclipse.its.shared.reddeer.dialogs.FixSuggestionAvailableDialog; import org.sonarlint.eclipse.its.shared.reddeer.dialogs.FixSuggestionUnavailableDialog; import org.sonarlint.eclipse.its.shared.reddeer.dialogs.ProjectSelectionDialog; -import org.sonarlint.eclipse.its.shared.reddeer.perspectives.CppPerspective; import org.sonarlint.eclipse.its.shared.reddeer.views.BindingsView; -import org.sonarlint.eclipse.its.shared.reddeer.views.OnTheFlyView; -import org.sonarlint.eclipse.its.shared.reddeer.views.SonarLintConsole; import org.sonarlint.eclipse.its.shared.reddeer.wizards.ProjectBindingWizard; import org.sonarlint.eclipse.its.shared.reddeer.wizards.ServerConnectionWizard; import org.sonarqube.ws.ProjectBranches.Branch; import org.sonarqube.ws.client.HttpConnector; -import org.sonarqube.ws.client.PostRequest; import org.sonarqube.ws.client.WsClient; import org.sonarqube.ws.client.WsClientFactories; import org.sonarqube.ws.client.projectbranches.ListRequest; @@ -72,7 +65,6 @@ import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.fail; -import static org.assertj.core.api.Assertions.tuple; public class SonarCloudConnectedModeTest extends AbstractSonarLintTest { private static final String TIMESTAMP = Long.toString(Instant.now().toEpochMilli()); @@ -82,8 +74,6 @@ public class SonarCloudConnectedModeTest extends AbstractSonarLintTest { private static final String SONARCLOUD_PASSWORD = System.getenv("SONARCLOUD_IT_PASSWORD"); private static final String TOKEN_NAME = "SLE-IT-" + TIMESTAMP; private static final String SAMPLE_JAVA_ISSUES_PROJECT_KEY = "sonarlint-its-sample-java-issues"; - private static final String MAKEFILE_PROJECT_KEY = "MakefileProject"; - private static final String MAKEFILE_PROJECT_SONAR_KEY = MAKEFILE_PROJECT_KEY + "-" + TIMESTAMP; private static HttpConnector connector; private static WsClient adminWsClient; @@ -100,8 +90,6 @@ public static void prepare() { .build(); adminWsClient = WsClientFactories.getDefault().newClient(connector); - createProject(MAKEFILE_PROJECT_KEY, MAKEFILE_PROJECT_SONAR_KEY); - token = adminWsClient.userTokens() .generate(new GenerateRequest().setName(TOKEN_NAME)) .getToken(); @@ -134,34 +122,6 @@ public void cleanBindings() { bindingsView.removeAllBindings(); } - @Test - public void test_makefile_based_project() { - // i) Open C/C++ perspective and import project - new CppPerspective().open(); - var rootProject = importExistingProjectIntoWorkspace("cdt/MakefileProject", MAKEFILE_PROJECT_KEY); - - // ii) Open file and await notification and no SonarLint issue to be shown - openFileAndWaitForAnalysisCompletion(rootProject.getResource("hello.c")); - shellByName("SonarQube for Eclipse - Language could not be analyzed").ifPresent(DefaultShell::close); - - var onTheFlyView = new OnTheFlyView(); - onTheFlyView.open(); - waitForNoSonarLintMarkers(onTheFlyView); - new DefaultEditor().close(); - - // iii) Create connection / bind project and SonarLint issue to be shown - createConnectionAndBindProject(MAKEFILE_PROJECT_KEY, MAKEFILE_PROJECT_SONAR_KEY); - shellByName("SonarQube - Binding Suggestion").ifPresent(DefaultShell::close); - new SonarLintConsole().clear(); - - openFileAndWaitForAnalysisCompletion(rootProject.getResource("hello.c")); - new WaitUntil(new CFamilyLoaded(new SonarLintConsole().getConsoleView()), TimePeriod.getCustom(120)); - onTheFlyView = new OnTheFlyView(); - onTheFlyView.open(); - waitForSonarLintMarkers(onTheFlyView, - tuple("Complete the task associated to this \"TODO\" comment.", "hello.c", "few seconds ago")); - } - @Test public void configureServerWithTokenAndOrganization() throws InterruptedException { var wizard = new ServerConnectionWizard(); @@ -563,15 +523,4 @@ protected static void createConnectionAndBindProject(String projectKey, String s serverProjectSelectionPage.setProjectKey(sonarProjectKey); projectBindingWizard.finish(); } - - /** Creating a project on SonarCloud with all necessary information */ - private static void createProject(String projectName, String projectKey) { - assertThat(hotspotServerPort).isNotEqualTo(-1); - - var response = connector.call(new PostRequest("/api/projects/create") - .setParam("name", projectName) - .setParam("project", projectKey) - .setParam("organization", SONARCLOUD_ORGANIZATION_KEY)); - assertThat(response.code()).isEqualTo(200); - } } diff --git a/its/org.sonarlint.eclipse.its.shared/src/org/sonarlint/eclipse/its/shared/reddeer/conditions/CFamilyLoaded.java b/its/org.sonarlint.eclipse.its.shared/src/org/sonarlint/eclipse/its/shared/reddeer/conditions/CFamilyLoaded.java deleted file mode 100644 index 541e1f767..000000000 --- a/its/org.sonarlint.eclipse.its.shared/src/org/sonarlint/eclipse/its/shared/reddeer/conditions/CFamilyLoaded.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.sonarlint.eclipse.its.shared.reddeer.conditions; - -import org.eclipse.reddeer.common.condition.AbstractWaitCondition; -import org.eclipse.reddeer.eclipse.ui.console.ConsoleView; - -/** - * When analyzing after a connection was established, make sure that everything was downloaded correctly and - * specifically await the CFamily analyzer to be available (for tests with Eclipse CDT). - */ -public class CFamilyLoaded extends AbstractWaitCondition { - private static final String PATTERN = "CFamily Code Quality and Security"; - - private final ConsoleView consoleView; - - public CFamilyLoaded(ConsoleView consoleView) { - this.consoleView = consoleView; - } - - @Override - public boolean test() { - var consoleText = consoleView.getConsoleText(); - return consoleText.lastIndexOf(PATTERN) != -1; - } -} diff --git a/its/pom.xml b/its/pom.xml index 583c7be43..19567b17e 100644 --- a/its/pom.xml +++ b/its/pom.xml @@ -216,6 +216,19 @@ + + + cdtIntegration + + + pom.xml + + + + org.sonarlint.eclipse.its.cdt + + + standaloneMode