Skip to content

Commit

Permalink
Correctly exit Stdlib tests on failure (#1888)
Browse files Browse the repository at this point in the history
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
  • Loading branch information
mathetake authored Dec 21, 2023
1 parent 866d555 commit 68729c0
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions internal/integration_test/stdlibs/bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ var (
readTestCase: func(fpath string, fname string) (_ []byte, c wazero.ModuleConfig, stdout, stderr *os.File, err error) {
bin, err := os.ReadFile(fpath)
c, stdout, stderr = defaultModuleConfig()
c.WithFSConfig(wazero.NewFSConfig().WithDirMount(".", "/")).
c = c.WithFSConfig(wazero.NewFSConfig().WithDirMount(".", "/")).
WithArgs("test.wasm")
return bin, c, stdout, stderr, err
},
Expand All @@ -87,7 +87,7 @@ var (
WithDirMount(os.TempDir(), "/tmp")

c, stdout, stderr = defaultModuleConfig()
c.WithFSConfig(fsconfig).
c = c.WithFSConfig(fsconfig).
WithArgs(fname, "-test.v")

return bin, c, stdout, stderr, err
Expand All @@ -113,7 +113,7 @@ var (
normalizedTestdir := normalizeOsPath(testdir)

c, stdout, stderr = defaultModuleConfig()
c.WithFSConfig(
c = c.WithFSConfig(
wazero.NewFSConfig().
WithDirMount(sysroot, "/").
WithDirMount(os.TempDir(), "/tmp")).
Expand Down Expand Up @@ -223,11 +223,13 @@ func requireZeroExitCode(b *testing.B, err error, stdout, stderr *os.File) {
b.Helper()
if se, ok := err.(*sys.ExitError); ok {
if se.ExitCode() != 0 { // Don't err on success.
stdoutBytes, err := io.ReadAll(stdout)
require.NoError(b, err)
stderrBytes, err := io.ReadAll(stderr)
require.NoError(b, err)
stdoutBytes, _ := io.ReadAll(stdout)
stderrBytes, _ := io.ReadAll(stderr)
require.NoError(b, err, "stdout: %s\nstderr: %s", string(stdoutBytes), string(stderrBytes))
}
} else if err != nil {
stdoutBytes, _ := io.ReadAll(stdout)
stderrBytes, _ := io.ReadAll(stderr)
require.NoError(b, err, "stdout: %s\nstderr: %s", string(stdoutBytes), string(stderrBytes))
}
}

0 comments on commit 68729c0

Please sign in to comment.