File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change 1
1
//! Tests for setting custom rustdoc flags.
2
2
3
3
use cargo_test_support:: project;
4
+ use cargo_test_support:: rustc_host;
5
+ use cargo_test_support:: rustc_host_env;
4
6
5
7
#[ cargo_test]
6
8
fn parses_env ( ) {
@@ -159,3 +161,29 @@ fn not_affected_by_target_rustflags() {
159
161
. with_stderr_contains ( "[RUNNING] `rustdoc [..] --cfg foo[..]`" )
160
162
. run ( ) ;
161
163
}
164
+
165
+ #[ cargo_test]
166
+ fn target_triple_rustdocflags_works ( ) {
167
+ let host = rustc_host ( ) ;
168
+ let host_env = rustc_host_env ( ) ;
169
+ let p = project ( ) . file ( "src/lib.rs" , "" ) . build ( ) ;
170
+
171
+ // target.triple.rustdocflags in env works
172
+ p. cargo ( "doc -v" )
173
+ . env (
174
+ & format ! ( "CARGO_TARGET_{host_env}_RUSTDOCFLAGS" ) ,
175
+ "--cfg=foo" ,
176
+ )
177
+ . with_stderr_contains ( "[RUNNING] `rustdoc[..]--cfg[..]foo[..]`" )
178
+ . run ( ) ;
179
+
180
+ // target.triple.rustdocflags in config is not supported.
181
+ p. cargo ( "doc -v" )
182
+ . arg ( "--config" )
183
+ . arg ( format ! ( "target.{host}.rustdocflags=['--cfg', 'foo']" ) )
184
+ . with_status ( 101 )
185
+ . with_stderr ( format ! (
186
+ "[ERROR] expected a table, but found a array for `target.{host}.rustdocflags` in --config cli option"
187
+ ) )
188
+ . run ( ) ;
189
+ }
You can’t perform that action at this time.
0 commit comments