Commit beb80d2e authored by Timon Stampfli's avatar Timon Stampfli
Browse files

fixing go runner bug, which forgets to output

parent 551bfa6b
......@@ -4,6 +4,7 @@ import (
"bytes"
"io"
"os/exec"
"sync"
)
type sampleExecutionResult struct {
......@@ -32,10 +33,24 @@ func runSample(cmd string, input io.Reader, output, stderr io.Writer) sampleExec
var collectedStdin bytes.Buffer
var collectedStdout bytes.Buffer
var collectedStderr bytes.Buffer
go io.Copy(io.MultiWriter(processStdin, &collectedStdin), input)
go io.Copy(io.MultiWriter(output, &collectedStdout), processStdout)
go io.Copy(io.MultiWriter(stderr, &collectedStderr), processStderr)
err = process.Run()
go func() {
io.Copy(io.MultiWriter(processStdin, &collectedStdin), input)
processStdin.Close()
}()
err = process.Start()
if err != nil {
panic(err)
}
var waitgroup sync.WaitGroup
waitgroup.Add(1)
go func() {
io.Copy(io.MultiWriter(stderr, &collectedStderr), processStderr)
waitgroup.Done()
}()
io.Copy(io.MultiWriter(output, &collectedStdout), processStdout)
waitgroup.Wait()
err = process.Wait()
processErrorString := ""
if err != nil {
processErrorString = err.Error()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment