-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
move one snapshot/add
test into testsuite/cargo_add/
#10631
Conversation
4462282
to
4e784f2
Compare
29921ca
to
e40350f
Compare
e40350f
to
8bb8392
Compare
build.rs
Outdated
@@ -11,6 +11,7 @@ fn main() { | |||
"cargo:rustc-env=RUST_HOST_TARGET={}", | |||
std::env::var("TARGET").unwrap() | |||
); | |||
println!("cargo:rerun-if-changed=tests/snapshots"); |
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.
Talking this over with @ehuss, we are concerned about the balance we are striking between writing new tests and the cost of rebuilding. In case its not clear, this line means that any time anything in the snapshots directory changes, whether directly by the user or from rebase from master, all of cargo, lib and bin, will rebuild.
If we had globbing support in rerun-if-changed
, we could limit this to just tests/snapshots/*/*/mod.rs
which might still cause too many rebuilds.
I know we proposed this solution and you put in a lot of work to learn how to write the function-like macro and get this working but I think we should change to a naive / macro-less solution for now where we rename tests/testsuite/cargo_add.rs
to tests/testsuite/cargo_add/mod.rs
and tests/snapshots/add/add_basic/mod.rs
to tests/testsuite/cargo_add/add_basic/mod.rs
and move the snapshots along with it so we can just mod add_basic;
in cargo_add/mod.rs
. The downside is that test writers have to make sure they keep the linkage up-to-date and don't add tests without linking them in but we already have that problem in tests/testsuite
.
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 completely agree with this decision. I do not think the rebuilds were worth it, even while testing this and making changes it was happening. It wasn't bad because I have a fast machine but it still slowed things down. It also completely mitigated some of the benefits of snapshot
.
I like the proposed solution better than using a macro here. Even if rerun-if-changed
supported globs the explicitness of having to add a test might be nice. As for the downsides of having to remember to link everything up, for me personally, I don't think it's a problem since Clion says if a mod.rs
isn't attached anywhere. That being said it may be nice to have something more set up so you don't have to manage paths in a mod.rs
test
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.
rename tests/testsuite/cargo_add.rs to tests/testsuite/cargo_add/mod.rs and tests/snapshots/add/add_basic/mod.rs to tests/testsuite/cargo_add/add_basic/mod.rs
Would this end up making more files with only one test case inside? I can imagine it is a little annoying when navigating a group of related tests but you need to jump back and forth between files.
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 whole aim of this direction is to have a file per test function, regardless of what the files are renamed. I've been dealing with this in my other crates with trycmd
and its not bad. I also see a lot of this as an experiment. We'll try things out, see what we think, and change as needed.
8bb8392
to
ea31298
Compare
snapshot
tests into snapshot directorysnapshot/add
test into testsuite/cargo_add/
@bors r+ |
📌 Commit ea31298 has been approved by |
☀️ Test successful - checks-actions |
Move snapshot tests into testsuite This moves all tests from the `snapshot` folder into the `testsuite` folder as described by [this comment](#10631 (comment)). A macro was also added so there is no need to specify the path in a `snapshot` test just the file. This was done for ease of refactoring and ease of porting new tests to `snapshot` close #10627 r? `@epage`
Update cargo 20 commits in a44758ac805600edbb6ba51e7e6fb81a6077c0cd..3f052d8eed98c6a24f8b332fb2e6e6249d12d8c1 2022-05-04 02:29:34 +0000 to 2022-05-12 15:19:04 +0000 - pre-stabilization documentation for workspace inheritance (rust-lang/cargo#10659) - test: Make curr_dir work in/out of workspace (rust-lang/cargo#10658) - Fix no_cross_doctests race condition. (rust-lang/cargo#10660) - Fix typo (rust-lang/cargo#10657) - feat(install): Support `foo@version` like cargo-add (rust-lang/cargo#10650) - fix typos found by the `typos-cli` crate (rust-lang/cargo#10649) - feat(yank): Support foo@version like cargo-add (rust-lang/cargo#10597) - add `cargo-features` to unstable docs for workspace inheritance (rust-lang/cargo#10648) - Use the traits added to the Rust 2021 Edition prelude (rust-lang/cargo#10646) - Pass `--target` to `rustdoc` for `cargo test` if specified with host target. (rust-lang/cargo#10594) - Fix use of .. in dep-info-basedir (rust-lang/cargo#10281) - fix some typos (rust-lang/cargo#10639) - Move snapshot tests into testsuite (rust-lang/cargo#10638) - Improve support of condition compilation checking (rust-lang/cargo#10566) - When documenting private items in a binary, ignore warnings about links to private items (rust-lang/cargo#10142) - Extend pkgid syntax with ``@`` support (rust-lang/cargo#10582) - move one `snapshot/add` test into `testsuite/cargo_add/` (rust-lang/cargo#10631) - Add caveat for covering features (rust-lang/cargo#10605) - Improve CARGO_ENCODED_RUSTFLAGS and CARGO_ENCODED_RUSTDOCFLAGS variables docs (rust-lang/cargo#10633) - reorganize `snapshot` tests to better work in contexts that sort by extension (rust-lang/cargo#10629)
This is an experiment with moving the test code related to a snapshot into the testsuite directory so it's easier to review.
This is a step towards #10627. A follow up will port all of the tests
r? @epage