Skip to content

Commit d15f7ee

Browse files
committed
Restore array solution for cursed npx test
I'm not finding any way to get this to work on all platforms, every idea I can think of fails on Windows so I'm just going to disable this test there.
1 parent f032e89 commit d15f7ee

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import com.github.gradle.node.NodeExtension
55
import org.gradle.testkit.runner.TaskOutcome
66
import org.junit.Rule
77
import org.junit.contrib.java.lang.system.EnvironmentVariables
8+
import spock.lang.IgnoreIf
89

910
import java.util.regex.Pattern
1011

@@ -82,6 +83,8 @@ class NpxTask_integTest extends AbstractIntegTest {
8283
result4.output.contains("> Task :version${System.lineSeparator()}${NodeExtension.DEFAULT_NPM_VERSION}")
8384
}
8485

86+
// This is cursed, see npx-env/build.gradle for details
87+
@IgnoreIf({ System.getProperty("os.name").toLowerCase().contains("windows") })
8588
def 'execute npx command with custom execution configuration and check up-to-date-detection'() {
8689
given:
8790
copyResources("fixtures/npx-env/")

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ task env(type: NpxTask) {
2121
task pwd(type: NpxTask) {
2222
dependsOn npmInstall
2323
command = "jseval"
24+
/* This is cursed.
25+
This used to work before we upgraded node+npm but now the backticks break, I tried to work around it and...
26+
["work..='", process.cwd(), "'"].join('') works, except on windows where it prints:
27+
, process.cwd,
28+
"work..='" + process.cwd() + "'" works, except on windows where it prints:
29+
+ process.cwd +
30+
And surprising nobody at this point:
31+
process.stdout.write("workingDirectory='"); process.stdout.write(process.cwd()); process.stdout.write("'\\n");
32+
Does work, except on windows, where it's parsed as:
33+
process.stdout.write(workingDirectory='); process.stdout.write(process.cwd()); process.stdout.write('\\n);
34+
35+
If someone manages to fix this, remove the @IgnoreIf from the NpxTask_integTest
36+
*/
2437
args = ["""console.log(["workingDirectory='", process.cwd(), "'"].join(''));"""]
2538
outputs.upToDateWhen {
2639
true

0 commit comments

Comments
 (0)