What version of Go are you using (go version)?
$ go version
go version go1.15 linux/amd64
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="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/user/.cache/go-build"
GOENV="/home/user/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/opt/go/path/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/opt/go/path"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/user/.gimme/versions/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/user/.gimme/versions/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/user/go-test/go.mod"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build146632005=/tmp/go-build -gno-record-gcc-switches"
What did you do?
Call t.Cleanup from inside of a cleanup function,
package main
import (
"fmt"
"testing"
)
func TestCleanup(t *testing.T) {
t.Cleanup(func() {
fmt.Println("cleanup initial")
t.Cleanup(func() {
fmt.Println("nested cleanup")
})
})
fmt.Println("run test")
}
What did you expect to see?
Either the newly added Cleanup function to be run immediately after the initial clean up (to respect LIFO order) or for the Cleanup call to cause the test to be marked as failed.
What did you see instead?
The nested cleanup function is ignored silently,
=== RUN TestCleanup
run test
cleanup initial
--- PASS: TestCleanup (0.00s)
PASS
ok command-line-arguments 0.004s
What version of Go are you using (
go version)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env)?go envOutputWhat did you do?
Call
t.Cleanupfrom inside of a cleanup function,What did you expect to see?
Either the newly added
Cleanupfunction to be run immediately after the initial clean up (to respect LIFO order) or for theCleanupcall to cause the test to be marked as failed.What did you see instead?
The nested cleanup function is ignored silently,