Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions app/src/processing/app/Sketch.java
Original file line number Diff line number Diff line change
Expand Up @@ -1320,10 +1320,13 @@ static protected File findMain(File folder, List<Mode> modeList) {
String main = props.get("main");
if (main != null) {
File mainFile = new File(folder, main);
if (!mainFile.exists()) {
if (mainFile.exists()) {
return mainFile;
}
else {
System.err.println(main + " does not exist inside " + folder);
// Fall through to the code below in case we can recover.
// Not removing the bad entry since this is a find() method.

}
}
} catch (IOException e) {
Expand Down
24 changes: 15 additions & 9 deletions app/src/processing/app/ui/Editor.java
Original file line number Diff line number Diff line change
Expand Up @@ -2256,20 +2256,26 @@ public boolean checkModified() {
* shouldn't rely on any of its variables being initialized already.
*/
protected void handleOpenInternal(String path) throws EditorException {
// Prior to 4.0 beta 6, a lot of logic happened here that was
// instead moved into Base. Probably was here so that other Modes
// could override the behavior, but that was too messy. [fry 220206]
try {
File sketchFolder = new File(path);

try {
sketch = new Sketch(path, this);
} catch (IOException e) {
throw new EditorException("Could not create the sketch.", e);
// Try to locate main file using sketch.properties or fallback
File mainFile = Sketch.findMain(sketchFolder, Base.getModeList());
if (mainFile == null) {
throw new EditorException("No valid main .pde file found in " + sketchFolder);
}

header.rebuild();
updateTitle();
// Use the parent folder of the main file
sketch = new Sketch(mainFile.getParentFile(), this);

} catch (IOException e) {
throw new EditorException("Could not create the sketch.", e);
}

header.rebuild();
updateTitle();
}


/**
* Set the title of the PDE window based on the current sketch, i.e.
Expand Down
18 changes: 17 additions & 1 deletion app/test/processing/app/CLITest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,20 @@ class CLITest {
println("Done running CLI with arguments: $args (Result: $result)")

}
}
fun runCLIAndCapture(vararg args: String): String {
val argLine = args.joinToString(" ")
println("Running CLI with arguments: $argLine")

val process = ProcessBuilder("./gradlew", "run", "--args=$argLine", "--quiet")
.directory(File(System.getProperty("user.dir")).resolve("../../../"))
.redirectErrorStream(true)
.start()

val output = process.inputStream.bufferedReader().readText()
val exitCode = process.waitFor()

println("Done running CLI with arguments: $argLine (Exit code: $exitCode)")
return output
}

}