diff --git a/src/test/wacc/examples.scala b/src/test/wacc/examples.scala index abf6769..e7397b6 100644 --- a/src/test/wacc/examples.scala +++ b/src/test/wacc/examples.scala @@ -6,6 +6,7 @@ import org.scalatest.Inspectors.forEvery import java.io.File import sys.process._ import java.io.PrintStream +import scala.io.Source class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll with ParallelTestExecution { val files = @@ -47,7 +48,7 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll with Paral .drop(outputLineIdx + 1) .takeWhile(_.startsWith("#")) .map(_.stripPrefix("#").stripLeading) - .mkString("") + .mkString("\n") val exitLineIdx = contents.indexWhere(_.matches("^# ?[Ee]xit:.*$")) val expectedExit = @@ -62,11 +63,16 @@ class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll with Paral // Run the executable with the provided input val stdout = new StringBuilder - // val execResult = s"$execFilename".!(ProcessLogger(stdout.append(_))) - val execResult = - s"echo $inputLine" #| s"timeout 5s $execFilename" ! ProcessLogger(stdout.append(_)) + val process = s"timeout 5s $execFilename" run ProcessIO( + in = w => { + w.write(inputLine.getBytes) + w.close() + }, + out = Source.fromInputStream(_).addString(stdout), + err = _ => () + ) - assert(execResult == expectedExit) + assert(process.exitValue == expectedExit) assert(stdout.toString == expectedOutput) } }