Skip to content
Merged
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
9 changes: 9 additions & 0 deletions src/it/scala/smtlib/it/ProcessInterpreterTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ class ProcessInterpreterTests extends AnyFunSuite with TestHelpers {
//TODO: properly get all interpreters
def interpreters: Seq[Interpreter] = Seq(getZ3Interpreter)

test("Interpreter can be created with complex executable names") {
// sometimes we are given arguments in the executable name itself;
// check that these are split and processed correctly
val z3Interpreter = new Z3Interpreter("z3 -in", Array("-smt2")) {}
z3Interpreter.eval(trees.Commands.SetLogic(trees.Commands.AUFLIA()))
z3Interpreter.eval(trees.Commands.CheckSat())
z3Interpreter.interrupt()
}

test("Interrupt after free does not throw an exception") {
//TODO: check against all interpreters
val z3Interpreter = getZ3Interpreter
Expand Down
8 changes: 7 additions & 1 deletion src/main/scala/smtlib/interpreters/ProcessInterpreter.scala
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,13 @@ object ProcessInterpreter {
private def ctorHelper(executable: String,
args: Array[String],
parserCtor: BufferedReader => Parser): (Parser, Process, BufferedWriter, BufferedReader, BufferedReader) = {
val process = java.lang.Runtime.getRuntime.exec(executable +: args)
val (executableName, implicitArgs) = if (executable.contains(" ")) {
val parts = executable.split(" ")
(parts(0), parts.drop(1))
} else {
(executable, Array.empty[String])
}
val process = java.lang.Runtime.getRuntime.exec(executableName +: (implicitArgs ++ args))
val in = new BufferedWriter(new OutputStreamWriter(process.getOutputStream))
val out = new BufferedReader(new InputStreamReader(process.getInputStream))
val err = new BufferedReader(new InputStreamReader(process.getErrorStream))
Expand Down