---
phase: 23-diff-and-show-flags
plan: 02
type: execute
wave: 2
depends_on: [23-01]
files_modified: [tests/test_diff_flags.py, tests/test_show_flags.py]
autonomous: true

must_haves:
  truths:
    - "All 12 DIFF requirements have E2E test coverage"
    - "All 8 SHOW requirements have E2E test coverage"
    - "pytest runs all tests successfully"
    - "Warning messages are verified in tests"
  artifacts:
    - path: "tests/test_diff_flags.py"
      provides: "E2E tests for diff flag requirements"
      min_lines: 150
    - path: "tests/test_show_flags.py"
      provides: "E2E tests for show flag requirements"
      min_lines: 100
  key_links:
    - from: "tests/test_diff_flags.py"
      to: "cmd_diff.py"
      via: "subprocess invocation of gitsl diff"
      pattern: "gitsl.*diff"
    - from: "tests/test_show_flags.py"
      to: "cmd_show.py"
      via: "subprocess invocation of gitsl show"
      pattern: "gitsl.*show"
---

<objective>
Create comprehensive E2E tests for all diff and show flag requirements.

Purpose: Validate that all 20 requirements (DIFF-01 through DIFF-12, SHOW-01 through SHOW-08) work correctly through the full gitsl execution path. Tests verify both successful flag translation and proper warning messages.

Output: Two test files covering all diff and show flag behaviors with requirement traceability.
</objective>

<execution_context>
@~/.claude/get-shit-done/workflows/execute-plan.md
@~/.claude/get-shit-done/templates/summary.md
</execution_context>

<context>
@.planning/PROJECT.md
@.planning/ROADMAP.md
@.planning/STATE.md
@.planning/phases/23-diff-and-show-flags/23-RESEARCH.md
@.planning/phases/23-diff-and-show-flags/23-01-SUMMARY.md

# Reference for test patterns
@tests/conftest.py
</context>

<tasks>

<task type="auto">
  <name>Task 1: Create E2E tests for diff flags (DIFF-01 through DIFF-12)</name>
  <files>tests/test_diff_flags.py</files>
  <action>
Create comprehensive E2E tests for all 12 diff flag requirements following the established test patterns.

**Test structure:**
```python
"""E2E tests for git diff flag support (DIFF-01 through DIFF-12)."""

import pytest
import subprocess
import os

# Use sl_repo fixture from conftest.py for Sapling repo setup
```

**Direct pass-through tests (DIFF-01, 02, 03):**
- `test_diff_stat_DIFF_01`: Run `gitsl diff --stat` in repo with changes, verify output contains diffstat format (insertions/deletions summary)
- `test_diff_ignore_all_space_DIFF_02`: Create file with whitespace changes, verify `-w` produces empty diff when only whitespace differs
- `test_diff_ignore_space_change_DIFF_03`: Similar to DIFF-02 but with `-b` flag

**Context lines test (DIFF-04):**
- `test_diff_unified_attached_DIFF_04`: Test `-U5` attached format
- `test_diff_unified_separate_DIFF_04`: Test `-U 5` separate format
- `test_diff_unified_equals_DIFF_04`: Test `--unified=5` format

**Name output tests (DIFF-05, 06):**
- `test_diff_name_only_DIFF_05`: Verify `--name-only` outputs only filenames (from sl status)
- `test_diff_name_status_DIFF_06`: Verify `--name-status` outputs status+filename format

**Warning tests - capture stderr (DIFF-07 through DIFF-12):**
- `test_diff_staged_warning_DIFF_07`: Run `gitsl diff --staged`, verify stderr contains "staging area" warning
- `test_diff_cached_warning_DIFF_07`: Same for `--cached` alias
- `test_diff_raw_warning_DIFF_08`: Run `gitsl diff --raw`, verify warning
- `test_diff_find_renames_warning_DIFF_09`: Run `gitsl diff -M`, verify warning mentions "sl mv"
- `test_diff_find_copies_warning_DIFF_10`: Run `gitsl diff -C`, verify warning mentions "sl copy"
- `test_diff_word_diff_warning_DIFF_11`: Run `gitsl diff --word-diff`, verify warning
- `test_diff_color_moved_warning_DIFF_12`: Run `gitsl diff --color-moved`, verify warning

**Test patterns:**
- Use `subprocess.run(['python', 'gitsl.py', 'diff', ...], capture_output=True, text=True)`
- For warning tests: check `result.stderr` contains expected warning text
- For success tests: check `result.returncode == 0`
- Create actual file changes in sl_repo fixture before running diff
  </action>
  <verify>
1. `pytest tests/test_diff_flags.py -v` passes all tests
2. File has 150+ lines
3. Each test function name includes requirement ID (e.g., DIFF_01)
  </verify>
  <done>
- 12 test functions covering DIFF-01 through DIFF-12
- All tests pass with exit code 0
- Warning tests verify stderr contains correct warning text
- Each test is traceable to its requirement
  </done>
</task>

<task type="auto">
  <name>Task 2: Create E2E tests for show flags (SHOW-01 through SHOW-08)</name>
  <files>tests/test_show_flags.py</files>
  <action>
Create comprehensive E2E tests for all 8 show flag requirements following the established test patterns.

**Test structure:**
```python
"""E2E tests for git show flag support (SHOW-01 through SHOW-08)."""

import pytest
import subprocess
import os

# Use sl_repo fixture from conftest.py for Sapling repo setup with commits
```

**Direct pass-through tests (SHOW-01, 02, 03):**
- `test_show_stat_SHOW_01`: Run `gitsl show --stat`, verify output contains diffstat format
- `test_show_context_lines_SHOW_02`: Run `gitsl show -U3`, verify context lines in diff output
- `test_show_ignore_whitespace_SHOW_03`: Run `gitsl show -w`, verify execution succeeds

**Template output tests (SHOW-04 through SHOW-08):**
- `test_show_name_only_SHOW_04`: Verify `--name-only` outputs commit header + file names only
- `test_show_name_status_SHOW_05`: Verify `--name-status` outputs commit header + status+filename
- `test_show_pretty_oneline_SHOW_06`: Run `gitsl show --pretty=oneline`, verify short format
- `test_show_pretty_short_SHOW_06`: Run `gitsl show --pretty=short`, verify format
- `test_show_format_custom_SHOW_06`: Run `gitsl show --format=format:%h %s`, verify placeholder translation
- `test_show_no_patch_SHOW_07`: Run `gitsl show -s`, verify NO diff output (only commit info)
- `test_show_no_patch_long_SHOW_07`: Run `gitsl show --no-patch`, same as `-s`
- `test_show_oneline_SHOW_08`: Run `gitsl show --oneline`, verify short one-line format

**Test setup:**
- Tests need at least one commit in the repo
- Create a commit with a modified file so there's something to show
- Use sl_repo fixture and create initial commit in test setup

**Test patterns:**
- Use `subprocess.run(['python', 'gitsl.py', 'show', ...], capture_output=True, text=True)`
- For format tests: verify output matches expected template format
- For -s/--no-patch: verify output does NOT contain diff markers (@@, +, -)
- All tests should have exit code 0
  </action>
  <verify>
1. `pytest tests/test_show_flags.py -v` passes all tests
2. File has 100+ lines
3. Each test function name includes requirement ID (e.g., SHOW_01)
  </verify>
  <done>
- 10+ test functions covering SHOW-01 through SHOW-08 (some requirements have multiple tests)
- All tests pass with exit code 0
- Template tests verify output format matches expectations
- -s/--no-patch tests verify diff is suppressed
- Each test is traceable to its requirement
  </done>
</task>

<task type="auto">
  <name>Task 3: Verify all tests pass together</name>
  <files>tests/test_diff_flags.py, tests/test_show_flags.py</files>
  <action>
Run the full test suite to ensure:
1. Both new test files pass independently
2. All existing tests still pass (no regressions)
3. Total test coverage includes all 20 requirements

```bash
# Run new tests
pytest tests/test_diff_flags.py tests/test_show_flags.py -v

# Run full test suite
pytest tests/ -v --tb=short
```

If any tests fail, debug and fix the implementation or test as needed.
  </action>
  <verify>
1. `pytest tests/test_diff_flags.py tests/test_show_flags.py -v` shows all tests passing
2. `pytest tests/ -v --tb=short` shows no regressions
3. No errors or failures in output
  </verify>
  <done>
- All new diff flag tests pass
- All new show flag tests pass
- No regressions in existing test suite
- Test coverage includes all 20 Phase 23 requirements
  </done>
</task>

</tasks>

<verification>
After completing all tasks:

1. **Test count verification:**
   ```bash
   cd /Users/vmakaev/NonWork/gitsl
   pytest tests/test_diff_flags.py tests/test_show_flags.py --collect-only | grep "test_" | wc -l
   # Should be 20+ tests (some requirements have multiple tests)
   ```

2. **Full test run:**
   ```bash
   pytest tests/test_diff_flags.py tests/test_show_flags.py -v
   # All tests should pass
   ```

3. **Requirement coverage check:**
   ```bash
   grep -E "DIFF_[0-9]+" tests/test_diff_flags.py | wc -l
   # Should be 12+ (one per DIFF requirement)
   grep -E "SHOW_[0-9]+" tests/test_show_flags.py | wc -l
   # Should be 8+ (one per SHOW requirement)
   ```

4. **No regressions:**
   ```bash
   pytest tests/ -v --tb=short
   # All tests pass, including existing tests
   ```
</verification>

<success_criteria>
1. tests/test_diff_flags.py exists with 12+ test functions
2. tests/test_show_flags.py exists with 8+ test functions
3. All test function names include requirement IDs for traceability
4. All tests pass when run with pytest
5. Warning tests verify stderr contains correct warning messages
6. No regressions in existing test suite
</success_criteria>

<output>
After completion, create `.planning/phases/23-diff-and-show-flags/23-02-SUMMARY.md`
</output>
