use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method scanProjectWithMixedSourcesAndTests.
/**
* SONAR-5419
*/
@Test
public void scanProjectWithMixedSourcesAndTests() 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").build()).execute();
assertThat(result.inputFiles()).hasSize(4);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method two_languages_with_same_extension.
@Test
public void two_languages_with_same_extension() throws IOException {
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
writeFile(srcDir, "sample.xoo", "Sample xoo\ncontent");
writeFile(srcDir, "sample.xoo2", "Sample xoo 2\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.sources", "src").build()).execute();
assertThat(result.inputFiles()).hasSize(2);
AnalysisBuilder analysisBuilder = tester.newAnalysis().properties(builder.put("sonar.lang.patterns.xoo2", "**/*.xoo").build());
assertThatThrownBy(analysisBuilder::execute).isInstanceOf(MessageException.class).hasMessage("Language of file 'src" + File.separator + "sample.xoo' can not be decided as the file matches patterns of both sonar.lang.patterns.xoo : **/*.xoo and sonar.lang.patterns.xoo2 : **/*.xoo");
// SONAR-9561
result = tester.newAnalysis().properties(builder.put("sonar.exclusions", "**/sample.xoo").build()).execute();
assertThat(result.inputFiles()).hasSize(1);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method scanProjectWithSourceDir.
@Test
public void scanProjectWithSourceDir() throws IOException {
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();
assertThat(result.inputFiles()).hasSize(1);
assertThat(result.inputFile("src/sample.xoo").type()).isEqualTo(InputFile.Type.MAIN);
assertThat(result.inputFile("src/sample.xoo").relativePath()).isEqualTo("src/sample.xoo");
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method ignore_files_outside_module_basedir.
@Test
public void ignore_files_outside_module_basedir() throws IOException {
File moduleA = new File(baseDir, "moduleA");
moduleA.mkdir();
writeFile(moduleA, "src/sampleA.xoo", "Sample xoo\ncontent");
File xooFile2 = writeFile(baseDir, "another.xoo", "Sample xoo 2\ncontent");
AnalysisResult result = tester.newAnalysis().properties(builder.put("sonar.modules", "moduleA").put("moduleA.sonar.sources", "src," + PathUtils.canonicalPath(xooFile2)).build()).execute();
assertThat(result.inputFiles()).hasSize(1);
assertThat(logTester.logs(LoggerLevel.WARN)).contains("File '" + xooFile2.getAbsolutePath() + "' is ignored. It is not located in module basedir '" + new File(baseDir, "moduleA") + "'.");
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method no_exclusion_when_scm_exclusions_is_disabled.
@Test
public void no_exclusion_when_scm_exclusions_is_disabled() {
File projectDir = new File("test-resources/mediumtest/xoo/sample-with-ignored-file");
AnalysisResult result = tester.newAnalysis(new File(projectDir, "sonar-project.properties")).property("sonar.scm.exclusions.disabled", "true").property("sonar.exclusions", "**/*.xoo.ignore").property("sonar.test.exclusions", "**/*.xoo.ignore").execute();
assertThat(result.inputFiles()).hasSize(4);
assertThat(result.inputFile("xources/hello/ClassTwo.xoo")).isNotNull();
assertThat(result.inputFile("testx/ClassTwoTest.xoo")).isNotNull();
assertThat(result.inputFile("xources/hello/ClassOne.xoo")).isNotNull();
assertThat(result.inputFile("testx/ClassOneTest.xoo")).isNotNull();
}
Aggregations