Commit 88632cac by Ben Clayton

Regres: Don't treat non-zero error codes as crashes.

Use go 1.13's new error functionality to create nested errors, and use the new errors.As() to unwrap them. Fixes bad classification of tests that have recently started returning non-zero exit codes. Change-Id: I4f356696d2a7ce1576be1c350fc14e156f63c659 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38130Reviewed-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarBen Clayton <bclayton@google.com>
parent 59fa599a
...@@ -19,15 +19,8 @@ import ( ...@@ -19,15 +19,8 @@ import (
"fmt" "fmt"
) )
// errWithCause is an error that wrap an inner error with additional info.
type errWithCause struct {
cause error
msg string
}
func (e errWithCause) Error() string { return fmt.Sprintf("%s. Cause: %v", e.msg, e.cause) }
// Wrap returns a new error wrapping cause with the additional message. // Wrap returns a new error wrapping cause with the additional message.
func Wrap(cause error, msg string, args ...interface{}) error { func Wrap(cause error, msg string, args ...interface{}) error {
return errWithCause{cause, fmt.Sprintf(msg, args...)} s := fmt.Sprintf(msg, args...)
return fmt.Errorf("%v. Cause: %w", s, cause)
} }
...@@ -1333,6 +1333,14 @@ nextTest: ...@@ -1333,6 +1333,14 @@ nextTest:
out := string(outRaw) out := string(outRaw)
out = strings.ReplaceAll(out, t.srcDir, "<SwiftShader>") out = strings.ReplaceAll(out, t.srcDir, "<SwiftShader>")
out = strings.ReplaceAll(out, exe, "<dEQP>") out = strings.ReplaceAll(out, exe, "<dEQP>")
// Don't treat non-zero error codes as crashes.
var exitErr *exec.ExitError
if errors.As(err, &exitErr) {
out += fmt.Sprintf("\nProcess terminated with code %d", exitErr.ExitCode())
err = nil
}
switch err.(type) { switch err.(type) {
default: default:
for _, test := range []struct { for _, test := range []struct {
......
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