1
1
//! Tests for the `cargo rustdoc` command.
2
2
3
- #![ allow( deprecated) ]
4
-
3
+ use cargo_test_support:: str;
5
4
use cargo_test_support:: { basic_manifest, cross_compile, project} ;
6
5
7
6
#[ cargo_test]
8
7
fn rustdoc_simple ( ) {
9
8
let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
10
9
11
10
p. cargo ( "rustdoc -v" )
12
- . with_stderr (
13
- "\
14
- [DOCUMENTING] foo v0.0.1 ([CWD])
15
- [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
16
- -o [CWD]/target/doc \
17
- [..] \
18
- -L dependency=[CWD]/target/debug/deps [..]`
19
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
20
- [GENERATED] [CWD]/target/doc/foo/index.html
21
- " ,
22
- )
11
+ . with_stderr_data ( str![ [ r#"
12
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
13
+ [RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] -L dependency=[ROOT]/foo/target/debug/deps [..]`
14
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
15
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
16
+
17
+ "# ] ] )
23
18
. run ( ) ;
24
19
}
25
20
@@ -29,13 +24,12 @@ fn rustdoc_simple_html() {
29
24
30
25
p. cargo ( "rustdoc --output-format html --open -v" )
31
26
. with_status ( 101 )
32
- . with_stderr (
33
- "\
34
- error: the `--output-format` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
35
- [..]
27
+ . with_stderr_data ( str![ [ r#"
28
+ [ERROR] the `--output-format` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
29
+ See https://doc.rust-lang.org/book/[..].html for more information about Rust release channels.
36
30
See https://github.com/rust-lang/cargo/issues/12103 for more information about the `--output-format` flag.
37
- " ,
38
- )
31
+
32
+ "# ] ] )
39
33
. run ( ) ;
40
34
}
41
35
@@ -45,14 +39,13 @@ fn rustdoc_simple_json() {
45
39
46
40
p. cargo ( "rustdoc -Z unstable-options --output-format json -v" )
47
41
. masquerade_as_nightly_cargo ( & [ "rustdoc-output-format" ] )
48
- . with_stderr (
49
- "\
50
- [DOCUMENTING] foo v0.0.1 ([CWD])
51
- [RUNNING] `rustdoc [..]--crate-name foo [..]-o [CWD]/target/doc [..]--output-format=json[..]
52
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
53
- [GENERATED] [CWD]/target/doc/foo.json
54
- " ,
55
- )
42
+ . with_stderr_data ( str![ [ r#"
43
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
44
+ [RUNNING] `rustdoc [..] --crate-name foo [..]-o [ROOT]/foo/target/doc [..] --output-format=json[..]
45
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
46
+ [GENERATED] [ROOT]/foo/target/doc/foo.json
47
+
48
+ "# ] ] )
56
49
. run ( ) ;
57
50
assert ! ( p. root( ) . join( "target/doc/foo.json" ) . is_file( ) ) ;
58
51
}
@@ -64,14 +57,13 @@ fn rustdoc_invalid_output_format() {
64
57
p. cargo ( "rustdoc -Z unstable-options --output-format pdf -v" )
65
58
. masquerade_as_nightly_cargo ( & [ "rustdoc-output-format" ] )
66
59
. with_status ( 1 )
67
- . with_stderr (
68
- "\
69
- error: invalid value 'pdf' for '--output-format <FMT>'
60
+ . with_stderr_data ( str![ [ r#"
61
+ [ERROR] invalid value 'pdf' for '--output-format <FMT>'
70
62
[possible values: html, json]
71
63
72
64
For more information, try '--help'.
73
- " ,
74
- )
65
+
66
+ "# ] ] )
75
67
. run ( ) ;
76
68
}
77
69
@@ -81,11 +73,12 @@ fn rustdoc_json_stable() {
81
73
82
74
p. cargo ( "rustdoc -Z unstable-options --output-format json -v" )
83
75
. with_status ( 101 )
84
- . with_stderr (
85
- "\
86
- error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
87
- [..]
88
- " ,
76
+ . with_stderr_data (
77
+ str![ [ r#"
78
+ [ERROR] the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
79
+ See https://doc.rust-lang.org/book/[..].html for more information about Rust release channels.
80
+
81
+ "# ] ]
89
82
)
90
83
. run ( ) ;
91
84
}
@@ -97,12 +90,11 @@ fn rustdoc_json_without_unstable_options() {
97
90
p. cargo ( "rustdoc --output-format json -v" )
98
91
. masquerade_as_nightly_cargo ( & [ "rustdoc-output-format" ] )
99
92
. with_status ( 101 )
100
- . with_stderr (
101
- "\
102
- error: the `--output-format` flag is unstable, pass `-Z unstable-options` to enable it
103
- [..]
104
- " ,
105
- )
93
+ . with_stderr_data ( str![ [ r#"
94
+ [ERROR] the `--output-format` flag is unstable, pass `-Z unstable-options` to enable it
95
+ See https://github.com/rust-lang/cargo/issues/12103 for more information about the `--output-format` flag.
96
+
97
+ "# ] ] )
106
98
. run ( ) ;
107
99
}
108
100
@@ -111,19 +103,13 @@ fn rustdoc_args() {
111
103
let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
112
104
113
105
p. cargo ( "rustdoc -v -- --cfg=foo" )
114
- . with_stderr (
115
- "\
116
- [DOCUMENTING] foo v0.0.1 ([CWD])
117
- [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
118
- -o [CWD]/target/doc \
119
- [..] \
120
- --cfg=foo \
121
- -C metadata=[..] \
122
- -L dependency=[CWD]/target/debug/deps [..]`
123
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
124
- [GENERATED] [CWD]/target/doc/foo/index.html
125
- " ,
126
- )
106
+ . with_stderr_data ( str![ [ r#"
107
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
108
+ [RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]`
109
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
110
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
111
+
112
+ "# ] ] )
127
113
. run ( ) ;
128
114
}
129
115
@@ -134,7 +120,11 @@ fn rustdoc_binary_args_passed() {
134
120
p. cargo ( "rustdoc -v" )
135
121
. arg ( "--" )
136
122
. arg ( "--markdown-no-toc" )
137
- . with_stderr_contains ( "[RUNNING] `rustdoc [..] --markdown-no-toc[..]`" )
123
+ . with_stderr_data ( str![ [ r#"
124
+ ...
125
+ [RUNNING] `rustdoc [..] --markdown-no-toc[..]`
126
+ ...
127
+ "# ] ] )
138
128
. run ( ) ;
139
129
}
140
130
@@ -163,23 +153,16 @@ fn rustdoc_foo_with_bar_dependency() {
163
153
. build ( ) ;
164
154
165
155
foo. cargo ( "rustdoc -v -- --cfg=foo" )
166
- . with_stderr (
167
- "\
156
+ . with_stderr_data ( str![ [ r#"
168
157
[LOCKING] 2 packages to latest compatible versions
169
- [CHECKING] bar v0.0.1 ([..])
170
- [RUNNING] `rustc [..]bar/src/lib.rs [..]`
171
- [DOCUMENTING] foo v0.0.1 ([CWD])
172
- [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
173
- -o [CWD]/target/doc \
174
- [..] \
175
- --cfg=foo \
176
- -C metadata=[..] \
177
- -L dependency=[CWD]/target/debug/deps \
178
- --extern [..]`
179
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
180
- [GENERATED] [CWD]/target/doc/foo/index.html
181
- " ,
182
- )
158
+ [CHECKING] bar v0.0.1 ([ROOT]/bar)
159
+ [RUNNING] `rustc [..] [ROOT]/bar/src/lib.rs [..]`
160
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
161
+ [RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps --extern [..]`
162
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
163
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
164
+
165
+ "# ] ] )
183
166
. run ( ) ;
184
167
}
185
168
@@ -208,20 +191,14 @@ fn rustdoc_only_bar_dependency() {
208
191
. build ( ) ;
209
192
210
193
foo. cargo ( "rustdoc -v -p bar -- --cfg=foo" )
211
- . with_stderr (
212
- "\
194
+ . with_stderr_data ( str![ [ r#"
213
195
[LOCKING] 2 packages to latest compatible versions
214
- [DOCUMENTING] bar v0.0.1 ([..])
215
- [RUNNING] `rustdoc [..]--crate-name bar [..]bar/src/lib.rs [..]\
216
- -o [CWD]/target/doc \
217
- [..] \
218
- --cfg=foo \
219
- -C metadata=[..] \
220
- -L dependency=[CWD]/target/debug/deps [..]`
221
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
222
- [GENERATED] [CWD]/target/doc/bar/index.html
223
- " ,
224
- )
196
+ [DOCUMENTING] bar v0.0.1 ([ROOT]/bar)
197
+ [RUNNING] `rustdoc [..] --crate-name bar [ROOT]/bar/src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]`
198
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
199
+ [GENERATED] [ROOT]/foo/target/doc/bar/index.html
200
+
201
+ "# ] ] )
225
202
. run ( ) ;
226
203
}
227
204
@@ -233,19 +210,13 @@ fn rustdoc_same_name_documents_lib() {
233
210
. build ( ) ;
234
211
235
212
p. cargo ( "rustdoc -v -- --cfg=foo" )
236
- . with_stderr (
237
- "\
238
- [DOCUMENTING] foo v0.0.1 ([..])
239
- [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
240
- -o [CWD]/target/doc \
241
- [..] \
242
- --cfg=foo \
243
- -C metadata=[..] \
244
- -L dependency=[CWD]/target/debug/deps [..]`
245
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
246
- [GENERATED] [CWD]/target/doc/foo/index.html
247
- " ,
248
- )
213
+ . with_stderr_data ( str![ [ r#"
214
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
215
+ [RUNNING] `rustdoc [..] --crate-name foo src/lib.rs -o [ROOT]/foo/target/doc [..] --cfg=foo -C metadata=[..] -L dependency=[ROOT]/foo/target/debug/deps [..]`
216
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
217
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
218
+
219
+ "# ] ] )
249
220
. run ( ) ;
250
221
}
251
222
@@ -269,7 +240,11 @@ fn features() {
269
240
. build ( ) ;
270
241
271
242
p. cargo ( "rustdoc --verbose --features quux" )
272
- . with_stderr_contains ( "[..]feature=[..]quux[..]" )
243
+ . with_stderr_data ( str![ [ r#"
244
+ ...
245
+ [RUNNING] `rustdoc [..]feature=[..]quux[..]`
246
+ ...
247
+ "# ] ] )
273
248
. run ( ) ;
274
249
}
275
250
@@ -294,11 +269,11 @@ fn proc_macro_crate_type() {
294
269
. build ( ) ;
295
270
296
271
p. cargo ( "rustdoc --verbose" )
297
- . with_stderr_contains (
298
- " \
272
+ . with_stderr_data ( str! [ [ r#"
273
+ ...
299
274
[RUNNING] `rustdoc --edition=2015 --crate-type proc-macro [..]`
300
- " ,
301
- )
275
+ ...
276
+ "# ] ] )
302
277
. run ( ) ;
303
278
}
304
279
@@ -312,19 +287,13 @@ fn rustdoc_target() {
312
287
313
288
p. cargo ( "rustdoc --verbose --target" )
314
289
. arg ( cross_compile:: alternate ( ) )
315
- . with_stderr ( format ! (
316
- "\
317
- [DOCUMENTING] foo v0.0.1 ([..])
318
- [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]\
319
- --target {target} \
320
- -o [CWD]/target/{target}/doc \
321
- [..] \
322
- -L dependency=[CWD]/target/{target}/debug/deps \
323
- -L dependency=[CWD]/target/debug/deps[..]`
324
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
325
- [GENERATED] [CWD]/target/[..]/doc/foo/index.html" ,
326
- target = cross_compile:: alternate( )
327
- ) )
290
+ . with_stderr_data ( str![ [ r#"
291
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
292
+ [RUNNING] `rustdoc [..]--crate-name foo src/lib.rs [..]--target [ALT_TARGET] -o [ROOT]/foo/target/[ALT_TARGET]/doc [..] -L dependency=[ROOT]/foo/target/[ALT_TARGET]/debug/deps -L dependency=[ROOT]/foo/target/debug/deps[..]`
293
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
294
+ [GENERATED] [ROOT]/foo/target/[..]/doc/foo/index.html
295
+
296
+ "# ] ] )
328
297
. run ( ) ;
329
298
}
330
299
@@ -344,6 +313,9 @@ fn fail_with_glob() {
344
313
345
314
p. cargo ( "rustdoc -p '*z'" )
346
315
. with_status ( 101 )
347
- . with_stderr ( "[ERROR] Glob patterns on package selection are not supported." )
316
+ . with_stderr_data ( str![ [ r#"
317
+ [ERROR] Glob patterns on package selection are not supported.
318
+
319
+ "# ] ] )
348
320
. run ( ) ;
349
321
}
0 commit comments