From da952f5320acea0e3b85dff527d51866aac93e0d Mon Sep 17 00:00:00 2001 From: Lennart Heimbs Date: Fri, 1 Dec 2023 22:11:08 +0100 Subject: [PATCH] fix tests failing due to os incompatible temp paths Signed-off-by: Lennart Heimbs --- .../override/TypesPropertyIntegrationTest.groovy | 13 ++++++------- .../GradlePitestPluginOverrideStrategyTest.groovy | 9 ++++++--- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy index 1ea25e2c..20a508c9 100644 --- a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy +++ b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/TypesPropertyIntegrationTest.groovy @@ -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. */ @@ -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 << """ @@ -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"' } } diff --git a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy index c3225246..a8b99cc8 100644 --- a/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy +++ b/pitmutationmate-override-plugin/plugin/src/test/groovy/io/github/amosproj/pitmutationmate/override/strategy/GradlePitestPluginOverrideStrategyTest.groovy @@ -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]. */ @@ -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