1
1
//! Tests for setting custom rustdoc flags.
2
2
3
- #![ allow( deprecated) ]
4
-
5
3
use cargo_test_support:: project;
6
4
use cargo_test_support:: rustc_host;
7
5
use cargo_test_support:: rustc_host_env;
6
+ use cargo_test_support:: str;
8
7
9
8
#[ cargo_test]
10
9
fn parses_env ( ) {
11
10
let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
12
11
13
12
p. cargo ( "doc -v" )
14
13
. env ( "RUSTDOCFLAGS" , "--cfg=foo" )
15
- . with_stderr_contains ( "[RUNNING] `rustdoc [..] --cfg=foo[..]`" )
14
+ . with_stderr_data ( str![ [ r#"
15
+ ...
16
+ [RUNNING] `rustdoc [..] --cfg=foo[..]`
17
+ ...
18
+ "# ] ] )
16
19
. run ( ) ;
17
20
}
18
21
@@ -30,7 +33,11 @@ fn parses_config() {
30
33
. build ( ) ;
31
34
32
35
p. cargo ( "doc -v" )
33
- . with_stderr_contains ( "[RUNNING] `rustdoc [..] --cfg foo[..]`" )
36
+ . with_stderr_data ( str![ [ r#"
37
+ ...
38
+ [RUNNING] `rustdoc [..] --cfg foo [..]`
39
+ ...
40
+ "# ] ] )
34
41
. run ( ) ;
35
42
}
36
43
@@ -41,7 +48,11 @@ fn bad_flags() {
41
48
p. cargo ( "doc" )
42
49
. env ( "RUSTDOCFLAGS" , "--bogus" )
43
50
. with_status ( 101 )
44
- . with_stderr_contains ( "[..]bogus[..]" )
51
+ . with_stderr_data ( str![ [ r#"
52
+ ...
53
+ [ERROR] Unrecognized option: 'bogus'
54
+ ...
55
+ "# ] ] )
45
56
. run ( ) ;
46
57
}
47
58
@@ -52,20 +63,20 @@ fn rerun() {
52
63
p. cargo ( "doc" ) . env ( "RUSTDOCFLAGS" , "--cfg=foo" ) . run ( ) ;
53
64
p. cargo ( "doc" )
54
65
. env ( "RUSTDOCFLAGS" , "--cfg=foo" )
55
- . with_stderr (
56
- "[FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
57
- [GENERATED] [CWD]/target/doc/foo/index.html" ,
58
- )
66
+ . with_stderr_data ( str![ [ r#"
67
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
68
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
69
+
70
+ "# ] ] )
59
71
. run ( ) ;
60
72
p. cargo ( "doc" )
61
73
. env ( "RUSTDOCFLAGS" , "--cfg=bar" )
62
- . with_stderr (
63
- "\
64
- [DOCUMENTING] foo v0.0.1 ([..])
65
- [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [..]
66
- [GENERATED] [CWD]/target/doc/foo/index.html
67
- " ,
68
- )
74
+ . with_stderr_data ( str![ [ r#"
75
+ [DOCUMENTING] foo v0.0.1 ([ROOT]/foo)
76
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
77
+ [GENERATED] [ROOT]/foo/target/doc/foo/index.html
78
+
79
+ "# ] ] )
69
80
. run ( ) ;
70
81
}
71
82
@@ -102,7 +113,10 @@ fn rustdocflags_misspelled() {
102
113
103
114
p. cargo ( "doc" )
104
115
. env ( "RUSTDOC_FLAGS" , "foo" )
105
- . with_stderr_contains ( "[WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?" )
116
+ . with_stderr_data ( str![ [ r#"
117
+ [WARNING] Cargo does not read `RUSTDOC_FLAGS` environment variable. Did you mean `RUSTDOCFLAGS`?
118
+ ...
119
+ "# ] ] )
106
120
. run ( ) ;
107
121
}
108
122
@@ -114,7 +128,11 @@ fn whitespace() {
114
128
// "too many operands"
115
129
p. cargo ( "doc" )
116
130
. env ( "RUSTDOCFLAGS" , "--crate-version this has spaces" )
117
- . with_stderr_contains ( "[ERROR] could not document `foo`" )
131
+ . with_stderr_data ( str![ [ r#"
132
+ ...
133
+ [ERROR] could not document `foo`
134
+ ...
135
+ "# ] ] )
118
136
. with_status ( 101 )
119
137
. run ( ) ;
120
138
@@ -155,12 +173,20 @@ fn not_affected_by_target_rustflags() {
155
173
// `cargo build` should fail due to missing docs.
156
174
p. cargo ( "build -v" )
157
175
. with_status ( 101 )
158
- . with_stderr_contains ( "[RUNNING] `rustc [..] -D missing-docs[..]`" )
176
+ . with_stderr_data ( str![ [ r#"
177
+ ...
178
+ [RUNNING] `rustc [..] -D missing-docs`
179
+ ...
180
+ "# ] ] )
159
181
. run ( ) ;
160
182
161
183
// `cargo doc` shouldn't fail.
162
184
p. cargo ( "doc -v" )
163
- . with_stderr_contains ( "[RUNNING] `rustdoc [..] --cfg foo[..]`" )
185
+ . with_stderr_data ( str![ [ r#"
186
+ ...
187
+ [RUNNING] `rustdoc [..] --cfg foo[..]`
188
+ ...
189
+ "# ] ] )
164
190
. run ( ) ;
165
191
}
166
192
@@ -176,14 +202,22 @@ fn target_triple_rustdocflags_works() {
176
202
& format ! ( "CARGO_TARGET_{host_env}_RUSTDOCFLAGS" ) ,
177
203
"--cfg=foo" ,
178
204
)
179
- . with_stderr_contains ( "[RUNNING] `rustdoc[..]--cfg[..]foo[..]`" )
205
+ . with_stderr_data ( str![ [ r#"
206
+ ...
207
+ [RUNNING] `rustdoc[..]--cfg[..]foo[..]`
208
+ ...
209
+ "# ] ] )
180
210
. run ( ) ;
181
211
182
212
// target.triple.rustdocflags in config works
183
213
p. cargo ( "doc -v" )
184
214
. arg ( "--config" )
185
215
. arg ( format ! ( "target.{host}.rustdocflags=['--cfg', 'foo']" ) )
186
- . with_stderr_contains ( "[RUNNING] `rustdoc[..]--cfg[..]foo[..]`" )
216
+ . with_stderr_data ( str![ [ r#"
217
+ ...
218
+ [RUNNING] `rustdoc [..] --cfg foo [..]`
219
+ ...
220
+ "# ] ] )
187
221
. run ( ) ;
188
222
}
189
223
@@ -208,27 +242,39 @@ fn target_triple_rustdocflags_works_through_cargo_test() {
208
242
& format ! ( "CARGO_TARGET_{host_env}_RUSTDOCFLAGS" ) ,
209
243
"--cfg=foo" ,
210
244
)
211
- . with_stderr_contains ( "[RUNNING] `rustdoc[..]--test[..]--cfg[..]foo[..]`" )
212
- . with_stdout_contains (
213
- "\
245
+ . with_stderr_data ( str![ [ r#"
246
+ ...
247
+ [RUNNING] `rustdoc[..]--test[..]--cfg[..]foo[..]`
248
+
249
+ "# ] ] )
250
+ . with_stdout_data ( str![ [ r#"
251
+
214
252
running 1 test
215
253
test src/lib.rs - (line 2) ... ok
216
254
217
- test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]" ,
218
- )
255
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
256
+
257
+
258
+ "# ] ] )
219
259
. run ( ) ;
220
260
221
261
// target.triple.rustdocflags in config works
222
262
p. cargo ( "test --doc -v" )
223
263
. arg ( "--config" )
224
264
. arg ( format ! ( "target.{host}.rustdocflags=['--cfg', 'foo']" ) )
225
- . with_stderr_contains ( "[RUNNING] `rustdoc[..]--test[..]--cfg[..]foo[..]`" )
226
- . with_stdout_contains (
227
- "\
265
+ . with_stderr_data ( str![ [ r#"
266
+ ...
267
+ [RUNNING] `rustdoc[..]--test[..]--cfg[..]foo[..]`
268
+
269
+ "# ] ] )
270
+ . with_stdout_data ( str![ [ r#"
271
+
228
272
running 1 test
229
273
test src/lib.rs - (line 2) ... ok
230
274
231
- test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]" ,
232
- )
275
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in [ELAPSED]s
276
+
277
+
278
+ "# ] ] )
233
279
. run ( ) ;
234
280
}
0 commit comments