Skip to content

Handle extended path length syntax in automatic [CWD] detection #153

Open
@kleinesfilmroellchen

Description

@kleinesfilmroellchen

Windows has the extended path length syntax to work around legacy file path restrictions. These paths start with the string \\?\ followed by a normal path; more details can be found here. The problem is that Rust's std::fs::canonicalize creates these kinds of paths on Windows (which makes sense given that paths over 260 characters are otherwise disallowed), but trycmd can't handle them. If my binary under test's output, on Windows, includes something like:

\\?\C:\Path\To\Working\Directory\Some\File.txt

trycmd will transform this into:

//?/[CWD]/Some/File.txt

However, on Posix-like systems, my binary's output looks like this:

/Path/To/Working/Directory/Some/File.txt

as the behaviour of fs::canonicalize is different (on all systems, canonicalization is handled by the operating system, in the case of Posix, via realpath). Therefore, trycmd "compresses" that into

[CWD]/Some/File.txt

Depending on whether the test was blessed on Windows or a Posix-like system, the tests will therefore fail on the other family of systems.

A workaround is of course to discard extended length path syntax in my binary before printing the path or file name, but as stated above that can lead to other problems. I'd like trycmd to be able to handle this; i.e. collapse the leading extended path syntax specifier into [CWD] if it is found before the normal working directory path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-snapboxArea: snapbox packageA-trycmdArea: trycmd package

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions