Skip to content

Commit 01d8d9c

Browse files
committed
Split windows-incompatible test into two
1 parent 1a26e9f commit 01d8d9c

File tree

3 files changed

+49
-42
lines changed

3 files changed

+49
-42
lines changed

gradle.properties

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
org.gradle.unsafe.configuration-cache=true
2-
systemProp.gradle.enterprise.testretry.enabled=false
2+
systemProp.gradle.enterprise.testretry.enabled=false
3+
systemProp.org.gradle.unsafe.kotlin.assignment=true

src/test/groovy/com/github/gradle/node/npm/task/NpxTask_integTest.groovy

Lines changed: 45 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,50 @@ class NpxTask_integTest extends AbstractIntegTest {
9595
9696
// This is cursed, see npx-env/build.gradle for details
9797
@IgnoreIf({ System.getProperty("os.name").toLowerCase().contains("windows") })
98-
def 'execute npx command with custom execution configuration and check up-to-date-detection'() {
98+
def 'execute npx pwd command with custom execution configuration and check up-to-date-detection'() {
99+
given:
100+
gradleVersion = gv
101+
102+
copyResources("fixtures/npx-env/")
103+
copyResources("fixtures/env/")
104+
105+
when:
106+
def result7 = build(":pwd")
107+
108+
then:
109+
result7.task(":pwd").outcome == TaskOutcome.SUCCESS
110+
result7.output.contains("workingDirectory='${projectDir}'")
111+
112+
when:
113+
def result8 = build(":pwd", "-DcustomWorkingDir=true")
114+
115+
then:
116+
result8.task(":pwd").outcome == TaskOutcome.UP_TO_DATE
117+
118+
when:
119+
def result9 = build(":pwd", "-DcustomWorkingDir=true", "--rerun-tasks")
120+
121+
then:
122+
result9.task(":nodeSetup").outcome == TaskOutcome.SUCCESS
123+
result9.task(":npmSetup").outcome == TaskOutcome.SKIPPED
124+
result9.task(":npmInstall").outcome == TaskOutcome.SUCCESS
125+
result9.task(":pwd").outcome == TaskOutcome.SUCCESS
126+
def expectedWorkingDirectory = "${projectDir}${File.separator}build${File.separator}customWorkingDirectory"
127+
result9.output.contains("workingDirectory='${expectedWorkingDirectory}'")
128+
new File(expectedWorkingDirectory).isDirectory()
129+
130+
when:
131+
def result10 = build(":version")
132+
133+
then:
134+
result10.task(":version").outcome == TaskOutcome.SUCCESS
135+
result10.output.contains("> Task :version${System.lineSeparator()}${DEFAULT_NPM_VERSION}")
136+
137+
where:
138+
gv << GRADLE_VERSIONS_UNDER_TEST
139+
}
140+
141+
def 'execute npx env command with custom execution configuration and check up-to-date-detection'() {
99142
given:
100143
gradleVersion = gv
101144
@@ -154,7 +197,7 @@ class NpxTask_integTest extends AbstractIntegTest {
154197
result5.output.contains("E404")
155198
156199
when:
157-
def result6 = build(":env", "-DoutputFile=true")
200+
def result6 = build(":env", "-DoutputFile=true", "--stacktrace")
158201
159202
then:
160203
result6.task(":nodeSetup").outcome == TaskOutcome.UP_TO_DATE
@@ -166,44 +209,6 @@ class NpxTask_integTest extends AbstractIntegTest {
166209
outputFile.exists()
167210
environmentDumpContainsPathVariable(outputFile.text)
168211
169-
when:
170-
def result7 = build(":pwd")
171-
172-
then:
173-
result7.task(":nodeSetup").outcome == TaskOutcome.UP_TO_DATE
174-
result7.task(":npmSetup").outcome == TaskOutcome.SKIPPED
175-
result7.task(":npmInstall").outcome == TaskOutcome.UP_TO_DATE
176-
result7.task(":pwd").outcome == TaskOutcome.SUCCESS
177-
result7.output.contains("workingDirectory='${projectDir}'")
178-
179-
when:
180-
def result8 = build(":pwd", "-DcustomWorkingDir=true")
181-
182-
then:
183-
result8.task(":nodeSetup").outcome == TaskOutcome.UP_TO_DATE
184-
result8.task(":npmSetup").outcome == TaskOutcome.SKIPPED
185-
result8.task(":npmInstall").outcome == TaskOutcome.UP_TO_DATE
186-
result8.task(":pwd").outcome == TaskOutcome.UP_TO_DATE
187-
188-
when:
189-
def result9 = build(":pwd", "-DcustomWorkingDir=true", "--rerun-tasks")
190-
191-
then:
192-
result9.task(":nodeSetup").outcome == TaskOutcome.SUCCESS
193-
result9.task(":npmSetup").outcome == TaskOutcome.SKIPPED
194-
result9.task(":npmInstall").outcome == TaskOutcome.SUCCESS
195-
result9.task(":pwd").outcome == TaskOutcome.SUCCESS
196-
def expectedWorkingDirectory = "${projectDir}${File.separator}build${File.separator}customWorkingDirectory"
197-
result9.output.contains("workingDirectory='${expectedWorkingDirectory}'")
198-
new File(expectedWorkingDirectory).isDirectory()
199-
200-
when:
201-
def result10 = build(":version")
202-
203-
then:
204-
result10.task(":version").outcome == TaskOutcome.SUCCESS
205-
result10.output.contains("> Task :version${System.lineSeparator()}${DEFAULT_NPM_VERSION}")
206-
207212
where:
208213
gv << GRADLE_VERSIONS_UNDER_TEST
209214
}

src/test/resources/fixtures/npx-env/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,9 @@ if (isPropertyEnabled("customWorkingDir")) {
6363
}
6464

6565
if (isPropertyEnabled("outputFile")) {
66+
def standardOutputFile = new File(buildDir, "standard-output.txt")
6667
env.execOverrides {
67-
standardOutput = new FileOutputStream("${buildDir}/standard-output.txt")
68+
standardOutput = new FileOutputStream(standardOutputFile)
6869
}
6970
}
7071

0 commit comments

Comments
 (0)