-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathTests.java
More file actions
80 lines (70 loc) · 2.87 KB
/
Tests.java
File metadata and controls
80 lines (70 loc) · 2.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
* SonarSource Scala
* Copyright (C) 2018-2025 SonarSource SA
* mailto:info AT sonarsource DOT com
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the Sonar Source-Available License Version 1, as published by SonarSource SA.
*
* 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 Sonar Source-Available License for more details.
*
* You should have received a copy of the Sonar Source-Available License
* along with this program; if not, see https://sonarsource.com/license/ssal/
*/
package org.sonarsource.slang;
import com.sonar.orchestrator.junit4.OrchestratorRule;
import com.sonar.orchestrator.junit4.OrchestratorRuleBuilder;
import com.sonar.orchestrator.locator.FileLocation;
import com.sonar.orchestrator.locator.Location;
import com.sonar.orchestrator.locator.MavenLocation;
import java.io.File;
import java.util.Collections;
import java.util.HashSet;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.junit.ClassRule;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@RunWith(Suite.class)
@Suite.SuiteClasses({
CoverageTest.class,
DuplicationsTest.class,
ExternalReportTest.class,
MeasuresTest.class,
NoSonarTest.class,
})
public class Tests {
static final String SQ_VERSION_PROPERTY = "sonar.runtimeVersion";
static final String DEFAULT_SQ_VERSION = "LATEST_RELEASE";
private static final Set<String> LANGUAGES = new HashSet<>(Collections.singletonList("scala"));
@ClassRule
public static final OrchestratorRule ORCHESTRATOR;
static {
OrchestratorRuleBuilder orchestratorBuilder = OrchestratorRule.builderEnv();
addLanguagePlugins(orchestratorBuilder);
ORCHESTRATOR = orchestratorBuilder
.useDefaultAdminCredentialsForBuilds(true)
.setSonarVersion(System.getProperty(SQ_VERSION_PROPERTY, DEFAULT_SQ_VERSION))
.restoreProfileAtStartup(FileLocation.of("src/test/resources/nosonar-scala.xml"))
.restoreProfileAtStartup(FileLocation.of("src/test/resources/norule.xml"))
.build();
}
static void addLanguagePlugins(OrchestratorRuleBuilder builder) {
String slangVersion = System.getProperty("slangVersion");
LANGUAGES.forEach(language -> {
Location pluginLocation;
String plugin = "sonar-" + language +"-plugin";
if (StringUtils.isEmpty(slangVersion)) {
// use the plugin that was built on local machine
pluginLocation = FileLocation.byWildcardMavenFilename(new File("../../" + plugin + "/build/libs"), plugin + "-*-all.jar");
} else {
// QA environment downloads the plugin built by the CI job
pluginLocation = MavenLocation.of("org.sonarsource.slang", plugin, slangVersion);
}
builder.addPlugin(pluginLocation);
});
}
}