Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCANGRADLE-176 Fix unit tests on Windows #255

Merged
merged 2 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions src/test/groovy/org/sonarqube/gradle/FunctionalTests.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -390,14 +390,15 @@ class FunctionalTests extends Specification {

var mainSources = ((String) props."sonar.sources").split(",")
mainSources.size() == 3
mainSources[0].endsWith("""$projectDir/build.gradle""")
mainSources[1].endsWith("""$projectDir/gradle.properties""")
mainSources[2].endsWith("""$projectDir/settings.gradle""")
var projectPath = projectDir.toString() + File.separator
mainSources[0].endsWith("""${projectPath}build.gradle""")
mainSources[1].endsWith("""${projectPath}gradle.properties""")
mainSources[2].endsWith("""${projectPath}settings.gradle""")

var testSources = ((String) props."sonar.tests").split(",")
testSources.size() == 2
testSources[0].endsWith("""$projectDir/integrationTests/run-all.sh""")
testSources[1].endsWith("""$projectDir/test-license.sh""")
testSources[0].endsWith("""${projectPath}integrationTests${File.separator}run-all.sh""")
testSources[1].endsWith("""${projectPath}test-license.sh""")
}

def "scan all is enabled but not applied because of overridden properties on the command line"() {
Expand Down Expand Up @@ -538,14 +539,15 @@ class FunctionalTests extends Specification {
// Test that the empty script is is collected but the reports are not collected
var mainSources = ((String) props."sonar.sources").split(",")
mainSources.size() == 4
mainSources[0].endsWith("""$projectDir/build.gradle""")
mainSources[1].endsWith("""$projectDir/empty-script.groovy""")
mainSources[2].endsWith("""$projectDir/gradle.properties""")
mainSources[3].endsWith("""$projectDir/settings.gradle""")
var projectPath = projectDir.toString() + File.separator
mainSources[0].endsWith("""${projectPath}build.gradle""")
mainSources[1].endsWith("""${projectPath}empty-script.groovy""")
mainSources[2].endsWith("""${projectPath}gradle.properties""")
mainSources[3].endsWith("""${projectPath}settings.gradle""")

var testSources = ((String) props."sonar.tests").split(",")
testSources.size() == 2
testSources[0].endsWith("""$projectDir/integrationTests/run-all.sh""")
testSources[1].endsWith("""$projectDir/test-license.sh""")
testSources[0].endsWith("""${projectPath}integrationTests${File.separator}run-all.sh""")
testSources[1].endsWith("""${projectPath}test-license.sh""")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1116,7 +1116,7 @@ class SonarQubePluginTest extends Specification {
return properties.getOrDefault(propertyName, "").split(",")
.stream()
.filter(s -> !s.isBlank())
.map(s -> project.projectDir.toPath().relativize(Path.of(s)).toString())
.map(s -> project.projectDir.toPath().relativize(Path.of(s)).toString().replace(File.separator, '/'))
// filter out an unexpected file internally created by the test framework
.filter(s -> !s.endsWith("file-access.properties"))
.sorted()
Expand Down
15 changes: 10 additions & 5 deletions src/test/java/org/sonarqube/gradle/SourceCollectorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,18 @@
*/
package org.sonarqube.gradle;

import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;

import java.io.IOException;
import java.nio.file.*;
import java.nio.file.FileVisitResult;
import java.nio.file.FileVisitor;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Set;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.condition.DisabledOnOs;
import org.junit.jupiter.api.condition.OS;
import org.junit.jupiter.api.io.TempDir;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
Expand Down Expand Up @@ -156,6 +160,7 @@ void visitorIgnoresExcludedFiles() throws IOException {
}

@Test
@DisabledOnOs(OS.WINDOWS)
void visitorIgnoresSymbolicLinks() throws IOException {
Path simpleProjectPom = simpleProjectBasedDir.resolve("pom.xml");
simpleProjectPom.toFile().createNewFile();
Expand Down