diff --git a/core_dsl.go b/core_dsl.go index a3e8237e9..0adc83579 100644 --- a/core_dsl.go +++ b/core_dsl.go @@ -20,6 +20,7 @@ import ( "io" "os" "path/filepath" + "strconv" "strings" "github.com/go-logr/logr" @@ -257,6 +258,14 @@ func RunSpecs(t GinkgoTestingT, description string, args ...interface{}) bool { suiteLabels := extractSuiteConfiguration(args) var reporter reporters.Reporter + reporterConfig := reporterConfig + if value, present := os.LookupEnv("GINGKO_COLOR"); present { + b, err := strconv.ParseBool(value) + if err == nil { + reporterConfig.NoColor = !b + } + } + if suiteConfig.ParallelTotal == 1 { reporter = reporters.NewDefaultReporter(reporterConfig, formatter.ColorableStdOut) outputInterceptor = internal.NoopOutputInterceptor{} diff --git a/types/config.go b/types/config.go index 97a049e0c..40406747a 100644 --- a/types/config.go +++ b/types/config.go @@ -115,7 +115,16 @@ func (rc ReporterConfig) WillGenerateReport() bool { } func NewDefaultReporterConfig() ReporterConfig { - return ReporterConfig{} + c := ReporterConfig{} + + if value, present := os.LookupEnv("GINGKO_COLOR"); present { + b, err := strconv.ParseBool(value) + if err == nil { + c.NoColor = !b + } + } + + return c } // Configuration for the Ginkgo CLI