Skip to content

Commit 8b383cb

Browse files
committed
test(patch-files): verify non-blocking gates and warnings
1 parent 5b6446c commit 8b383cb

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed

tests/testsuite/main.rs

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ mod owner;
134134
mod package;
135135
mod package_features;
136136
mod patch;
137+
mod patch_files;
137138
mod path;
138139
mod paths;
139140
mod pkgid;

tests/testsuite/patch_files.rs

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
//! Tests for unstable `patch-files` feature.
2+
3+
use cargo_test_support::registry::Package;
4+
use cargo_test_support::project;
5+
6+
#[cargo_test]
7+
fn gated_manifest() {
8+
Package::new("bar", "1.0.0").publish();
9+
let p = project()
10+
.file(
11+
"Cargo.toml",
12+
r#"
13+
[package]
14+
name = "foo"
15+
edition = "2015"
16+
17+
[dependencies]
18+
bar = "1"
19+
20+
[patch.crates-io]
21+
bar = { version = "=1.0.0", patches = [] }
22+
"#,
23+
)
24+
.file("src/lib.rs", "")
25+
.build();
26+
27+
p.cargo("check")
28+
.with_status(101)
29+
.with_stderr(
30+
"\
31+
[WARNING] ignoring `patches` on patch for `bar` in `[..]`; see [..] about the status of this feature.
32+
[UPDATING] [..]
33+
[ERROR] failed to resolve patches for `[..]`
34+
35+
Caused by:
36+
patch for `bar` in `[..]` points to the same source, but patches must point to different sources
37+
",
38+
)
39+
.run();
40+
}
41+
42+
#[cargo_test]
43+
fn gated_config() {
44+
Package::new("bar", "1.0.0").publish();
45+
let p = project()
46+
.file(
47+
"Cargo.toml",
48+
r#"
49+
[package]
50+
name = "foo"
51+
edition = "2015"
52+
53+
[dependencies]
54+
bar = "1"
55+
56+
[patch.crates-io]
57+
bar = { version = "=1.0.0", patches = [] }
58+
"#,
59+
)
60+
.file("src/lib.rs", "")
61+
.file(
62+
".cargo/config.toml",
63+
r#"
64+
[patch.crates-io]
65+
bar = { version = "=1.0.0", patches = [] }
66+
"#,
67+
)
68+
.build();
69+
70+
p.cargo("check")
71+
.with_status(101)
72+
.with_stderr(
73+
"\
74+
[WARNING] ignoring `patches` on patch for `bar` in `[..]`; see [..] about the status of this feature.
75+
[WARNING] [patch] in cargo config: ignoring `patches` on patch for `bar` in `[..]`; see [..] about the status of this feature.
76+
[UPDATING] [..]
77+
[ERROR] failed to resolve patches for `[..]`
78+
79+
Caused by:
80+
patch for `bar` in `[..]` points to the same source, but patches must point to different sources
81+
",
82+
)
83+
.run();
84+
}
85+
86+
#[cargo_test]
87+
fn warn_if_in_normal_dep() {
88+
Package::new("bar", "1.0.0").publish();
89+
let p = project()
90+
.file(
91+
"Cargo.toml",
92+
r#"
93+
[package]
94+
name = "foo"
95+
edition = "2015"
96+
97+
[dependencies]
98+
bar = { version = "1", patches = [] }
99+
"#,
100+
)
101+
.file("src/lib.rs", "")
102+
.build();
103+
104+
p.cargo("check")
105+
.with_stderr(
106+
"\
107+
[WARNING] unused manifest key: dependencies.bar.patches; see [..] about the status of this feature.
108+
[UPDATING] `dummy-registry` index
109+
[LOCKING] [..]
110+
[DOWNLOADING] crates ...
111+
[DOWNLOADED] bar v1.0.0 (registry `dummy-registry`)
112+
[CHECKING] bar v1.0.0
113+
[CHECKING] foo v0.0.0 ([CWD])
114+
[FINISHED] `dev` profile [..]
115+
",
116+
)
117+
.run();
118+
}

0 commit comments

Comments
 (0)