Skip to content

Commit 7d12956

Browse files
committed
test: migrate vendor to snapbox
1 parent aeeed9f commit 7d12956

File tree

1 file changed

+75
-41
lines changed

1 file changed

+75
-41
lines changed

tests/testsuite/vendor.rs

Lines changed: 75 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,11 @@
44
//! "fake" crates.io is used. Otherwise `vendor` would download the crates.io
55
//! index from the network.
66
7-
#![allow(deprecated)]
8-
97
use std::fs;
108

119
use cargo_test_support::compare::assert_e2e;
1210
use cargo_test_support::git;
11+
use cargo_test_support::prelude::*;
1312
use cargo_test_support::registry::{self, Package, RegistryBuilder};
1413
use cargo_test_support::str;
1514
use cargo_test_support::{basic_lib_manifest, basic_manifest, paths, project, Project};
@@ -61,14 +60,14 @@ fn vendor_sample_config() {
6160
Package::new("log", "0.3.5").publish();
6261

6362
p.cargo("vendor --respect-source-config")
64-
.with_stdout(
65-
r#"[source.crates-io]
63+
.with_stdout_data(str![[r#"
64+
[source.crates-io]
6665
replace-with = "vendored-sources"
6766
6867
[source.vendored-sources]
6968
directory = "vendor"
70-
"#,
71-
)
69+
70+
"#]])
7271
.run();
7372
}
7473

@@ -93,7 +92,7 @@ fn vendor_sample_config_alt_registry() {
9392
Package::new("log", "0.3.5").alternative(true).publish();
9493

9594
p.cargo("vendor --respect-source-config")
96-
.with_stdout(format!(
95+
.with_stdout_data(format!(
9796
r#"[source."{0}"]
9897
registry = "{0}"
9998
replace-with = "vendored-sources"
@@ -438,12 +437,14 @@ fn test_sync_argument() {
438437
Package::new("bitflags", "0.8.0").publish();
439438

440439
p.cargo("vendor --respect-source-config --manifest-path foo/Cargo.toml -s bar/Cargo.toml baz/Cargo.toml test_vendor")
441-
.with_stderr("\
442-
error: unexpected argument 'test_vendor' found
440+
.with_stderr_data(str![[r#"
441+
[ERROR] unexpected argument 'test_vendor' found
443442
444-
Usage: cargo[EXE] vendor [OPTIONS] [path]
443+
Usage: cargo vendor [OPTIONS] [path]
445444
446-
For more information, try '--help'.",
445+
For more information, try '--help'.
446+
447+
"#]]
447448
)
448449
.with_status(1)
449450
.run();
@@ -714,21 +715,21 @@ fn git_diff_rev() {
714715
.build();
715716

716717
p.cargo("vendor --respect-source-config")
717-
.with_stdout(
718-
r#"[source."git+file://[..]/git?rev=v0.1.0"]
719-
git = [..]
718+
.with_stdout_data(str![[r#"
719+
[source."git+[ROOTURL]/git?rev=v0.1.0"]
720+
git = "[ROOTURL]/git"
720721
rev = "v0.1.0"
721722
replace-with = "vendored-sources"
722723
723-
[source."git+file://[..]/git?rev=v0.2.0"]
724-
git = [..]
724+
[source."git+[ROOTURL]/git?rev=v0.2.0"]
725+
git = "[ROOTURL]/git"
725726
rev = "v0.2.0"
726727
replace-with = "vendored-sources"
727728
728729
[source.vendored-sources]
729730
directory = "vendor"
730-
"#,
731-
)
731+
732+
"#]])
732733
.run();
733734
}
734735

@@ -773,22 +774,21 @@ fn git_duplicate() {
773774
Package::new("b", "0.5.0").publish();
774775

775776
p.cargo("vendor --respect-source-config")
776-
.with_stderr(
777-
"\
778-
[UPDATING] [..]
779-
[UPDATING] [..]
777+
.with_stderr_data(str![[r#"
778+
[UPDATING] git repository `[ROOTURL]/a`
779+
[UPDATING] `dummy-registry` index
780780
[LOCKING] 4 packages to latest compatible versions
781-
[DOWNLOADING] [..]
782-
[DOWNLOADED] [..]
783-
error: failed to sync
781+
[DOWNLOADING] crates ...
782+
[DOWNLOADED] b v0.5.0 (registry `dummy-registry`)
783+
[ERROR] failed to sync
784784
785785
Caused by:
786786
found duplicate version of package `b v0.5.0` vendored from two sources:
787787
788-
<tab>source 1: [..]
789-
<tab>source 2: [..]
790-
",
791-
)
788+
source 1: registry `crates-io`
789+
source 2: [ROOTURL]/a#[..]
790+
791+
"#]])
792792
.with_status(101)
793793
.run();
794794
}
@@ -859,10 +859,23 @@ fn git_complex() {
859859
p.change_file(".cargo/config.toml", &output);
860860

861861
p.cargo("check -v")
862-
.with_stderr_contains("[..]foo/vendor/a/src/lib.rs[..]")
863-
.with_stderr_contains("[..]foo/vendor/dep_a/src/lib.rs[..]")
864-
.with_stderr_contains("[..]foo/vendor/b/src/lib.rs[..]")
865-
.with_stderr_contains("[..]foo/vendor/dep_b/src/lib.rs[..]")
862+
.with_stderr_data(
863+
str![[r#"
864+
[CHECKING] dep_b v0.5.0 ([ROOTURL]/git_b#[..])
865+
[CHECKING] dep_a v0.5.0 ([ROOTURL]/git_a#[..])
866+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/dep_b/src/lib.rs [..]`
867+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/dep_a/src/lib.rs [..]`
868+
[CHECKING] b v0.1.0 ([ROOTURL]/git_b#[..])
869+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/b/src/lib.rs [..]`
870+
[CHECKING] a v0.1.0 ([ROOTURL]/git_a#[..])
871+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/a/src/lib.rs [..]`
872+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
873+
[RUNNING] `rustc [..] src/lib.rs [..]`
874+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
875+
876+
"#]]
877+
.unordered(),
878+
)
866879
.run();
867880
}
868881

@@ -1106,9 +1119,21 @@ fn config_instructions_works() {
11061119
p.change_file(".cargo/config.toml", &output);
11071120

11081121
p.cargo("check -v")
1109-
.with_stderr_contains("[..]foo/vendor/dep/src/lib.rs[..]")
1110-
.with_stderr_contains("[..]foo/vendor/altdep/src/lib.rs[..]")
1111-
.with_stderr_contains("[..]foo/vendor/gitdep/src/lib.rs[..]")
1122+
.with_stderr_data(
1123+
str![[r#"
1124+
[CHECKING] altdep v0.1.0 (registry `alternative`)
1125+
[CHECKING] dep v0.1.0
1126+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/altdep/src/lib.rs [..]`
1127+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/gitdep/src/lib.rs [..]`
1128+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/dep/src/lib.rs [..]`
1129+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
1130+
[RUNNING] `rustc [..] src/lib.rs [..]`
1131+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1132+
[CHECKING] gitdep v0.5.0 ([ROOTURL]/gitdep#[..])
1133+
1134+
"#]]
1135+
.unordered(),
1136+
)
11121137
.run();
11131138
}
11141139

@@ -1214,11 +1239,11 @@ fn no_remote_dependency_no_vendor() {
12141239
.build();
12151240

12161241
p.cargo("vendor")
1217-
.with_stderr(
1218-
"\
1242+
.with_stderr_data(str![[r#"
12191243
[LOCKING] 2 packages to latest compatible versions
1220-
There is no dependency to vendor in this project.",
1221-
)
1244+
There is no dependency to vendor in this project.
1245+
1246+
"#]])
12221247
.run();
12231248
assert!(!p.root().join("vendor").exists());
12241249
}
@@ -1241,6 +1266,7 @@ fn vendor_crate_with_ws_inherit() {
12411266
[package]
12421267
name = "bar"
12431268
version.workspace = true
1269+
edition = "2021"
12441270
"#,
12451271
)
12461272
.file("bar/src/lib.rs", "")
@@ -1254,6 +1280,7 @@ fn vendor_crate_with_ws_inherit() {
12541280
[package]
12551281
name = "foo"
12561282
version = "0.1.0"
1283+
edition = "2021"
12571284
12581285
[dependencies]
12591286
bar = {{ git = '{}' }}
@@ -1282,6 +1309,13 @@ fn vendor_crate_with_ws_inherit() {
12821309
);
12831310

12841311
p.cargo("check -v")
1285-
.with_stderr_contains("[..]foo/vendor/bar/src/lib.rs[..]")
1312+
.with_stderr_data(str![[r#"
1313+
[CHECKING] bar v0.1.0 ([ROOTURL]/ws#[..])
1314+
[RUNNING] `rustc [..] [ROOT]/foo/vendor/bar/src/lib.rs [..]`
1315+
[CHECKING] foo v0.1.0 ([ROOT]/foo)
1316+
[RUNNING] `rustc [..] src/lib.rs [..]`
1317+
[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
1318+
1319+
"#]])
12861320
.run();
12871321
}

0 commit comments

Comments
 (0)