@@ -7,7 +7,6 @@ use cargo::util::ProcessBuilder;
77use support:: process;
88use support:: { execs, paths} ;
99use support:: hamcrest:: { assert_that, existing_dir, existing_file, is_not} ;
10- use tempfile;
1110
1211fn cargo_process ( s : & str ) -> ProcessBuilder {
1312 let mut p = support:: cargo_process ( ) ;
@@ -110,27 +109,22 @@ fn both_lib_and_bin() {
110109
111110#[ test]
112111fn 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 ( ) ;
117112 assert_that (
118113 cargo_process ( "new" )
119114 . arg ( "--lib" )
120115 . arg ( "foo" )
121- . cwd ( td. path ( ) )
122116 . env ( "USER" , "foo" ) ,
123117 execs ( ) . with_status ( 0 ) ,
124118 ) ;
125119
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 ( ) ) ;
131125
132126 assert_that (
133- cargo_process ( "build" ) . cwd ( & td . path ( ) . join ( "foo" ) ) ,
127+ cargo_process ( "build" ) . cwd ( & paths :: root ( ) . join ( "foo" ) ) ,
134128 execs ( ) . with_status ( 0 ) ,
135129 ) ;
136130}
@@ -476,6 +470,9 @@ fn subpackage_no_git() {
476470 execs ( ) . with_status ( 0 ) ,
477471 ) ;
478472
473+ assert_that ( & paths:: root ( ) . join ( "foo/.git" ) , existing_dir ( ) ) ;
474+ assert_that ( & paths:: root ( ) . join ( "foo/.gitignore" ) , existing_file ( ) ) ;
475+
479476 let subpackage = paths:: root ( ) . join ( "foo" ) . join ( "components" ) ;
480477 fs:: create_dir ( & subpackage) . unwrap ( ) ;
481478 assert_that (
@@ -502,10 +499,19 @@ fn subpackage_git_with_gitignore() {
502499 execs ( ) . with_status ( 0 ) ,
503500 ) ;
504501
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" ) ;
506512 fs:: write ( gitignore, b"components" ) . unwrap ( ) ;
507513
508- let subpackage = paths:: root ( ) . join ( "foo" ) . join ( " components") ;
514+ let subpackage = paths:: root ( ) . join ( "foo/ components" ) ;
509515 fs:: create_dir ( & subpackage) . unwrap ( ) ;
510516 assert_that (
511517 cargo_process ( "new" )
@@ -515,11 +521,11 @@ fn subpackage_git_with_gitignore() {
515521 ) ;
516522
517523 assert_that (
518- & paths:: root ( ) . join ( "foo" ) . join ( " components" ) . join ( " subcomponent" ) . join ( " .git") ,
524+ & paths:: root ( ) . join ( "foo/ components/ subcomponent/ .git" ) ,
519525 existing_dir ( ) ,
520526 ) ;
521527 assert_that (
522- & paths:: root ( ) . join ( "foo" ) . join ( " components" ) . join ( " subcomponent" ) . join ( " .gitignore") ,
528+ & paths:: root ( ) . join ( "foo/ components/ subcomponent/ .gitignore" ) ,
523529 existing_file ( ) ,
524530 ) ;
525531
0 commit comments