Skip to content

Commit

Permalink
fix tests failing due to os incompatible temp paths
Browse files Browse the repository at this point in the history
Signed-off-by: Lennart Heimbs <[email protected]>
  • Loading branch information
lheimbs committed Dec 1, 2023
1 parent c7e12de commit da952f5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ package io.github.amosproj.pitmutationmate.override
import nebula.test.IntegrationSpec
import nebula.test.functional.internal.toolingapi.ToolingExecutionResult
import org.gradle.api.logging.LogLevel
import spock.lang.IgnoreIf
import spock.lang.Unroll

import java.nio.file.Files

/**
* Integration tests for the plugin.
*/
Expand Down Expand Up @@ -112,7 +115,7 @@ class TypesPropertyIntegrationTest extends IntegrationSpec {
'null' || 0 // should become 0
}

@Unroll("'#commandLineParameter' should be converted to '#expectedValue'")
@IgnoreIf({ System.properties['os.name'].toLowerCase().contains('windows') })
def "Should allow to override Directory pitest properties"() {
given:
buildFile << """
Expand All @@ -123,19 +126,15 @@ class TypesPropertyIntegrationTest extends IntegrationSpec {
assert pitest.reportDir == null
task checkOverriddenProperties {
doLast {
assert pitest.reportDir.toString() == $expectedValue
assert pitest.reportDir.toString() == '$projectDir/test'
}
}
"""
when:
ToolingExecutionResult executionResult = runTasksSuccessfully(
'checkOverriddenProperties',
"-Dpitmutationmate.override.reportDir=$commandLineParameter") as ToolingExecutionResult
"-Dpitmutationmate.override.reportDir=test") as ToolingExecutionResult
then:
executionResult.standardOutput.contains(':checkOverriddenProperties')
where:
commandLineParameter || expectedValue
'/tmp/test' || 'new File("/tmp/test").toString()'
'null' || '"null"'
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import nebula.test.ProjectSpec
import org.gradle.api.GradleException
import org.gradle.api.file.Directory

import java.nio.file.Files

/**
* Tests for [GradlePitestPluginOverrideStrategy].
*/
Expand Down Expand Up @@ -152,12 +154,13 @@ class GradlePitestPluginOverrideStrategyTest extends ProjectSpec {
given:
OverrideStrategy overrideStrategy = new GradlePitestPluginOverrideStrategy()
project.extensions.create('pitest', PITConfigurationValues)
def givenDir = new File("build/reports/pitest") as Directory
def newDir = new File("/tmp/test") as Directory
def givenDir = new File('build/reports/pitest') as Directory
def newDirPath = Files.createTempDirectory("myTempDirPrefix")
def newDir = new File(newDirPath.toString()) as Directory
assert project.pitest.reportDir.absolutePath == givenDir.absolutePath

when:
overrideStrategy.apply(project, 'reportDir', '/tmp/test')
overrideStrategy.apply(project, 'reportDir', newDirPath.toString())

then:
project.pitest.reportDir.toString() == newDir.absolutePath
Expand Down

0 comments on commit da952f5

Please sign in to comment.