File tree 2 files changed +18
-10
lines changed
2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -1391,17 +1391,22 @@ fn check_cfg_args(unit: &Unit) -> Vec<OsString> {
1391
1391
}
1392
1392
arg_feature. push ( "))" ) ;
1393
1393
1394
- // In addition to the package features, we also include the `test` cfg (since
1395
- // compiler-team#785, as to be able to someday apply yt conditionaly), as well
1396
- // the `docsrs` cfg from the docs.rs service .
1394
+ // In addition to the package features, we also conditionaly include the `test` cfg
1395
+ // based on the unit target "test" field (ie `lib.test = false`, `[[bin]] test = false` and
1396
+ // others) .
1397
1397
//
1398
- // We include `docsrs` here (in Cargo) instead of rustc, since there is a much closer
1398
+ // We also include `docsrs` here (in Cargo) instead of rustc, since there is a much closer
1399
1399
// relationship between Cargo and docs.rs than rustc and docs.rs. In particular, all
1400
1400
// users of docs.rs use Cargo, but not all users of rustc (like Rust-for-Linux) use docs.rs.
1401
+ let arg_extra = if unit. target . tested ( ) {
1402
+ OsString :: from ( "cfg(docsrs,test)" )
1403
+ } else {
1404
+ OsString :: from ( "cfg(docsrs)" )
1405
+ } ;
1401
1406
1402
1407
vec ! [
1403
1408
OsString :: from( "--check-cfg" ) ,
1404
- OsString :: from ( "cfg(docsrs,test)" ) ,
1409
+ arg_extra ,
1405
1410
OsString :: from( "--check-cfg" ) ,
1406
1411
arg_feature,
1407
1412
]
Original file line number Diff line number Diff line change @@ -336,17 +336,18 @@ fn test_false_lib() {
336
336
. build ( ) ;
337
337
338
338
p. cargo ( "check -v" )
339
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test" ) )
339
+ . with_stderr_does_not_contain ( x ! ( "rustc" => "cfg" of "docsrs,test" ) )
340
+ . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
340
341
. run ( ) ;
341
342
342
343
p. cargo ( "clean" ) . run ( ) ;
343
344
p. cargo ( "test -v" )
344
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test " ) )
345
+ . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
345
346
. run ( ) ;
346
347
347
348
p. cargo ( "clean" ) . run ( ) ;
348
349
p. cargo ( "test --lib -v" )
349
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test " ) )
350
+ . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
350
351
. run ( ) ;
351
352
}
352
353
@@ -372,7 +373,8 @@ fn test_false_bins() {
372
373
. build ( ) ;
373
374
374
375
p. cargo ( "check -v" )
375
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test" ) ) // for foo & deamon
376
+ . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test" ) ) // for foo
377
+ . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) ) // for deamon
376
378
. run ( ) ;
377
379
}
378
380
@@ -401,7 +403,8 @@ fn test_false_examples() {
401
403
. build ( ) ;
402
404
403
405
p. cargo ( "check --examples -v" )
404
- . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs,test" ) )
406
+ . with_stderr_does_not_contain ( x ! ( "rustc" => "cfg" of "docsrs,test" ) )
407
+ . with_stderr_contains ( x ! ( "rustc" => "cfg" of "docsrs" ) )
405
408
. run ( ) ;
406
409
}
407
410
You can’t perform that action at this time.
0 commit comments