main: use shared code for both run and test subcommands

This means that we don't need duplicate code to pass parameters to
wasmtime and that the following actually produces verbose output (it
didn't before this commit):

    tinygo test -v -target=cortex-m-qemu math
This commit is contained in:
Ayke van Laethem
2022-04-19 23:07:31 +02:00
committed by Ron Evans
parent 69d7ed5cda
commit 9160f3f16d
2 changed files with 71 additions and 94 deletions
+3 -1
View File
@@ -332,7 +332,9 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c
// Build the test binary.
stdout := &bytes.Buffer{}
err = buildAndRun("./"+path, config, stdout, cmdArgs, environmentVars, time.Minute)
err = buildAndRun("./"+path, config, stdout, cmdArgs, environmentVars, time.Minute, func(cmd *exec.Cmd, result builder.BuildResult) error {
return cmd.Run()
})
if err != nil {
printCompilerError(t.Log, err)
t.Fail()