Search in sources :

Example 1 with ScannerProperties

use of org.sonar.scanner.bootstrap.ScannerProperties in project sonarqube by SonarSource.

the class ProjectReactorBuilderTest method shouldInitWorkDirWithCustomRelativeFolder.

@Test
public void shouldInitWorkDirWithCustomRelativeFolder() {
    Map<String, String> props = singletonMap("sonar.working.directory", ".foo");
    ProjectReactorBuilder builder = new ProjectReactorBuilder(new ScannerProperties(props), mock(AnalysisWarnings.class));
    File baseDir = new File("target/tmp/baseDir");
    File workDir = builder.initRootProjectWorkDir(baseDir, props);
    assertThat(workDir).isEqualTo(new File(baseDir, ".foo"));
}
Also used : ScannerProperties(org.sonar.scanner.bootstrap.ScannerProperties) File(java.io.File) AnalysisWarnings(org.sonar.api.notifications.AnalysisWarnings) Test(org.junit.Test)

Example 2 with ScannerProperties

use of org.sonar.scanner.bootstrap.ScannerProperties in project sonarqube by SonarSource.

the class ProjectReactorBuilderTest method shouldInitRootWorkDir.

@Test
public void shouldInitRootWorkDir() {
    ProjectReactorBuilder builder = new ProjectReactorBuilder(new ScannerProperties(emptyMap()), mock(AnalysisWarnings.class));
    File baseDir = new File("target/tmp/baseDir");
    File workDir = builder.initRootProjectWorkDir(baseDir, emptyMap());
    assertThat(workDir).isEqualTo(new File(baseDir, ".sonar"));
}
Also used : ScannerProperties(org.sonar.scanner.bootstrap.ScannerProperties) File(java.io.File) AnalysisWarnings(org.sonar.api.notifications.AnalysisWarnings) Test(org.junit.Test)

Example 3 with ScannerProperties

use of org.sonar.scanner.bootstrap.ScannerProperties in project sonarqube by SonarSource.

the class ScmRevisionImplTest method ignore_failure_if_scm_does_not_support_revisions.

@Test
public void ignore_failure_if_scm_does_not_support_revisions() {
    CiConfiguration ciConfiguration = mock(CiConfiguration.class);
    when(ciConfiguration.getScmRevision()).thenReturn(Optional.empty());
    Map<String, String> scannerConfiguration = new HashMap<>();
    ScmConfiguration scmConfiguration = mock(ScmConfiguration.class, RETURNS_DEEP_STUBS);
    when(scmConfiguration.provider().revisionId(any())).thenThrow(new UnsupportedOperationException("BOOM"));
    InputModuleHierarchy moduleHierarchy = mock(InputModuleHierarchy.class, RETURNS_DEEP_STUBS);
    ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new ScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
    assertThat(underTest.get()).isEmpty();
}
Also used : InputModuleHierarchy(org.sonar.scanner.fs.InputModuleHierarchy) ScannerProperties(org.sonar.scanner.bootstrap.ScannerProperties) HashMap(java.util.HashMap) CiConfiguration(org.sonar.scanner.ci.CiConfiguration) Test(org.junit.Test)

Example 4 with ScannerProperties

use of org.sonar.scanner.bootstrap.ScannerProperties in project sonarqube by SonarSource.

the class ScmRevisionImplTest method testGet.

private Optional<String> testGet(@Nullable String cliValue, @Nullable String ciValue, @Nullable String scmValue) {
    CiConfiguration ciConfiguration = mock(CiConfiguration.class);
    when(ciConfiguration.getScmRevision()).thenReturn(Optional.ofNullable(ciValue));
    Map<String, String> scannerConfiguration = new HashMap<>();
    scannerConfiguration.put("sonar.scm.revision", cliValue);
    ScmConfiguration scmConfiguration = mock(ScmConfiguration.class, RETURNS_DEEP_STUBS);
    when(scmConfiguration.provider().revisionId(any())).thenReturn(scmValue);
    InputModuleHierarchy moduleHierarchy = mock(InputModuleHierarchy.class, RETURNS_DEEP_STUBS);
    ScmRevisionImpl underTest = new ScmRevisionImpl(ciConfiguration, new ScannerProperties(scannerConfiguration), scmConfiguration, moduleHierarchy);
    return underTest.get();
}
Also used : InputModuleHierarchy(org.sonar.scanner.fs.InputModuleHierarchy) ScannerProperties(org.sonar.scanner.bootstrap.ScannerProperties) HashMap(java.util.HashMap) CiConfiguration(org.sonar.scanner.ci.CiConfiguration)

Example 5 with ScannerProperties

use of org.sonar.scanner.bootstrap.ScannerProperties in project sonarqube by SonarSource.

the class ProjectReactorBuilderTest method shouldInitRootWorkDirWithCustomAbsoluteFolder.

@Test
public void shouldInitRootWorkDirWithCustomAbsoluteFolder() {
    Map<String, String> props = singletonMap("sonar.working.directory", new File("src").getAbsolutePath());
    ProjectReactorBuilder builder = new ProjectReactorBuilder(new ScannerProperties(props), mock(AnalysisWarnings.class));
    File baseDir = new File("target/tmp/baseDir");
    File workDir = builder.initRootProjectWorkDir(baseDir, props);
    assertThat(workDir).isEqualTo(new File("src").getAbsoluteFile());
}
Also used : ScannerProperties(org.sonar.scanner.bootstrap.ScannerProperties) File(java.io.File) AnalysisWarnings(org.sonar.api.notifications.AnalysisWarnings) Test(org.junit.Test)

Aggregations

ScannerProperties (org.sonar.scanner.bootstrap.ScannerProperties)6 Test (org.junit.Test)4 File (java.io.File)3 AnalysisWarnings (org.sonar.api.notifications.AnalysisWarnings)3 HashMap (java.util.HashMap)2 CiConfiguration (org.sonar.scanner.ci.CiConfiguration)2 InputModuleHierarchy (org.sonar.scanner.fs.InputModuleHierarchy)2 ProjectReactor (org.sonar.api.batch.bootstrap.ProjectReactor)1