tui: skip path-quoting tests on windows
normalisePathToken's heuristic only fires for unix-shaped paths (leading /, ~, or file:// with a / path). On Windows, t.TempDir() returns paths like C:\Users\RUNNER~1\AppData\Local\Temp\... which never match those prefixes, so the test inputs never get quoted and every assertion fails. The function is unix-only by design (drag-and-drop on macOS/Linux); skip the test on Windows rather than carry a parallel Windows test that would just duplicate platform-specific quoting logic.
- commit
- 1056bfc3495549567916656d97d3f8672f56cd51
- author
- patriceckhart · · 2026-04-27 09:14 UTC
- parent
- 902122e
- signature
- unsigned
- refs
- tag: v0.1.25
1 file · +13 -0
M internal/tui/quote_paste_test.go +13 -0
| @@ -4,6 +4,7 @@ import ( | |||
| 4 | 4 | "net/url" | |
| 5 | 5 | "os" | |
| 6 | 6 | "path/filepath" | |
| 7 | + | "runtime" | |
| 7 | 8 | "strings" | |
| 8 | 9 | "testing" | |
| 9 | 10 | ) | |
| @@ -25,6 +26,15 @@ func makeFiles(t *testing.T, base string, rels ...string) string { | |||
| 25 | 26 | } | |
| 26 | 27 | ||
| 27 | 28 | func TestQuotePastedFilePaths(t *testing.T) { | |
| 29 | + | // normalisePathToken's heuristics target Unix-shaped paths | |
| 30 | + | // (leading "/", "~", or "file://" with a "/" path component) — | |
| 31 | + | // the same shapes drag-and-drop produces on macOS and Linux. | |
| 32 | + | // Windows TempDir paths look like C:\Users\... which never | |
| 33 | + | // match those prefixes, so the test fixtures wouldn't exercise | |
| 34 | + | // any real code path on that platform. | |
| 35 | + | if runtime.GOOS == "windows" { | |
| 36 | + | t.Skip("path-quoting heuristics are unix-shaped") | |
| 37 | + | } | |
| 28 | 38 | dir := t.TempDir() | |
| 29 | 39 | makeFiles(t, dir, | |
| 30 | 40 | "foo bar.png", | |
| @@ -106,6 +116,9 @@ func TestQuotePastedFilePaths(t *testing.T) { | |||
| 106 | 116 | // when the home directory contains the candidate. We don't write | |
| 107 | 117 | // into the user's real home; instead, override HOME for the test. | |
| 108 | 118 | func TestTildePathExists(t *testing.T) { | |
| 119 | + | if runtime.GOOS == "windows" { | |
| 120 | + | t.Skip("path-quoting heuristics are unix-shaped") | |
| 121 | + | } | |
| 109 | 122 | tmp := t.TempDir() | |
| 110 | 123 | makeFiles(t, tmp, "tilde-test.png") | |
| 111 | 124 | t.Setenv("HOME", tmp) | |
| @@ -4,6 +4,7 @@ import ( | |||||
| 4 | "net/url" | 4 | "net/url" | ||
| 5 | "os" | 5 | "os" | ||
| 6 | "path/filepath" | 6 | "path/filepath" | ||
| 7 | + | "runtime" | |||
| 7 | "strings" | 8 | "strings" | ||
| 8 | "testing" | 9 | "testing" | ||
| 9 | ) | 10 | ) | ||
| @@ -25,6 +26,15 @@ func makeFiles(t *testing.T, base string, rels ...string) string { | |||||
| 25 | } | 26 | } | ||
| 26 | 27 | ||||
| 27 | func TestQuotePastedFilePaths(t *testing.T) { | 28 | func TestQuotePastedFilePaths(t *testing.T) { | ||
| 29 | + | // normalisePathToken's heuristics target Unix-shaped paths | |||
| 30 | + | // (leading "/", "~", or "file://" with a "/" path component) — | |||
| 31 | + | // the same shapes drag-and-drop produces on macOS and Linux. | |||
| 32 | + | // Windows TempDir paths look like C:\Users\... which never | |||
| 33 | + | // match those prefixes, so the test fixtures wouldn't exercise | |||
| 34 | + | // any real code path on that platform. | |||
| 35 | + | if runtime.GOOS == "windows" { | |||
| 36 | + | t.Skip("path-quoting heuristics are unix-shaped") | |||
| 37 | + | } | |||
| 28 | dir := t.TempDir() | 38 | dir := t.TempDir() | ||
| 29 | makeFiles(t, dir, | 39 | makeFiles(t, dir, | ||
| 30 | "foo bar.png", | 40 | "foo bar.png", | ||
| @@ -106,6 +116,9 @@ func TestQuotePastedFilePaths(t *testing.T) { | |||||
| 106 | // when the home directory contains the candidate. We don't write | 116 | // when the home directory contains the candidate. We don't write | ||
| 107 | // into the user's real home; instead, override HOME for the test. | 117 | // into the user's real home; instead, override HOME for the test. | ||
| 108 | func TestTildePathExists(t *testing.T) { | 118 | func TestTildePathExists(t *testing.T) { | ||
| 119 | + | if runtime.GOOS == "windows" { | |||
| 120 | + | t.Skip("path-quoting heuristics are unix-shaped") | |||
| 121 | + | } | |||
| 109 | tmp := t.TempDir() | 122 | tmp := t.TempDir() | ||
| 110 | makeFiles(t, tmp, "tilde-test.png") | 123 | makeFiles(t, tmp, "tilde-test.png") | ||
| 111 | t.Setenv("HOME", tmp) | 124 | t.Setenv("HOME", tmp) | ||