@@ -44,6 +44,62 @@ fn setup() {
44
44
fn simple ( ) {
45
45
setup ( ) ;
46
46
47
+ let p = project ( "foo" )
48
+ . file ( "Cargo.toml" , r#"
49
+ [project]
50
+ name = "foo"
51
+ version = "0.0.1"
52
+ authors = []
53
+ license = "MIT"
54
+ description = "foo"
55
+ "# )
56
+ . file ( "src/main.rs" , "fn main() {}" ) ;
57
+
58
+ assert_that ( p. cargo_process ( "publish" ) . arg ( "--no-verify" )
59
+ . arg ( "--index" ) . arg ( registry ( ) . to_string ( ) ) ,
60
+ execs ( ) . with_status ( 0 ) . with_stderr ( & format ! ( "\
61
+ [UPDATING] registry `{reg}`
62
+ [WARNING] manifest has no documentation, [..]
63
+ See [..]
64
+ [PACKAGING] foo v0.0.1 ({dir})
65
+ [UPLOADING] foo v0.0.1 ({dir})
66
+ " ,
67
+ dir = p. url( ) ,
68
+ reg = registry( ) ) ) ) ;
69
+
70
+ let mut f = File :: open ( & upload_path ( ) . join ( "api/v1/crates/new" ) ) . unwrap ( ) ;
71
+ // Skip the metadata payload and the size of the tarball
72
+ let mut sz = [ 0 ; 4 ] ;
73
+ assert_eq ! ( f. read( & mut sz) . unwrap( ) , 4 ) ;
74
+ let sz = ( ( sz[ 0 ] as u32 ) << 0 ) |
75
+ ( ( sz[ 1 ] as u32 ) << 8 ) |
76
+ ( ( sz[ 2 ] as u32 ) << 16 ) |
77
+ ( ( sz[ 3 ] as u32 ) << 24 ) ;
78
+ f. seek ( SeekFrom :: Current ( sz as i64 + 4 ) ) . unwrap ( ) ;
79
+
80
+ // Verify the tarball
81
+ let mut rdr = GzDecoder :: new ( f) . unwrap ( ) ;
82
+ assert_eq ! ( rdr. header( ) . filename( ) . unwrap( ) , "foo-0.0.1.crate" . as_bytes( ) ) ;
83
+ let mut contents = Vec :: new ( ) ;
84
+ rdr. read_to_end ( & mut contents) . unwrap ( ) ;
85
+ let mut ar = Archive :: new ( & contents[ ..] ) ;
86
+ for file in ar. entries ( ) . unwrap ( ) {
87
+ let file = file. unwrap ( ) ;
88
+ let fname = file. header ( ) . path_bytes ( ) ;
89
+ let fname = & * fname;
90
+ assert ! ( fname == b"foo-0.0.1/Cargo.toml" ||
91
+ fname == b"foo-0.0.1/Cargo.toml.orig" ||
92
+ fname == b"foo-0.0.1/src/main.rs" ,
93
+ "unexpected filename: {:?}" , file. header( ) . path( ) ) ;
94
+ }
95
+ }
96
+
97
+ // TODO: Deprecated
98
+ // remove once it has been decided --host can be removed
99
+ #[ test]
100
+ fn simple_with_host ( ) {
101
+ setup ( ) ;
102
+
47
103
let p = project ( "foo" )
48
104
. file ( "Cargo.toml" , r#"
49
105
[project]
@@ -58,6 +114,83 @@ fn simple() {
58
114
assert_that ( p. cargo_process ( "publish" ) . arg ( "--no-verify" )
59
115
. arg ( "--host" ) . arg ( registry ( ) . to_string ( ) ) ,
60
116
execs ( ) . with_status ( 0 ) . with_stderr ( & format ! ( "\
117
+ [WARNING] The flag '--host' is no longer valid.
118
+
119
+ Previous versions of Cargo accepted this flag, but it is being
120
+ deprecated. The flag is being renamed to 'index', as the flag
121
+ wants the location of the index to which to publish. Please
122
+ use '--index' instead.
123
+
124
+ This will soon become a hard error, so it's either recommended
125
+ to update to a fixed version or contact the upstream maintainer
126
+ about this warning.
127
+ [UPDATING] registry `{reg}`
128
+ [WARNING] manifest has no documentation, [..]
129
+ See [..]
130
+ [PACKAGING] foo v0.0.1 ({dir})
131
+ [UPLOADING] foo v0.0.1 ({dir})
132
+ " ,
133
+ dir = p. url( ) ,
134
+ reg = registry( ) ) ) ) ;
135
+
136
+ let mut f = File :: open ( & upload_path ( ) . join ( "api/v1/crates/new" ) ) . unwrap ( ) ;
137
+ // Skip the metadata payload and the size of the tarball
138
+ let mut sz = [ 0 ; 4 ] ;
139
+ assert_eq ! ( f. read( & mut sz) . unwrap( ) , 4 ) ;
140
+ let sz = ( ( sz[ 0 ] as u32 ) << 0 ) |
141
+ ( ( sz[ 1 ] as u32 ) << 8 ) |
142
+ ( ( sz[ 2 ] as u32 ) << 16 ) |
143
+ ( ( sz[ 3 ] as u32 ) << 24 ) ;
144
+ f. seek ( SeekFrom :: Current ( sz as i64 + 4 ) ) . unwrap ( ) ;
145
+
146
+ // Verify the tarball
147
+ let mut rdr = GzDecoder :: new ( f) . unwrap ( ) ;
148
+ assert_eq ! ( rdr. header( ) . filename( ) . unwrap( ) , "foo-0.0.1.crate" . as_bytes( ) ) ;
149
+ let mut contents = Vec :: new ( ) ;
150
+ rdr. read_to_end ( & mut contents) . unwrap ( ) ;
151
+ let mut ar = Archive :: new ( & contents[ ..] ) ;
152
+ for file in ar. entries ( ) . unwrap ( ) {
153
+ let file = file. unwrap ( ) ;
154
+ let fname = file. header ( ) . path_bytes ( ) ;
155
+ let fname = & * fname;
156
+ assert ! ( fname == b"foo-0.0.1/Cargo.toml" ||
157
+ fname == b"foo-0.0.1/Cargo.toml.orig" ||
158
+ fname == b"foo-0.0.1/src/main.rs" ,
159
+ "unexpected filename: {:?}" , file. header( ) . path( ) ) ;
160
+ }
161
+ }
162
+
163
+ // TODO: Deprecated
164
+ // remove once it has been decided --host can be removed
165
+ #[ test]
166
+ fn simple_with_index_and_host ( ) {
167
+ setup ( ) ;
168
+
169
+ let p = project ( "foo" )
170
+ . file ( "Cargo.toml" , r#"
171
+ [project]
172
+ name = "foo"
173
+ version = "0.0.1"
174
+ authors = []
175
+ license = "MIT"
176
+ description = "foo"
177
+ "# )
178
+ . file ( "src/main.rs" , "fn main() {}" ) ;
179
+
180
+ assert_that ( p. cargo_process ( "publish" ) . arg ( "--no-verify" )
181
+ . arg ( "--index" ) . arg ( registry ( ) . to_string ( ) )
182
+ . arg ( "--host" ) . arg ( registry ( ) . to_string ( ) ) ,
183
+ execs ( ) . with_status ( 0 ) . with_stderr ( & format ! ( "\
184
+ [WARNING] The flag '--host' is no longer valid.
185
+
186
+ Previous versions of Cargo accepted this flag, but it is being
187
+ deprecated. The flag is being renamed to 'index', as the flag
188
+ wants the location of the index to which to publish. Please
189
+ use '--index' instead.
190
+
191
+ This will soon become a hard error, so it's either recommended
192
+ to update to a fixed version or contact the upstream maintainer
193
+ about this warning.
61
194
[UPDATING] registry `{reg}`
62
195
[WARNING] manifest has no documentation, [..]
63
196
See [..]
@@ -113,7 +246,7 @@ fn git_deps() {
113
246
. file ( "src/main.rs" , "fn main() {}" ) ;
114
247
115
248
assert_that ( p. cargo_process ( "publish" ) . arg ( "-v" ) . arg ( "--no-verify" )
116
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
249
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
117
250
execs ( ) . with_status ( 101 ) . with_stderr ( "\
118
251
[UPDATING] registry [..]
119
252
[ERROR] crates cannot be published to crates.io with dependencies sourced from \
@@ -150,7 +283,7 @@ fn path_dependency_no_version() {
150
283
. file ( "bar/src/lib.rs" , "" ) ;
151
284
152
285
assert_that ( p. cargo_process ( "publish" )
153
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
286
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
154
287
execs ( ) . with_status ( 101 ) . with_stderr ( "\
155
288
[UPDATING] registry [..]
156
289
[ERROR] all path dependencies must have a version specified when publishing.
@@ -175,7 +308,7 @@ fn unpublishable_crate() {
175
308
. file ( "src/main.rs" , "fn main() {}" ) ;
176
309
177
310
assert_that ( p. cargo_process ( "publish" )
178
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
311
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
179
312
execs ( ) . with_status ( 101 ) . with_stderr ( "\
180
313
[ERROR] some crates cannot be published.
181
314
`foo` is marked as unpublishable
@@ -205,7 +338,7 @@ fn dont_publish_dirty() {
205
338
. build ( ) ;
206
339
207
340
assert_that ( p. cargo ( "publish" )
208
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
341
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
209
342
execs ( ) . with_status ( 101 ) . with_stderr ( "\
210
343
[UPDATING] registry `[..]`
211
344
error: 1 files in the working directory contain changes that were not yet \
@@ -240,7 +373,7 @@ fn publish_clean() {
240
373
. build ( ) ;
241
374
242
375
assert_that ( p. cargo ( "publish" )
243
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
376
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
244
377
execs ( ) . with_status ( 0 ) ) ;
245
378
}
246
379
@@ -268,7 +401,7 @@ fn publish_in_sub_repo() {
268
401
. build ( ) ;
269
402
270
403
assert_that ( p. cargo ( "publish" ) . cwd ( p. root ( ) . join ( "bar" ) )
271
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
404
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
272
405
execs ( ) . with_status ( 0 ) ) ;
273
406
}
274
407
@@ -297,7 +430,7 @@ fn publish_when_ignored() {
297
430
. build ( ) ;
298
431
299
432
assert_that ( p. cargo ( "publish" )
300
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
433
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
301
434
execs ( ) . with_status ( 0 ) ) ;
302
435
}
303
436
@@ -324,7 +457,7 @@ fn ignore_when_crate_ignored() {
324
457
"# )
325
458
. nocommit_file ( "bar/src/main.rs" , "fn main() {}" ) ;
326
459
assert_that ( p. cargo ( "publish" ) . cwd ( p. root ( ) . join ( "bar" ) )
327
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
460
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
328
461
execs ( ) . with_status ( 0 ) ) ;
329
462
}
330
463
@@ -350,7 +483,7 @@ fn new_crate_rejected() {
350
483
"# )
351
484
. nocommit_file ( "src/main.rs" , "fn main() {}" ) ;
352
485
assert_that ( p. cargo ( "publish" )
353
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
486
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
354
487
execs ( ) . with_status ( 101 ) ) ;
355
488
}
356
489
@@ -370,7 +503,7 @@ fn dry_run() {
370
503
. file ( "src/main.rs" , "fn main() {}" ) ;
371
504
372
505
assert_that ( p. cargo_process ( "publish" ) . arg ( "--dry-run" )
373
- . arg ( "--host " ) . arg ( registry ( ) . to_string ( ) ) ,
506
+ . arg ( "--index " ) . arg ( registry ( ) . to_string ( ) ) ,
374
507
execs ( ) . with_status ( 0 ) . with_stderr ( & format ! ( "\
375
508
[UPDATING] registry `[..]`
376
509
[WARNING] manifest has no documentation, [..]
0 commit comments