test: migrate some files to snapbox #14113
Conversation
1bf5eea to
f7b0fac
Compare
| } | ||
|
|
||
| #[cargo_test] | ||
| fn list_builtin_aliases_with_descriptions() { |
There was a problem hiding this comment.
Since the output on the right is complete, the test case here is deleted.
| ); | ||
| } | ||
|
|
||
| #[allow(deprecated)] |
There was a problem hiding this comment.
Since with_stdout_does_not_contain,add #[allow(deprecated)].
f7b0fac to
7c172ec
Compare
cd4aa8c to
464d232
Compare
|
☔ The latest upstream changes (presumably #14126) made this pull request unmergeable. Please resolve the merge conflicts. |
|
Could you clean up the commit history? |
tests/testsuite/cargo_command.rs
Outdated
| .with_stdout_data(str![[r#" | ||
| [CARGO_PATH] | ||
|
|
||
| "#]]) |
There was a problem hiding this comment.
So this was already a "self updating" test output and I believe the design of it means that there is little to evolve that we'd need to allow snapshotting more from this.
Should we keep the expected-str generation that was in here before, just switching the assert method used?
There was a problem hiding this comment.
It is not possible to just convert with_stdout to with_stdout_data, such as the error reported below:
--- Expected
++++ actual: stdout
1 - /home/heisen/temp/temp/temp/cargo/target/debug/cargo∅
1 + /home/heisen/temp/temp/temp/cargo/target/debug/cargo
Need to add line breaks.
There was a problem hiding this comment.
Adding in a newline is trivial and doesn't invalidate the idea I mentioned that this is unlikely to have surrounding text that gets regularly changed.
There was a problem hiding this comment.
It has been modified and you can see if it meets the requirements.
204d05d to
c335fb0
Compare
tests/testsuite/cargo_command.rs
Outdated
| [cargo-new] | ||
| vcs = "none" | ||
| "#, | ||
| [cargo-new] |
There was a problem hiding this comment.
Ditto. It's normal in my local area.
tests/testsuite/cargo_command.rs
Outdated
| cargo_process("envtest") | ||
| .env("PATH", &path) | ||
| .with_stdout(cargo.to_str().unwrap()) | ||
| .with_stdout_data(str![[r#" |
There was a problem hiding this comment.
This asserts an exact value. I don't think we need a snapshot here.
| .with_stdout_data(str![[r#" | |
| .with_stdout_data(cargo.to_str()) |
There was a problem hiding this comment.
Sorry, this modification doesn't work, I tried several different modification options and got different results. I would like to describe it in detail:
1.Try modifying it to:.with_stdout_data(cargo.to_str().unwrap());
The results obtained are:
--- Expected
++++ actual: stdout
1 - /home/heisen/temp/temp/temp/cargo/target/debug/cargo∅
1 + /home/heisen/temp/temp/temp/cargo/target/debug/cargo
Line breaks need to be added. If line breaks are added after: .with_stdout_data(format!("{}\n",cargo.to_str().unwrap()), then the suffix [EXE] needs to be handled. If [EXE] is added, then an error occurs:
--- Expected
++++ actual: stdout
1 - \\?\D:\Rust\temp\temp\temp\cargo\target\debug\cargo.exe[EXE]
1 + //?/D:/Rust/temp/temp/temp/cargo/target/debug/cargo[EXE]
2.Try changing it to .with_stdout_data(cargo.to_str()); it gives an error:
error[E0277]: the trait bound `std::option::Option<&str>: snapbox::IntoData` is not satisfied
- Trying to change to
.with_stdout_data(envtest_bin)in the following will result in an error:
--- Expected
++++ actual: stdout
1 - \\?\D:\Rust\temp\temp\temp\cargo\target\tmp\cit\t0\cargo-envtest\target\debug\cargo-envtest.exe∅
1 + //?/[ROOT]/cargo-envtest/target/debug/cargo-envtest[EXE]
All I can think of at the moment is to use the current modification or add #[allow(deprecated)].
tests/testsuite/cargo_command.rs
Outdated
| .env("PATH", &path) | ||
| .env(cargo::CARGO_ENV, &envtest_bin) | ||
| .with_stdout(envtest_bin) | ||
| .with_stdout_data(str![[r#" |
There was a problem hiding this comment.
ditto. Just check the value against envtest_bin.
c335fb0 to
7dc6253
Compare
7dc6253 to
1b90556
Compare
1b90556 to
a32be92
Compare
| assert!(paths::root().join("foo2/.git").is_dir()); | ||
| } | ||
|
|
||
| #[allow(deprecated)] |
|
Looks good. Thanks! @bors r+ |
|
☀️ Test successful - checks-actions |
Update cargo 13 commits in a515d463427b3912ec0365d106791f88c1c14e1b..f86ce56396168edf5d0e1c412ddda0b2edba7d46 2024-07-02 20:53:36 +0000 to 2024-07-05 17:52:05 +0000 - test: Migrate jobserver to snapbox (rust-lang/cargo#14191) - chore(deps): update msrv (3 versions) to v1.77 (rust-lang/cargo#14186) - test: migrate build_plan and build_script to snapbox (rust-lang/cargo#14193) - test: migrate cfg and check to snapbox (rust-lang/cargo#14185) - test: migrate install* and inheritable_workspace_fields to snapbox (rust-lang/cargo#14170) - Pass rustflags to artifacts built with implicit targets when using target-applies-to-host (rust-lang/cargo#13900) - test: Migrate network tests to snapbox (rust-lang/cargo#14187) - test: migrate some files to snapbox (rust-lang/cargo#14113) - test: Auto-redact `... after last build at ...`; Migrate `freshness` to Snapbox (rust-lang/cargo#14161) - chore: fix some typos (rust-lang/cargo#14182) - fix: improve message for inactive weak optional feature with edition2024 through unused dep collection (rust-lang/cargo#14026) - test:migrate `doc/directory/docscrape` to snapbox (rust-lang/cargo#14171) - test: Migrate git_auth to snapbox (rust-lang/cargo#14172)
Update cargo 20 commits in a515d463427b3912ec0365d106791f88c1c14e1b..154fdac39ae9629954e19e9986fd2cf2cdd8d964 2024-07-02 20:53:36 +0000 to 2024-07-07 01:28:23 +0000 - test: relax redactions for rust-lang/rust (rust-lang/cargo#14203) - use "bootstrap" instead of "rustbuild" (rust-lang/cargo#14207) - test: migrate serveral files to snapbox (rust-lang/cargo#14180) - Add rustdocflags to Unit's Debug impl (rust-lang/cargo#14201) - Allow enabling `config-include` feature in config (rust-lang/cargo#14196) - fix(test): Restore `does_not_contain` for check (rust-lang/cargo#14198) - test: migrate patch, pkgid, proc_macro and progress to snapbox (rust-lang/cargo#14181) - test: Migrate jobserver to snapbox (rust-lang/cargo#14191) - chore(deps): update msrv (3 versions) to v1.77 (rust-lang/cargo#14186) - test: migrate build_plan and build_script to snapbox (rust-lang/cargo#14193) - test: migrate cfg and check to snapbox (rust-lang/cargo#14185) - test: migrate install* and inheritable_workspace_fields to snapbox (rust-lang/cargo#14170) - Pass rustflags to artifacts built with implicit targets when using target-applies-to-host (rust-lang/cargo#13900) - test: Migrate network tests to snapbox (rust-lang/cargo#14187) - test: migrate some files to snapbox (rust-lang/cargo#14113) - test: Auto-redact `... after last build at ...`; Migrate `freshness` to Snapbox (rust-lang/cargo#14161) - chore: fix some typos (rust-lang/cargo#14182) - fix: improve message for inactive weak optional feature with edition2024 through unused dep collection (rust-lang/cargo#14026) - test:migrate `doc/directory/docscrape` to snapbox (rust-lang/cargo#14171) - test: Migrate git_auth to snapbox (rust-lang/cargo#14172)
This is a follow up to rust-lang#14113
test: Ensure --list test works with cargo-bloat This is a follow up to #14113
What does this PR try to resolve?
Changes to the following documents were completed:
tests/testsuite/cargo_command.rstests/testsuite/cargo_env_config.rstests/testsuite/cargo_features.rstests/testsuite/cargo_targets.rspart of #14039