Skip to content

Commit e794520

Browse files
committed
test(config-include): optional field
Capture current behavior where optional field is not yet supported.
1 parent e1a37a3 commit e794520

File tree

1 file changed

+76
-0
lines changed

1 file changed

+76
-0
lines changed

tests/testsuite/config_include.rs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -621,3 +621,79 @@ Caused by:
621621
"#]],
622622
);
623623
}
624+
625+
#[cargo_test]
626+
fn optional_include_missing_and_existing() {
627+
write_config_at(
628+
".cargo/config.toml",
629+
"
630+
key1 = 1
631+
632+
[[include]]
633+
path = 'missing.toml'
634+
optional = true
635+
636+
[[include]]
637+
path = 'other.toml'
638+
optional = true
639+
",
640+
);
641+
write_config_at(
642+
".cargo/other.toml",
643+
"
644+
key2 = 2
645+
",
646+
);
647+
648+
let gctx = GlobalContextBuilder::new()
649+
.unstable_flag("config-include")
650+
.build_err();
651+
assert_error(
652+
gctx.unwrap_err(),
653+
str![[r#"
654+
could not load Cargo configuration
655+
656+
Caused by:
657+
failed to load config include `missing.toml` from `[ROOT]/.cargo/config.toml`
658+
659+
Caused by:
660+
failed to read configuration file `[ROOT]/.cargo/missing.toml`
661+
662+
Caused by:
663+
[NOT_FOUND]
664+
"#]],
665+
);
666+
}
667+
668+
#[cargo_test]
669+
fn optional_false_missing_file() {
670+
write_config_at(
671+
".cargo/config.toml",
672+
"
673+
key1 = 1
674+
675+
[[include]]
676+
path = 'missing.toml'
677+
optional = false
678+
",
679+
);
680+
681+
let gctx = GlobalContextBuilder::new()
682+
.unstable_flag("config-include")
683+
.build_err();
684+
assert_error(
685+
gctx.unwrap_err(),
686+
str![[r#"
687+
could not load Cargo configuration
688+
689+
Caused by:
690+
failed to load config include `missing.toml` from `[ROOT]/.cargo/config.toml`
691+
692+
Caused by:
693+
failed to read configuration file `[ROOT]/.cargo/missing.toml`
694+
695+
Caused by:
696+
[NOT_FOUND]
697+
"#]],
698+
);
699+
}

0 commit comments

Comments
 (0)