-
Notifications
You must be signed in to change notification settings - Fork 31
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
Make the recursive option of cargo-sweep recurse past Cargo directories #78
Conversation
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.
Can you please add a test for the new behavior? You may need to add the project from #66 into tests
, see tests/integration.rs
for some existing code you can use as an example.
Otherwise this looks fine to me :) the CI failures are unrelated and should be fixed if you rebase over master.
2dd47ac
to
1ff2a84
Compare
@jyn514 I finally got some time to write an integration test, and I think it came out OK. But I have to say, the state of the Tests should be easy to follow step-by-step by reading the test function, but folks have tried to be too clever with the code. Deduplication, DRY, and utility functions that assume too much about how a test works will end up hurting tests as much as they help improve regular code. I had to start by documenting a lot of the code that I didn't understand and then patch my integration test on top of that. Furthermore, the |
1ff2a84
to
84fc0f9
Compare
Yeah I just confirmed that the test |
The regex requires this order \[DEBUG\] Successfully removed: ".+libsample_project-.+\.rlib"
\[DEBUG\] Successfully removed: ".+libsample_project-.+\.rmeta"
\[DEBUG\] Successfully removed: ".+sample_project-.+\.d"
\[DEBUG\] Successfully removed: ".+.fingerprint.+sample-project-.+" But my machine outputs this order [DEBUG] Successfully removed: "/var/folders/g8/qgn3gbf514b_p34n_jc_1_lc0000gn/T/.tmpKdJQnA/debug/deps/sample_project-f27e05aa5c13ed9b.d"
[DEBUG] Successfully removed: "/var/folders/g8/qgn3gbf514b_p34n_jc_1_lc0000gn/T/.tmpKdJQnA/debug/deps/libsample_project-f27e05aa5c13ed9b.rlib"
[DEBUG] Successfully removed: "/var/folders/g8/qgn3gbf514b_p34n_jc_1_lc0000gn/T/.tmpKdJQnA/debug/deps/libsample_project-f27e05aa5c13ed9b.rmeta"
[DEBUG] Successfully removed: "/var/folders/g8/qgn3gbf514b_p34n_jc_1_lc0000gn/T/.tmpKdJQnA/debug/.fingerprint/sample-project-f27e05aa5c13ed9b" |
I managed to fix it by changing the regexp to this monstrosity. My guess is that regex isn't the right tool for the job, though. (\[DEBUG\] Successfully removed: (".+libsample_project-.+\.rlib"|".+libsample_project-.+\.rmeta"|".+sample_project-.+\.d"|".+.fingerprint.+sample-project-.+")\n{0,1}){4} |
603d59c
to
8c4ca2b
Compare
ba43ad6
to
8b75297
Compare
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.
LGTM, sorry my last PR gave you some conflicts xD.
These should be easy to fix because you only changed one line at main.rs
, and there aren't many changes on integration.rs
, here's the diff, just in case it helps.
EDIT: oh and overwrite your PR's regex pattern over mine please.
e542c06
to
48e462e
Compare
Updated |
48e462e
to
bf1b8a2
Compare
Looks like there is a "bug" in
|
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.
The source changes seem ok, but I had a few comments about the test changes - most of them are non-blocking except the fact that the test isn't actually effective.
When passing the -r (recursive) option to cargo-sweep, it is supposed to be recursive over the subdirectories of the root path it is given (whether implicit or explicit). cargo-sweep erronously assumed that a Cargo project could not contain unrelated subprojects. This patch lets cargo-sweep keep recursing past cargo roots. The drawback of this patch is that cargo-sweep will need to recurse more, and as such becomes a bit slower to run. Fixes holmgr#66
The empty_project_output test doesn't have the same traversing/logging order on macos as it does on whatever os/machine it was written for. This commit tries to improve the situation somewhat by making the test runnable on macos as well, while sacrificing readability and test accuracy. An alternative fix would be to not use regex for the test at all.
There is an edge case where the `cargo test` invocation can be run with `CARGO_TARGET_DIR` set, which needs to be handled by the recursive_multiple_root_workspaces test since it assumes that `CARGO_TARGET_DIR` isn't set.
This commit improves the recursive_multiple_root_workspaces by applying some review comments: * Deduplicating the cargo command by making the cargo function take an absolute path instead of a relative one. * Removing an unnecessary CARGO_INCREMENTAL=0 environment variable * Renaming the temporary workspace directory variable
25a73db
to
c88fa94
Compare
…spaces This commit changes the recursive_multiple_root_workspaces test by adding assertions to make sure that the actions of cargo-sweep were actually effective in cleaning nested root workspaces.
Fixed 👍 |
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! This looks really good :) I just have a couple nits.
* Remove a few comments that are no longer valid. * Improve the understanding of the final assertions by adding a more detailed explanation.
Thanks for sticking with this! |
When passing the -r (recursive) option to cargo-sweep, it is supposed to be recursive over the subdirectories of the root path it is given (whether implicit or explicit). cargo-sweep erronously assumed that a Cargo project could not contain unrelated subprojects.
This patch lets cargo-sweep keep recursing past cargo roots.
The drawback of this patch is that cargo-sweep will need to recurse more, and as such becomes a bit slower to run.
Fixes #66