@@ -7,7 +7,7 @@ use flate2::read::GzDecoder;
77use  tar:: Archive ; 
88use  url:: Url ; 
99
10- use  support:: { project ,   execs} ; 
10+ use  support:: execs; 
1111use  support:: paths; 
1212use  support:: git:: repo; 
1313
@@ -36,8 +36,100 @@ fn setup() {
3636        . build ( ) ; 
3737} 
3838
39+ test ! ( uncommited_git_files_allowed { 
40+     let  root = paths:: root( ) . join( "uncommited_git_files_allowed" ) ; 
41+     let  p = repo( & root) 
42+         . file( "Cargo.toml" ,  r#" 
43+             [project] 
44+             name = "foo" 
45+             version = "0.0.1" 
46+             authors = [] 
47+             license = "MIT" 
48+             description = "foo" 
49+         "# ) 
50+         . nocommit_file( "bad" , "file" ) 
51+         . file( "src/main.rs" ,  "fn main() {}" ) ; 
52+     p. build( ) ; 
53+     let  mut  cargo = :: cargo_process( ) ; 
54+     cargo. cwd( p. root( ) ) ; 
55+     assert_that( cargo. arg( "publish" ) . arg( "--allow-untracked" ) . arg( "--no-verify" ) , 
56+                 execs( ) . with_status( 0 ) . with_stdout( & format!( "\  
57+ 
58+ [PACKAGING] foo v0.0.1 ({dir}) 
59+ [UPLOADING] foo v0.0.1 ({dir})" , 
60+         dir = p. url( ) , 
61+         reg = registry( ) ) ) ) ; 
62+ } ) ; 
63+ 
64+ test ! ( uncommited_git_files_error_from_sub_crate { 
65+     let  root = paths:: root( ) . join( "sub_uncommited_git" ) ; 
66+     let  p = repo( & root) 
67+         . file( "Cargo.toml" ,  r#" 
68+             [project] 
69+             name = "foo" 
70+             version = "0.0.1" 
71+             authors = [] 
72+             license = "MIT" 
73+             description = "foo" 
74+         "# ) 
75+         . nocommit_file( "bad.txt" , "file" ) 
76+         . file( "src/main.rs" ,  "fn main() {}" ) 
77+         . file( "sub/lib.rs" ,  "pub fn l() {}" ) 
78+         . file( "sub/Cargo.toml" ,  r#" 
79+             [package] 
80+             name = "crates-io" 
81+             version = "0.2.0" 
82+             authors = [] 
83+             license = "MIT/Apache-2.0" 
84+             repository = "https://github.com/rust-lang/cargo" 
85+             description = """ 
86+             """ 
87+ 
88+             [lib] 
89+             name = "crates_io" 
90+             path = "lib.rs" 
91+         "# ) ; 
92+     p. build( ) ; 
93+ 
94+     let  mut  cargo = :: cargo_process( ) ; 
95+     cargo. cwd( p. root( ) . join( "sub" ) ) ; 
96+     assert_that( cargo. arg( "publish" ) . arg( "--no-verify" ) , 
97+                 execs( ) . with_status( 101 ) . with_stderr( & "\  
98+ \ 
99+ 
100+ problem files: 
101+ bad.txt" , 
102+         ) ) ; 
103+ } ) ; 
104+ 
105+ test ! ( uncommited_git_files_error { 
106+     let  root = paths:: root( ) . join( "uncommited_git_files_error" ) ; 
107+     let  p = repo( & root) 
108+         . file( "Cargo.toml" ,  r#" 
109+             [project] 
110+             name = "foo" 
111+             version = "0.0.1" 
112+             authors = [] 
113+             license = "MIT" 
114+             description = "foo" 
115+         "# ) 
116+         . nocommit_file( "bad.txt" , "file" ) 
117+         . file( "src/main.rs" ,  "fn main() {}" ) ; 
118+     p. build( ) ; 
119+ 
120+     let  mut  cargo = :: cargo_process( ) ; 
121+     cargo. cwd( p. root( ) ) ; 
122+     assert_that( cargo. arg( "publish" ) . arg( "--no-verify" ) , 
123+                 execs( ) . with_status( 101 ) . with_stderr_contains( & "\  
124+ \ 
125+ 
126+ problem files:" , 
127+         ) . with_stderr_contains( & "bad.txt" ) ) ; 
128+ } ) ; 
129+ 
39130test ! ( simple { 
40-     let  p = project( "foo" ) 
131+     let  root = paths:: root( ) . join( "simple" ) ; 
132+     let  p = repo( & root) 
41133        . file( "Cargo.toml" ,  r#" 
42134            [project] 
43135            name = "foo" 
@@ -47,8 +139,12 @@ test!(simple {
47139            description = "foo" 
48140        "# ) 
49141        . file( "src/main.rs" ,  "fn main() {}" ) ; 
142+     p. build( ) ; 
143+ 
144+     let  mut  cargo = :: cargo_process( ) ; 
145+     cargo. cwd( p. root( ) ) ; 
50146
51-     assert_that( p . cargo_process ( "publish" ) . arg( "--no-verify" ) , 
147+     assert_that( cargo . arg ( "publish" ) . arg( "--no-verify" ) , 
52148                execs( ) . with_status( 0 ) . with_stdout( & format!( "\  
53149
54150[PACKAGING] foo v0.0.1 ({dir}) 
@@ -84,7 +180,8 @@ test!(simple {
84180} ) ; 
85181
86182test ! ( git_deps { 
87-     let  p = project( "foo" ) 
183+     let  root = paths:: root( ) . join( "git_deps" ) ; 
184+     let  p = repo( & root) 
88185        . file( "Cargo.toml" ,  r#" 
89186            [project] 
90187            name = "foo" 
@@ -97,16 +194,20 @@ test!(git_deps {
97194            git = "git://path/to/nowhere" 
98195        "# ) 
99196        . file( "src/main.rs" ,  "fn main() {}" ) ; 
197+     p. build( ) ; 
100198
101-     assert_that( p. cargo_process( "publish" ) . arg( "-v" ) . arg( "--no-verify" ) , 
199+     let  mut  cargo = :: cargo_process( ) ; 
200+     cargo. cwd( p. root( ) ) ; 
201+     assert_that( cargo. arg( "publish" ) . arg( "-v" ) . arg( "--no-verify" ) , 
102202                execs( ) . with_status( 101 ) . with_stderr( "\  
103203
104204dependency `foo` comes from git://path/to/nowhere instead 
105205" ) ) ; 
106206} ) ; 
107207
108208test ! ( path_dependency_no_version { 
109-     let  p = project( "foo" ) 
209+     let  root = paths:: root( ) . join( "path_dependency_no_version" ) ; 
210+     let  p = repo( & root) 
110211        . file( "Cargo.toml" ,  r#" 
111212            [project] 
112213            name = "foo" 
@@ -126,16 +227,20 @@ test!(path_dependency_no_version {
126227            authors = [] 
127228        "# ) 
128229        . file( "bar/src/lib.rs" ,  "" ) ; 
230+     p. build( ) ; 
129231
130-     assert_that( p. cargo_process( "publish" ) , 
232+     let  mut  cargo = :: cargo_process( ) ; 
233+     cargo. cwd( p. root( ) ) ; 
234+     assert_that( cargo. arg( "publish" ) , 
131235                execs( ) . with_status( 101 ) . with_stderr( "\  
132236
133237dependency `bar` does not specify a version 
134238" ) ) ; 
135239} ) ; 
136240
137241test ! ( unpublishable_crate { 
138-     let  p = project( "foo" ) 
242+     let  root = paths:: root( ) . join( "unpublishable_crate" ) ; 
243+     let  p = repo( & root) 
139244        . file( "Cargo.toml" ,  r#" 
140245            [project] 
141246            name = "foo" 
@@ -146,8 +251,11 @@ test!(unpublishable_crate {
146251            publish = false 
147252        "# ) 
148253        . file( "src/main.rs" ,  "fn main() {}" ) ; 
254+     p. build( ) ; 
149255
150-     assert_that( p. cargo_process( "publish" ) , 
256+     let  mut  cargo = :: cargo_process( ) ; 
257+     cargo. cwd( p. root( ) ) ; 
258+     assert_that( cargo. arg( "publish" ) , 
151259                execs( ) . with_status( 101 ) . with_stderr( "\  
152260
153261`foo` is marked as unpublishable 
0 commit comments