You've already forked goreleaser
mirror of
https://github.com/goreleaser/goreleaser.git
synced 2025-07-17 01:42:37 +02:00
test: remove redundant os.Exit in TestMain (#5257)
This PR simplifies tests by removing redundant `os.Exit` calls in `TestMain` functions. As of Go 1.15, we do not need to call `os.Exit(m.Run())` explicitly, as value returned by `m.Run()` is stored into unexported field of `m` and go test executable is smart enough to automatically call `os.Exit(retValue)` when `TestMain` returns. See golang/go#34129.
This commit is contained in:
@ -11,5 +11,5 @@ func TestMain(m *testing.M) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(m.Run())
|
m.Run()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package before
|
package before
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
@ -15,9 +14,8 @@ import (
|
|||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
log.SetLevel(log.DebugLevel)
|
log.SetLevel(log.DebugLevel)
|
||||||
code := m.Run()
|
m.Run()
|
||||||
log.SetLevel(log.InfoLevel)
|
log.SetLevel(log.InfoLevel)
|
||||||
os.Exit(code)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDescription(t *testing.T) {
|
func TestDescription(t *testing.T) {
|
||||||
|
@ -30,7 +30,8 @@ var listen string
|
|||||||
|
|
||||||
func TestMain(m *testing.M) {
|
func TestMain(m *testing.M) {
|
||||||
if !testlib.InPath("docker") {
|
if !testlib.InPath("docker") {
|
||||||
os.Exit(m.Run())
|
m.Run()
|
||||||
|
return
|
||||||
}
|
}
|
||||||
prepareEnv()
|
prepareEnv()
|
||||||
|
|
||||||
@ -67,10 +68,9 @@ func TestMain(m *testing.M) {
|
|||||||
}))
|
}))
|
||||||
listen = "localhost:" + resource.GetPort("9000/tcp")
|
listen = "localhost:" + resource.GetPort("9000/tcp")
|
||||||
|
|
||||||
code := m.Run()
|
m.Run()
|
||||||
|
|
||||||
requireNoErr(pool.Purge(resource))
|
requireNoErr(pool.Purge(resource))
|
||||||
os.Exit(code)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMinioUpload(t *testing.T) {
|
func TestMinioUpload(t *testing.T) {
|
||||||
|
4
internal/pipe/env/env_test.go
vendored
4
internal/pipe/env/env_test.go
vendored
@ -24,13 +24,11 @@ func TestMain(m *testing.M) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
code := m.Run()
|
m.Run()
|
||||||
|
|
||||||
for k, v := range restores {
|
for k, v := range restores {
|
||||||
_ = os.Setenv(k, v)
|
_ = os.Setenv(k, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Exit(code)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDescription(t *testing.T) {
|
func TestDescription(t *testing.T) {
|
||||||
|
@ -46,9 +46,8 @@ func TestMain(m *testing.M) {
|
|||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
code := m.Run()
|
m.Run()
|
||||||
_ = os.RemoveAll(keyring)
|
_ = os.RemoveAll(keyring)
|
||||||
os.Exit(code)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestDescription(t *testing.T) {
|
func TestDescription(t *testing.T) {
|
||||||
|
Reference in New Issue
Block a user