Skip to content

Commit 6f5674b

Browse files
committed
test: make ssh resolver tests portable on windows
1 parent 615b1ec commit 6f5674b

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

internal/ssh/resolve_test.go

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"os"
55
"os/exec"
66
"path/filepath"
7+
"runtime"
78
"strings"
89
"testing"
910

@@ -173,17 +174,21 @@ func TestResolveScriptAiderScopedByEnvFindsHistoryFiles(t *testing.T) {
173174
require.NoError(t, err, "resolve script failed: output: %s", out)
174175

175176
dirs, _ := parseResolvedDirs(string(out))
176-
assert.ElementsMatch(t, []string{historyA, historyB}, dirs[parser.AgentAider],
177+
aiderTargets := slashPaths(dirs[parser.AgentAider])
178+
assert.ElementsMatch(t, []string{filepath.ToSlash(historyA), filepath.ToSlash(historyB)}, aiderTargets,
177179
"explicit AIDER_DIR must resolve only aider history files")
178-
assert.NotContains(t, dirs[parser.AgentAider], codeRoot,
180+
assert.NotContains(t, aiderTargets, filepath.ToSlash(codeRoot),
179181
"AIDER_DIR itself must not become a tar target")
180-
assert.NotContains(t, dirs[parser.AgentAider], skippedHistory,
182+
assert.NotContains(t, aiderTargets, filepath.ToSlash(skippedHistory),
181183
"remote aider discovery must prune local-discovery skip dirs")
182-
assert.NotContains(t, dirs[parser.AgentAider], deepHistory,
184+
assert.NotContains(t, aiderTargets, filepath.ToSlash(deepHistory),
183185
"remote aider discovery must enforce the local depth cap")
184186
}
185187

186188
func TestResolveScriptAiderNewlinePathCannotInjectTarget(t *testing.T) {
189+
if runtime.GOOS == "windows" {
190+
t.Skip("Windows path APIs reject embedded newlines; this regression covers POSIX remote shell output")
191+
}
187192
home := t.TempDir()
188193
codeRoot := filepath.Join(home, "code")
189194
injected := "/home/victim/" + parser.AiderHistoryFileName()
@@ -207,6 +212,14 @@ func TestResolveScriptAiderNewlinePathCannotInjectTarget(t *testing.T) {
207212
}
208213
}
209214

215+
func slashPaths(paths []string) []string {
216+
out := make([]string, len(paths))
217+
for i, p := range paths {
218+
out[i] = filepath.ToSlash(p)
219+
}
220+
return out
221+
}
222+
210223
// TestResolveScriptAiderRejectsHomeOverride verifies that setting AIDER_DIR
211224
// to literal $HOME (the very thing the home-default skip prevents) is also
212225
// dropped, so an unscoped override cannot reintroduce a whole-home tar.

0 commit comments

Comments
 (0)