Skip to content
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

Split each source code in test_crates/ into pair of crates #203

Merged
merged 28 commits into from
Dec 13, 2022

Conversation

tonowak
Copy link
Collaborator

@tonowak tonowak commented Dec 2, 2022

Closes #144

Unfortunately this PR is a bit tedious to review, sorry.

scripts/regenerate_test_rustdocs.sh Outdated Show resolved Hide resolved
scripts/regenerate_test_rustdocs.sh Outdated Show resolved Hide resolved
scripts/regenerate_test_rustdocs.sh Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to get some comments to you before it's too late in your timezone, and only managed to go through about half of this PR so far.

I'd highly recommend reading your own PR in the PR review interface. There are a bunch of things that stand out there that you probably wouldn't notice in your editor, and I bet you'll catch a number of issues and areas in need of polish and improvement by doing that. This is a high-risk PR since it changes so many things at once, and having more eyes reviewing it will also make it less likely that we end up with bugs as a result.

src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
test_crates/enum_repr_int_changed/new/src/main.rs Outdated Show resolved Hide resolved
test_crates/item_missing/new/src/main.rs Outdated Show resolved Hide resolved
test_crates/item_missing/new/Cargo.toml Outdated Show resolved Hide resolved
tonowak and others added 5 commits December 4, 2022 21:03
Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
Co-authored-by: Predrag Gruevski <2348618+obi1kenobi@users.noreply.github.com>
test_outputs/enum_missing.output.ron Outdated Show resolved Hide resolved
test_outputs/inherent_method_missing.output.ron Outdated Show resolved Hide resolved
test_outputs/struct_missing.output.ron Outdated Show resolved Hide resolved
test_outputs/method_parameter_count_changed.output.ron Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
test_crates/item_missing/new/Cargo.toml Outdated Show resolved Hide resolved
test_outputs/enum_repr_int_removed.output.ron Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
@obi1kenobi
Copy link
Owner

Merged main into this branch to pull in the update to trustfall v0.1.1 which will resolve at least one of the issues this PR ran into.

@tonowak
Copy link
Collaborator Author

tonowak commented Dec 9, 2022

Edit: done in bd42fd9.

The CONTRIBUTING.md needs to be updated (after merging #216 )

test_crates/README.md Outdated Show resolved Hide resolved
@tonowak
Copy link
Collaborator Author

tonowak commented Dec 9, 2022

The CONTRIBUTING.md needs to be updated (after merging #216 )

Maybe it's better to move test_crates/README.md to CONTRIBUTING.md @obi1kenobi ?

@tonowak
Copy link
Collaborator Author

tonowak commented Dec 10, 2022

It might be beneficial to create the witness crates in a separate PR.

@tonowak
Copy link
Collaborator Author

tonowak commented Dec 10, 2022

Edit: done in 03c8333

I believe that cargo clippy and cargo fmt needs to be ran on each crate separately.

src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
@@ -0,0 +1 @@
pub struct CheckPubUseHandling;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm trying to understand what it's doing, it should be in a inner mod?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to mirror the old structure it should be in a pub mod inner module and have a pub use in lib.rs.

Really this test doesn't need to have old/new versions. It's more just testing that re-exports are detected correctly — the re-exports are why this test case (which you said you were unsure about) exists and used to include multiple import paths for this CheckPubUseHandling struct.

But there's no problem with having this in an old/new configuration as well. Just add the pub mod inner and pub use in both the old and the new crates, and we can test that way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what you had in mind, or should I also put all of the code into an inner crate, just like it was in the previous test structure? 0f9b7ec

test_crates/struct_missing/old/new/Cargo.toml Outdated Show resolved Hide resolved
test_crates/struct_pub_field_missing/new/src/lib.rs Outdated Show resolved Hide resolved
test_outputs/enum_repr_int_removed.output.ron Outdated Show resolved Hide resolved
@obi1kenobi
Copy link
Owner

The CONTRIBUTING.md needs to be updated (after merging #216 )

Maybe it's better to move test_crates/README.md to CONTRIBUTING.md @obi1kenobi ?

I'd say move the contributing-specific information to CONTRIBUTING.md but also have a README.md because that's what GitHub shows when you open that directory, and because not all the info that belongs in that file is contributing-related.

What do you think?

Copy link
Owner

@obi1kenobi obi1kenobi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, it's great: it has already helped flag multiple false-positive issues, and the test crate code is much more readable on account of not having to mess with features and conditional compilation.

I flagged a few minor things that should be easy to fix, and we need to remember to open a few GitHub issues so we don't forget to resolve the lint issues we've flagged. If you get a chance to open them — great! If not, I'll open them when it's not 1am over here 😴

scripts/regenerate_test_rustdocs.sh Outdated Show resolved Hide resolved
# Run rustdoc on test_crates/*/{new,old}/
for crate_pair in $(find "$TOPLEVEL/test_crates/" -maxdepth 1 -mindepth 1 -type d); do
# Removing path prefix, leaving only the directory name without forward slashes
crate_pair=${crate_pair#"$TOPLEVEL/test_crates/"}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
crate_pair=${crate_pair#"$TOPLEVEL/test_crates/"}
crate_pair="${crate_pair#"$TOPLEVEL/test_crates/"}"

Should this be quoted?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why shouldn't this be quoted? Maybe the crate_pair would have spaces in it, for whatever reasons. Though I hope that the quotation marks match with each other correctly in the old version.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be quoted -- my suggested edit just wraps the whole thing in one extra set of quotes. That's just something I do obsessively in bash scripts since I've debugged several too many scripts where missing quotes either broke something (less bad option) or enabled script injection (much worse option). I just was wondering if adding the extra quotes might break something that I didn't notice.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh sorry, I've misunderstood. I thought you wanted to delete the quotes. I'll change it in a separate PR.

@@ -0,0 +1 @@
pub struct CheckPubUseHandling;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, to mirror the old structure it should be in a pub mod inner module and have a pub use in lib.rs.

Really this test doesn't need to have old/new versions. It's more just testing that re-exports are detected correctly — the re-exports are why this test case (which you said you were unsure about) exists and used to include multiple import paths for this CheckPubUseHandling struct.

But there's no problem with having this in an old/new configuration as well. Just add the pub mod inner and pub use in both the old and the new crates, and we can test that way.

src/query.rs Outdated Show resolved Hide resolved
src/query.rs Outdated Show resolved Hide resolved
src/query.rs Show resolved Hide resolved
test_crates/README.md Outdated Show resolved Hide resolved
test_outputs/struct_missing.output.ron Show resolved Hide resolved
tonowak and others added 6 commits December 11, 2022 09:11
@tonowak
Copy link
Collaborator Author

tonowak commented Dec 11, 2022

I'd say move the contributing-specific information to CONTRIBUTING.md but also have a README.md because that's what GitHub shows when you open that directory, and because not all the info that belongs in that file is contributing-related.

Done.

I flagged a few minor things that should be easy to fix, and we need to remember to open a few GitHub issues so we don't forget to resolve the lint issues we've flagged. If you get a chance to open them — great! If not, I'll open them when it's not 1am over here sleeping

I'll create the issues after merging this PR, to reference the exact lines of codes in the main branch.
I plan to create the following issues:

  • witness crates,
  • method_parameter_count_changed lint false-positive,
  • struct_missing lint false-posivite,
  • struct_marked_non_exhaustive lint false-positive.

Is there anything I've missed?

@obi1kenobi
Copy link
Owner

Another idea I had for automating false-positive detection in the future:

Some crates intentionally include items that are crafted as "bait" for false-positives, e.g. to act as regression tests for past false-positive issues. If we always place such "bait" in a dedicated file / module (e.g. false_positive.rs), then any time a rule reports an item from its own crate's false_positive module, we know that's a bug.

Other crates are allowed to report on false_positive modules' items, since those items may trigger other lints. For example, the false-positive where deleted methods get reported as changing their number of parameters: if that test case existed in false_positive.rs test crates for the lint for changing parameter count, it would have correctly been reported as a missing method by the lint that looks for those instead.

@obi1kenobi
Copy link
Owner

I'll create the issues after merging this PR, to reference the exact lines of codes in the main branch. I plan to create the following issues:

  • witness crates,
  • method_parameter_count_changed lint false-positive,
  • struct_missing lint false-posivite,
  • struct_marked_non_exhaustive lint false-positive.

I hit a burst of productivity today, so I debugged and fixed all three false-positives, and opened the witness crates issue 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert tests to pairs of Rust projects with their own manifests
2 participants