1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
|
//! Tests for `paths` overrides.
use cargo_test_support::registry::Package;
use cargo_test_support::{basic_manifest, project};
#[cargo_test]
fn broken_path_override_warns() {
Package::new("bar", "0.1.0").publish();
Package::new("bar", "0.2.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
a = { path = "a1" }
"#,
)
.file("src/lib.rs", "")
.file(
"a1/Cargo.toml",
r#"
[package]
name = "a"
version = "0.0.1"
authors = []
[dependencies]
bar = "0.1"
"#,
)
.file("a1/src/lib.rs", "")
.file(
"a2/Cargo.toml",
r#"
[package]
name = "a"
version = "0.0.1"
authors = []
[dependencies]
bar = "0.2"
"#,
)
.file("a2/src/lib.rs", "")
.file(".cargo/config", r#"paths = ["a2"]"#)
.build();
p.cargo("check")
.with_stderr(
"\
[UPDATING] [..]
warning: path override for crate `a` has altered the original list of
dependencies; the dependency on `bar` was either added or
modified to not match the previously resolved version
This is currently allowed but is known to produce buggy behavior with spurious
recompiles and changes to the crate graph. Path overrides unfortunately were
never intended to support this feature, so for now this message is just a
warning. In the future, however, this message will become a hard error.
To change the dependency graph via an override it's recommended to use the
`[patch]` feature of Cargo instead of the path override feature. This is
documented online at the url below for more information.
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html
[DOWNLOADING] crates ...
[DOWNLOADED] [..]
[CHECKING] [..]
[CHECKING] [..]
[CHECKING] [..]
[FINISHED] [..]
",
)
.run();
}
#[cargo_test]
fn override_to_path_dep() {
Package::new("bar", "0.1.0").dep("baz", "0.1").publish();
Package::new("baz", "0.1.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
bar = "0.1.0"
"#,
)
.file("src/lib.rs", "")
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.0.1"
authors = []
[dependencies]
baz = { path = "baz" }
"#,
)
.file("bar/src/lib.rs", "")
.file("bar/baz/Cargo.toml", &basic_manifest("baz", "0.0.1"))
.file("bar/baz/src/lib.rs", "")
.file(".cargo/config", r#"paths = ["bar"]"#)
.build();
p.cargo("check").run();
}
#[cargo_test]
fn paths_ok_with_optional() {
Package::new("baz", "0.1.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
bar = { path = "bar" }
"#,
)
.file("src/lib.rs", "")
.file(
"bar/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.1.0"
authors = []
[dependencies]
baz = { version = "0.1", optional = true }
"#,
)
.file("bar/src/lib.rs", "")
.file(
"bar2/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.1.0"
authors = []
[dependencies]
baz = { version = "0.1", optional = true }
"#,
)
.file("bar2/src/lib.rs", "")
.file(".cargo/config", r#"paths = ["bar2"]"#)
.build();
p.cargo("check")
.with_stderr(
"\
[CHECKING] bar v0.1.0 ([..]bar2)
[CHECKING] foo v0.0.1 ([..])
[FINISHED] [..]
",
)
.run();
}
#[cargo_test]
fn paths_add_optional_bad() {
Package::new("baz", "0.1.0").publish();
let p = project()
.file(
"Cargo.toml",
r#"
[package]
name = "foo"
version = "0.0.1"
authors = []
[dependencies]
bar = { path = "bar" }
"#,
)
.file("src/lib.rs", "")
.file("bar/Cargo.toml", &basic_manifest("bar", "0.1.0"))
.file("bar/src/lib.rs", "")
.file(
"bar2/Cargo.toml",
r#"
[package]
name = "bar"
version = "0.1.0"
authors = []
[dependencies]
baz = { version = "0.1", optional = true }
"#,
)
.file("bar2/src/lib.rs", "")
.file(".cargo/config", r#"paths = ["bar2"]"#)
.build();
p.cargo("check")
.with_stderr_contains(
"\
warning: path override for crate `bar` has altered the original list of
dependencies; the dependency on `baz` was either added or\
",
)
.run();
}
|