File tree Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Expand file tree Collapse file tree 2 files changed +71
-0
lines changed Original file line number Diff line number Diff line change @@ -236,6 +236,10 @@ fn run_doc_tests(
236
236
p. arg ( "--test-args" ) . arg ( arg) ;
237
237
}
238
238
239
+ if config. shell ( ) . verbosity ( ) == Verbosity :: Quiet {
240
+ p. arg ( "--test-args" ) . arg ( "--quiet" ) ;
241
+ }
242
+
239
243
p. args ( args) ;
240
244
241
245
if * unstable_opts {
Original file line number Diff line number Diff line change @@ -216,6 +216,73 @@ fn cargo_test_quiet_no_harness() {
216
216
p. cargo ( "test -q" ) . with_stdout ( "" ) . with_stderr ( "" ) . run ( ) ;
217
217
}
218
218
219
+ #[ cargo_test]
220
+ fn cargo_doc_test_quiet ( ) {
221
+ let p = project ( )
222
+ . file (
223
+ "Cargo.toml" ,
224
+ r#"
225
+ [package]
226
+ name = "foo"
227
+ version = "0.1.0"
228
+ authors = []
229
+ "# ,
230
+ )
231
+ . file (
232
+ "src/lib.rs" ,
233
+ r#"
234
+ /// ```
235
+ /// let result = foo::add(2, 3);
236
+ /// assert_eq!(result, 5);
237
+ /// ```
238
+ pub fn add(a: i32, b: i32) -> i32 {
239
+ a + b
240
+ }
241
+
242
+ /// ```
243
+ /// let result = foo::div(10, 2);
244
+ /// assert_eq!(result, 5);
245
+ /// ```
246
+ ///
247
+ /// # Panics
248
+ ///
249
+ /// The function panics if the second argument is zero.
250
+ ///
251
+ /// ```rust,should_panic
252
+ /// // panics on division by zero
253
+ /// foo::div(10, 0);
254
+ /// ```
255
+ pub fn div(a: i32, b: i32) -> i32 {
256
+ if b == 0 {
257
+ panic!("Divide-by-zero error");
258
+ }
259
+
260
+ a / b
261
+ }
262
+
263
+ #[test] fn test_hello() {}
264
+ "# ,
265
+ )
266
+ . build ( ) ;
267
+
268
+ p. cargo ( "test -q" )
269
+ . with_stdout (
270
+ "
271
+ running 1 test
272
+ .
273
+ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]
274
+
275
+
276
+ running 3 tests
277
+ ...
278
+ test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out[..]
279
+
280
+ " ,
281
+ )
282
+ . with_stderr ( "" )
283
+ . run ( ) ;
284
+ }
285
+
219
286
#[ cargo_test]
220
287
fn cargo_test_verbose ( ) {
221
288
let p = project ( )
You can’t perform that action at this time.
0 commit comments