Skip to content

Commit 91f3e45

Browse files
committed
Tests: Add test case for config.toml -> config
1 parent dcce007 commit 91f3e45

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

tests/testsuite/config.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@ fn make_config_symlink_to_config_toml_relative() {
195195
t!(symlink_file(Path::new("config.toml"), &symlink_path));
196196
}
197197

198+
fn rename_config_toml_to_config_replacing_with_symlink() {
199+
let root = paths::root();
200+
t!(fs::rename(
201+
root.join(".cargo/config.toml"),
202+
root.join(".cargo/config")
203+
));
204+
t!(symlink_file(
205+
Path::new("config"),
206+
&root.join(".cargo/config.toml")
207+
));
208+
}
209+
198210
#[track_caller]
199211
pub fn assert_error<E: Borrow<anyhow::Error>>(error: E, msgs: &str) {
200212
let causes = error
@@ -344,6 +356,36 @@ f1 = 1
344356
assert_match(expected, &output);
345357
}
346358

359+
#[cargo_test]
360+
fn config_ambiguous_filename_symlink_doesnt_warn_backward() {
361+
// Windows requires special permissions to create symlinks.
362+
// If we don't have permission, just skip this test.
363+
if !symlink_supported() {
364+
return;
365+
};
366+
367+
write_config_toml(
368+
"\
369+
[foo]
370+
f1 = 1
371+
",
372+
);
373+
374+
rename_config_toml_to_config_replacing_with_symlink();
375+
376+
let gctx = new_gctx();
377+
378+
assert_eq!(gctx.get::<Option<i32>>("foo.f1").unwrap(), Some(1));
379+
380+
// It should NOT have warned for this situation.
381+
// But, currently it does!
382+
let output = read_output(gctx);
383+
let expected = "\
384+
[WARNING] both `[..]/.cargo/config` and `[..]/.cargo/config.toml` exist. Using `[..]/.cargo/config`
385+
";
386+
assert_match(expected, &output);
387+
}
388+
347389
#[cargo_test]
348390
fn config_ambiguous_filename() {
349391
write_config_extless(

0 commit comments

Comments
 (0)