use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method fileInclusionsExclusions.
@Test
public void fileInclusionsExclusions() throws IOException {
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
writeFile(srcDir, "sample.xoo", "Sample xoo\ncontent");
writeFile(baseDir, "another.xoo", "Sample xoo 2\ncontent");
File testDir = new File(baseDir, "test");
testDir.mkdir();
writeFile(baseDir, "sampleTest2.xoo", "Sample test xoo\ncontent");
writeFile(testDir, "sampleTest.xoo", "Sample test xoo 2\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.sources", "src,another.xoo").put("sonar.tests", "test,sampleTest2.xoo").put("sonar.inclusions", "src/**").put("sonar.exclusions", "**/another.*").put("sonar.test.inclusions", "**/sampleTest*.*").put("sonar.test.exclusions", "**/sampleTest2.xoo").build()).execute();
assertThat(result.inputFiles()).hasSize(2);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method warn_user_for_outdated_server_side_inherited_exclusions_for_multi_module_project.
@Test
public void warn_user_for_outdated_server_side_inherited_exclusions_for_multi_module_project() throws IOException {
File baseDir = temp.getRoot();
File baseDirModuleA = new File(baseDir, "moduleA");
File baseDirModuleB = new File(baseDir, "moduleB");
File srcDirA = new File(baseDirModuleA, "src");
srcDirA.mkdirs();
File srcDirB = new File(baseDirModuleB, "src");
srcDirB.mkdirs();
writeFile(srcDirA, "sample.xoo", "Sample xoo\ncontent");
writeFile(srcDirB, "sample.xoo", "Sample xoo\ncontent");
tester.addProjectServerSettings("sonar.exclusions", "src/sample.xoo");
AnalysisResult result = tester.newAnalysis().properties(ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.sources", "src").put("sonar.modules", "moduleA,moduleB").build()).execute();
InputFile fileA = result.inputFile("moduleA/src/sample.xoo");
assertThat(fileA).isNull();
InputFile fileB = result.inputFile("moduleB/src/sample.xoo");
assertThat(fileB).isNull();
assertThat(logTester.logs(LoggerLevel.WARN)).contains("Specifying module-relative paths at project level in the property 'sonar.exclusions' is deprecated. " + "To continue matching files like 'moduleA/src/sample.xoo', update this property so that patterns refer to project-relative paths.");
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method scan_project_with_comma_in_source_path.
@Test
public void scan_project_with_comma_in_source_path() throws IOException {
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
writeFile(srcDir, "sample,1.xoo", "Sample xoo\ncontent");
writeFile(baseDir, "another,2.xoo", "Sample xoo 2\ncontent");
File testDir = new File(baseDir, "test");
testDir.mkdir();
writeFile(testDir, "sampleTest,1.xoo", "Sample test xoo\ncontent");
writeFile(baseDir, "sampleTest,2.xoo", "Sample test xoo 2\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.sources", "src,\"another,2.xoo\"").put("sonar.tests", "\"test\",\"sampleTest,2.xoo\"").build()).execute();
assertThat(result.inputFiles()).hasSize(4);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method deprecated_global_sensor_should_see_project_relative_paths.
@Test
public void deprecated_global_sensor_should_see_project_relative_paths() {
File projectDir = new File("test-resources/mediumtest/xoo/multi-modules-sample");
AnalysisResult result = tester.newAnalysis(new File(projectDir, "sonar-project.properties")).property(DeprecatedGlobalSensor.ENABLE_PROP, "true").execute();
assertThat(result.inputFiles()).hasSize(4);
assertThat(logTester.logs(LoggerLevel.INFO)).contains("Deprecated Global Sensor: module_a/module_a1/src/main/xoo/com/sonar/it/samples/modules/a1/HelloA1.xoo", "Deprecated Global Sensor: module_a/module_a2/src/main/xoo/com/sonar/it/samples/modules/a2/HelloA2.xoo", "Deprecated Global Sensor: module_b/module_b1/src/main/xoo/com/sonar/it/samples/modules/b1/HelloB1.xoo", "Deprecated Global Sensor: module_b/module_b2/src/main/xoo/com/sonar/it/samples/modules/b2/HelloB2.xoo");
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method publishFilesWithIssues.
@Test
public void publishFilesWithIssues() throws IOException {
tester.addRules(new XooRulesDefinition()).addActiveRule("xoo", "OneIssueOnDirPerFile", null, "OneIssueOnDirPerFile", "MAJOR", null, "xoo");
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
writeFile(srcDir, "sample.xoo", "Sample xoo\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.sources", "src").build()).execute();
DefaultInputFile file = (DefaultInputFile) result.inputFile("src/sample.xoo");
assertThat(file.isPublished()).isTrue();
assertThat(result.getReportComponent(file)).isNotNull();
}
Aggregations