File tree 3 files changed +17
-4
lines changed
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> {
66
66
/// Flags to pass to rustdoc when invoked from cargo test, per package.
67
67
pub rustdocflags : HashMap < PackageId , Vec < String > > ,
68
68
69
+ /// The target host triple.
70
+ pub host : String ,
71
+
69
72
config : & ' cfg Config ,
70
73
71
74
/// Rustc process to be used by default
@@ -123,6 +126,7 @@ impl<'cfg> Compilation<'cfg> {
123
126
cfgs : HashMap :: new ( ) ,
124
127
rustdocflags : HashMap :: new ( ) ,
125
128
config : bcx. config ,
129
+ host : bcx. host_triple ( ) . to_string ( ) ,
126
130
rustc_process : rustc,
127
131
rustc_workspace_wrapper_process,
128
132
primary_rustc_process,
Original file line number Diff line number Diff line change @@ -137,6 +137,7 @@ fn run_doc_tests(
137
137
compilation : & Compilation < ' _ > ,
138
138
) -> CargoResult < ( Test , Vec < ProcessError > ) > {
139
139
let mut errors = Vec :: new ( ) ;
140
+ let doctest_xcompile = config. cli_unstable ( ) . doctest_xcompile ;
140
141
141
142
for doctest_info in & compilation. to_doc_test {
142
143
let Doctest {
@@ -145,9 +146,16 @@ fn run_doc_tests(
145
146
unit,
146
147
} = doctest_info;
147
148
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
+ }
151
159
}
152
160
153
161
config. shell ( ) . status ( "Doc-tests" , unit. target . name ( ) ) ?;
@@ -157,7 +165,7 @@ fn run_doc_tests(
157
165
. arg ( "--crate-name" )
158
166
. arg ( & unit. target . crate_name ( ) ) ;
159
167
160
- if config . cli_unstable ( ) . doctest_xcompile {
168
+ if doctest_xcompile {
161
169
if let CompileKind :: Target ( target) = unit. kind {
162
170
// use `rustc_target()` to properly handle JSON target paths
163
171
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() {
396
396
[COMPILING] foo v0.0.1 ([CWD])
397
397
[FINISHED] test [unoptimized + debuginfo] target(s) in [..]
398
398
[RUNNING] target/{triple}/debug/deps/foo-[..][EXE]
399
+ [DOCTEST] foo
399
400
" ,
400
401
triple = target
401
402
) )
You can’t perform that action at this time.
0 commit comments