Skip to content

Test_paths fails on Windows: hardcoded forward-slash separators #87

@spf13

Description

@spf13

Bug

\Test_paths\ fails on Windows because the test expectations hardcode /\ as the path separator, but \CleanPath\ uses \ ilepath.Separator\ which is \\ on Windows.

Failing tests

\
--- FAIL: Test_paths/several_dirs
paths() = foobarbaz, want foo/bar/baz
--- FAIL: Test_paths/several_dirs2
paths() = foo\bar\baz, want foobarbaz
--- FAIL: Test_paths/dirs_with_spaces
paths() = foo barbaz, want foo bar/baz
--- FAIL: Test_paths/dirs_with_bad_chars
paths() = foobarbaz, want foobar/baz
--- FAIL: Test_paths/example
paths() = foobarbazqux, want foo/barbazqux
--- FAIL: Test_paths/readme
paths() = CUsersdirectoryCON, want C/Users/directory/CON_
\\

Root cause

The test inputs use /\ as the path separator and the expected values also use /. On Windows, \ ilepath.Separator\ is \\, so \strings.Split(path, string(filepath.Separator))\ doesn't split on /\ — the entire input is treated as a single filename component.

Fix

Replace hardcoded /\ separators in the test with \string(filepath.Separator)\ (or \ ilepath.Join), or use \path.Clean\ semantics consistently. Alternatively, \CleanPath\ itself could normalise separators before splitting.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions