-
Notifications
You must be signed in to change notification settings - Fork 192
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
Fix windows compilation and testing #62
Conversation
|| parent == "/" | ||
let path_parent = std::path::Path::new(parent); | ||
let path_child = std::path::Path::new(child); | ||
(path_child.starts_with(path_parent) && !path_parent.starts_with(path_child)) |
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.
I've been staring at this for sometime and I think it is good.
Can you add a test for this case as it was bothering me:
is_a_parent_of('/usr/folder', '/usr/folder_not_a_child') == False
?
@rivy
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.
I tried to find a portable std::path-based method to determine parent-child relation and couldn't find anything. This was what I finally came up with as a possible design. But, yep, it's a bit twisty and I mentally bounced the code around for a while as well. I had to add a few test cases just to help prove it to myself. I'll happily add any extra test cases.
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.
Done, and it passes (unlike std::String::starts_with()
, std::path::Path.starts_with()
says that it "only considers whole path components to match" which is why this works).
I'll add the commit later tonight or tomorrow.
We also have a similar problem on linux if the filesystem is a different type we will see different numbers. #60. I'm not sure what the best way round this is. I'm considering running it once to see what the value should be and then dynamically generating the tests. Or we could add a statement like: pass if test=A or test=B. |
Overall It looks good, I want to play with this branch myself for a bit but I think I'd be happy to merge it. |
Although I am going to be offline for the next 10 days, so apologies in advance for going quiet. |
No worries on the timing. The testing is breaking (solely based on sizes) on my local windows I also cut some CI code that builds/deploys a deb package. It might satisfy issue #7. I'll add it back in as a separate commit. I also don't see the GitHub-Actions CI building on your repo side. I'm not quite sure how to get it enabled, but I'll google around if it's not obvious from your end. |
I just looked through my repository settings and it looks like you'll need to enable Actions via https://github.com/bootandy/dust/settings/actions for the CICD workflow to run for the PR. I have "Enable local and third party Actions for this repository" selected. I think that's the setting needed since the CI here pulls in actions to setup rust and cross-compile. |
Just an additional note here to prompt myself ... I'm seeing "Did not have permissions for all directories" (though I surely have permissions for all searched directories) during execution on windows platforms. I'll investigate further. |
I may be stating the obvious here but:
This message is printed to stderr if you don't have permission on 1 or more files or directories which dust encounters. |
I found the problem.
The bug was fixed with one change at the first use. But now I'm looking at the second use, trying to figure out if a directory could ever be an argument. I would think that |
I fixed/updated and polished a few things based upon this discussion. Additionally, I've also created a commit that refactors the code to use Here's the commit (based on top of this branch) ... rivy/rs.dust@add.gha...rivy:rf.pathbuf. If you think the change is useful, I'd like to add it to this PR. But I can open it in a new PR if, again, you'd like the change but prefer a new / separate PR. It's just a start and I'm sure that some of the remaining conversions between paths and strings can be avoided and overall portable path handling improved with some more study and development. |
…emporarily disable tests which vary by 'windows' hosts'
…isable two symlink tests which may not be possible on 'windows''
…t be a directory .# [why] "If you use `from_path()` on a directory, then subsequent queries using that handle will fail." Instead, use `from_path_any()` which supports opening files or directories. ref: "Struct winapi_util::Handle" from <https://docs.rs/crate/winapi-util>
…f path manipulation'
…ccurate descriptor)
cargo tarpaulin
inability to handle test coverage (use alternate framework?)