-
Notifications
You must be signed in to change notification settings - Fork 228
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Java ITs: Enable parallelization #7570
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -52,9 +52,10 @@ public class MetricsIncludeHeaderCommentTest { | |||||
|
||||||
public static TemporaryFolder temp = TestUtils.createTempFolder(); | ||||||
|
||||||
private static final String PROJECT = "MetricsTest"; | ||||||
private static final String DIRECTORY = "MetricsTest:foo"; | ||||||
private static final String FILE = "MetricsTest:foo/Class1.cs"; | ||||||
private static final String PROJECT_DIR = "MetricsTest"; | ||||||
pavel-mikula-sonarsource marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
private static final String PROJECT_NAME = "MetricsTestIncludeHeaderComment"; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
private static final String DIRECTORY = "MetricsTestIncludeHeaderComment:foo"; | ||||||
private static final String FILE = "MetricsTestIncludeHeaderComment:foo/Class1.cs"; | ||||||
private static final int NUMBER_OF_HEADER_COMMENT_LINES = 2; | ||||||
|
||||||
// This is where the analysis is done. | ||||||
|
@@ -63,7 +64,7 @@ public class MetricsIncludeHeaderCommentTest { | |||||
|
||||||
@Test | ||||||
public void projectIsAnalyzed() { | ||||||
assertThat(getComponent(PROJECT).getName()).isEqualTo("MetricsTest"); | ||||||
assertThat(getComponent(PROJECT_NAME).getName()).isEqualTo("MetricsTestIncludeHeaderComment"); | ||||||
assertThat(getComponent(DIRECTORY).getName()).isEqualTo("foo"); | ||||||
assertThat(getComponent(FILE).getName()).isEqualTo("Class1.cs"); | ||||||
} | ||||||
|
@@ -122,7 +123,7 @@ public void commentLinesAtFileLevel() { | |||||
/* Helper methods */ | ||||||
|
||||||
private Integer getProjectMeasureAsInt(String metricKey) { | ||||||
return getMeasureAsInt(PROJECT, metricKey); | ||||||
return getMeasureAsInt(PROJECT_NAME, metricKey); | ||||||
} | ||||||
|
||||||
private Integer getDirectoryMeasureAsInt(String metricKey) { | ||||||
|
@@ -144,9 +145,9 @@ private static RuleChain getRuleChain() { | |||||
protected void before() throws Throwable { | ||||||
TestUtils.initLocal(ORCHESTRATOR); | ||||||
|
||||||
Path projectDir = Tests.projectDir(temp, "MetricsTest"); | ||||||
Path projectDir = Tests.projectDir(temp, PROJECT_DIR); | ||||||
|
||||||
ScannerForMSBuild beginStep = TestUtils.createBeginStep("MetricsTest", projectDir) | ||||||
ScannerForMSBuild beginStep = TestUtils.createBeginStep(PROJECT_NAME, projectDir) | ||||||
.setProfile("no_rule") | ||||||
// Without that, the MetricsTest project is considered as a Test project :) | ||||||
.setProperty("sonar.msbuild.testProjectPattern", "noTests"); | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,6 +30,7 @@ | |
import javax.annotation.CheckForNull; | ||
import javax.annotation.Nullable; | ||
import org.apache.commons.io.FileUtils; | ||
import org.junit.BeforeClass; | ||
import org.junit.ClassRule; | ||
import org.junit.rules.TemporaryFolder; | ||
import org.junit.runner.RunWith; | ||
|
@@ -54,6 +55,16 @@ public class Tests { | |
.addPlugin(MavenLocation.of("org.sonarsource.html", "sonar-html-plugin", "3.2.0.2082")) | ||
.build(); | ||
|
||
@ClassRule | ||
public static final TemporaryFolder temp = TestUtils.createTempFolder(); | ||
|
||
@BeforeClass | ||
public static void init() throws IOException { | ||
TestUtils.deleteLocalCache(); | ||
// Analyze a project to avoid race conditions | ||
analyzeProject(temp, "Empty"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In theory, you can skip the msbuild part. And just run "begin" and "end", where "end" will emit some useless warning that sarif report and other stuff was not configured for C# analysis. You would just get project dir, execute begin step, execute end step. You can make it a method in
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There would also be no more accidental cache deletions |
||
} | ||
|
||
public static Path projectDir(TemporaryFolder temp, String projectName) throws IOException { | ||
Path projectDir = Paths.get("projects").resolve(projectName); | ||
FileUtils.deleteDirectory(new File(temp.getRoot(), projectName)); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you testing this with C#-only run to get local data? While excluding the time needed to download SQ zip at the 1st local SQ-cache populating run?
Because from what I saw, surefire is stupid, JUnit is stupid, and they are not any smarter together in test discovery. So "parallel" might not play nicely with "Suite", only with the usual "run all at once" scaffolding