Description: the test assumes /tmp/etc does not exist so that it would raise an error when trying to open that location. Due to the many packages that run tests, it happens to exist on the builders. Use a dedicated directory as root using os.MkdirTemp(). Upstream: https://github.com/caddyserver/caddy/pull/4544 diff --git a/modules/caddyhttp/templates/tplcontext_test.go b/modules/caddyhttp/templates/tplcontext_test.go index 401df3c..580b396 100644 --- a/modules/caddyhttp/templates/tplcontext_test.go +++ b/modules/caddyhttp/templates/tplcontext_test.go @@ -504,8 +504,12 @@ func initTestContext() (TemplateContext, error) { if err != nil { return TemplateContext{}, err } + tmpDir, err := os.MkdirTemp(os.TempDir(), "caddy") + if err != nil { + return TemplateContext{}, err + } return TemplateContext{ - Root: http.Dir(os.TempDir()), + Root: http.Dir(tmpDir), Req: request, RespHeader: WrappedHeader{make(http.Header)}, }, nil