Skip to content

Commit b99a5a3

Browse files
Copilotquintesse
andcommitted
Fix cross-platform compatibility for test commands by using platform-specific simple commands
Co-authored-by: quintesse <778793+quintesse@users.noreply.github.com>
1 parent 9337631 commit b99a5a3

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/test/java/org/codejive/jpm/MainIntegrationTest.java

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,8 @@ void testMainWithNoArgs() {
267267
}
268268

269269
private void createAppYml() throws IOException {
270+
// Use platform-specific command for simple action that works on both Windows and Unix
271+
String simpleCommand = ScriptUtils.isWindows() ? "echo off" : "true";
270272
String yamlContent =
271273
"dependencies:\n"
272274
+ " com.github.lalyos:jfiglet: \"0.0.9\"\n"
@@ -275,7 +277,9 @@ private void createAppYml() throws IOException {
275277
+ " build: \"javac -cp {{deps}} *.java\"\n"
276278
+ " test: \"java -cp {{deps}} TestRunner\"\n"
277279
+ " run: \"java -cp .:{{deps}} MainClass\"\n"
278-
+ " hello: \"true\"\n";
280+
+ " hello: \""
281+
+ simpleCommand
282+
+ "\"\n";
279283
Files.writeString(tempDir.resolve("app.yml"), yamlContent);
280284
}
281285

@@ -285,23 +289,31 @@ private void createAppYmlWithoutActions() throws IOException {
285289
}
286290

287291
private void createAppYmlWithoutBuildAction() throws IOException {
292+
// Use platform-specific command for simple action that works on both Windows and Unix
293+
String simpleCommand = ScriptUtils.isWindows() ? "echo off" : "true";
288294
String yamlContent =
289295
"dependencies:\n"
290296
+ " com.github.lalyos:jfiglet: \"0.0.9\"\n"
291297
+ "\n"
292298
+ "actions:\n"
293299
+ " test: \"java -cp {{deps}} TestRunner\"\n"
294-
+ " hello: \"true\"\n";
300+
+ " hello: \""
301+
+ simpleCommand
302+
+ "\"\n";
295303
Files.writeString(tempDir.resolve("app.yml"), yamlContent);
296304
}
297305

298306
private void createAppYmlWithSimpleAction() throws IOException {
307+
// Use platform-specific command for simple action that works on both Windows and Unix
308+
String simpleCommand = ScriptUtils.isWindows() ? "echo off" : "true";
299309
String yamlContent =
300310
"dependencies:\n"
301311
+ " com.github.lalyos:jfiglet: \"0.0.9\"\n"
302312
+ "\n"
303313
+ "actions:\n"
304-
+ " simple: \"true\"\n";
314+
+ " simple: \""
315+
+ simpleCommand
316+
+ "\"\n";
305317
Files.writeString(tempDir.resolve("app.yml"), yamlContent);
306318
}
307319
}

0 commit comments

Comments
 (0)