test: migrate rename_deps to snapbox

This commit is contained in:
eth3lbert 2024-06-22 13:15:42 +08:00
parent bc89bffa59
commit 2d23d031e3
No known key found for this signature in database

View File

@ -1,11 +1,9 @@
//! Tests for renaming dependencies. //! Tests for renaming dependencies.
#![allow(deprecated)]
use cargo_test_support::git; use cargo_test_support::git;
use cargo_test_support::paths; use cargo_test_support::paths;
use cargo_test_support::registry::{self, Package}; use cargo_test_support::registry::{self, Package};
use cargo_test_support::{basic_manifest, project}; use cargo_test_support::{basic_manifest, project, str};
#[cargo_test] #[cargo_test]
fn rename_dependency() { fn rename_dependency() {
@ -191,15 +189,14 @@ fn rename_twice() {
p.cargo("build -v") p.cargo("build -v")
.with_status(101) .with_status(101)
.with_stderr( .with_stderr_data(str![[r#"
"\ [UPDATING] `dummy-registry` index
[UPDATING] `[..]` index
[LOCKING] 2 packages to latest compatible versions [LOCKING] 2 packages to latest compatible versions
[DOWNLOADING] crates ... [DOWNLOADING] crates ...
[DOWNLOADED] foo v0.1.0 (registry [..]) [DOWNLOADED] foo v0.1.0 (registry `dummy-registry`)
error: the crate `test v0.1.0 ([CWD])` depends on crate `foo v0.1.0` multiple times with different names [ERROR] the crate `test v0.1.0 ([ROOT]/foo)` depends on crate `foo v0.1.0` multiple times with different names
",
) "#]])
.run(); .run();
} }
@ -242,7 +239,14 @@ fn rename_affects_fingerprint() {
p.cargo("build -v") p.cargo("build -v")
.with_status(101) .with_status(101)
.with_stderr_contains("[..]can't find crate for `foo`") .with_stderr_data(str![[r#"
[FRESH] foo v0.1.0
[DIRTY] test v0.1.0 ([ROOT]/foo): name of dependency changed (foo => bar)
[COMPILING] test v0.1.0 ([ROOT]/foo)
[RUNNING] `rustc [..]`
error[E0463]: can't find crate for `foo`
...
"#]])
.run(); .run();
} }
@ -274,18 +278,12 @@ fn can_run_doc_tests() {
) )
.build(); .build();
foo.cargo("test -v") foo.cargo("test -v").with_stderr_data(str![[r#"
.with_stderr_contains( ...
"\
[DOCTEST] foo [DOCTEST] foo
[RUNNING] `rustdoc [..]--test [..]src/lib.rs \ [RUNNING] `rustdoc [..]--test src/lib.rs [..] --extern bar=[ROOT]/foo/target/debug/deps/libbar-[HASH].rlib --extern baz=[ROOT]/foo/target/debug/deps/libbar-[HASH].rlib [..]`
[..] \
--extern bar=[CWD]/target/debug/deps/libbar-[..].rlib \ "#]]).run();
--extern baz=[CWD]/target/debug/deps/libbar-[..].rlib \
[..]`
",
)
.run();
} }
#[cargo_test] #[cargo_test]
@ -373,14 +371,13 @@ fn features_not_working() {
p.cargo("build -v") p.cargo("build -v")
.with_status(101) .with_status(101)
.with_stderr( .with_stderr_data(str![[r#"
"\ [ERROR] failed to parse manifest at `[ROOT]/foo/Cargo.toml`
error: failed to parse manifest at `[..]`
Caused by: Caused by:
feature `default` includes `p1` which is neither a dependency nor another feature feature `default` includes `p1` which is neither a dependency nor another feature
",
) "#]])
.run(); .run();
} }