# Testing
## Automated tests
`cargo test` runs two kinds of tests, and CI runs them on Windows, macOS and Ubuntu:
- Unit tests, next to the code they test. They use made-up input: fake process trees
(`procs::fake::FakeTable`) and invented environment variables, folders and ids.
- [tests/conventions.rs](../tests/conventions.rs), which checks the repository against the
rules in [CONVENTIONS.md](../CONVENTIONS.md) that a program can check.
## End-to-end tests
Each terminal has a manual checklist below. Run it once kaeru supports that terminal; the
[roadmap](../README.md#roadmap) says which ones it does.
Every checklist follows the same idea: open some tabs, close the whole terminal, open it again,
and check that the right tabs come back.
### Use a second copy of the terminal
Test in a separate copy of the terminal, so that you can close it completely without closing
the one you work in.
- Windows Terminal: download the portable zip (`Microsoft.WindowsTerminal_<version>_x64.zip`)
from the [releases page](https://github.com/microsoft/terminal/releases), check that
`WindowsTerminal.exe` is signed by Microsoft, and put an empty file named `.portable` next to
it, so that it keeps its own settings. In its settings, set
`"warning.confirmCloseAllTabs": false`, so that it closes without asking.
- macOS: each terminal app runs once, so test a terminal while you work in another one, such as
iTerm2 while you work in Terminal, and quit the one you test only.
- Linux: test a terminal while you work in another one, such as kitty while you work in GNOME
Terminal. A separate WSL distribution or virtual machine keeps the test away from your own
setup, and a virtual X display, such as Xvfb, runs the terminals without windows on your
screen.
### Windows Terminal
1. Run `kaeru install`. Start Codex once, trust the kaeru hook when it asks, and quit it. Open a
new tab in the test terminal: `kaeru doctor` reports no problems there.
2. In the test terminal, open four tabs:
- A: a shell in some folder;
- B: Claude Code in another folder, with one message sent;
- C: Codex in a third folder, with one message sent;
- D: a plain shell.
3. Close tab D, then open a new tab. `kaeru list` no longer shows D.
4. Close the whole test terminal window.
5. Open the test terminal again. The picker lists A, B and C, but not D.
6. Press Enter: every tab starts checked, so the checked tabs come back, one about every
second, in the order they were first opened, while the picker's tab shows `Reopening 1 of 3`
and so on. Then the picker's tab closes, so that the test terminal has three tabs. A comes
back in its folder, B comes back with `claude --resume`, and C comes back with
`codex resume`, all in the test terminal and not in your main one.
7. Run a command that fails, such as `Get-Item nothing-here`, in a tab with a prompt theme that
shows failures, such as oh-my-posh or starship. The prompt shows the failure.
8. Close the test terminal. The next time you're asked, press `a` to uncheck every tab, check
that the line above the keys says `forget`, and press Enter, to forget the test tabs.
To test adopting, take out kaeru's line with `kaeru uninstall`, keeping the notes, and open
three tabs in the test terminal: one PowerShell tab with Claude Code in some folder, with one
message sent, one Git Bash tab in another folder, and one Codex tab. On macOS and Linux, take a zsh or bash tab
for the PowerShell one, and a second zsh or bash tab for the Git Bash one. Then:
1. Run `kaeru install` in your other terminal. Its last question lists the three tabs: say yes.
Each tab gets a line, the Claude Code and Codex tabs with their sessions. Running
`kaeru adopt` right after finds nothing more.
2. `kaeru list` shows the three tabs, marked adopted, and `kaeru doctor` counts them.
3. In the Git Bash tab, go to another folder, then open a new tab. `kaeru list` shows the new
folder.
4. Close the test terminal and open it again. The list offers the three tabs. Press Enter: the
Claude Code and Codex sessions resume, and the Git Bash tab opens in its new folder.
Run the checklist twice for Codex: once with the `codex-no-daemon` option on, which you turn on
in `kaeru install`, and once with `codex-no-daemon = false` in kaeru's `config.toml`. In the
first run, C runs in its tab; in the second, Codex's shared background server runs it.
### Git Bash
Git Bash runs in Windows Terminal, with Git Bash's profile, and in its own windows (mintty). Test
both, in the test copy of Windows Terminal and in Git Bash windows that you open from the Start
menu.
1. Run `kaeru install`, and let it add its line to `~/.bashrc`. Open a new Git Bash window:
`kaeru doctor` reports no problems there, and says that the window is tracked.
2. In the test terminal, open two Git Bash tabs: E in some folder, and F with Claude Code in
another folder, with one message sent. Close the test terminal, and open it again with a Git
Bash tab. The picker lists E and F; press Enter. E comes back in its folder, and F comes back
with `claude --resume`. After you quit Claude Code in F, the tab is a bash to type in.
3. Open two Git Bash windows, G in some folder and H with Claude Code in another folder. In
kaeru's options (`o` in the picker, or `single-window-close = "offer"` in `config.toml`),
choose to offer closed single windows. Close both windows, and open a new Git Bash window.
The picker shows in it, through `winpty`; press Enter. G and H come back as Git Bash windows,
with Git Bash's icon, H with `claude --resume`, and the window that showed the picker closes.
4. Run a command that fails, such as `false`, in a tab with a prompt theme that shows failures,
such as starship. The prompt shows the failure.
5. Set the option back, and forget the test tabs as in step 8 above.
### Warp
Warp has no separate test copy, so use a Warp with nothing to keep, and close its tabs that
you don't need. Warp builds the `PATH` of its shells from the one Windows keeps, so in a Warp
tab, `claude` is the real Claude Code.
1. Run `kaeru install` if the profile line isn't there yet. Open a Warp tab: `kaeru doctor`
says that the tab of Warp is tracked.
2. In a Warp tab, start Claude Code and send one message. In a second tab, go to some folder.
3. Wait a minute or two, because Warp saves its tabs a while after they change. Then end Warp
and everything it started, as a crash or restart would, from a Windows Terminal tab:
`taskkill /F /T /IM warp.exe`. Ending only `warp.exe`, as `Stop-Process -Name warp` does,
leaves the tabs' shells and agents running without a window, and kaeru then rightly sees the
session as still running.
4. Start Warp. It brings back both tabs in their folders. The first tab says that it had a
Claude Code session and that `kaeru resume` resumes it. The second says nothing, and no tab
shows the list for these tabs.
5. Run `kaeru resume` in the first tab: the session comes back, with `claude --resume`. Run it
in the second tab: it says that no session waits there.
6. Repeat with a crash that leaves the tabs' programs running: end only Warp's process, with
`Stop-Process -Name warp -Force`. The first tab says that its session still runs without a
window. `kaeru resume` ends the hidden Claude Code and resumes the session in the tab.
### Terminal
1. Run `kaeru install`, and let it add its line to `~/.zshrc`. Open a new Terminal window:
`kaeru doctor` says that the tab of Terminal is tracked.
2. Open three tabs: A in some folder, B with Claude Code in another folder, with one message
sent, and C, a plain shell. Close C, then run `kaeru list` in A: it no longer shows C.
3. Quit Terminal with Cmd+Q, and answer Terminate if it asks. `kaeru list` in your other
terminal shows A and B waiting, with B as Claude Code.
4. Start Terminal. Its new window shows the list with A and B. Press Enter: A comes back in its
folder and B with `claude --resume`, each as a window of its own.
5. Make Terminal keep its windows when it quits: restart the Mac with "Reopen windows when
logging back in" checked, or quit with Option+Cmd+Q. When Terminal brings back A and B by
itself, B says that it had a Claude Code session, and no window shows the list. Run
`kaeru resume` in B: the session comes back.
6. End Terminal from your other terminal, as a crash would: `pkill -9 -x Terminal`. Start
Terminal: it brings back its windows, and B says that it had a session, as in step 5.
7. Run `false` in a tab with a prompt theme that shows failures, such as starship. The prompt
shows the failure.
### iTerm2
1. Run `kaeru install`, and let it add its line to `~/.zshrc`. Open a new iTerm2 tab:
`kaeru doctor` says that the tab of iTerm2 is tracked.
2. Open three tabs: A in some folder, B with Claude Code in another folder, with one message
sent, and C, a plain shell. Close C, then run `kaeru list` in A: it no longer shows C.
3. Quit iTerm2 with Cmd+Q, and answer Quit if it asks. Within a minute, `kaeru list` in your
other terminal shows A and B waiting, with B as Claude Code.
4. Start iTerm2. Its first tab shows the list with A and B. Press Enter: A comes back in its
folder, B comes back with `claude --resume`, and the list's tab closes. After you quit Claude
Code in B, the tab is a shell to type in.
5. With Claude Code running in B, end only iTerm2's process from your other terminal:
`pkill -9 -x iTerm2`. Start iTerm2: it brings B back with Claude Code still running, and no
tab shows the list.
6. Make iTerm2 keep its windows when it quits: restart the Mac with "Reopen windows when logging
back in" checked, or hold Option in the iTerm2 menu and choose Quit and Keep Windows when it
shows that item. When iTerm2 brings back A and B by itself, B says that it had a Claude Code
session, and no tab shows the list. Run `kaeru resume` in B: the session comes back. Run it in
A: it says that no session waits there.
7. Run `false` in a tab with a prompt theme that shows failures, such as starship. The prompt
shows the failure.
### Ghostty
1. Run `kaeru install`, and let it add its line to `~/.zshrc`. Open a new Ghostty tab:
`kaeru doctor` says that the tab of Ghostty is tracked. Unless your Ghostty config sets
`window-save-state = never`, it also reports that Ghostty brings back its own tabs. Add that
line to Ghostty's config, quit Ghostty and start it again: `kaeru doctor` reports no problem
with Ghostty.
2. Open three tabs: A in some folder, B with Claude Code in another folder, with one message
sent, and C, a plain shell. Close C, then run `kaeru list` in A: it no longer shows C.
3. Quit Ghostty with Cmd+Q, and answer Close Ghostty if it asks. `kaeru list` in your other
terminal shows A and B waiting, with B as Claude Code.
4. Start Ghostty. Its first tab shows the list with A and B. Press Enter: A comes back in its
folder, B comes back with `claude --resume`, and the list's tab closes.
5. End Ghostty from your other terminal, as a crash would: `pkill -9 -x ghostty`. Start Ghostty:
it brings no tab back by itself, and its first tab shows the list. Press Enter, as in step 4.
6. Run `false` in a tab with a prompt theme that shows failures, such as starship. The prompt
shows the failure.
### Linux terminals
Run this in GNOME Terminal, kitty, WezTerm and Ghostty, and in each of bash, zsh and fish in one
of them.
1. Run `kaeru install`, and let it add its line to your shell's startup file. Open a new tab:
`kaeru doctor` says that the tab is tracked.
2. Open three tabs: A in some folder, B with Claude Code in another folder, with one message
sent, and C, a plain shell. Close C, then run `kaeru list` in A: it no longer shows C.
3. End the terminal from your other terminal, as a crash would, such as
`pkill -9 -x kitty`. `kaeru list` there shows A and B waiting, with B as Claude Code.
4. Start the terminal. Its first tab shows the list with A and B. Press Enter: A comes back in
its folder, B comes back with `claude --resume`, and the list's tab closes. In GNOME Terminal
and WezTerm, they come back as tabs of that window; in kitty and Ghostty, as windows.
5. In B, quit Claude Code. `kaeru list` shows B as a plain shell.
6. Quit the terminal normally, and start it again: the list shows the tabs, as in step 4.
7. Run `false` in a tab with a prompt theme that shows failures, such as starship. The prompt
shows the failure.