@@ -7,15 +7,20 @@ use snapbox::str;
7
7
use cargo_test_support:: compare:: assert_e2e;
8
8
use cargo_test_support:: registry:: { Package , RegistryBuilder } ;
9
9
use cargo_test_support:: {
10
- basic_bin_manifest, cargo_test, project, symlink_supported, Execs , ProjectBuilder ,
10
+ basic_bin_manifest, cargo_test, project, symlink_supported, ProjectBuilder ,
11
11
} ;
12
12
13
13
#[ cargo_test]
14
14
fn basic_lockfile_created ( ) {
15
15
let lockfile_path = "mylockfile/is/burried/Cargo.lock" ;
16
16
let p = make_project ( ) . build ( ) ;
17
17
18
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
18
+ p. cargo ( "generate-lockfile" )
19
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
20
+ . arg ( "-Zunstable-options" )
21
+ . arg ( "--lockfile-path" )
22
+ . arg ( lockfile_path)
23
+ . run ( ) ;
19
24
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
20
25
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
21
26
}
@@ -25,7 +30,12 @@ fn basic_lockfile_read() {
25
30
let lockfile_path = "mylockfile/Cargo.lock" ;
26
31
let p = make_project ( ) . file ( lockfile_path, VALID_LOCKFILE ) . build ( ) ;
27
32
28
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
33
+ p. cargo ( "generate-lockfile" )
34
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
35
+ . arg ( "-Zunstable-options" )
36
+ . arg ( "--lockfile-path" )
37
+ . arg ( lockfile_path)
38
+ . run ( ) ;
29
39
30
40
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
31
41
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
@@ -38,7 +48,12 @@ fn basic_lockfile_override() {
38
48
. file ( "Cargo.lock" , "This is an invalid lock file!" )
39
49
. build ( ) ;
40
50
41
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
51
+ p. cargo ( "generate-lockfile" )
52
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
53
+ . arg ( "-Zunstable-options" )
54
+ . arg ( "--lockfile-path" )
55
+ . arg ( lockfile_path)
56
+ . run ( ) ;
42
57
43
58
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
44
59
}
@@ -62,7 +77,12 @@ fn symlink_in_path() {
62
77
fs:: create_dir ( p. root ( ) . join ( "dst" ) ) . unwrap ( ) ;
63
78
assert ! ( p. root( ) . join( src) . is_dir( ) ) ;
64
79
65
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path. as_str ( ) ) . run ( ) ;
80
+ p. cargo ( "generate-lockfile" )
81
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
82
+ . arg ( "-Zunstable-options" )
83
+ . arg ( "--lockfile-path" )
84
+ . arg ( lockfile_path. as_str ( ) )
85
+ . run ( ) ;
66
86
67
87
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
68
88
assert ! ( p. root( ) . join( dst) . join( "Cargo.lock" ) . is_file( ) ) ;
@@ -85,7 +105,12 @@ fn symlink_lockfile() {
85
105
86
106
assert ! ( p. root( ) . join( src) . is_file( ) ) ;
87
107
88
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
108
+ p. cargo ( "generate-lockfile" )
109
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
110
+ . arg ( "-Zunstable-options" )
111
+ . arg ( "--lockfile-path" )
112
+ . arg ( lockfile_path)
113
+ . run ( ) ;
89
114
90
115
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
91
116
}
@@ -103,7 +128,11 @@ fn broken_symlink() {
103
128
let p = make_project ( ) . symlink_dir ( invalid_dst, src) . build ( ) ;
104
129
assert ! ( !p. root( ) . join( src) . is_dir( ) ) ;
105
130
106
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path. as_str ( ) )
131
+ p. cargo ( "generate-lockfile" )
132
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
133
+ . arg ( "-Zunstable-options" )
134
+ . arg ( "--lockfile-path" )
135
+ . arg ( lockfile_path)
107
136
. with_status ( 101 )
108
137
. with_stderr_data ( str![ [
109
138
r#"[ERROR] failed to create directory `[ROOT]/foo/somedir/link`
@@ -131,7 +160,11 @@ fn loop_symlink() {
131
160
. build ( ) ;
132
161
assert ! ( !p. root( ) . join( src) . is_dir( ) ) ;
133
162
134
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path. as_str ( ) )
163
+ p. cargo ( "generate-lockfile" )
164
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
165
+ . arg ( "-Zunstable-options" )
166
+ . arg ( "--lockfile-path" )
167
+ . arg ( lockfile_path)
135
168
. with_status ( 101 )
136
169
. with_stderr_data ( str![ [
137
170
r#"[ERROR] failed to create directory `[ROOT]/foo/somedir/link`
@@ -158,7 +191,11 @@ fn add_lockfile_override() {
158
191
let p = make_project ( )
159
192
. file ( "Cargo.lock" , "This is an invalid lock file!" )
160
193
. build ( ) ;
161
- make_execs ( & mut p. cargo ( "add" ) , lockfile_path)
194
+ p. cargo ( "add" )
195
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
196
+ . arg ( "-Zunstable-options" )
197
+ . arg ( "--lockfile-path" )
198
+ . arg ( lockfile_path)
162
199
. arg ( "--path" )
163
200
. arg ( "../bar" )
164
201
. run ( ) ;
@@ -172,7 +209,11 @@ fn clean_lockfile_override() {
172
209
let p = make_project ( )
173
210
. file ( "Cargo.lock" , "This is an invalid lock file!" )
174
211
. build ( ) ;
175
- make_execs ( & mut p. cargo ( "clean" ) , lockfile_path)
212
+ p. cargo ( "clean" )
213
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
214
+ . arg ( "-Zunstable-options" )
215
+ . arg ( "--lockfile-path" )
216
+ . arg ( lockfile_path)
176
217
. arg ( "--package" )
177
218
. arg ( "test_foo" )
178
219
. run ( ) ;
@@ -186,7 +227,11 @@ fn fix_lockfile_override() {
186
227
let p = make_project ( )
187
228
. file ( "Cargo.lock" , "This is an invalid lock file!" )
188
229
. build ( ) ;
189
- make_execs ( & mut p. cargo ( "fix" ) , lockfile_path)
230
+ p. cargo ( "fix" )
231
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
232
+ . arg ( "-Zunstable-options" )
233
+ . arg ( "--lockfile-path" )
234
+ . arg ( lockfile_path)
190
235
. arg ( "--package" )
191
236
. arg ( "test_foo" )
192
237
. arg ( "--allow-no-vcs" )
@@ -201,7 +246,11 @@ fn publish_lockfile_read() {
201
246
let p = make_project ( ) . file ( lockfile_path, VALID_LOCKFILE ) . build ( ) ;
202
247
let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
203
248
204
- make_execs ( & mut p. cargo ( "publish" ) , lockfile_path)
249
+ p. cargo ( "publish" )
250
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
251
+ . arg ( "-Zunstable-options" )
252
+ . arg ( "--lockfile-path" )
253
+ . arg ( lockfile_path)
205
254
. replace_crates_io ( registry. index_url ( ) )
206
255
. run ( ) ;
207
256
@@ -239,7 +288,11 @@ fn remove_lockfile_override() {
239
288
. file ( "src/main.rs" , "fn main() {}" )
240
289
. file ( "Cargo.lock" , "This is an invalid lock file!" )
241
290
. build ( ) ;
242
- make_execs ( & mut p. cargo ( "remove" ) , lockfile_path)
291
+ p. cargo ( "remove" )
292
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
293
+ . arg ( "-Zunstable-options" )
294
+ . arg ( "--lockfile-path" )
295
+ . arg ( lockfile_path)
243
296
. arg ( "test_bar" )
244
297
. run ( ) ;
245
298
@@ -272,15 +325,25 @@ bar = "0.1.0"
272
325
. build ( ) ;
273
326
274
327
Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
275
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
328
+ p. cargo ( "generate-lockfile" )
329
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
330
+ . arg ( "-Zunstable-options" )
331
+ . arg ( "--lockfile-path" )
332
+ . arg ( lockfile_path)
333
+ . run ( ) ;
276
334
277
335
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
278
336
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
279
337
280
338
let lockfile_original = fs:: read_to_string ( p. root ( ) . join ( lockfile_path) ) . unwrap ( ) ;
281
339
282
340
Package :: new ( "bar" , "0.1.1" ) . publish ( ) ;
283
- make_execs ( & mut p. cargo ( "package" ) , lockfile_path) . run ( ) ;
341
+ p. cargo ( "package" )
342
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
343
+ . arg ( "-Zunstable-options" )
344
+ . arg ( "--lockfile-path" )
345
+ . arg ( lockfile_path)
346
+ . run ( ) ;
284
347
285
348
assert ! ( p
286
349
. root( )
@@ -353,11 +416,3 @@ fn make_project() -> ProjectBuilder {
353
416
. file ( "Cargo.toml" , & basic_bin_manifest ( "test_foo" ) )
354
417
. file ( "src/main.rs" , "fn main() {}" )
355
418
}
356
-
357
- fn make_execs < ' a > ( execs : & ' a mut Execs , lockfile_path_argument : & str ) -> & ' a mut Execs {
358
- execs
359
- . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
360
- . arg ( "-Zunstable-options" )
361
- . arg ( "--lockfile-path" )
362
- . arg ( lockfile_path_argument)
363
- }
0 commit comments