Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/terminal/account_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
// reads back is the environment the provider actually runs with — not the one
// lich spawned the wrapper with.
func TestSessionAccountReadsWhatTheWrapperExecsInto(t *testing.T) {
t.Parallel()
dir := t.TempDir()
bin := filepath.Join(dir, "claude-work.sh")
script := "#!/bin/sh\nexport CLAUDE_CONFIG_DIR=" + dir + "\nexec sleep 30\n"
Expand Down
1 change: 1 addition & 0 deletions internal/terminal/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
// A card whose PTY is not up has no environment to read, and reporting it as
// read is what would serve it the machine-wide login's quota.
func TestSessionAccountWithoutALiveProcess(t *testing.T) {
t.Parallel()
svc := New(stubBins{bin: "/opt/claude-work.sh"}, nil, events.New())

env, read := svc.SessionAccount("s1")
Expand Down
1 change: 1 addition & 0 deletions internal/terminal/agentname_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
// again every turn and on every /rename. The name a session answers to is
// therefore the last record in the file, whichever of the two it is.
func TestClaudeAgentNameReadsTheLastRecord(t *testing.T) {
t.Parallel()
const (
head = `{"type":"last-prompt","leafUuid":"a"}
{"type":"custom-title","customTitle":"lich-4f2a"}
Expand Down
4 changes: 4 additions & 0 deletions internal/terminal/antigravity_trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ func resolved(t *testing.T, dir string) string {
}

func TestAntigravityTrustCarriesARepositorysAnswerToItsWorktreeAndSubfolders(t *testing.T) {
t.Parallel()
main, worktree := gitWorktree(t)
sub := filepath.Join(main, "pkg")
if err := os.Mkdir(sub, 0o755); err != nil {
Expand All @@ -76,6 +77,7 @@ func TestAntigravityTrustCarriesARepositorysAnswerToItsWorktreeAndSubfolders(t *
}

func TestAntigravityTrustNeverTrustsWhatNobodyTrustedUnconfined(t *testing.T) {
t.Parallel()
main, worktree := gitWorktree(t)
home := t.TempDir()
writeAntigravitySettings(t, home, map[string]any{"trustedWorkspaces": []string{filepath.Dir(main)}})
Expand All @@ -98,6 +100,7 @@ func TestAntigravityTrustNeverTrustsWhatNobodyTrustedUnconfined(t *testing.T) {
// A confined session is trusted whatever the list says, and the file is made
// when Antigravity has not written one yet.
func TestAntigravityTrustsAConfinedFolder(t *testing.T) {
t.Parallel()
plain := t.TempDir()
home := t.TempDir()
if err := trustAntigravityFolder(home, plain, true); err != nil {
Expand All @@ -115,6 +118,7 @@ func TestAntigravityTrustsAConfinedFolder(t *testing.T) {
}

func TestAntigravityTrustRefusesSettingsItCannotRead(t *testing.T) {
t.Parallel()
home := t.TempDir()
path := antigravitySettingsFile(home)
if err := os.MkdirAll(filepath.Dir(path), 0o755); err != nil {
Expand Down
11 changes: 11 additions & 0 deletions internal/terminal/coalescer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ func captureEmit(buf int) (func([]byte), chan []byte) {
// hour-long hidden one, so the flush also proves the timer picked the visible
// cadence.
func TestCoalescerVisibleBatchesBurstOnShortTimer(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(3)
c := newCoalescer(emit, 20*time.Millisecond, time.Hour)

Expand Down Expand Up @@ -57,6 +58,7 @@ func TestCoalescerVisibleBatchesBurstOnShortTimer(t *testing.T) {
// lone write on an idle visible terminal — a keystroke echo — has no burst to
// collapse, so it must not pay the window.
func TestCoalescerVisibleLeadingEdgeEmitsIdleWriteAtOnce(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(1)
c := newCoalescer(emit, time.Hour, time.Hour)

Expand All @@ -76,6 +78,7 @@ func TestCoalescerVisibleLeadingEdgeEmitsIdleWriteAtOnce(t *testing.T) {
// write a whole window after the last emission is leading, one still inside
// the window is not.
func TestCoalescerLeadingEdgeWindowBoundary(t *testing.T) {
t.Parallel()
const window = 20 * time.Millisecond

atEdge, atEdgeEmits := captureEmit(1)
Expand Down Expand Up @@ -111,6 +114,7 @@ func TestCoalescerLeadingEdgeWindowBoundary(t *testing.T) {
// TestCoalescerHiddenNeverTakesLeadingEdge: a hidden terminal does not paint,
// so it has no echo latency to protect and batches hard instead.
func TestCoalescerHiddenNeverTakesLeadingEdge(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(1)
c := newCoalescer(emit, time.Hour, time.Hour)
c.SetVisible(false)
Expand All @@ -127,6 +131,7 @@ func TestCoalescerHiddenNeverTakesLeadingEdge(t *testing.T) {
// TestCoalescerHiddenBuffersThenFlushesOnTimer is the mirror image: an
// hour-long visible interval with a short hidden one.
func TestCoalescerHiddenBuffersThenFlushesOnTimer(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(1)
c := newCoalescer(emit, time.Hour, 10*time.Millisecond)
c.SetVisible(false)
Expand All @@ -151,6 +156,7 @@ func TestCoalescerHiddenBuffersThenFlushesOnTimer(t *testing.T) {
}

func TestCoalescerTimerRearmsPerBurst(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(2)
c := newCoalescer(emit, time.Hour, 10*time.Millisecond)
c.SetVisible(false)
Expand All @@ -172,6 +178,7 @@ func TestCoalescerTimerRearmsPerBurst(t *testing.T) {
}

func TestCoalescerSetVisibleFlushesPending(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(1)
c := newCoalescer(emit, time.Hour, time.Hour)
c.SetVisible(false)
Expand All @@ -190,6 +197,7 @@ func TestCoalescerSetVisibleFlushesPending(t *testing.T) {
}

func TestCoalescerSetVisibleWithEmptyPendingEmitsNothing(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(1)
c := newCoalescer(emit, time.Hour, time.Hour)
c.SetVisible(false)
Expand All @@ -204,6 +212,7 @@ func TestCoalescerSetVisibleWithEmptyPendingEmitsNothing(t *testing.T) {
}

func TestCoalescerOverflowForcesEarlyFlush(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(1)
c := newCoalescer(emit, time.Hour, time.Hour)
c.SetVisible(false)
Expand All @@ -221,6 +230,7 @@ func TestCoalescerOverflowForcesEarlyFlush(t *testing.T) {
}

func TestCoalescerCloseFlushesOnceAndSeals(t *testing.T) {
t.Parallel()
emit, emits := captureEmit(2)
c := newCoalescer(emit, time.Hour, time.Hour)
c.SetVisible(false)
Expand All @@ -244,6 +254,7 @@ func TestCoalescerCloseFlushesOnceAndSeals(t *testing.T) {
// multiple goroutines; under -race this checks the locking, and afterwards the
// total emitted bytes must equal the total written.
func TestCoalescerConcurrentWritesAndFlips(t *testing.T) {
t.Parallel()
var mu sync.Mutex
var emitted bytes.Buffer
c := newCoalescer(func(data []byte) {
Expand Down
3 changes: 3 additions & 0 deletions internal/terminal/command_kiro_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ func TestKiroPluginAgentIsNeverAskedForByAnotherProvider(t *testing.T) {
// unusable name is dropped rather than passed on: a value starting with a dash
// would be read by Kiro as another flag.
func TestAgentArgsIsKiroOnly(t *testing.T) {
t.Parallel()
tests := []struct {
name, kind, agent string
want []string
Expand All @@ -108,6 +109,7 @@ func TestAgentArgsIsKiroOnly(t *testing.T) {
// not conditional on which settings a session happens to carry — it is argv[0]
// on every Kiro spawn, ahead of all of them.
func TestKiroSpawnsTheChatSubcommandBeforeEveryFlag(t *testing.T) {
t.Parallel()
tests := []struct {
name string
agent string
Expand Down Expand Up @@ -148,6 +150,7 @@ func TestKiroSpawnsTheChatSubcommandBeforeEveryFlag(t *testing.T) {
// argv[0] that the harness has no subcommand for is a spawn that dies before the
// session exists, which is the same failure from the other direction.
func TestSubcommandArgsIsKiroOnly(t *testing.T) {
t.Parallel()
for _, kind := range []string{
providers.Claude, providers.Codex, providers.Antigravity, providers.OpenCode,
providers.OMP, providers.Crush, providers.Cursor, KindShell,
Expand Down
1 change: 1 addition & 0 deletions internal/terminal/command_ultracode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
)

func TestUltracodeArgs(t *testing.T) {
t.Parallel()
if got := ultracodeArgs(providers.Claude, true); !slices.Equal(got, []string{"--settings", `{"ultracode":true}`}) {
t.Errorf("claude, on: args = %v, want --settings with the ultracode key", got)
}
Expand Down
3 changes: 3 additions & 0 deletions internal/terminal/conversations_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ func TestConversationsReadsEveryProvider(t *testing.T) {
}

func TestFirstWorkspaceKeepsAWindowsDrive(t *testing.T) {
t.Parallel()
if got := firstWorkspace(`["file:///C:/work/alpha"]`); got != filepath.FromSlash("C:/work/alpha") {
t.Errorf("firstWorkspace = %q, want the drive kept", got)
}
Expand All @@ -274,6 +275,7 @@ func TestFirstWorkspaceKeepsAWindowsDrive(t *testing.T) {
}

func TestPromptTitleCutsALongPromptToOneLine(t *testing.T) {
t.Parallel()
long := strings.Repeat("ã", conversationTitleRunes+10)
if got := promptTitle(long); got != strings.Repeat("ã", conversationTitleRunes)+"…" {
t.Errorf("promptTitle(long) = %q", got)
Expand All @@ -286,6 +288,7 @@ func TestPromptTitleCutsALongPromptToOneLine(t *testing.T) {
// TestHeadLinesDropsTheLineTheBoundCuts pins the bound: a record cut in half
// by it would otherwise reach the parser as a different, shorter record.
func TestHeadLinesDropsTheLineTheBoundCuts(t *testing.T) {
t.Parallel()
path := filepath.Join(t.TempDir(), "long.jsonl")
first := `{"type":"session"}`
plant(t, path, first+"\n"+strings.Repeat("x", conversationHeadBytes)+"\n")
Expand Down
2 changes: 2 additions & 0 deletions internal/terminal/crush_init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

func TestMarkCrushInitializedAtTheCheckoutsTop(t *testing.T) {
t.Parallel()
_, worktree := gitWorktree(t)
sub := filepath.Join(worktree, "pkg")
if err := os.Mkdir(sub, 0o755); err != nil {
Expand All @@ -34,6 +35,7 @@ func TestMarkCrushInitializedAtTheCheckoutsTop(t *testing.T) {
}

func TestMarkCrushInitializedKeepsWhatIsThere(t *testing.T) {
t.Parallel()
dir := t.TempDir()
crush := filepath.Join(dir, ".crush")
if err := os.Mkdir(crush, 0o755); err != nil {
Expand Down
2 changes: 2 additions & 0 deletions internal/terminal/cursor_trust_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func TestInheritCursorTrustNeverTrustsWhatNobodyTrusted(t *testing.T) {
// The rule is the bundle's: one dash per run of anything outside [A-Za-z0-9],
// none at either end.
func TestCursorSlug(t *testing.T) {
t.Parallel()
for in, want := range map[string]string{
"/home/u/.local/share/lich/worktrees/e48f04f46a4a/fuzzy-pine": "home-u-local-share-lich-worktrees-e48f04f46a4a-fuzzy-pine",
`C:\Users\u\my repo_1\`: "C-Users-u-my-repo-1",
Expand All @@ -97,6 +98,7 @@ func TestCursorSlug(t *testing.T) {
// A marker on a parent counts only below home and three components deep, so
// trusting the home (or / ) once does not trust every folder under it.
func TestCursorTrustsAParentOnlyBelowHome(t *testing.T) {
t.Parallel()
sep := string(filepath.Separator)
home := filepath.Join(sep+"h", "u")
deep := filepath.Join(home, "src", "app")
Expand Down
5 changes: 5 additions & 0 deletions internal/terminal/cwd_foreground_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
// and e_tpgid on macOS are set by a shell handing the terminal to a job, and
// nothing about that is reachable without one.
func TestProcessCwdFollowsForegroundJob(t *testing.T) {
t.Parallel()
outer := physical(t, t.TempDir())
inner := physical(t, t.TempDir())

Expand Down Expand Up @@ -78,6 +79,7 @@ func TestProcessCwdFollowsForegroundJob(t *testing.T) {
// refuse. And that an ordinary command is not mistaken for a shell host, which
// is the half of shellHost no list of names can assert on its own.
func TestReadCommNamesTheProcess(t *testing.T) {
t.Parallel()
comm := readComm(os.Getpid())
if comm == "" {
t.Fatal(`readComm(self) = "", want the test binary's name`)
Expand All @@ -94,6 +96,7 @@ func TestReadCommNamesTheProcess(t *testing.T) {
// so processCwd falls through to the directory read rather than matching the
// empty string against the host list.
func TestReadCommOfDeadPidIsEmpty(t *testing.T) {
t.Parallel()
// Far beyond any real PID space (Linux pid_max < 2^22, macOS ~1e5).
if got := readComm(1 << 30); got != "" {
t.Errorf("readComm(dead) = %q, want empty", got)
Expand All @@ -111,6 +114,7 @@ func TestReadCommOfDeadPidIsEmpty(t *testing.T) {
// under that name is one: it reads as a host to the very seam a real tmux would,
// without a multiplexer, a socket or a server anywhere in the test.
func TestProcessCwdNamesAShellHostInTheForeground(t *testing.T) {
t.Parallel()
// A hard link to this test binary, which is the one executable that is both
// nameable and runnable on both OSes. The two other shapes are dead ends,
// and each was measured against the macOS runner:
Expand Down Expand Up @@ -210,6 +214,7 @@ const (
// bound for the run where that does not arrive: three times the caller's own
// deadline, so it can never be what a passing run is waiting on.
func TestStandsInForAShellHost(t *testing.T) {
t.Parallel()
if os.Getenv(hostStubVar) == "" {
t.Skip("runs only as the hard-linked stand-in")
}
Expand Down
7 changes: 7 additions & 0 deletions internal/terminal/cwd_track_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func waitEmit(t *testing.T, emits <-chan emitted) emitted {
// empty buffer — the Windows walk reads into &buf[0], so a zero-length buffer
// there panics and, on its bare goroutine, takes the whole app with it.
func TestDosPathRunesRejectsUnusableLengths(t *testing.T) {
t.Parallel()
cases := []struct {
name string
in uint16
Expand All @@ -74,6 +75,7 @@ func TestDosPathRunesRejectsUnusableLengths(t *testing.T) {
// with no controlling terminal (tpgid -1, what every non-PTY child reports)
// yields no group rather than a negative pid the cwd read would chase.
func TestParseTpgidSurvivesComm(t *testing.T) {
t.Parallel()
cases := []struct {
name string
in string
Expand All @@ -95,6 +97,7 @@ func TestParseTpgidSurvivesComm(t *testing.T) {
// TestProcessCwdReadsSelf proves the platform read resolves a live process's
// working directory — exercised against the test process itself.
func TestProcessCwdReadsSelf(t *testing.T) {
t.Parallel()
wd, err := os.Getwd()
if err != nil {
t.Fatalf("Getwd: %v", err)
Expand All @@ -111,6 +114,7 @@ func TestProcessCwdReadsSelf(t *testing.T) {
// TestProcessCwdOfDeadPidIsEmpty proves an unresolvable process degrades to
// "", which pollCwd skips instead of reporting.
func TestProcessCwdOfDeadPidIsEmpty(t *testing.T) {
t.Parallel()
// Far beyond any real PID space (Linux pid_max < 2^22, macOS ~1e5); Windows
// simply finds no such process to open.
if got, host := processCwd(1 << 30); got != "" || host != "" {
Expand Down Expand Up @@ -178,6 +182,7 @@ func TestPollCwdEmitsOnlyOnChange(t *testing.T) {
// it is a real path, and naming it is the whole failure this seam exists to
// end. Driven off a hand-fed read, because the alternative is starting a tmux.
func TestPollCwdPublishesTheHostInsteadOfAPath(t *testing.T) {
t.Parallel()
readings := make(chan emitted, 8)
tick := make(chan time.Time)
done := make(chan struct{})
Expand Down Expand Up @@ -218,6 +223,7 @@ func TestPollCwdPublishesTheHostInsteadOfAPath(t *testing.T) {
// answered with, an ordinary foreground job is not, and tmux's own comm — which
// carries its role after a colon — still matches.
func TestShellHostNamesOnlyKnownHosts(t *testing.T) {
t.Parallel()
cases := []struct {
in string
want string
Expand Down Expand Up @@ -257,6 +263,7 @@ func TestShellHostNamesOnlyKnownHosts(t *testing.T) {
// exit and the card closing — a session's last visible state would be that it
// is nowhere.
func TestPollCwdSkipsAReadThatAnswersNothing(t *testing.T) {
t.Parallel()
readings := make(chan emitted, 4)
tick := make(chan time.Time)
done := make(chan struct{})
Expand Down
Loading
Loading