Skip to content

Commit c9768b2

Browse files
committed
Remove test of old scanner, and add IT for SONARMSBRU-325
1 parent ac7402b commit c9768b2

File tree

6 files changed

+22
-174
lines changed

6 files changed

+22
-174
lines changed

.cix.yml

-9
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,6 @@
11
# Definition of QA pipeline at SonarSource
22

3-
SCANNER_PAYLOAD_VERSION:
4-
- DEV
5-
6-
SCANNER_VERSION:
7-
- 2.1.0.0
8-
- DEV
9-
103
SQ_VERSION:
114
- DEV
125
- LTS
13-
14-
156

cix.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ get_version $SCANNER_PAYLOAD_VERSION
3333
SCANNER_PAYLOAD_VERSION=$output
3434

3535
# default versions of csharp and vbnet plugin are defined in the pom file
36-
mvn -B -e verify -Dsonar.runtimeVersion=$SQ_VERSION -DscannerForMSBuild.version=$SCANNER_VERSION -DscannerForMSBuildPayload.version=$SCANNER_PAYLOAD_VERSION -DfxcopVersion=LATEST_RELEASE -Dmsbuild.path=$MSBUILD_PATH
36+
mvn -B -e verify -Dsonar.runtimeVersion=$SQ_VERSION -DscannerForMSBuild.version=$SCANNER_VERSION -DscannerForMSBuildPayload.version=$SCANNER_PAYLOAD_VERSION -Dmsbuild.path=$MSBUILD_PATH

its/pom.xml

+2-83
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
<inceptionYear>2016</inceptionYear>
1919

20-
<properties>
21-
<vbnetPlugin.version>3.0.1.293</vbnetPlugin.version>
22-
<csharpPlugin.version>5.5.0.479</csharpPlugin.version>
23-
</properties>
24-
2520
<dependencies>
2621
<dependency>
2722
<groupId>org.sonarsource.orchestrator</groupId>
@@ -32,7 +27,7 @@
3227
<dependency>
3328
<groupId>org.sonarsource.sonarqube</groupId>
3429
<artifactId>sonar-ws</artifactId>
35-
<version>6.3-build16607</version>
30+
<version>6.3.1</version>
3631
<scope>test</scope>
3732
</dependency>
3833
<dependency>
@@ -41,40 +36,13 @@
4136
<version>1.7.2</version>
4237
</dependency>
4338

44-
<!-- Force Maven to download these artifacts -->
45-
<dependency>
46-
<groupId>org.sonarsource.dotnet</groupId>
47-
<artifactId>sonar-csharp-plugin</artifactId>
48-
<version>${csharpPlugin.version}</version>
49-
</dependency>
50-
<dependency>
51-
<groupId>com.sonarsource.vbnet</groupId>
52-
<artifactId>sonar-vbnet-plugin</artifactId>
53-
<version>${vbnetPlugin.version}</version>
54-
</dependency>
55-
5639
<dependency>
5740
<groupId>org.assertj</groupId>
5841
<artifactId>assertj-core</artifactId>
5942
<version>3.4.1</version>
6043
</dependency>
6144
</dependencies>
62-
63-
<build>
64-
<plugins>
65-
<plugin>
66-
<groupId>org.apache.maven.plugins</groupId>
67-
<artifactId>maven-surefire-plugin</artifactId>
68-
<configuration>
69-
<systemProperties>
70-
<vbnetPlugin.version>${vbnetPlugin.version}</vbnetPlugin.version>
71-
<csharpPlugin.version>${csharpPlugin.version}</csharpPlugin.version>
72-
</systemProperties>
73-
</configuration>
74-
</plugin>
75-
</plugins>
76-
</build>
77-
45+
7846
<profiles>
7947
<profile>
8048
<id>download-scanner-artifacts</id>
@@ -100,55 +68,6 @@
10068
<artifact>org.sonarsource.scanner.msbuild:sonar-scanner-msbuild:${scannerForMSBuild.version}:zip</artifact>
10169
</configuration>
10270
</execution>
103-
<execution>
104-
<id>download-scanner-impl</id>
105-
<phase>initialize</phase>
106-
<goals>
107-
<goal>get</goal>
108-
</goals>
109-
<configuration>
110-
<artifact>org.sonarsource.scanner.msbuild:sonar-scanner-msbuild:${scannerForMSBuild.version}:zip:impl</artifact>
111-
</configuration>
112-
</execution>
113-
</executions>
114-
</plugin>
115-
</plugins>
116-
</build>
117-
</profile>
118-
<profile>
119-
<id>download-scanner-payload-artifacts</id>
120-
<activation>
121-
<property>
122-
<name>scannerForMSBuildPayload.version</name>
123-
</property>
124-
</activation>
125-
<build>
126-
<plugins>
127-
<plugin>
128-
<groupId>org.apache.maven.plugins</groupId>
129-
<artifactId>maven-dependency-plugin</artifactId>
130-
<version>2.10</version>
131-
<executions>
132-
<execution>
133-
<id>download-scanner-payload</id>
134-
<phase>initialize</phase>
135-
<goals>
136-
<goal>get</goal>
137-
</goals>
138-
<configuration>
139-
<artifact>org.sonarsource.scanner.msbuild:sonar-scanner-msbuild:${scannerForMSBuildPayload.version}:zip</artifact>
140-
</configuration>
141-
</execution>
142-
<execution>
143-
<id>download-scanner-payload-impl</id>
144-
<phase>initialize</phase>
145-
<goals>
146-
<goal>get</goal>
147-
</goals>
148-
<configuration>
149-
<artifact>org.sonarsource.scanner.msbuild:sonar-scanner-msbuild:${scannerForMSBuildPayload.version}:zip:impl</artifact>
150-
</configuration>
151-
</execution>
15271
</executions>
15372
</plugin>
15473
</plugins>

its/src/test/java/com/sonar/it/scanner/msbuild/ScannerMSBuildTest.java

+17-5
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import com.sonar.orchestrator.build.BuildResult;
2424
import com.sonar.orchestrator.junit.SingleStartExternalResource;
2525
import com.sonar.orchestrator.locator.FileLocation;
26-
import com.sonar.orchestrator.locator.PluginLocation;
2726
import java.io.IOException;
2827
import java.nio.file.Path;
2928
import java.util.Arrays;
@@ -69,14 +68,16 @@ public class ScannerMSBuildTest {
6968
@Override
7069
protected void beforeAll() {
7170

72-
Path modifiedCs = TestUtils.prepareCSharpPlugin(temp);
7371
Path customRoslyn = TestUtils.getCustomRoslynPlugin();
7472
ORCHESTRATOR = Orchestrator.builderEnv()
75-
.addPlugin(FileLocation.of(modifiedCs.toFile()))
73+
.setOrchestratorProperty("csharpVersion", "LATEST_RELEASE")
74+
.addPlugin("csharp")
7675
.addPlugin(FileLocation.of(customRoslyn.toFile()))
77-
.addPlugin(PluginLocation.of("com.sonarsource.vbnet", "sonar-vbnet-plugin", TestUtils.getVBNetVersion()))
78-
.addPlugin("fxcop")
76+
.setOrchestratorProperty("vbnetVersion", "LATEST_RELEASE")
77+
.addPlugin("vbnet")
7978
.activateLicense("vbnet")
79+
.setOrchestratorProperty("fxcopVersion", "LATEST_RELEASE")
80+
.addPlugin("fxcop")
8081
.build();
8182
ORCHESTRATOR.start();
8283
}
@@ -309,6 +310,17 @@ public void testVerbose() throws IOException {
309310
assertThat(result.getLogs()).contains("sonar.verbose=true was specified - setting the log verbosity to 'Debug'");
310311
}
311312

313+
@Test
314+
public void testHelp() throws IOException {
315+
316+
Path projectDir = TestUtils.projectDir(temp, "ProjectUnderTest");
317+
BuildResult result = ORCHESTRATOR.executeBuild(TestUtils.newScanner(projectDir)
318+
.addArgument("/?"));
319+
320+
assertThat(result.getLogs()).contains("Usage:");
321+
assertThat(result.getLogs()).contains("SonarQube.Scanner.MSBuild.exe");
322+
}
323+
312324
@Test
313325
public void testAllProjectsExcluded() throws Exception {
314326
ORCHESTRATOR.getServer().restoreProfile(FileLocation.of("projects/ProjectUnderTest/TestQualityProfile.xml"));

its/src/test/java/com/sonar/it/scanner/msbuild/TestUtils.java

-74
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import com.sonar.orchestrator.build.ScannerForMSBuild;
2424
import com.sonar.orchestrator.config.Configuration;
2525
import com.sonar.orchestrator.locator.FileLocation;
26-
import com.sonar.orchestrator.locator.Locators;
27-
import com.sonar.orchestrator.locator.MavenLocation;
2826
import com.sonar.orchestrator.util.Command;
2927
import com.sonar.orchestrator.util.CommandExecutor;
3028
import java.io.File;
@@ -56,68 +54,6 @@ public class TestUtils {
5654
public static final String MSBUILD_PATH = "msbuild.path";
5755
private final static Logger LOG = LoggerFactory.getLogger(ScannerMSBuildTest.class);
5856

59-
public static Path prepareCSharpPlugin(TemporaryFolder temp) {
60-
Path t;
61-
try {
62-
t = temp.newFolder("CSharpPlugin").toPath();
63-
} catch (IOException e) {
64-
throw new IllegalStateException(e);
65-
}
66-
Configuration configuration = Orchestrator.builderEnv().build().getConfiguration();
67-
Locators locators = new Locators(configuration);
68-
String pluginVersion = getCSharpVersion();
69-
MavenLocation csharp = MavenLocation.create("org.sonarsource.dotnet", "sonar-csharp-plugin", pluginVersion);
70-
Path modifiedCs = t.resolve("modified-chsarp.jar");
71-
if (locators.copyToFile(csharp, modifiedCs.toFile()) == null) {
72-
throw new IllegalStateException("Couldn't locate csharp plugin in the local maven repository: " + csharp);
73-
}
74-
75-
String scannerPayloadVersion = getScannerPayloadVersion();
76-
77-
Path scannerImpl;
78-
if (scannerPayloadVersion != null) {
79-
LOG.info("Updating C# plugin ({}) with Scanner For MSBuild implementation ({})", pluginVersion, scannerPayloadVersion);
80-
MavenLocation scannerImplLocation = MavenLocation.builder()
81-
.setGroupId("org.sonarsource.scanner.msbuild")
82-
.setArtifactId("sonar-scanner-msbuild")
83-
.setVersion(scannerPayloadVersion)
84-
.setClassifier("impl")
85-
.withPackaging("zip")
86-
.build();
87-
scannerImpl = t.resolve("sonar-scanner-msbuild-impl.zip");
88-
if (locators.copyToFile(scannerImplLocation, scannerImpl.toFile()) == null) {
89-
throw new IllegalStateException("Unable to find sonar-scanner-msbuild " + scannerPayloadVersion + " in local Maven repository");
90-
}
91-
} else {
92-
// Run locally
93-
LOG.info("Updating C# plugin ({}) with local build of Scanner For MSBuild implementation", pluginVersion);
94-
scannerImpl = Paths.get("../DeploymentArtifacts/CSharpPluginPayload/Release/SonarQube.MSBuild.Runner.Implementation.zip");
95-
}
96-
97-
replaceInZip(modifiedCs.toUri(), scannerImpl, "/static/SonarQube.MSBuild.Runner.Implementation.zip");
98-
return modifiedCs;
99-
}
100-
101-
public static String getVBNetVersion() {
102-
Configuration configuration = Orchestrator.builderEnv().build().getConfiguration();
103-
String version = configuration.getString("vbnetPlugin.version");
104-
if (version != null) {
105-
return version;
106-
}
107-
108-
throw new IllegalStateException("Unspecified version of VB.NET plugin. Define 'vbnetPlugin.version'");
109-
}
110-
111-
public static String getCSharpVersion() {
112-
Configuration configuration = Orchestrator.builderEnv().build().getConfiguration();
113-
String version = configuration.getString("csharpPlugin.version");
114-
if (version != null) {
115-
return version;
116-
}
117-
118-
throw new IllegalStateException("Unspecified version of C# plugin. Define 'csharpPlugin.version'");
119-
}
120-
12157
@CheckForNull
12258
public static String getScannerVersion() {
12359
Configuration configuration = Orchestrator.builderEnv().build().getConfiguration();
@@ -140,16 +76,6 @@ public static ScannerForMSBuild newScanner(Path projectDir) {
14076
}
14177
}
14278

143-
/**
144-
* Try to get version of the Scanner for MSBuild to embed in the C# plugin (use as payload).
145-
* If no version is found, null is returned.
146-
*/
147-
@CheckForNull
148-
public static String getScannerPayloadVersion() {
149-
Configuration configuration = Orchestrator.builderEnv().build().getConfiguration();
150-
return configuration.getString("scannerForMSBuildPayload.version");
151-
}
152-
15379
public static Path getCustomRoslynPlugin() {
15480
Path customPluginDir = Paths.get("").resolve("analyzers");
15581

its/src/test/java/com/sonar/it/scanner/msbuild/VBNetTest.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import com.sonar.orchestrator.Orchestrator;
2323
import com.sonar.orchestrator.locator.FileLocation;
24-
import com.sonar.orchestrator.locator.PluginLocation;
2524
import java.nio.file.Path;
2625
import java.util.Arrays;
2726
import java.util.List;
@@ -60,7 +59,8 @@ public static void checkSkip() {
6059

6160
@ClassRule
6261
public static Orchestrator ORCHESTRATOR = Orchestrator.builderEnv()
63-
.addPlugin(PluginLocation.of("com.sonarsource.vbnet", "sonar-vbnet-plugin", TestUtils.getVBNetVersion()))
62+
.setOrchestratorProperty("vbnetVersion", "LATEST_RELEASE")
63+
.addPlugin("vbnet")
6464
.addPlugin("fxcop")
6565
.activateLicense("vbnet")
6666
.build();

0 commit comments

Comments
 (0)