Skip to content

testing: panic + Skip is not reported as a failure, though Error + Skip is #53259

@prashantv

Description

@prashantv

What version of Go are you using (go version)?

$ go version
go version go1.18.3 darwin/arm64

Also reproduced on Go Playground using 1.17, 1.18, and latest dev branch.

Does this issue reproduce with the latest release?

Yes.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="arm64"
GOBIN=""
GOCACHE="/Users/prashant/Library/Caches/go-build"
GOENV="/Users/prashant/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/prashant/go/pkg/mod"
GONOPROXY="github.com/chronosphereio"
GONOSUMDB="github.com/chronosphereio"
GOOS="darwin"
GOPATH="/Users/prashant/go"
GOPRIVATE="github.com/chronosphereio"
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/prashant/.gimme/versions/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/prashant/.gimme/versions/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.18.3"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/prashant/tmp/panic-skip/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/2f/kn4pgn0x5dv1nqm97qh06sch0000gp/T/go-build1443169597=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

Called t.Skip inside of a cleanup function, for a test that failed due to a panic.

func TestCleanupSkipPanic(t *testing.T) {
	t.Cleanup(func() {
		t.Skip("skip: t.Failed() = ", t.Failed())
	})
	panic("fail")
}

See playground for other similar tests and how they behave:
https://go.dev/play/p/zK1cXf5iAG5

What did you expect to see?

Expected the test to be marked as failed due to the panic.

What did you see instead?

The test was marked as skipped, and the cleanup function (or defer) reported the test as not failed.

=== RUN   TestCleanupSkipPanic
    prog.go:21: skip: t.Failed() =  false
--- SKIP: TestCleanupSkipPanic (0.00s)

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsDecisionFeedback is required from experts, contributors, and/or the community before a change can be made.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions