File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -94,6 +94,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
94
94
95
95
let mut compile_opts = args. compile_options ( config, CompileMode :: Test , Some ( & ws) ) ?;
96
96
97
+ let no_run = args. is_present ( "no-run" ) ;
97
98
let doc = args. is_present ( "doc" ) ;
98
99
if doc {
99
100
if let CompileFilter :: Only { .. } = compile_opts. filter {
@@ -102,6 +103,12 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
102
103
101 ,
103
104
) ) ;
104
105
}
106
+ if no_run {
107
+ return Err ( CliError :: new (
108
+ failure:: format_err!( "Can't skip running doc tests with --no-run" ) ,
109
+ 101 ,
110
+ ) ) ;
111
+ }
105
112
compile_opts. build_config . mode = CompileMode :: Doctest ;
106
113
compile_opts. filter = ops:: CompileFilter :: new (
107
114
true ,
@@ -118,7 +125,7 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
118
125
}
119
126
120
127
let ops = ops:: TestOptions {
121
- no_run : args . is_present ( "no-run" ) ,
128
+ no_run,
122
129
no_fail_fast : args. is_present ( "no-fail-fast" ) ,
123
130
compile_opts,
124
131
} ;
Original file line number Diff line number Diff line change @@ -3449,6 +3449,26 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out
3449
3449
. run ( ) ;
3450
3450
}
3451
3451
3452
+ #[ test]
3453
+ fn can_not_no_run_doc_tests ( ) {
3454
+ let p = project ( )
3455
+ . file (
3456
+ "src/lib.rs" ,
3457
+ r#"
3458
+ /// ```
3459
+ /// let _x = 1 + "foo";
3460
+ /// ```
3461
+ pub fn foo() -> u8 { 1 }
3462
+ "# ,
3463
+ )
3464
+ . build ( ) ;
3465
+
3466
+ p. cargo ( "test --doc --no-run" )
3467
+ . with_status ( 101 )
3468
+ . with_stderr ( "[ERROR] Can't skip running doc tests with --no-run" )
3469
+ . run ( ) ;
3470
+ }
3471
+
3452
3472
#[ test]
3453
3473
fn test_all_targets_lib ( ) {
3454
3474
let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
You can’t perform that action at this time.
0 commit comments