Search in sources :

Example 46 with TaskResult

use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.

the class FileSystemMediumTest method scanProjectWithWrongCase.

// SONAR-6719
@Test
public void scanProjectWithWrongCase() {
    if (System2.INSTANCE.isOsWindows()) {
        File projectDir = new File("src/test/resources/mediumtest/xoo/sample");
        TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).property("sonar.sources", "XOURCES").property("sonar.tests", "TESTX").start();
        assertThat(result.inputFiles()).hasSize(3);
        assertThat(result.inputFiles()).extractingResultOf("relativePath").containsOnly("xources/hello/HelloJava.xoo", "xources/hello/helloscala.xoo", "testx/ClassOneTest.xoo");
    }
}
Also used : TaskResult(org.sonar.scanner.mediumtest.TaskResult) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Example 47 with TaskResult

use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.

the class FileSystemMediumTest method scanProjectWithSourceSymlink.

// SONAR-5330
@Test
public void scanProjectWithSourceSymlink() {
    if (!System2.INSTANCE.isOsWindows()) {
        File projectDir = new File("src/test/resources/mediumtest/xoo/sample-with-symlink");
        TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).start();
        assertThat(result.inputFiles()).hasSize(3);
        // check that symlink was not resolved to target
        assertThat(result.inputFiles()).extractingResultOf("path").toString().startsWith(projectDir.toString());
    }
}
Also used : TaskResult(org.sonar.scanner.mediumtest.TaskResult) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Example 48 with TaskResult

use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.

the class FileSystemMediumTest method scanMultiModuleProject.

@Test
public void scanMultiModuleProject() {
    File projectDir = new File("src/test/resources/mediumtest/xoo/multi-modules-sample");
    TaskResult result = tester.newScanTask(new File(projectDir, "sonar-project.properties")).start();
    assertThat(result.inputFiles()).hasSize(4);
    assertThat(result.inputDirs()).hasSize(4);
}
Also used : TaskResult(org.sonar.scanner.mediumtest.TaskResult) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Example 49 with TaskResult

use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.

the class FileSystemMediumTest method scanProjectWithTestDir.

@Test
public void scanProjectWithTestDir() throws IOException {
    File test = new File(baseDir, "test");
    test.mkdir();
    File xooFile = new File(test, "sampleTest.xoo");
    FileUtils.write(xooFile, "Sample test xoo\ncontent");
    TaskResult result = tester.newTask().properties(builder.put("sonar.sources", "").put("sonar.tests", "test").build()).start();
    assertThat(result.inputFiles()).hasSize(1);
    assertThat(result.inputFile("test/sampleTest.xoo").type()).isEqualTo(InputFile.Type.TEST);
}
Also used : TaskResult(org.sonar.scanner.mediumtest.TaskResult) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Example 50 with TaskResult

use of org.sonar.scanner.mediumtest.TaskResult in project sonarqube by SonarSource.

the class FileSystemMediumTest method scanProjectWithSourceDir.

@Test
public void scanProjectWithSourceDir() throws IOException {
    File srcDir = new File(baseDir, "src");
    srcDir.mkdir();
    File xooFile = new File(srcDir, "sample.xoo");
    FileUtils.write(xooFile, "Sample xoo\ncontent");
    TaskResult result = tester.newTask().properties(builder.put("sonar.sources", "src").build()).start();
    assertThat(result.inputFiles()).hasSize(1);
    assertThat(result.inputDirs()).hasSize(1);
    assertThat(result.inputFile("src/sample.xoo").type()).isEqualTo(InputFile.Type.MAIN);
    assertThat(result.inputFile("src/sample.xoo").relativePath()).isEqualTo("src/sample.xoo");
    assertThat(result.inputDir("src").relativePath()).isEqualTo("src");
}
Also used : TaskResult(org.sonar.scanner.mediumtest.TaskResult) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) File(java.io.File) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)61 TaskResult (org.sonar.scanner.mediumtest.TaskResult)61 File (java.io.File)59 InputFile (org.sonar.api.batch.fs.InputFile)31 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)21 List (java.util.List)8 Issue (org.sonar.scanner.protocol.output.ScannerReport.Issue)7 ScannerReport (org.sonar.scanner.protocol.output.ScannerReport)6 Path (java.nio.file.Path)3 InputDir (org.sonar.api.batch.fs.InputDir)3 ScannerMediumTester (org.sonar.scanner.mediumtest.ScannerMediumTester)3 XooPlugin (org.sonar.xoo.XooPlugin)3 XooRulesDefinition (org.sonar.xoo.rule.XooRulesDefinition)3 TrackedIssue (org.sonar.scanner.issue.tracking.TrackedIssue)2 Date (java.util.Date)1 LogOutputRecorder (org.sonar.scanner.mediumtest.LogOutputRecorder)1