New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open absolute paths as files, limited Windows support #1159
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1159 +/- ##
==========================================
+ Coverage 98.24% 98.34% +0.09%
==========================================
Files 49 49
Lines 2165 2169 +4
==========================================
+ Hits 2127 2133 +6
+ Misses 29 28 -1
+ Partials 9 8 -1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! No blockers, left a few suggestions.
This makes it easier to test sinkRegistry functionality that registers temporary sinks, and in future, stubbing of the os.OpenFile call.
This avoids a dependency on the underlying filesystem, which avoids unnecessarily trying to open files when we just want to ensure that paths are opened using the file sink.
Windows absolute paths such as `c:\log.json` parse as URLs with the scheme set. The sink registry currently expects file paths to either have a `file` scheme, or no scheme. Rather than trying to special-case drives in schemes, and reassemble paths, simplify by checking for `filepath.IsAbs` before parsing the path as a URL. Since `filepath.IsAbs` is OS-specific, windows paths will not be treated as absolute paths on other systems, and will still work using any registered sink factories.
9802e6a
to
ffd9b49
Compare
Thanks for the suggestions, updated to incorporate them. |
ffd9b49
to
15c26e5
Compare
Ref #994, #1000
Alternate approach to #999, this approach brings absolute path support to Windows.
It does so by checking for absolute paths and handling them using the file factory directly.
To test different paths without trying to actually open them (UNC paths hit the network), this change also
prefactors the sink registry into a separate type that allows stubbing of the
os.OpenFile
call.Note: This change does not bring full Windows support -- many tests still fail, and Windows file URIs don't work.