Skip to content

Commit 0ae4789

Browse files
committed
test: convert to automated CLI test with temp directory
Converted testSketchWithCustomMainFile() from manual to automated test. Now creates a temporary sketch folder with custom main file and sketch.properties, then tests the CLI build command. Follows the pattern from SchemaTest.kt using Files.createTempDirectory() and automatic cleanup.
1 parent 62e5c20 commit 0ae4789

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

app/test/processing/app/CLITest.kt

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package processing.app
22

33
import java.io.File
4+
import java.nio.file.Files
45
import kotlin.test.Test
56

67
/*
@@ -27,13 +28,32 @@ class CLITest {
2728

2829
@Test
2930
fun testSketchWithCustomMainFile(){
30-
// This test requires manual setup:
31-
// 1. Create a sketch folder with a custom main file (e.g., sketch/custom.pde)
32-
// 2. Add sketch.properties with: main=custom.pde
33-
// 3. Update the path below to your test sketch
34-
// 4. Run this test in IntelliJ IDEA
35-
// Uncomment and modify the path below to test:
36-
// runCLIWithArguments("cli --sketch=path/to/your/test/sketch --run")
31+
val tempDir = Files.createTempDirectory("cli_custom_main_test")
32+
try {
33+
val sketchFolder = tempDir.resolve("TestSketch").toFile()
34+
sketchFolder.mkdirs()
35+
36+
// Create custom main file (not matching folder name)
37+
val customMain = File(sketchFolder, "custom_main.pde")
38+
customMain.writeText("""
39+
void setup() {
40+
println("Custom main file test");
41+
}
42+
43+
void draw() {
44+
exit();
45+
}
46+
""".trimIndent())
47+
48+
// Create sketch.properties with custom main
49+
val propsFile = File(sketchFolder, "sketch.properties")
50+
propsFile.writeText("main=custom_main.pde")
51+
52+
// Test with CLI
53+
runCLIWithArguments("cli --sketch=${sketchFolder.absolutePath} --build")
54+
} finally {
55+
tempDir.toFile().deleteRecursively()
56+
}
3757
}
3858

3959
/*

0 commit comments

Comments
 (0)