Skip to content

Commit 68729c0

Browse files
authored
Correctly exit Stdlib tests on failure (#1888)
Signed-off-by: Takeshi Yoneda <t.y.mathetake@gmail.com>
1 parent 866d555 commit 68729c0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

internal/integration_test/stdlibs/bench_test.go

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ var (
6868
readTestCase: func(fpath string, fname string) (_ []byte, c wazero.ModuleConfig, stdout, stderr *os.File, err error) {
6969
bin, err := os.ReadFile(fpath)
7070
c, stdout, stderr = defaultModuleConfig()
71-
c.WithFSConfig(wazero.NewFSConfig().WithDirMount(".", "/")).
71+
c = c.WithFSConfig(wazero.NewFSConfig().WithDirMount(".", "/")).
7272
WithArgs("test.wasm")
7373
return bin, c, stdout, stderr, err
7474
},
@@ -87,7 +87,7 @@ var (
8787
WithDirMount(os.TempDir(), "/tmp")
8888

8989
c, stdout, stderr = defaultModuleConfig()
90-
c.WithFSConfig(fsconfig).
90+
c = c.WithFSConfig(fsconfig).
9191
WithArgs(fname, "-test.v")
9292

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

115115
c, stdout, stderr = defaultModuleConfig()
116-
c.WithFSConfig(
116+
c = c.WithFSConfig(
117117
wazero.NewFSConfig().
118118
WithDirMount(sysroot, "/").
119119
WithDirMount(os.TempDir(), "/tmp")).
@@ -223,11 +223,13 @@ func requireZeroExitCode(b *testing.B, err error, stdout, stderr *os.File) {
223223
b.Helper()
224224
if se, ok := err.(*sys.ExitError); ok {
225225
if se.ExitCode() != 0 { // Don't err on success.
226-
stdoutBytes, err := io.ReadAll(stdout)
227-
require.NoError(b, err)
228-
stderrBytes, err := io.ReadAll(stderr)
229-
require.NoError(b, err)
226+
stdoutBytes, _ := io.ReadAll(stdout)
227+
stderrBytes, _ := io.ReadAll(stderr)
230228
require.NoError(b, err, "stdout: %s\nstderr: %s", string(stdoutBytes), string(stderrBytes))
231229
}
230+
} else if err != nil {
231+
stdoutBytes, _ := io.ReadAll(stdout)
232+
stderrBytes, _ := io.ReadAll(stderr)
233+
require.NoError(b, err, "stdout: %s\nstderr: %s", string(stdoutBytes), string(stderrBytes))
232234
}
233235
}

0 commit comments

Comments
 (0)