@@ -8,13 +8,13 @@ use crate::support::{paths, Execs};
8
8
fn cargo_process ( s : & str ) -> Execs {
9
9
let mut execs = support:: cargo_process ( s) ;
10
10
execs. cwd ( & paths:: root ( ) ) . env ( "HOME" , & paths:: home ( ) ) ;
11
+ execs. env ( "USER" , "foo" ) ;
11
12
execs
12
13
}
13
14
14
15
#[ test]
15
16
fn simple_lib ( ) {
16
17
cargo_process ( "init --lib --vcs none --edition 2015" )
17
- . env ( "USER" , "foo" )
18
18
. with_stderr ( "[CREATED] library package" )
19
19
. run ( ) ;
20
20
@@ -30,7 +30,6 @@ fn simple_bin() {
30
30
let path = paths:: root ( ) . join ( "foo" ) ;
31
31
fs:: create_dir ( & path) . unwrap ( ) ;
32
32
cargo_process ( "init --bin --vcs none --edition 2015" )
33
- . env ( "USER" , "foo" )
34
33
. cwd ( & path)
35
34
. with_stderr ( "[CREATED] binary (application) package" )
36
35
. run ( ) ;
@@ -53,9 +52,7 @@ fn simple_git_ignore_exists() {
53
52
. write ( "/target\n **/some.file" . as_bytes ( ) )
54
53
. unwrap ( ) ;
55
54
56
- cargo_process ( "init --lib foo --edition 2015" )
57
- . env ( "USER" , "foo" )
58
- . run ( ) ;
55
+ cargo_process ( "init --lib foo --edition 2015" ) . run ( ) ;
59
56
60
57
assert ! ( paths:: root( ) . is_dir( ) ) ;
61
58
assert ! ( paths:: root( ) . join( "foo/Cargo.toml" ) . is_file( ) ) ;
@@ -88,7 +85,6 @@ fn simple_git_ignore_exists() {
88
85
#[ test]
89
86
fn both_lib_and_bin ( ) {
90
87
cargo_process ( "init --lib --bin" )
91
- . env ( "USER" , "foo" )
92
88
. with_status ( 101 )
93
89
. with_stderr ( "[ERROR] can't specify both lib and binary outputs" )
94
90
. run ( ) ;
@@ -112,15 +108,9 @@ fn bin_already_exists(explicit: bool, rellocation: &str) {
112
108
. unwrap ( ) ;
113
109
114
110
if explicit {
115
- cargo_process ( "init --bin --vcs none" )
116
- . env ( "USER" , "foo" )
117
- . cwd ( & path)
118
- . run ( ) ;
111
+ cargo_process ( "init --bin --vcs none" ) . cwd ( & path) . run ( ) ;
119
112
} else {
120
- cargo_process ( "init --vcs none" )
121
- . env ( "USER" , "foo" )
122
- . cwd ( & path)
123
- . run ( ) ;
113
+ cargo_process ( "init --vcs none" ) . cwd ( & path) . run ( ) ;
124
114
}
125
115
126
116
assert ! ( paths:: root( ) . join( "foo/Cargo.toml" ) . is_file( ) ) ;
@@ -184,7 +174,7 @@ fn confused_by_multiple_lib_files() {
184
174
. write_all ( br#" fn qqq () { println!("Hello, world 3!"); }"# )
185
175
. unwrap ( ) ;
186
176
187
- cargo_process ( "init --vcs none" ) . env ( "USER" , "foo" ) . cwd ( & path) . with_status ( 101 ) . with_stderr (
177
+ cargo_process ( "init --vcs none" ) . cwd ( & path) . with_status ( 101 ) . with_stderr (
188
178
"[ERROR] cannot have a package with multiple libraries, found both `src/lib.rs` and `lib.rs`" ,
189
179
)
190
180
. run ( ) ;
@@ -212,7 +202,6 @@ fn multibin_project_name_clash() {
212
202
. unwrap ( ) ;
213
203
214
204
cargo_process ( "init --lib --vcs none" )
215
- . env ( "USER" , "foo" )
216
205
. cwd ( & path)
217
206
. with_status ( 101 )
218
207
. with_stderr (
@@ -243,10 +232,7 @@ fn lib_already_exists(rellocation: &str) {
243
232
. write_all ( content)
244
233
. unwrap ( ) ;
245
234
246
- cargo_process ( "init --vcs none" )
247
- . env ( "USER" , "foo" )
248
- . cwd ( & path)
249
- . run ( ) ;
235
+ cargo_process ( "init --vcs none" ) . cwd ( & path) . run ( ) ;
250
236
251
237
assert ! ( paths:: root( ) . join( "foo/Cargo.toml" ) . is_file( ) ) ;
252
238
assert ! ( !paths:: root( ) . join( "foo/src/main.rs" ) . is_file( ) ) ;
@@ -272,9 +258,7 @@ fn lib_already_exists_nosrc() {
272
258
273
259
#[ test]
274
260
fn simple_git ( ) {
275
- cargo_process ( "init --lib --vcs git" )
276
- . env ( "USER" , "foo" )
277
- . run ( ) ;
261
+ cargo_process ( "init --lib --vcs git" ) . run ( ) ;
278
262
279
263
assert ! ( paths:: root( ) . join( "Cargo.toml" ) . is_file( ) ) ;
280
264
assert ! ( paths:: root( ) . join( "src/lib.rs" ) . is_file( ) ) ;
@@ -284,7 +268,7 @@ fn simple_git() {
284
268
285
269
#[ test]
286
270
fn auto_git ( ) {
287
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
271
+ cargo_process ( "init --lib" ) . run ( ) ;
288
272
289
273
assert ! ( paths:: root( ) . join( "Cargo.toml" ) . is_file( ) ) ;
290
274
assert ! ( paths:: root( ) . join( "src/lib.rs" ) . is_file( ) ) ;
@@ -298,7 +282,6 @@ fn invalid_dir_name() {
298
282
fs:: create_dir_all ( & foo) . unwrap ( ) ;
299
283
cargo_process ( "init" )
300
284
. cwd ( foo. clone ( ) )
301
- . env ( "USER" , "foo" )
302
285
. with_status ( 101 )
303
286
. with_stderr (
304
287
"\
@@ -317,7 +300,6 @@ fn reserved_name() {
317
300
fs:: create_dir_all ( & test) . unwrap ( ) ;
318
301
cargo_process ( "init" )
319
302
. cwd ( test. clone ( ) )
320
- . env ( "USER" , "foo" )
321
303
. with_status ( 101 )
322
304
. with_stderr (
323
305
"\
@@ -334,7 +316,7 @@ use --name to override crate name
334
316
fn git_autodetect ( ) {
335
317
fs:: create_dir ( & paths:: root ( ) . join ( ".git" ) ) . unwrap ( ) ;
336
318
337
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
319
+ cargo_process ( "init --lib" ) . run ( ) ;
338
320
339
321
assert ! ( paths:: root( ) . join( "Cargo.toml" ) . is_file( ) ) ;
340
322
assert ! ( paths:: root( ) . join( "src/lib.rs" ) . is_file( ) ) ;
@@ -346,7 +328,7 @@ fn git_autodetect() {
346
328
fn mercurial_autodetect ( ) {
347
329
fs:: create_dir ( & paths:: root ( ) . join ( ".hg" ) ) . unwrap ( ) ;
348
330
349
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
331
+ cargo_process ( "init --lib" ) . run ( ) ;
350
332
351
333
assert ! ( paths:: root( ) . join( "Cargo.toml" ) . is_file( ) ) ;
352
334
assert ! ( paths:: root( ) . join( "src/lib.rs" ) . is_file( ) ) ;
@@ -363,7 +345,7 @@ fn gitignore_appended_not_replaced() {
363
345
. write_all ( b"qqqqqq\n " )
364
346
. unwrap ( ) ;
365
347
366
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
348
+ cargo_process ( "init --lib" ) . run ( ) ;
367
349
368
350
assert ! ( paths:: root( ) . join( "Cargo.toml" ) . is_file( ) ) ;
369
351
assert ! ( paths:: root( ) . join( "src/lib.rs" ) . is_file( ) ) ;
@@ -387,7 +369,7 @@ fn gitignore_added_newline_in_existing() {
387
369
. write_all ( b"first" )
388
370
. unwrap ( ) ;
389
371
390
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
372
+ cargo_process ( "init --lib" ) . run ( ) ;
391
373
392
374
assert ! ( paths:: root( ) . join( ".gitignore" ) . is_file( ) ) ;
393
375
@@ -403,7 +385,7 @@ fn gitignore_added_newline_in_existing() {
403
385
fn gitignore_no_newline_in_new ( ) {
404
386
fs:: create_dir ( & paths:: root ( ) . join ( ".git" ) ) . unwrap ( ) ;
405
387
406
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
388
+ cargo_process ( "init --lib" ) . run ( ) ;
407
389
408
390
assert ! ( paths:: root( ) . join( ".gitignore" ) . is_file( ) ) ;
409
391
@@ -424,7 +406,7 @@ fn mercurial_added_newline_in_existing() {
424
406
. write_all ( b"first" )
425
407
. unwrap ( ) ;
426
408
427
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
409
+ cargo_process ( "init --lib" ) . run ( ) ;
428
410
429
411
assert ! ( paths:: root( ) . join( ".hgignore" ) . is_file( ) ) ;
430
412
@@ -440,7 +422,7 @@ fn mercurial_added_newline_in_existing() {
440
422
fn mercurial_no_newline_in_new ( ) {
441
423
fs:: create_dir ( & paths:: root ( ) . join ( ".hg" ) ) . unwrap ( ) ;
442
424
443
- cargo_process ( "init --lib" ) . env ( "USER" , "foo" ) . run ( ) ;
425
+ cargo_process ( "init --lib" ) . run ( ) ;
444
426
445
427
assert ! ( paths:: root( ) . join( ".hgignore" ) . is_file( ) ) ;
446
428
@@ -456,9 +438,7 @@ fn mercurial_no_newline_in_new() {
456
438
fn cargo_lock_gitignored_if_lib1 ( ) {
457
439
fs:: create_dir ( & paths:: root ( ) . join ( ".git" ) ) . unwrap ( ) ;
458
440
459
- cargo_process ( "init --lib --vcs git" )
460
- . env ( "USER" , "foo" )
461
- . run ( ) ;
441
+ cargo_process ( "init --lib --vcs git" ) . run ( ) ;
462
442
463
443
assert ! ( paths:: root( ) . join( ".gitignore" ) . is_file( ) ) ;
464
444
@@ -479,7 +459,7 @@ fn cargo_lock_gitignored_if_lib2() {
479
459
. write_all ( br#""# )
480
460
. unwrap ( ) ;
481
461
482
- cargo_process ( "init --vcs git" ) . env ( "USER" , "foo" ) . run ( ) ;
462
+ cargo_process ( "init --vcs git" ) . run ( ) ;
483
463
484
464
assert ! ( paths:: root( ) . join( ".gitignore" ) . is_file( ) ) ;
485
465
@@ -495,9 +475,7 @@ fn cargo_lock_gitignored_if_lib2() {
495
475
fn cargo_lock_not_gitignored_if_bin1 ( ) {
496
476
fs:: create_dir ( & paths:: root ( ) . join ( ".git" ) ) . unwrap ( ) ;
497
477
498
- cargo_process ( "init --vcs git --bin" )
499
- . env ( "USER" , "foo" )
500
- . run ( ) ;
478
+ cargo_process ( "init --vcs git --bin" ) . run ( ) ;
501
479
502
480
assert ! ( paths:: root( ) . join( ".gitignore" ) . is_file( ) ) ;
503
481
@@ -518,7 +496,7 @@ fn cargo_lock_not_gitignored_if_bin2() {
518
496
. write_all ( br#""# )
519
497
. unwrap ( ) ;
520
498
521
- cargo_process ( "init --vcs git" ) . env ( "USER" , "foo" ) . run ( ) ;
499
+ cargo_process ( "init --vcs git" ) . run ( ) ;
522
500
523
501
assert ! ( paths:: root( ) . join( ".gitignore" ) . is_file( ) ) ;
524
502
@@ -532,9 +510,7 @@ fn cargo_lock_not_gitignored_if_bin2() {
532
510
533
511
#[ test]
534
512
fn with_argument ( ) {
535
- cargo_process ( "init foo --vcs none" )
536
- . env ( "USER" , "foo" )
537
- . run ( ) ;
513
+ cargo_process ( "init foo --vcs none" ) . run ( ) ;
538
514
assert ! ( paths:: root( ) . join( "foo/Cargo.toml" ) . is_file( ) ) ;
539
515
}
540
516
0 commit comments