diff options
author | a <[email protected]> | 2024-06-18 20:11:56 -0500 |
---|---|---|
committer | a <[email protected]> | 2024-06-18 20:11:56 -0500 |
commit | b491fc5d6ce68eb4630e950fa514575965172682 (patch) | |
tree | fba15c10bcb009388d095676cff0444f945364c6 | |
parent | 01cb87808708ef047bb82cc8083ef19708ea3f54 (diff) | |
download | caddy-b491fc5d6ce68eb4630e950fa514575965172682.tar.gz caddy-b491fc5d6ce68eb4630e950fa514575965172682.zip |
noot
-rw-r--r-- | caddy.go | 2 | ||||
-rw-r--r-- | cmd/commandfuncs.go | 8 |
2 files changed, 8 insertions, 2 deletions
@@ -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 746cf3da6..bdee24d11 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) { |