File tree Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Expand file tree Collapse file tree 3 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,9 @@ pub struct Compilation<'cfg> {
6666 /// Flags to pass to rustdoc when invoked from cargo test, per package.
6767 pub rustdocflags : HashMap < PackageId , Vec < String > > ,
6868
69+ /// The target host triple.
70+ pub host : String ,
71+
6972 config : & ' cfg Config ,
7073
7174 /// Rustc process to be used by default
@@ -123,6 +126,7 @@ impl<'cfg> Compilation<'cfg> {
123126 cfgs : HashMap :: new ( ) ,
124127 rustdocflags : HashMap :: new ( ) ,
125128 config : bcx. config ,
129+ host : bcx. host_triple ( ) . to_string ( ) ,
126130 rustc_process : rustc,
127131 rustc_workspace_wrapper_process,
128132 primary_rustc_process,
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ fn run_doc_tests(
137137 compilation : & Compilation < ' _ > ,
138138) -> CargoResult < ( Test , Vec < ProcessError > ) > {
139139 let mut errors = Vec :: new ( ) ;
140+ let doctest_xcompile = config. cli_unstable ( ) . doctest_xcompile ;
140141
141142 for doctest_info in & compilation. to_doc_test {
142143 let Doctest {
@@ -145,9 +146,16 @@ fn run_doc_tests(
145146 unit,
146147 } = doctest_info;
147148
148- // Skip any `--target` tests unless `doctest-xcompile` is specified.
149- if !config. cli_unstable ( ) . doctest_xcompile && !unit. kind . is_host ( ) {
150- continue ;
149+ if !doctest_xcompile {
150+ match unit. kind {
151+ CompileKind :: Host => { }
152+ CompileKind :: Target ( target) => {
153+ if target. short_name ( ) != compilation. host {
154+ // Skip doctests, -Zdoctest-xcompile not enabled.
155+ continue ;
156+ }
157+ }
158+ }
151159 }
152160
153161 config. shell ( ) . status ( "Doc-tests" , unit. target . name ( ) ) ?;
@@ -157,7 +165,7 @@ fn run_doc_tests(
157165 . arg ( "--crate-name" )
158166 . arg ( & unit. target . crate_name ( ) ) ;
159167
160- if config . cli_unstable ( ) . doctest_xcompile {
168+ if doctest_xcompile {
161169 if let CompileKind :: Target ( target) = unit. kind {
162170 // use `rustc_target()` to properly handle JSON target paths
163171 p. arg ( "--target" ) . arg ( target. rustc_target ( ) ) ;
Original file line number Diff line number Diff line change @@ -396,6 +396,7 @@ fn no_cross_doctests() {
396396 [COMPILING] foo v0.0.1 ([CWD])
397397[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
398398[RUNNING] target/{triple}/debug/deps/foo-[..][EXE]
399+ [DOCTEST] foo
399400" ,
400401 triple = target
401402 ) )
You can’t perform that action at this time.
0 commit comments