1
1
//! Tests for the -Zrustdoc-map feature.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_test_support:: registry:: { self , Package } ;
6
- use cargo_test_support:: { paths, project, Project } ;
4
+ use cargo_test_support:: { paths, project, str , Project } ;
7
5
8
6
fn basic_project ( ) -> Project {
9
7
Package :: new ( "bar" , "1.0.0" )
@@ -34,6 +32,7 @@ fn basic_project() -> Project {
34
32
. build ( )
35
33
}
36
34
35
+ #[ allow( deprecated) ]
37
36
#[ cargo_test]
38
37
fn ignores_on_stable ( ) {
39
38
// Requires -Zrustdoc-map to use.
@@ -49,14 +48,19 @@ fn simple() {
49
48
let p = basic_project ( ) ;
50
49
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
51
50
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
52
- . with_stderr_contains (
53
- "[RUNNING] `rustdoc [..]--crate-name foo [..]bar=https://docs.rs/bar/1.0.0/[..]" ,
54
- )
51
+ . with_stderr_data ( str![ [ r#"
52
+ ...
53
+ [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]bar=https://docs.rs/bar/1.0.0/[..]`
54
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
55
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
56
+
57
+ "# ] ] )
55
58
. run ( ) ;
56
59
let myfun = p. read_file ( "target/doc/foo/fn.myfun.html" ) ;
57
60
assert ! ( myfun. contains( r#"href="https://docs.rs/bar/1.0.0/bar/struct.Straw.html""# ) ) ;
58
61
}
59
62
63
+ #[ allow( deprecated) ]
60
64
#[ ignore = "Broken, temporarily disabled until https://github.com/rust-lang/rust/pull/82776 is resolved." ]
61
65
#[ cargo_test]
62
66
// #[cargo_test(nightly, reason = "--extern-html-root-url is unstable")]
@@ -139,9 +143,13 @@ fn renamed_dep() {
139
143
. build ( ) ;
140
144
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
141
145
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
142
- . with_stderr_contains (
143
- "[RUNNING] `rustdoc [..]--crate-name foo [..]bar=https://docs.rs/bar/1.0.0/[..]" ,
144
- )
146
+ . with_stderr_data ( str![ [ r#"
147
+ ...
148
+ [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]bar=https://docs.rs/bar/1.0.0/[..]`
149
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
150
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
151
+
152
+ "# ] ] )
145
153
. run ( ) ;
146
154
let myfun = p. read_file ( "target/doc/foo/fn.myfun.html" ) ;
147
155
assert ! ( myfun. contains( r#"href="https://docs.rs/bar/1.0.0/bar/struct.Straw.html""# ) ) ;
@@ -188,9 +196,13 @@ fn lib_name() {
188
196
. build ( ) ;
189
197
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
190
198
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
191
- . with_stderr_contains (
192
- "[RUNNING] `rustdoc [..]--crate-name foo [..]rumpelstiltskin=https://docs.rs/bar/1.0.0/[..]" ,
193
- )
199
+ . with_stderr_data ( str![ [ r#"
200
+ ...
201
+ [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]rumpelstiltskin=https://docs.rs/bar/1.0.0/[..]`
202
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
203
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
204
+
205
+ "# ] ] )
194
206
. run ( ) ;
195
207
let myfun = p. read_file ( "target/doc/foo/fn.myfun.html" ) ;
196
208
assert ! ( myfun. contains( r#"href="https://docs.rs/bar/1.0.0/rumpelstiltskin/struct.Straw.html""# ) ) ;
@@ -253,10 +265,13 @@ fn alt_registry() {
253
265
. build ( ) ;
254
266
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
255
267
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
256
- . with_stderr_contains (
257
- "[RUNNING] `rustdoc [..]--crate-name foo \
258
- [..]bar=https://example.com/bar/1.0.0/[..]grimm=https://docs.rs/grimm/1.0.0/[..]",
259
- )
268
+ . with_stderr_data ( str![ [ r#"
269
+ ...
270
+ [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]bar=https://example.com/bar/1.0.0/[..] --extern-html-root-url [..]baz=https://example.com/baz/1.0.0/[..] --extern-html-root-url [..]grimm=https://docs.rs/grimm/1.0.0/[..]`
271
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
272
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
273
+
274
+ "# ] ] )
260
275
. run ( ) ;
261
276
let queen = p. read_file ( "target/doc/foo/fn.queen.html" ) ;
262
277
assert ! ( queen. contains( r#"href="https://example.com/bar/1.0.0/bar/struct.Queen.html""# ) ) ;
@@ -303,10 +318,13 @@ fn multiple_versions() {
303
318
. build ( ) ;
304
319
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
305
320
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
306
- . with_stderr_contains (
307
- "[RUNNING] `rustdoc [..]--crate-name foo \
308
- [..]bar=https://docs.rs/bar/1.0.0/[..]bar=https://docs.rs/bar/2.0.0/[..]",
309
- )
321
+ . with_stderr_data ( str![ [ r#"
322
+ ...
323
+ [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]bar=https://docs.rs/bar/1.0.0/[..] --extern-html-root-url [..]bar=https://docs.rs/bar/2.0.0/[..]`
324
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
325
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
326
+
327
+ "# ] ] )
310
328
. run ( ) ;
311
329
let fn1 = p. read_file ( "target/doc/foo/fn.fn1.html" ) ;
312
330
// This should be 1.0.0, rustdoc seems to use the last entry when there
@@ -322,7 +340,13 @@ fn rebuilds_when_changing() {
322
340
let p = basic_project ( ) ;
323
341
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
324
342
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
325
- . with_stderr_contains ( "[..]--extern-html-root-url[..]" )
343
+ . with_stderr_data ( str![ [ r#"
344
+ ...
345
+ [RUNNING] `rustdoc [..]--extern-html-root-url[..]`
346
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
347
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
348
+
349
+ "# ] ] )
326
350
. run ( ) ;
327
351
328
352
// This also tests that the map for docs.rs can be overridden.
@@ -335,9 +359,13 @@ fn rebuilds_when_changing() {
335
359
) ;
336
360
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
337
361
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
338
- . with_stderr_contains (
339
- "[RUNNING] `rustdoc [..]--extern-html-root-url [..]bar=https://example.com/bar/1.0.0/[..]" ,
340
- )
362
+ . with_stderr_data ( str![ [ r#"
363
+ ...
364
+ [RUNNING] `rustdoc [..]--extern-html-root-url [..]bar=https://example.com/bar/1.0.0/[..]`
365
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
366
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
367
+
368
+ "# ] ] )
341
369
. run ( ) ;
342
370
}
343
371
@@ -404,10 +432,13 @@ fn alt_sparse_registry() {
404
432
. build ( ) ;
405
433
p. cargo ( "doc -v --no-deps -Zrustdoc-map" )
406
434
. masquerade_as_nightly_cargo ( & [ "rustdoc-map" ] )
407
- . with_stderr_contains (
408
- "[RUNNING] `rustdoc [..]--crate-name foo \
409
- [..]bar=https://example.com/bar/1.0.0/[..]grimm=https://docs.rs/grimm/1.0.0/[..]",
410
- )
435
+ . with_stderr_data ( str![ [ r#"
436
+ ...
437
+ [RUNNING] `rustdoc [..]--crate-name foo [..]--extern-html-root-url [..]bar=https://example.com/bar/1.0.0/[..] --extern-html-root-url [..]baz=https://example.com/baz/1.0.0/[..] --extern-html-root-url [..]grimm=https://docs.rs/grimm/1.0.0/[..]`
438
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
439
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
440
+
441
+ "# ] ] )
411
442
. run ( ) ;
412
443
let queen = p. read_file ( "target/doc/foo/fn.queen.html" ) ;
413
444
assert ! ( queen. contains( r#"href="https://example.com/bar/1.0.0/bar/struct.Queen.html""# ) ) ;
@@ -419,6 +450,7 @@ fn alt_sparse_registry() {
419
450
assert ! ( gold. contains( r#"href="https://docs.rs/grimm/1.0.0/grimm/struct.Gold.html""# ) ) ;
420
451
}
421
452
453
+ #[ allow( deprecated) ]
422
454
#[ cargo_test( nightly, reason = "--extern-html-root-url is unstable" ) ]
423
455
fn same_deps_multi_occurrence_in_dep_tree ( ) {
424
456
// rust-lang/cargo#13543
0 commit comments