@@ -7,15 +7,64 @@ 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
+ ///////////////////////////////
14
+ //// Unstable feature tests start
15
+ ///////////////////////////////
16
+
17
+ #[ cargo_test]
18
+ fn must_have_unstable_options ( ) {
19
+ let lockfile_path = "mylockfile/is/burried/Cargo.lock" ;
20
+ let p = make_project ( ) . build ( ) ;
21
+
22
+ p. cargo ( "generate-lockfile" )
23
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
24
+ . arg ( "--lockfile-path" )
25
+ . arg ( lockfile_path)
26
+ . with_stderr_data ( str![ [
27
+ r#"[ERROR] the `--lockfile-path` flag is unstable, pass `-Z unstable-options` to enable it
28
+ See https://github.com/rust-lang/cargo/issues/5707 for more information about the `--lockfile-path` flag.
29
+
30
+ "# ] ] )
31
+ . with_status ( 101 )
32
+ . run ( ) ;
33
+ }
34
+
35
+ #[ cargo_test]
36
+ fn must_be_nightly ( ) {
37
+ let lockfile_path = "mylockfile/is/burried/Cargo.lock" ;
38
+ let p = make_project ( ) . build ( ) ;
39
+
40
+ p. cargo ( "generate-lockfile" )
41
+ . arg ( "-Zunstable-options" )
42
+ . arg ( "--lockfile-path" )
43
+ . arg ( lockfile_path)
44
+ . with_stderr_data ( str![ [
45
+ r#"[ERROR] the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
46
+ See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
47
+
48
+ "# ] ] )
49
+ . with_status ( 101 )
50
+ . run ( ) ;
51
+ }
52
+
53
+ ///////////////////////////////
54
+ //// Unstable feature tests end
55
+ ///////////////////////////////
56
+
13
57
#[ cargo_test]
14
58
fn basic_lockfile_created ( ) {
15
59
let lockfile_path = "mylockfile/is/burried/Cargo.lock" ;
16
60
let p = make_project ( ) . build ( ) ;
17
61
18
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
62
+ p. cargo ( "generate-lockfile" )
63
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
64
+ . arg ( "-Zunstable-options" )
65
+ . arg ( "--lockfile-path" )
66
+ . arg ( lockfile_path)
67
+ . run ( ) ;
19
68
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
20
69
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
21
70
}
@@ -25,7 +74,12 @@ fn basic_lockfile_read() {
25
74
let lockfile_path = "mylockfile/Cargo.lock" ;
26
75
let p = make_project ( ) . file ( lockfile_path, VALID_LOCKFILE ) . build ( ) ;
27
76
28
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
77
+ p. cargo ( "generate-lockfile" )
78
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
79
+ . arg ( "-Zunstable-options" )
80
+ . arg ( "--lockfile-path" )
81
+ . arg ( lockfile_path)
82
+ . run ( ) ;
29
83
30
84
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
31
85
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
@@ -38,7 +92,12 @@ fn basic_lockfile_override() {
38
92
. file ( "Cargo.lock" , "This is an invalid lock file!" )
39
93
. build ( ) ;
40
94
41
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
95
+ p. cargo ( "generate-lockfile" )
96
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
97
+ . arg ( "-Zunstable-options" )
98
+ . arg ( "--lockfile-path" )
99
+ . arg ( lockfile_path)
100
+ . run ( ) ;
42
101
43
102
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
44
103
}
@@ -62,7 +121,12 @@ fn symlink_in_path() {
62
121
fs:: create_dir ( p. root ( ) . join ( "dst" ) ) . unwrap ( ) ;
63
122
assert ! ( p. root( ) . join( src) . is_dir( ) ) ;
64
123
65
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path. as_str ( ) ) . run ( ) ;
124
+ p. cargo ( "generate-lockfile" )
125
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
126
+ . arg ( "-Zunstable-options" )
127
+ . arg ( "--lockfile-path" )
128
+ . arg ( lockfile_path. as_str ( ) )
129
+ . run ( ) ;
66
130
67
131
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
68
132
assert ! ( p. root( ) . join( dst) . join( "Cargo.lock" ) . is_file( ) ) ;
@@ -85,7 +149,12 @@ fn symlink_lockfile() {
85
149
86
150
assert ! ( p. root( ) . join( src) . is_file( ) ) ;
87
151
88
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
152
+ p. cargo ( "generate-lockfile" )
153
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
154
+ . arg ( "-Zunstable-options" )
155
+ . arg ( "--lockfile-path" )
156
+ . arg ( lockfile_path)
157
+ . run ( ) ;
89
158
90
159
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
91
160
}
@@ -103,7 +172,11 @@ fn broken_symlink() {
103
172
let p = make_project ( ) . symlink_dir ( invalid_dst, src) . build ( ) ;
104
173
assert ! ( !p. root( ) . join( src) . is_dir( ) ) ;
105
174
106
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path. as_str ( ) )
175
+ p. cargo ( "generate-lockfile" )
176
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
177
+ . arg ( "-Zunstable-options" )
178
+ . arg ( "--lockfile-path" )
179
+ . arg ( lockfile_path)
107
180
. with_status ( 101 )
108
181
. with_stderr_data ( str![ [
109
182
r#"[ERROR] failed to create directory `[ROOT]/foo/somedir/link`
@@ -131,7 +204,11 @@ fn loop_symlink() {
131
204
. build ( ) ;
132
205
assert ! ( !p. root( ) . join( src) . is_dir( ) ) ;
133
206
134
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path. as_str ( ) )
207
+ p. cargo ( "generate-lockfile" )
208
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
209
+ . arg ( "-Zunstable-options" )
210
+ . arg ( "--lockfile-path" )
211
+ . arg ( lockfile_path)
135
212
. with_status ( 101 )
136
213
. with_stderr_data ( str![ [
137
214
r#"[ERROR] failed to create directory `[ROOT]/foo/somedir/link`
@@ -158,7 +235,11 @@ fn add_lockfile_override() {
158
235
let p = make_project ( )
159
236
. file ( "Cargo.lock" , "This is an invalid lock file!" )
160
237
. build ( ) ;
161
- make_execs ( & mut p. cargo ( "add" ) , lockfile_path)
238
+ p. cargo ( "add" )
239
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
240
+ . arg ( "-Zunstable-options" )
241
+ . arg ( "--lockfile-path" )
242
+ . arg ( lockfile_path)
162
243
. arg ( "--path" )
163
244
. arg ( "../bar" )
164
245
. run ( ) ;
@@ -172,7 +253,11 @@ fn clean_lockfile_override() {
172
253
let p = make_project ( )
173
254
. file ( "Cargo.lock" , "This is an invalid lock file!" )
174
255
. build ( ) ;
175
- make_execs ( & mut p. cargo ( "clean" ) , lockfile_path)
256
+ p. cargo ( "clean" )
257
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
258
+ . arg ( "-Zunstable-options" )
259
+ . arg ( "--lockfile-path" )
260
+ . arg ( lockfile_path)
176
261
. arg ( "--package" )
177
262
. arg ( "test_foo" )
178
263
. run ( ) ;
@@ -186,7 +271,11 @@ fn fix_lockfile_override() {
186
271
let p = make_project ( )
187
272
. file ( "Cargo.lock" , "This is an invalid lock file!" )
188
273
. build ( ) ;
189
- make_execs ( & mut p. cargo ( "fix" ) , lockfile_path)
274
+ p. cargo ( "fix" )
275
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
276
+ . arg ( "-Zunstable-options" )
277
+ . arg ( "--lockfile-path" )
278
+ . arg ( lockfile_path)
190
279
. arg ( "--package" )
191
280
. arg ( "test_foo" )
192
281
. arg ( "--allow-no-vcs" )
@@ -201,7 +290,11 @@ fn publish_lockfile_read() {
201
290
let p = make_project ( ) . file ( lockfile_path, VALID_LOCKFILE ) . build ( ) ;
202
291
let registry = RegistryBuilder :: new ( ) . http_api ( ) . http_index ( ) . build ( ) ;
203
292
204
- make_execs ( & mut p. cargo ( "publish" ) , lockfile_path)
293
+ p. cargo ( "publish" )
294
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
295
+ . arg ( "-Zunstable-options" )
296
+ . arg ( "--lockfile-path" )
297
+ . arg ( lockfile_path)
205
298
. replace_crates_io ( registry. index_url ( ) )
206
299
. run ( ) ;
207
300
@@ -239,7 +332,11 @@ fn remove_lockfile_override() {
239
332
. file ( "src/main.rs" , "fn main() {}" )
240
333
. file ( "Cargo.lock" , "This is an invalid lock file!" )
241
334
. build ( ) ;
242
- make_execs ( & mut p. cargo ( "remove" ) , lockfile_path)
335
+ p. cargo ( "remove" )
336
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
337
+ . arg ( "-Zunstable-options" )
338
+ . arg ( "--lockfile-path" )
339
+ . arg ( lockfile_path)
243
340
. arg ( "test_bar" )
244
341
. run ( ) ;
245
342
@@ -272,15 +369,25 @@ bar = "0.1.0"
272
369
. build ( ) ;
273
370
274
371
Package :: new ( "bar" , "0.1.0" ) . publish ( ) ;
275
- make_execs ( & mut p. cargo ( "generate-lockfile" ) , lockfile_path) . run ( ) ;
372
+ p. cargo ( "generate-lockfile" )
373
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
374
+ . arg ( "-Zunstable-options" )
375
+ . arg ( "--lockfile-path" )
376
+ . arg ( lockfile_path)
377
+ . run ( ) ;
276
378
277
379
assert ! ( !p. root( ) . join( "Cargo.lock" ) . exists( ) ) ;
278
380
assert ! ( p. root( ) . join( lockfile_path) . is_file( ) ) ;
279
381
280
382
let lockfile_original = fs:: read_to_string ( p. root ( ) . join ( lockfile_path) ) . unwrap ( ) ;
281
383
282
384
Package :: new ( "bar" , "0.1.1" ) . publish ( ) ;
283
- make_execs ( & mut p. cargo ( "package" ) , lockfile_path) . run ( ) ;
385
+ p. cargo ( "package" )
386
+ . masquerade_as_nightly_cargo ( & [ "lockfile-path" ] )
387
+ . arg ( "-Zunstable-options" )
388
+ . arg ( "--lockfile-path" )
389
+ . arg ( lockfile_path)
390
+ . run ( ) ;
284
391
285
392
assert ! ( p
286
393
. root( )
@@ -353,11 +460,3 @@ fn make_project() -> ProjectBuilder {
353
460
. file ( "Cargo.toml" , & basic_bin_manifest ( "test_foo" ) )
354
461
. file ( "src/main.rs" , "fn main() {}" )
355
462
}
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