diff options
author | Michael Muré <batolettre@gmail.com> | 2023-01-08 12:12:51 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-08 12:12:51 +0100 |
commit | 978552bb69e742e9e81ddc2ebb66e1e12dba91fe (patch) | |
tree | bc9b44d46271348e8f0f25744a41616ad1a059fd /commands/bug | |
parent | c7662a13acf6db50a45d22e70e7beac3276fe784 (diff) | |
parent | e4707cd8d5d9de4d4f8b7d7213596c764c6dc0ba (diff) | |
download | git-bug-978552bb69e742e9e81ddc2ebb66e1e12dba91fe.tar.gz |
Merge pull request #984 from MichaelMure/fix/926/tests-fail-with-color
fix(commands): run tests in ./commands/... without ANSI color
Diffstat (limited to 'commands/bug')
-rw-r--r-- | commands/bug/testenv/testenv.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/commands/bug/testenv/testenv.go b/commands/bug/testenv/testenv.go index acd1f389..ffa428d4 100644 --- a/commands/bug/testenv/testenv.go +++ b/commands/bug/testenv/testenv.go @@ -3,6 +3,7 @@ package testenv import ( "testing" + "github.com/fatih/color" "github.com/stretchr/testify/require" "github.com/MichaelMure/git-bug/commands/execenv" @@ -17,6 +18,22 @@ const ( func NewTestEnvAndUser(t *testing.T) (*execenv.Env, entity.Id) { t.Helper() + // The Go testing framework either uses os.Stdout directly or a buffer + // depending on how the command is initially launched. This results + // in os.Stdout.Fd() sometimes being a Terminal, and other times not + // being a Terminal which determines whether the ANSI library sends + // escape sequences to colorize the text. + // + // The line below disables all colorization during testing so that the + // git-bug command output is consistent in all test scenarios. + // + // See: + // - https://github.com/MichaelMure/git-bug/issues/926 + // - https://github.com/golang/go/issues/57671 + // - https://github.com/golang/go/blob/f721fa3be9bb52524f97b409606f9423437535e8/src/cmd/go/internal/test/test.go#L1180-L1208 + // - https://github.com/golang/go/issues/34877 + color.NoColor = true + testEnv := execenv.NewTestEnv(t) i, err := testEnv.Backend.Identities().New(testUserName, testUserEmail) |