aports/testing/git-bug/fix-tests.patch
2023-07-13 00:57:57 +02:00

40 lines
1.3 KiB
Diff

See:
* https://github.com/MichaelMure/git-bug/issues/926
* https://github.com/MichaelMure/git-bug/pull/984
diff --git a/commands/add_test.go b/commands/add_test.go
index 077995a6..d603e79a 100644
--- a/commands/add_test.go
+++ b/commands/add_test.go
@@ -4,12 +4,29 @@ import (
"strings"
"testing"
+ "github.com/fatih/color"
"github.com/stretchr/testify/require"
)
func newTestEnvAndBug(t *testing.T) (*testEnv, string) {
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, _ := newTestEnvAndUser(t)
opts := addOptions{
title: "this is a bug title",