From a69eb396604552422c34edfb14aee71a98f4015d Mon Sep 17 00:00:00 2001 From: Onsi Fakhouri Date: Tue, 29 Oct 2024 14:41:51 -0600 Subject: [PATCH] add support for GINKGO_TIME_FORMAT --- docs/index.md | 3 +++ types/types.go | 10 +++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/docs/index.md b/docs/index.md index a8762aa8b..da633dbc5 100644 --- a/docs/index.md +++ b/docs/index.md @@ -3446,8 +3446,11 @@ When you [filter specs](#filtering-specs) using Ginkgo's various filtering mecha Here are a grab bag of other settings: You can disable Ginkgo's color output by running `ginkgo --no-color` or setting the `GINKGO_NO_COLOR=TRUE` environment variable. + You can also output in a format that makes it easier to read in github actions console by running `ginkgo --github-output`. +You can change how Ginkgo formats timestamps in the timeline by setting `GINKGO_TIME_FORMAT` to a valid Golang time format layout (e.g. `GINKGO_TIME_FORMAT=02/01/06 3:04:05.00`). + By default, Ginkgo only emits full stack traces when a spec panics. When a normal assertion failure occurs, Ginkgo simply emits the line at which the failure occurred. You can, instead, have Ginkgo always emit the full stack trace by running `ginkgo --trace`. ### Reporting Infrastructure diff --git a/types/types.go b/types/types.go index aae69b04c..ddcbec1ba 100644 --- a/types/types.go +++ b/types/types.go @@ -3,13 +3,21 @@ package types import ( "encoding/json" "fmt" + "os" "sort" "strings" "time" ) const GINKGO_FOCUS_EXIT_CODE = 197 -const GINKGO_TIME_FORMAT = "01/02/06 15:04:05.999" + +var GINKGO_TIME_FORMAT = "01/02/06 15:04:05.999" + +func init() { + if os.Getenv("GINKGO_TIME_FORMAT") != "" { + GINKGO_TIME_FORMAT = os.Getenv("GINKGO_TIME_FORMAT") + } +} // Report captures information about a Ginkgo test run type Report struct {