Skip to content

Conversation

@timvw
Copy link
Owner

@timvw timvw commented Dec 2, 2025

Summary

  • Added PowerShell PTY test harness (newPtyPowerShell) similar to bash/zsh
  • Created interactive and non-interactive PowerShell tests
  • Enabled Windows e2e tests in CI workflow for both powershell and pwsh

Changes

  1. e2e_interactive_test.go:

    • Added newPtyPowerShell() to spawn PowerShell in a PTY
    • Added TestInteractiveCheckoutWithoutArgsPowerShell()
    • Added TestNonInteractiveCheckoutWithArgsPowerShell()
  2. .github/workflows/ci.yml:

    • Replaced disabled Windows job with active e2e-windows job
    • Tests run on windows-latest with matrix for powershell and pwsh

Known Issue

The PowerShell shellenv function currently uses direct wt.exe invocation without a PTY wrapper (unlike bash/zsh which use script(1)). This means interactive tests will likely fail until we add an equivalent PTY wrapper for Windows.

Next step: Add Windows PTY wrapper to PowerShell shellenv (similar to how bash/zsh use script command).

Test Plan

  • Added PTY test harness for PowerShell
  • Enabled Windows CI tests
  • Windows interactive tests pass (blocked on PTY wrapper)

🤖 Generated with Claude Code

timvw and others added 4 commits December 2, 2025 21:08
Added PowerShell PTY support to e2e_interactive_test.go:
- newPtyPowerShell() function to spawn PowerShell in a PTY
- TestInteractiveCheckoutWithoutArgsPowerShell() for interactive prompt testing
- TestNonInteractiveCheckoutWithArgsPowerShell() for explicit branch checkout

Enabled Windows e2e tests in CI workflow:
- Added e2e-windows job for windows-latest runners
- Tests both powershell and pwsh shells
- Uses PTY for true interactive testing like macOS/Linux

Note: PowerShell shellenv still uses direct wt.exe invocation without
PTY wrapper (unlike bash/zsh). Interactive tests will likely fail until
we add a PTY wrapper similar to the script(1) approach used on Unix.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Added interactive terminal detection to PowerShell shellenv function:
- Uses [Console]::IsOutputRedirected to detect if running in a real terminal
- Interactive mode: Runs wt.exe directly with Tee-Object to preserve TTY/PTY
- Non-interactive mode: Captures output normally
- Both modes: Extracts TREE_ME_CD marker from temp file for auto-cd

This is the PowerShell equivalent of the Unix script(1) approach used in
bash/zsh. It allows promptui interactive menus to work correctly by
preserving the TTY connection while still capturing output for auto-cd.

References:
- https://powershellmagazine.com/2013/05/13/pstip-detecting-if-the-console-is-in-interactive-mode/
- https://superuser.com/questions/900032/detect-powershell-function-input-is-redirected

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

Co-Authored-By: Claude <noreply@anthropic.com>
Fixed PowerShell error:
  Cannot convert 'System.Object[]' to the type 'System.String'  required by parameter 'Command'

The issue was using `Invoke-Expression (& 'wt' shellenv)` which tries
to pass an array to Invoke-Expression.

Changed to: `& 'wt' shellenv | Invoke-Expression`
This pipes the output line-by-line to Invoke-Expression, which handles
it correctly.

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

Co-Authored-By: Claude <noreply@anthropic.com>
PowerShell tests can only run on Windows because:
- shellenv detects OS at compile time (runtime.GOOS)
- On macOS/Linux, shellenv outputs bash/zsh syntax
- PowerShell cannot execute bash/zsh shell functions

Added platform check using filepath.Separator to skip PowerShell
tests on Unix platforms. Tests will only run on Windows where
shellenv outputs PowerShell syntax.

Verified locally on macOS:
- PowerShell tests skip correctly
- Bash/zsh tests continue to pass

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

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

codecov bot commented Dec 2, 2025

Codecov Report

❌ Patch coverage is 0% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 19.49%. Comparing base (f0ebfa8) to head (5baaceb).

Files with missing lines Patch % Lines
main.go 0.00% 22 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #23      +/-   ##
==========================================
- Coverage   20.17%   19.49%   -0.68%     
==========================================
  Files           1        1              
  Lines         461      477      +16     
==========================================
  Hits           93       93              
- Misses        362      378      +16     
  Partials        6        6              
Files with missing lines Coverage Δ
main.go 19.49% <0.00%> (-0.68%) ⬇️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

timvw and others added 4 commits December 2, 2025 21:28
Changed shellenv from compile-time OS detection (runtime.GOOS) to runtime
shell detection by checking for the PSModulePath environment variable.

Benefits:
- PowerShell Core (pwsh) now works on macOS, Linux, and Windows
- Tests can run on any platform where PowerShell is installed
- No platform-specific test skipping needed

Changes:
1. main.go:
   - Removed runtime import (no longer needed)
   - Check PSModulePath env var instead of runtime.GOOS
   - Output PowerShell syntax if PSModulePath is set
   - Output bash/zsh syntax otherwise

2. e2e_interactive_test.go:
   - Removed platform checks (filepath.Separator)
   - Updated PowerShell initialization to use Out-String
   - Fixed: & wt shellenv | Out-String | Invoke-Expression

Verified locally on macOS:
- PowerShell (pwsh): shellenv outputs PowerShell syntax ✓
- Bash: shellenv outputs bash/zsh syntax ✓
- PowerShell tests skip if pwsh not available ✓

Note: PowerShell e2e tests load shellenv successfully but command
execution needs debugging. Will address in follow-up commit.

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

Co-Authored-By: Claude <noreply@anthropic.com>
Added comprehensive PowerShell setup guide to README:
- How to add shellenv to $PROFILE
- How to find and edit profile location
- Verification steps (Get-Command wt)
- Cross-platform notes (Windows, macOS, Linux)

Restructured Shell Integration section:
- Separate subsections for Bash/Zsh and PowerShell
- Clear platform guidance
- Step-by-step instructions for PowerShell users

Key instruction:
  & wt shellenv | Out-String | Invoke-Expression

This enables auto-cd and interactive prompts in PowerShell.

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

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

Fixed two critical issues in PowerShell shellenv function:

1. Removed hardcoded wt.exe references (doesn't exist on Unix)
2. Used Get-Command wt -CommandType Application to find executable
   - Avoids infinite recursion (function calling itself)
   - Works on Windows (finds wt.exe) and Unix (finds wt)

Before: PowerShell shellenv was broken on macOS/Linux
After: PowerShell works on all platforms where pwsh is installed

Verified locally on macOS:
- wt version: ✓ works
- wt list: ✓ works
- Function correctly wraps executable

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

Co-Authored-By: Claude <noreply@anthropic.com>
Added PowerShell (pwsh) to test matrix for cross-platform testing:

**macOS runners:**
- Added 'pwsh' to shell matrix (bash, zsh, pwsh)
- Install PowerShell via homebrew if needed
- Run PowerShell PTY interactive tests

**Linux (Ubuntu) runners:**
- Install PowerShell 7.4.6 from official .deb package
- PowerShell tests now run alongside bash/zsh tests
- All PTY tests (bash, zsh, pwsh) execute on Linux

**Shellenv validation:**
- Updated validation to handle PowerShell syntax ("function wt" vs "wt()")
- Check for PowerShell-specific features (Get-Command, PowerShell integration)

This enables testing the new cross-platform PowerShell shellenv on all platforms,
not just Windows. Now we have:
- Linux: bash, zsh, pwsh ✓
- macOS: bash, zsh, pwsh ✓
- Windows: pwsh, powershell ✓

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

Co-Authored-By: Claude <noreply@anthropic.com>
@timvw timvw enabled auto-merge December 2, 2025 21:15
@timvw timvw disabled auto-merge December 2, 2025 21:16
@timvw
Copy link
Owner Author

timvw commented Dec 3, 2025

Closing in favor of merged PR #24

@timvw timvw closed this Dec 3, 2025
@timvw timvw deleted the enable-windows-pty-tests branch December 3, 2025 08:00
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.

2 participants