From b491fc5d6ce68eb4630e950fa514575965172682 Mon Sep 17 00:00:00 2001 From: a Date: Tue, 18 Jun 2024 20:11:56 -0500 Subject: [PATCH] noot --- caddy.go | 2 +- cmd/commandfuncs.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/caddy.go b/caddy.go index 2c18053a..e7afc13b 100644 --- a/caddy.go +++ b/caddy.go @@ -780,7 +780,7 @@ func exitProcess(ctx context.Context, logger *zap.Logger) { logger.Error("unclean shutdown") } // check if we are in test environment, and dont call exit if we are - if flag.Lookup("test.v") == nil || !strings.Contains(os.Args[0], ".test") { + if flag.Lookup("test.v") == nil && !strings.Contains(os.Args[0], ".test") { os.Exit(exitCode) } }() diff --git a/cmd/commandfuncs.go b/cmd/commandfuncs.go index 746cf3da..bdee24d1 100644 --- a/cmd/commandfuncs.go +++ b/cmd/commandfuncs.go @@ -20,6 +20,7 @@ import ( "crypto/rand" "encoding/json" "errors" + "flag" "fmt" "io" "io/fs" @@ -257,6 +258,7 @@ func cmdRun(fl Flags) (int, error) { // if enabled, reload config file automatically on changes // (this better only be used in dev!) + // do not enable this during tests, it will cause leaks if watchFlag { go watchConfigFile(configFile, configAdapterFlag) } @@ -280,7 +282,11 @@ func cmdRun(fl Flags) (int, error) { } } - select {} + if flag.Lookup("test.v") == nil || !strings.Contains(os.Args[0], ".test") { + return caddy.ExitCodeSuccess, nil + } else { + select {} + } } func cmdStop(fl Flags) (int, error) {