curl / trurl

trurl is a command line tool for URL parsing and manipulation.
https://curl.se/trurl/
Other
3.15k stars 102 forks source link

Test fails on windows because of different null device name #213

Closed krishean closed 1 year ago

krishean commented 1 year ago

On windows test 114 ( trurl.exe -f /dev/null --json ) fails because the null device is called just "nul"

This could potentially be fixed by adding:

# change the null device name to "nul" if running on windows
if sys.platform == "win32" and "/dev/null" in self.arguments:
    self.arguments = ["nul" if arg == "/dev/null" else arg for arg in self.arguments]

below line 52 in test.py: https://github.com/curl/trurl/blob/c1bd6b8e30b428ee79cccdcffa2d87fa33b95dff/test.py#L52

There may be a better way to do this, if so I'm open to suggestions, otherwise I can submit a pull request.

dfandrich commented 1 year ago

os.devnull is the /dev/null device on the current platform, but that might not be any easier to integrate.

krishean commented 1 year ago

Could do something like:

if os.devnull != "/dev/null" and "/dev/null" in self.arguments:
    self.arguments = [os.devnull if arg == "/dev/null" else arg for arg in self.arguments]

to remove the explicit win32 check, but it's roughly the same in either case, macos uses /dev/null as well, windows is the only os that uses a different device name as far as I'm aware, even cygwin and msys2 have code to allow /dev/null to work on windows.

emanuele6 commented 1 year ago

We could just create a new empty file in testfiles/ and use that instead of /dev/null

krishean commented 1 year ago

I wouldn't have thought to do it that way, a much simpler way to fix it.