detached 94efc28

test: compare PowerShell working directory by file identity

commit
94efc287e098e34632056e455aa5dc42287f71ea
author
patriceckhart · · 2026-09-06 18:18 UTC
parent
e5fc4d2
signature
unsigned
refs
tag: v0.3.66
1 file · +18 -1
M packages/agent/tools/powershell_test.go +18 -1
@@ -6,6 +6,7 @@ import (
66 "encoding/binary"
77 "encoding/json"
88 "fmt"
9+ "os"
910 "os/exec"
1011 "reflect"
1112 "runtime"
@@ -118,7 +119,7 @@ func TestPowerShellExecution(t *testing.T) {
118119 timeout int
119120 }{
120121 {"unicode and quoting", "Write-Output 'Grüße 世界'; Write-Output '\"quoted\"'", "Grüße 世界", false, 0},
121- {"cwd", "(Get-Location).Path", cwd, false, 0},
122+ {"cwd", "(Get-Location).Path", "", false, 0},
122123 {"stderr", "[Console]::Error.WriteLine('stderr output')", "stderr output", false, 0},
123124 {"exit", "exit 7", "[exit 7]", true, 0},
124125 {"error", "throw 'failure'", "failure", true, 0},
@@ -136,6 +137,22 @@ func TestPowerShellExecution(t *testing.T) {
136137 if res.IsError != tc.failure || !strings.Contains(text, tc.want) || !strings.HasPrefix(text, "PS> ") {
137138 t.Fatalf("result: %+v, %s", res, text)
138139 }
140+ if tc.name == "cwd" {
141+ // Windows temp paths can use short names or different casing
142+ // than Get-Location. Compare directory identity, not spelling.
143+ gotPath := strings.TrimSpace(streamed.String())
144+ gotInfo, err := os.Stat(gotPath)
145+ if err != nil {
146+ t.Fatalf("stat reported cwd %q (expected %q): %v", gotPath, cwd, err)
147+ }
148+ wantInfo, err := os.Stat(cwd)
149+ if err != nil {
150+ t.Fatal(err)
151+ }
152+ if !os.SameFile(gotInfo, wantInfo) {
153+ t.Fatalf("reported cwd %q is not the expected directory %q", gotPath, cwd)
154+ }
155+ }
139156 if tc.name == "unicode and quoting" && !strings.Contains(streamed.String(), "Grüße 世界") {
140157 t.Fatalf("stream: %q", streamed.String())
141158 }
@@ -6,6 +6,7 @@ import (
6 "encoding/binary"6 "encoding/binary"
7 "encoding/json"7 "encoding/json"
8 "fmt"8 "fmt"
9+ "os"
9 "os/exec"10 "os/exec"
10 "reflect"11 "reflect"
11 "runtime"12 "runtime"
@@ -118,7 +119,7 @@ func TestPowerShellExecution(t *testing.T) {
118 timeout int119 timeout int
119 }{120 }{
120 {"unicode and quoting", "Write-Output 'Grüße 世界'; Write-Output '\"quoted\"'", "Grüße 世界", false, 0},121 {"unicode and quoting", "Write-Output 'Grüße 世界'; Write-Output '\"quoted\"'", "Grüße 世界", false, 0},
121- {"cwd", "(Get-Location).Path", cwd, false, 0},122+ {"cwd", "(Get-Location).Path", "", false, 0},
122 {"stderr", "[Console]::Error.WriteLine('stderr output')", "stderr output", false, 0},123 {"stderr", "[Console]::Error.WriteLine('stderr output')", "stderr output", false, 0},
123 {"exit", "exit 7", "[exit 7]", true, 0},124 {"exit", "exit 7", "[exit 7]", true, 0},
124 {"error", "throw 'failure'", "failure", true, 0},125 {"error", "throw 'failure'", "failure", true, 0},
@@ -136,6 +137,22 @@ func TestPowerShellExecution(t *testing.T) {
136 if res.IsError != tc.failure || !strings.Contains(text, tc.want) || !strings.HasPrefix(text, "PS> ") {137 if res.IsError != tc.failure || !strings.Contains(text, tc.want) || !strings.HasPrefix(text, "PS> ") {
137 t.Fatalf("result: %+v, %s", res, text)138 t.Fatalf("result: %+v, %s", res, text)
138 }139 }
140+ if tc.name == "cwd" {
141+ // Windows temp paths can use short names or different casing
142+ // than Get-Location. Compare directory identity, not spelling.
143+ gotPath := strings.TrimSpace(streamed.String())
144+ gotInfo, err := os.Stat(gotPath)
145+ if err != nil {
146+ t.Fatalf("stat reported cwd %q (expected %q): %v", gotPath, cwd, err)
147+ }
148+ wantInfo, err := os.Stat(cwd)
149+ if err != nil {
150+ t.Fatal(err)
151+ }
152+ if !os.SameFile(gotInfo, wantInfo) {
153+ t.Fatalf("reported cwd %q is not the expected directory %q", gotPath, cwd)
154+ }
155+ }
139 if tc.name == "unicode and quoting" && !strings.Contains(streamed.String(), "Grüße 世界") {156 if tc.name == "unicode and quoting" && !strings.Contains(streamed.String(), "Grüße 世界") {
140 t.Fatalf("stream: %q", streamed.String())157 t.Fatalf("stream: %q", streamed.String())
141 }158 }

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 1

Tags 476

↑↓ moveenter openesc close