aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authora <[email protected]>2024-06-18 20:11:56 -0500
committera <[email protected]>2024-06-18 20:11:56 -0500
commitb491fc5d6ce68eb4630e950fa514575965172682 (patch)
treefba15c10bcb009388d095676cff0444f945364c6
parent01cb87808708ef047bb82cc8083ef19708ea3f54 (diff)
downloadcaddy-b491fc5d6ce68eb4630e950fa514575965172682.tar.gz
caddy-b491fc5d6ce68eb4630e950fa514575965172682.zip
noot
-rw-r--r--caddy.go2
-rw-r--r--cmd/commandfuncs.go8
2 files changed, 8 insertions, 2 deletions
diff --git a/caddy.go b/caddy.go
index 2c18053a5..e7afc13b8 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 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) {