File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change @@ -308,6 +308,46 @@ fn left_to_right_bottom_to_top() {
308308 assert_eq ! ( gctx. get:: <i32 >( "left-bottom" ) . unwrap( ) , -3 ) ;
309309}
310310
311+ #[ cargo_test]
312+ fn nested_include_resolves_relative_to_including_file ( ) {
313+ write_config_at (
314+ ".cargo/config.toml" ,
315+ "
316+ include = '../config/cargo.toml'
317+ " ,
318+ ) ;
319+ write_config_at (
320+ "config/cargo.toml" ,
321+ "
322+ include = 'other.toml'
323+ middle = 10
324+ " ,
325+ ) ;
326+ write_config_at (
327+ "config/other.toml" ,
328+ "
329+ nested = 42
330+ " ,
331+ ) ;
332+
333+ // This should not be included,
334+ // because `include` path is resolved relative to the including config
335+ // (where the `include` is defined)
336+ write_config_at (
337+ ".cargo/other.toml" ,
338+ "
339+ INVALID = SYNTAX
340+ " ,
341+ ) ;
342+
343+ let gctx = GlobalContextBuilder :: new ( )
344+ . unstable_flag ( "config-include" )
345+ . build ( ) ;
346+
347+ assert_eq ! ( gctx. get:: <i32 >( "nested" ) . unwrap( ) , 42 ) ;
348+ assert_eq ! ( gctx. get:: <i32 >( "middle" ) . unwrap( ) , 10 ) ;
349+ }
350+
311351#[ cargo_test]
312352fn missing_file ( ) {
313353 // Error when there's a missing file.
You can’t perform that action at this time.
0 commit comments