Skip to content

test: add color tag rendering coverage (framework#1571) - #158

Open
goravel-coder wants to merge 1 commit into
masterfrom
implement/2026-10-15-pr1571-color-tags
Open

goravel-coder wants to merge 1 commit into
masterfrom
implement/2026-10-15-pr1571-color-tags

Conversation

@goravel-coder

Copy link
Copy Markdown
Contributor

Summary

  • Bumps github.com/goravel/framework to v1.18.1-0.20261013093243-4da928651f19, the head of framework PR #1571, restoring <red> / <fg=green> color-tag rendering that pterm v0.12.84 had dropped.
  • Adds a test:console-color example command and feature tests asserting tagged output renders to ANSI instead of leaking into the terminal as literal text.
  • Covers color.StripColor, color.Disable() / color.Enable() toggling, and TwoColumnDetail measuring tagged text by its rendered width so colored columns stay aligned.

Why

Goravel renders console color tags such as <fg=green>ok</> through gookit/color. Framework PR #1571 ("restore color tag rendering for pterm v0.12.84 via gookit/color") re-added gookit/color v1.6.1 as a direct dependency after pterm v0.12.84 stopped bundling it, so tags are parsed again instead of leaking as literal text. This branch bumps the example app to that PR head and confirms the restored behavior from the example app itself, so a future dependency update cannot silently regress it. The bump also pulls in the PR head's transitive dependency drift: gookit/color v1.6.1, pterm v0.12.84, go-runewidth v0.0.31, and the newer otel/x/grpc versions that commit requires.

package commands

import (
	"github.com/goravel/framework/contracts/console"
	"github.com/goravel/framework/contracts/console/command"
	supportconsole "github.com/goravel/framework/support/console"
)

type ConsoleColorCommand struct{}

func (r *ConsoleColorCommand) Signature() string {
	return "test:console-color"
}

func (r *ConsoleColorCommand) Description() string {
	return "Verify color tag rendering through gookit/color (framework#1571)"
}

func (r *ConsoleColorCommand) Extend() command.Extend {
	return command.Extend{Category: "console"}
}

func (r *ConsoleColorCommand) Handle(ctx console.Context) error {
	ctx.Info("<fg=green>Application is healthy</>")
	ctx.Warning("<fg=yellow>Queue worker is not running</>")
	ctx.Success("<green>Migration finished</>")
	ctx.Error("<fg=red>Cache connection failed</>")

	ctx.Line(supportconsole.TwoColumnDetail("<fg=cyan>cache</>", "<fg=green>OK</>"))

	return nil
}

Before the fix, tags were printed literally, so colored output had to be pre-rendered by hand, and support/console measured column widths on the raw tag text, which skewed alignment. After the fix, tags resolve to ANSI and widths are measured on the rendered text, so tagged and pre-colored forms produce identical layout.

// Before: tags leaked as literal text, so colors had to be pre-rendered by hand.
ctx.Info(color.Green().Sprint("Application is healthy"))
ctx.Line(supportconsole.TwoColumnDetail("<fg=cyan>cache</>", color.Green().Sprint("OK")))

// After: tags render through gookit/color and are measured on the rendered width.
ctx.Info("<fg=green>Application is healthy</>")
ctx.Line(supportconsole.TwoColumnDetail("<fg=cyan>cache</>", "<fg=green>OK</>"))

Note: the tests/feature suite boots Artisan with --no-ansi, which latches color off for the whole process, so TestRunColorCommand performs a discarded warm-up run to clear that flag before the asserted run.

Bump github.com/goravel/framework to v1.18.1-0.20261013093243-4da928651f19
(head of framework PR #1571) and add the `test:console-color` command plus
feature tests confirming gookit-based tag rendering, StripColor, disable/enable
toggling, and TwoColumnDetail width measurement.

The framework bump also pulls in the PR head's transitive dependency drift
(gookit/color v1.6.1, pterm v0.12.84, go-runewidth v0.0.31, and the newer
otel/x/grpc versions required by that commit).
@goravel-coder
goravel-coder requested a review from a team as a code owner October 15, 2026 10:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant