mirror of
https://github.com/CPunch/gopenfusion.git
synced 2024-11-21 15:00:07 +00:00
fix: os.Exit() kills any deferred cleanup functions
os.Exit() itself is now also a deferred function, which will be the last to run.
This commit is contained in:
parent
79f68187bf
commit
02afe67ac3
@ -32,6 +32,7 @@ func TestMain(m *testing.M) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
// this is fine since we don't defer anything
|
||||
os.Exit(m.Run())
|
||||
}
|
||||
|
||||
|
@ -18,6 +18,11 @@ var (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
ret := 1
|
||||
defer func() {
|
||||
os.Exit(ret)
|
||||
}()
|
||||
|
||||
ctx := context.Background()
|
||||
psql, err := sqltestutil.StartPostgresContainer(ctx, "15")
|
||||
if err != nil {
|
||||
@ -35,7 +40,7 @@ func TestMain(m *testing.M) {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
os.Exit(m.Run())
|
||||
ret = m.Run()
|
||||
}
|
||||
|
||||
func TestDBAccount(t *testing.T) {
|
||||
|
@ -14,6 +14,11 @@ var (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
ret := 1
|
||||
defer func() {
|
||||
os.Exit(ret)
|
||||
}()
|
||||
|
||||
r, err := miniredis.Run()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
@ -26,7 +31,7 @@ func TestMain(m *testing.M) {
|
||||
}
|
||||
defer rh.Close()
|
||||
|
||||
os.Exit(m.Run())
|
||||
ret = m.Run()
|
||||
}
|
||||
|
||||
func TestRedisLogin(t *testing.T) {
|
||||
|
@ -22,6 +22,11 @@ var (
|
||||
rh *redis.RedisHandler
|
||||
)
|
||||
|
||||
/*
|
||||
test data was scraped by dumping packets, just adding a println to the LoginService
|
||||
to print the packet data
|
||||
*/
|
||||
|
||||
var (
|
||||
testCharCreate = protocol.SP_CL2LS_REQ_CHAR_CREATE{
|
||||
PCStyle: protocol.SPCStyle{
|
||||
@ -42,6 +47,11 @@ var (
|
||||
)
|
||||
|
||||
func TestMain(m *testing.M) {
|
||||
ret := 1
|
||||
defer func() {
|
||||
os.Exit(ret)
|
||||
}()
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
@ -70,10 +80,9 @@ func TestMain(m *testing.M) {
|
||||
|
||||
// wait for login server to start, then start tests
|
||||
<-loginSrv.Service().Started()
|
||||
ret := m.Run()
|
||||
ret = m.Run()
|
||||
cancel()
|
||||
<-loginSrv.Service().Stopped()
|
||||
os.Exit(ret)
|
||||
}
|
||||
|
||||
// This test tries a typical login sequence.
|
||||
|
Loading…
Reference in New Issue
Block a user