@@ -317,7 +317,7 @@ fn well_known_names_values_doctest() {
317
317
. run ( ) ;
318
318
}
319
319
320
- #[ cargo_test]
320
+ #[ cargo_test( nightly , reason = "warning currently only on nightly" ) ]
321
321
fn test_false_lib ( ) {
322
322
let p = project ( )
323
323
. file (
@@ -332,26 +332,68 @@ fn test_false_lib() {
332
332
test = false
333
333
"# ,
334
334
)
335
- . file ( "src/lib.rs" , "" )
335
+ . file ( "src/lib.rs" , "#[cfg(test)] mod tests {} " )
336
336
. build ( ) ;
337
337
338
338
p. cargo ( "check -v" )
339
339
. with_stderr_does_not_contain ( x ! ( "rustc" => "cfg" of "docsrs,test" ) )
340
340
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
341
+ . with_stderr_data ( str![ [ r#"
342
+ ...
343
+ [WARNING] unexpected `cfg` condition name: `test`
344
+ --> src/lib.rs:1:7
345
+ |
346
+ 1 | #[cfg(test)] mod tests {}
347
+ | ^^^^
348
+ ...
349
+
350
+ [WARNING] `foo` (lib) generated 1 warning
351
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
352
+
353
+ "# ] ] )
341
354
. run ( ) ;
342
355
343
356
p. cargo ( "clean" ) . run ( ) ;
344
357
p. cargo ( "test -v" )
345
358
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
359
+ . with_stderr_data ( str![ [ r#"
360
+ ...
361
+ [WARNING] unexpected `cfg` condition name: `test`
362
+ --> src/lib.rs:1:7
363
+ |
364
+ 1 | #[cfg(test)] mod tests {}
365
+ | ^^^^
366
+ ...
367
+
368
+ [WARNING] `foo` (lib) generated 1 warning
369
+ [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
370
+ [DOCTEST] foo
371
+ [RUNNING] [..]
372
+
373
+ "# ] ] )
346
374
. run ( ) ;
347
375
348
376
p. cargo ( "clean" ) . run ( ) ;
349
377
p. cargo ( "test --lib -v" )
350
378
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
379
+ . with_stderr_data ( str![ [ r#"
380
+ ...
381
+ [WARNING] unexpected `cfg` condition name: `test`
382
+ --> src/lib.rs:1:7
383
+ |
384
+ 1 | #[cfg(test)] mod tests {}
385
+ | ^^^^
386
+ ...
387
+
388
+ [WARNING] `foo` (lib test) generated 1 warning
389
+ [FINISHED] `test` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
390
+ [RUNNING] `[ROOT]/foo/target/debug/deps/foo-[HASH]`
391
+
392
+ "# ] ] )
351
393
. run ( ) ;
352
394
}
353
395
354
- #[ cargo_test]
396
+ #[ cargo_test( nightly , reason = "warning currently only on nightly" ) ]
355
397
fn test_false_bins ( ) {
356
398
let p = project ( )
357
399
. file (
@@ -368,17 +410,30 @@ fn test_false_bins() {
368
410
path = "src/deamon.rs"
369
411
"# ,
370
412
)
371
- . file ( "src/main.rs" , "fn main() {}" )
372
- . file ( "src/deamon.rs" , "fn main() {}" )
413
+ . file ( "src/main.rs" , "fn main() {}\n #[cfg(test)] mod tests {} " )
414
+ . file ( "src/deamon.rs" , "fn main() {}\n #[cfg(test)] mod tests {} " )
373
415
. build ( ) ;
374
416
375
417
p. cargo ( "check -v" )
376
418
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test" ) ) // for foo
377
419
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) ) // for deamon
420
+ . with_stderr_data ( str![ [ r#"
421
+ ...
422
+ [WARNING] unexpected `cfg` condition name: `test`
423
+ --> src/deamon.rs:2:7
424
+ |
425
+ 2 | #[cfg(test)] mod tests {}
426
+ | ^^^^
427
+ ...
428
+
429
+ [WARNING] `foo` (bin "daemon") generated 1 warning
430
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
431
+
432
+ "# ] ] )
378
433
. run ( ) ;
379
434
}
380
435
381
- #[ cargo_test]
436
+ #[ cargo_test( nightly , reason = "warning currently only on nightly" ) ]
382
437
fn test_false_examples ( ) {
383
438
let p = project ( )
384
439
. file (
@@ -398,13 +453,35 @@ fn test_false_examples() {
398
453
path = "src/deamon.rs"
399
454
"# ,
400
455
)
401
- . file ( "src/lib.rs" , "" )
402
- . file ( "src/deamon.rs" , "fn main() {}" )
456
+ . file ( "src/lib.rs" , "#[cfg(test)] mod tests {} " )
457
+ . file ( "src/deamon.rs" , "fn main() {}\n #[cfg(test)] mod tests {} " )
403
458
. build ( ) ;
404
459
405
460
p. cargo ( "check --examples -v" )
406
461
. with_stderr_does_not_contain ( x ! ( "rustc" => "cfg" of "docsrs,test" ) )
407
462
. with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
463
+ . with_stderr_data ( str![ [ r#"
464
+ ...
465
+ [WARNING] unexpected `cfg` condition name: `test`
466
+ --> src/lib.rs:1:7
467
+ |
468
+ 1 | #[cfg(test)] mod tests {}
469
+ | ^^^^
470
+ ...
471
+
472
+ [WARNING] `foo` (lib) generated 1 warning
473
+ ...
474
+ [WARNING] unexpected `cfg` condition name: `test`
475
+ --> src/deamon.rs:2:7
476
+ |
477
+ 2 | #[cfg(test)] mod tests {}
478
+ | ^^^^
479
+ ...
480
+
481
+ [WARNING] `foo` (example "daemon") generated 1 warning
482
+ [FINISHED] `dev` profile [unoptimized + debuginfo] target(s) in [ELAPSED]s
483
+
484
+ "# ] ] )
408
485
. run ( ) ;
409
486
}
410
487
0 commit comments