Skip to content

Fix ambiguous explain-flag test assertion and build failure in interactive mode - #31

Merged
kriserickson merged 2 commits into
add-explainfrom
copilot/sub-pr-27-another-one
Mar 1, 2026
Merged

kriserickson merged 2 commits into
add-explainfrom
copilot/sub-pr-27-another-one

Conversation

Copilot AI commented Mar 1, 2026 •

Copy link
Copy Markdown
Contributor

TestRunWithExplainTrue asserted on "explain-test", which also appeared in the command's own output (echo explain-test), making the test vacuously pass even with broken explanation logic. Additionally, fatih/color's Printf writes to a package-level Output captured at init time, bypassing os.Stdout redirects in tests entirely.

Changes

  • internal/executor/executor.go: Switch dimColor.Printf(...) → dimColor.Fprintf(os.Stdout, ...) so explanation output goes to the current os.Stdout, making it capturable via pipe redirect in tests.

  • internal/executor/executor_test.go: Use a command (echo hello) whose output cannot overlap with the explanation, and assert on a unique explanationText constant:

    const explanationText = "Unique explanation string that only appears in the explanation output."
    // ...
    if !strings.Contains(output, explanationText) { ... }
  • internal/config/config.go: Add Explain bool \toml:"-"`toConfig— runtime-only, not persisted — to resolve the build failure whererepl.goreferencedcfg.Explain` without the field existing.

  • cmd/root.go: Set cfg.Explain = explainFlag before entering interactive mode so the flag propagates through the REPL path.


🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.

Co-authored-by: kriserickson <325934+kriserickson@users.noreply.github.com>
Copilot AI changed the title [WIP] WIP to address feedback on previous PR for explain flag Fix ambiguous explain-flag test assertion and build failure in interactive mode Mar 1, 2026
@kriserickson
kriserickson marked this pull request as ready for review March 1, 2026 20:25
Copilot AI review requested due to automatic review settings March 1, 2026 20:25
@kriserickson
kriserickson merged commit 90bcf86 into add-explain Mar 1, 2026
@kriserickson
kriserickson deleted the copilot/sub-pr-27-another-one branch March 1, 2026 20:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a vacuously-passing --explain test and resolves an interactive-mode build failure by ensuring explanation output is capturable via os.Stdout redirection and by plumbing the explain flag through interactive configuration.

Changes:

  • Make executor explanation output write to the current os.Stdout so tests can capture it.
  • Strengthen TestRunWithExplainTrue by using a non-overlapping command output and asserting on a unique explanation string.
  • Add a runtime-only Config.Explain field and propagate --explain into interactive mode.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.

File Description
internal/executor/executor.go Sends explanation output to os.Stdout (capturable in tests / redirectable).
internal/executor/executor_test.go Removes ambiguous assertion by using unique explanation text and echo hello.
internal/config/config.go Adds Config.Explain as a non-persisted runtime flag carrier.
cmd/root.go Sets cfg.Explain before entering interactive mode so REPL execution respects --explain.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

3 participants