Commit Graph

11 Commits

Author SHA1 Message Date
Worktrunk Bot 7735d115ce fix(tests): restore hidden-subcommand completion coverage (#3492) 2026-07-16 01:24:55 -07:00
Maximilian Roos 87321281d4 Replace --internal flag with WORKTRUNK_DIRECTIVE_FILE environment variable (#269)
* Replace --internal flag with WT_DIRECTIVE_FILE environment variable

* Rename directive file environment variable to WORKTRUNK_DIRECTIVE_FILE

* Update stale comments referencing directive scripts

Codex review identified comments that still referenced "directive scripts"
after migrating to file-based directive passing. Updated to reference
"data output" which is the current terminology.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Address documentation review feedback

- Add WORKTRUNK_DIRECTIVE_FILE to env var tables (cli.rs, config.md)
- Update stale "directive mode" terminology in test comments to use
  "shell integration" or "data output" as appropriate
- Regenerate help snapshot

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* Refactor progressive table output to use output module

Remove finalize_non_tty method and simplify non-TTY output path to use
output::table() directly, consistent with buffered mode. Add WORKTRUNK_SHELL
environment variable support for PowerShell-specific path escaping. Update
documentation and templates accordingly.

* Preserve directive script exit code in PowerShell

Add logic to use the directive script's exit code when wt succeeds, and
add redaction for WORKTRUNK_DIRECTIVE_FILE in test snapshots.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-20 21:33:25 -08:00
Maximilian Roos bc0502ff09 Rename _EMOJI constants to _SYMBOL
Completes the emoji → symbol migration by renaming all constants
from _EMOJI to _SYMBOL naming convention:

- SUCCESS_EMOJI → SUCCESS_SYMBOL
- ERROR_EMOJI → ERROR_SYMBOL
- PROGRESS_EMOJI → PROGRESS_SYMBOL
- WARNING_EMOJI → WARNING_SYMBOL
- HINT_EMOJI → HINT_SYMBOL
- INFO_EMOJI → INFO_SYMBOL
- PROMPT_EMOJI → PROMPT_SYMBOL

Also renames .emoji() methods to .symbol() in configure_shell.rs
and removes legacy _EMOJI aliases from constants.rs.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-19 17:46:08 -08:00
Maximilian Roos 798e7cfd49 Add black-box completion tests for zsh, bash, and fish (#117)
Replace implementation-specific validation (parsing sed patterns) with
black-box snapshot tests that verify actual completion output.

Each test:
- Sources the real shell integration script
- Triggers the completion pipeline
- Snapshots what users would see

Removes ZshDescribeSyntax validation that was checking implementation details.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude <noreply@anthropic.com>
2025-12-08 15:14:14 -08:00
Maximilian Roos 6ae9d0f939 Fix zsh _describe syntax and add validation tests
The sed command was incorrectly passing arguments to the -V flag, which
does not accept arguments in zsh's _describe function. The -V flag only
sets a flag for unsorted groups; the actual nosort behavior is handled
internally by _describe when passed to compadd.

Add validation tests to catch invalid _describe syntax patterns in
future changes, including checks for improper flag arguments and invalid
option combinations.
2025-12-08 14:20:16 -08:00
Maximilian Roos 7a05a54aaa Refactor: Replace expect with unwrap in tests
Replaces most uses of `.expect(...)` with `.unwrap()` in test code. This is a common pattern in Rust tests for operations that are expected to succeed, simplifying the code.
2025-11-23 21:00:31 -08:00
Maximilian Roos 7ca9f3596c refactor: Rename config init to config create 2025-11-21 03:36:47 -08:00
Maximilian Roos 81ace9ff03 refactor: Standardize CLI command setup for tests
This refactoring introduces `wt_command` and `configure_cli_command` helper functions in `tests/common/mod.rs` to centralize the setup of `wt` CLI commands in integration tests.

The new helpers ensure all test commands:
- Clear host `GIT_*` and `WORKTRUNK_*` environment variables.
- Force color output (`CLICOLOR_FORCE=1`) for consistent snapshot testing.
- Set a default terminal width of 150 columns (`COLUMNS=150`) if not already specified.

This change reduces duplication across integration tests by moving common command environment configuration into reusable functions. Existing calls to `Command::new(get_cargo_bin("wt"))` have been replaced with `wt_command()`, and manual environment variable settings have been replaced with calls to `configure_cli_command`.

A new helper `set_temp_home_env` is also introduced to simplify setting `HOME` and `XDG_CONFIG_HOME` for commands requiring an isolated home directory.
2025-11-06 15:23:41 -08:00
Maximilian Roos 37eab1182f chore(deps): bump multiple dependencies
Updates `aho-corasick`, `assert_cmd`, `clap`, `tree-sitter` and related crates.
Includes minor test refactors to align with `assert_cmd` API changes.
2025-10-31 00:04:34 -07:00
Maximilian Roos a1de883f53 Use SUCCESS_EMOJI constant for success messages
This change centralizes the "✅" emoji into a `SUCCESS_EMOJI` constant.
It replaces hardcoded instances across `config`, `configure_shell`, `merge`,
`worktree`, `main`, and `output` modules, ensuring consistent
display for successful operations.
2025-10-27 21:06:45 -07:00
Maximilian Roos 4acfd0459f Refactor: Improve completion filtering and add validation tests
This commit refactors the completion generation logic to filter out hidden commands and flags more robustly. It also introduces a new integration test module for validating shell completions across different shells.

The changes include:
- Modifying `handle_init` to iterate through completion lines and filter out hidden commands (`completion`, `complete`) and the `--internal` flag.
- Removing a redundant `complete -c wt -l base` line from the Fish shell template, as `clap` already generates this.
- Adding `completion_validation.rs` with functions to:
    - Validate Fish, Bash, and Zsh completions for hidden flags.
    - Extract flags from completion content for cross-shell consistency checks.
    - Perform cross-shell validation to ensure flags are consistent and hidden flags do not appear.
- Updating snapshot tests for Bash, Fish, and Zsh completions to reflect the filtering changes.
- Adding a specific test `test_fish_no_duplicate_base_completion` to ensure `--base` is not duplicated in Fish completions.

Co-authored-by: Claude <no-reply@anthropic.com>
2025-10-20 23:29:27 -07:00