use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method scanProjectWithSourceSymlink.
// SONAR-5330
@Test
public void scanProjectWithSourceSymlink() {
assumeTrue(!System2.INSTANCE.isOsWindows());
File projectDir = new File("test-resources/mediumtest/xoo/sample-with-symlink");
AnalysisResult result = tester.newAnalysis(new File(projectDir, "sonar-project.properties")).property("sonar.exclusions", "**/*.xoo.measures,**/*.xoo.scm").property("sonar.test.exclusions", "**/*.xoo.measures,**/*.xoo.scm").property("sonar.scm.exclusions.disabled", "true").execute();
assertThat(result.inputFiles()).hasSize(3);
// check that symlink was not resolved to target
assertThat(result.inputFiles()).extractingResultOf("path").toString().startsWith(projectDir.toString());
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class FileSystemMediumTest method test_module_level_inclusions_override_parent_on_multi_modules.
@Test
public void test_module_level_inclusions_override_parent_on_multi_modules() 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, "sampleA.xoo", "Sample xoo\ncontent");
writeFile(srcDirB, "sampleB.xoo", "Sample xoo\ncontent");
final ImmutableMap.Builder<String, String> builder = ImmutableMap.<String, String>builder().put("sonar.projectBaseDir", baseDir.getAbsolutePath()).put("sonar.projectKey", "com.foo.project").put("sonar.sources", "src").put("sonar.modules", "moduleA,moduleB").put("sonar.inclusions", "**/*.php");
AnalysisResult result = tester.newAnalysis().properties(builder.build()).execute();
assertThat(result.inputFiles()).isEmpty();
result = tester.newAnalysis().properties(builder.put("moduleA.sonar.inclusions", "**/*.xoo").build()).execute();
assertThat(result.inputFiles()).hasSize(1);
InputFile fileA = result.inputFile("moduleA/src/sampleA.xoo");
assertThat(fileA).isNotNull();
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class BranchMediumTest method verify_metadata.
@Test
public void verify_metadata() {
String branchName = "feature";
String branchTarget = "branch-1.x";
AnalysisResult result = getResult(tester.setBranchName(branchName).setBranchTarget(branchTarget).setReferenceBranchName(branchTarget).setBranchType(BranchType.BRANCH));
ScannerReport.Metadata metadata = result.getReportReader().readMetadata();
assertThat(metadata.getBranchName()).isEqualTo(branchName);
assertThat(metadata.getBranchType()).isEqualTo(ScannerReport.Metadata.BranchType.BRANCH);
assertThat(metadata.getReferenceBranchName()).isEqualTo(branchTarget);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class BranchMediumTest method shouldSkipSensorForUnchangedFilesOnPr.
@Test
public void shouldSkipSensorForUnchangedFilesOnPr() throws Exception {
AnalysisResult result = getResult(tester.setBranchName("myBranch").setBranchTarget("master").setBranchType(BranchType.PULL_REQUEST));
final DefaultInputFile file = (DefaultInputFile) result.inputFile(FILE_PATH);
List<ScannerReport.Issue> issues = result.issuesFor(file);
assertThat(issues).isEmpty();
assertThat(logTester.logs()).contains(ONE_ISSUE_PER_LINE_IS_RESTRICTED_TO_CHANGED_FILES_ONLY);
}
use of org.sonar.scanner.mediumtest.AnalysisResult in project sonarqube by SonarSource.
the class CoverageMediumTest method exclusionsForSimpleProject.
@Test
public void exclusionsForSimpleProject() throws IOException {
File baseDir = temp.getRoot();
File srcDir = new File(baseDir, "src");
srcDir.mkdir();
File xooFile = new File(srcDir, "sample.xoo");
File xooUtCoverageFile = new File(srcDir, "sample.xoo.coverage");
FileUtils.write(xooFile, "function foo() {\n if (a && b) {\nalert('hello');\n}\n}", StandardCharsets.UTF_8);
FileUtils.write(xooUtCoverageFile, "2:2:2:1\n3:1", StandardCharsets.UTF_8);
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.coverage.exclusions", "**/sample.xoo").build()).execute();
InputFile file = result.inputFile("src/sample.xoo");
assertThat(result.coverageFor(file, 2)).isNull();
}
Aggregations