From 20a2e77e19ac1d0941438eafbaf1d77d7dbc9701 Mon Sep 17 00:00:00 2001 From: Virgil Date: Thu, 2 Apr 2026 17:56:01 +0000 Subject: [PATCH] fix(cli): restore glyph theme after stateful tests Co-Authored-By: Virgil --- pkg/cli/ansi_test.go | 3 +++ pkg/cli/check_test.go | 3 +++ pkg/cli/glyph_test.go | 6 ++++++ pkg/cli/output_test.go | 3 +++ 4 files changed, 15 insertions(+) diff --git a/pkg/cli/ansi_test.go b/pkg/cli/ansi_test.go index 1e52169..8674718 100644 --- a/pkg/cli/ansi_test.go +++ b/pkg/cli/ansi_test.go @@ -112,6 +112,7 @@ func TestUseUnicodeAndEmojiRestoreColorsAfterASCII(t *testing.T) { } func TestRender_NilStyle_Good(t *testing.T) { + restoreThemeAndColors(t) var s *AnsiStyle got := s.Render("test") if got != "test" { @@ -120,6 +121,7 @@ func TestRender_NilStyle_Good(t *testing.T) { } func TestAnsiStyle_Bad(t *testing.T) { + restoreThemeAndColors(t) original := ColorEnabled() defer SetColorEnabled(original) @@ -140,6 +142,7 @@ func TestAnsiStyle_Bad(t *testing.T) { } func TestAnsiStyle_Ugly(t *testing.T) { + restoreThemeAndColors(t) original := ColorEnabled() defer SetColorEnabled(original) diff --git a/pkg/cli/check_test.go b/pkg/cli/check_test.go index a46b42f..6354862 100644 --- a/pkg/cli/check_test.go +++ b/pkg/cli/check_test.go @@ -6,6 +6,7 @@ import ( ) func TestCheckBuilder_Good(t *testing.T) { + restoreThemeAndColors(t) UseASCII() // Deterministic output checkResult := Check("database").Pass() @@ -19,6 +20,7 @@ func TestCheckBuilder_Good(t *testing.T) { } func TestCheckBuilder_Bad(t *testing.T) { + restoreThemeAndColors(t) UseASCII() checkResult := Check("lint").Fail() @@ -41,6 +43,7 @@ func TestCheckBuilder_Bad(t *testing.T) { } func TestCheckBuilder_Ugly(t *testing.T) { + restoreThemeAndColors(t) UseASCII() // Zero-value builder should not panic. diff --git a/pkg/cli/glyph_test.go b/pkg/cli/glyph_test.go index bc9978e..219ee60 100644 --- a/pkg/cli/glyph_test.go +++ b/pkg/cli/glyph_test.go @@ -3,6 +3,7 @@ package cli import "testing" func TestGlyph_Good(t *testing.T) { + restoreThemeAndColors(t) UseUnicode() if Glyph(":check:") != "✓" { t.Errorf("Expected ✓, got %s", Glyph(":check:")) @@ -15,6 +16,7 @@ func TestGlyph_Good(t *testing.T) { } func TestGlyph_Bad(t *testing.T) { + restoreThemeAndColors(t) // Unknown shortcode returns the shortcode unchanged. UseUnicode() got := Glyph(":unknown:") @@ -24,6 +26,7 @@ func TestGlyph_Bad(t *testing.T) { } func TestGlyph_Ugly(t *testing.T) { + restoreThemeAndColors(t) // Empty shortcode should not panic. got := Glyph("") if got != "" { @@ -32,6 +35,7 @@ func TestGlyph_Ugly(t *testing.T) { } func TestCompileGlyphs_Good(t *testing.T) { + restoreThemeAndColors(t) UseUnicode() got := compileGlyphs("Status: :check:") if got != "Status: ✓" { @@ -40,6 +44,7 @@ func TestCompileGlyphs_Good(t *testing.T) { } func TestCompileGlyphs_Bad(t *testing.T) { + restoreThemeAndColors(t) UseUnicode() // Text with no shortcodes should be returned as-is. got := compileGlyphs("no glyphs here") @@ -49,6 +54,7 @@ func TestCompileGlyphs_Bad(t *testing.T) { } func TestCompileGlyphs_Ugly(t *testing.T) { + restoreThemeAndColors(t) // Empty string should not panic. got := compileGlyphs("") if got != "" { diff --git a/pkg/cli/output_test.go b/pkg/cli/output_test.go index 9dbf400..dcc3f41 100644 --- a/pkg/cli/output_test.go +++ b/pkg/cli/output_test.go @@ -27,6 +27,7 @@ func captureOutput(f func()) string { } func TestSemanticOutput_Good(t *testing.T) { + restoreThemeAndColors(t) UseASCII() SetColorEnabled(false) defer SetColorEnabled(true) @@ -52,6 +53,7 @@ func TestSemanticOutput_Good(t *testing.T) { } func TestSemanticOutput_Bad(t *testing.T) { + restoreThemeAndColors(t) UseASCII() SetColorEnabled(false) defer SetColorEnabled(true) @@ -74,6 +76,7 @@ func TestSemanticOutput_Bad(t *testing.T) { } func TestSemanticOutput_Ugly(t *testing.T) { + restoreThemeAndColors(t) UseASCII() // Severity with various levels should not panic.