@@ -7,7 +7,6 @@ use cargo::util::ProcessBuilder;
7
7
use support:: process;
8
8
use support:: { execs, paths} ;
9
9
use support:: hamcrest:: { assert_that, existing_dir, existing_file, is_not} ;
10
- use tempfile;
11
10
12
11
fn cargo_process ( s : & str ) -> ProcessBuilder {
13
12
let mut p = support:: cargo_process ( ) ;
@@ -110,27 +109,22 @@ fn both_lib_and_bin() {
110
109
111
110
#[ test]
112
111
fn simple_git ( ) {
113
- // Run inside a temp directory so that cargo will initialize a git repo.
114
- // If this ran inside paths::root() it would detect that we are already
115
- // inside a git repo and skip the initialization.
116
- let td = tempfile:: Builder :: new ( ) . prefix ( "cargo" ) . tempdir ( ) . unwrap ( ) ;
117
112
assert_that (
118
113
cargo_process ( "new" )
119
114
. arg ( "--lib" )
120
115
. arg ( "foo" )
121
- . cwd ( td. path ( ) )
122
116
. env ( "USER" , "foo" ) ,
123
117
execs ( ) . with_status ( 0 ) ,
124
118
) ;
125
119
126
- assert_that ( td . path ( ) , existing_dir ( ) ) ;
127
- assert_that ( & td . path ( ) . join ( "foo/Cargo.toml" ) , existing_file ( ) ) ;
128
- assert_that ( & td . path ( ) . join ( "foo/src/lib.rs" ) , existing_file ( ) ) ;
129
- assert_that ( & td . path ( ) . join ( "foo/.git" ) , existing_dir ( ) ) ;
130
- assert_that ( & td . path ( ) . join ( "foo/.gitignore" ) , existing_file ( ) ) ;
120
+ assert_that ( & paths :: root ( ) , existing_dir ( ) ) ;
121
+ assert_that ( & paths :: root ( ) . join ( "foo/Cargo.toml" ) , existing_file ( ) ) ;
122
+ assert_that ( & paths :: root ( ) . join ( "foo/src/lib.rs" ) , existing_file ( ) ) ;
123
+ assert_that ( & paths :: root ( ) . join ( "foo/.git" ) , existing_dir ( ) ) ;
124
+ assert_that ( & paths :: root ( ) . join ( "foo/.gitignore" ) , existing_file ( ) ) ;
131
125
132
126
assert_that (
133
- cargo_process ( "build" ) . cwd ( & td . path ( ) . join ( "foo" ) ) ,
127
+ cargo_process ( "build" ) . cwd ( & paths :: root ( ) . join ( "foo" ) ) ,
134
128
execs ( ) . with_status ( 0 ) ,
135
129
) ;
136
130
}
@@ -476,6 +470,9 @@ fn subpackage_no_git() {
476
470
execs ( ) . with_status ( 0 ) ,
477
471
) ;
478
472
473
+ assert_that ( & paths:: root ( ) . join ( "foo/.git" ) , existing_dir ( ) ) ;
474
+ assert_that ( & paths:: root ( ) . join ( "foo/.gitignore" ) , existing_file ( ) ) ;
475
+
479
476
let subpackage = paths:: root ( ) . join ( "foo" ) . join ( "components" ) ;
480
477
fs:: create_dir ( & subpackage) . unwrap ( ) ;
481
478
assert_that (
@@ -502,10 +499,19 @@ fn subpackage_git_with_gitignore() {
502
499
execs ( ) . with_status ( 0 ) ,
503
500
) ;
504
501
505
- let gitignore = paths:: root ( ) . join ( "foo" ) . join ( ".gitignore" ) ;
502
+ assert_that (
503
+ & paths:: root ( ) . join ( "foo/.git" ) ,
504
+ existing_dir ( ) ,
505
+ ) ;
506
+ assert_that (
507
+ & paths:: root ( ) . join ( "foo/.gitignore" ) ,
508
+ existing_file ( ) ,
509
+ ) ;
510
+
511
+ let gitignore = paths:: root ( ) . join ( "foo/.gitignore" ) ;
506
512
fs:: write ( gitignore, b"components" ) . unwrap ( ) ;
507
513
508
- let subpackage = paths:: root ( ) . join ( "foo" ) . join ( " components") ;
514
+ let subpackage = paths:: root ( ) . join ( "foo/ components" ) ;
509
515
fs:: create_dir ( & subpackage) . unwrap ( ) ;
510
516
assert_that (
511
517
cargo_process ( "new" )
@@ -515,11 +521,11 @@ fn subpackage_git_with_gitignore() {
515
521
) ;
516
522
517
523
assert_that (
518
- & paths:: root ( ) . join ( "foo" ) . join ( " components" ) . join ( " subcomponent" ) . join ( " .git") ,
524
+ & paths:: root ( ) . join ( "foo/ components/ subcomponent/ .git" ) ,
519
525
existing_dir ( ) ,
520
526
) ;
521
527
assert_that (
522
- & paths:: root ( ) . join ( "foo" ) . join ( " components" ) . join ( " subcomponent" ) . join ( " .gitignore") ,
528
+ & paths:: root ( ) . join ( "foo/ components/ subcomponent/ .gitignore" ) ,
523
529
existing_file ( ) ,
524
530
) ;
525
531
0 commit comments