Skip to content

Commit dcce007

Browse files
committed
Tests: Add test case for config -> config.toml (relative)
1 parent 13be0cf commit dcce007

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

tests/testsuite/config.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,11 @@ fn make_config_symlink_to_config_toml_absolute() {
190190
t!(symlink_file(&toml_path, &symlink_path));
191191
}
192192

193+
fn make_config_symlink_to_config_toml_relative() {
194+
let symlink_path = paths::root().join(".cargo/config");
195+
t!(symlink_file(Path::new("config.toml"), &symlink_path));
196+
}
197+
193198
#[track_caller]
194199
pub fn assert_error<E: Borrow<anyhow::Error>>(error: E, msgs: &str) {
195200
let causes = error
@@ -309,6 +314,36 @@ f1 = 1
309314
assert_match("", &output);
310315
}
311316

317+
#[cargo_test]
318+
fn config_ambiguous_filename_symlink_doesnt_warn_relative() {
319+
// Windows requires special permissions to create symlinks.
320+
// If we don't have permission, just skip this test.
321+
if !symlink_supported() {
322+
return;
323+
};
324+
325+
write_config_toml(
326+
"\
327+
[foo]
328+
f1 = 1
329+
",
330+
);
331+
332+
make_config_symlink_to_config_toml_relative();
333+
334+
let gctx = new_gctx();
335+
336+
assert_eq!(gctx.get::<Option<i32>>("foo.f1").unwrap(), Some(1));
337+
338+
// It should NOT have warned for the symlink.
339+
// But, currently it does!
340+
let output = read_output(gctx);
341+
let expected = "\
342+
[WARNING] both `[..]/.cargo/config` and `[..]/.cargo/config.toml` exist. Using `[..]/.cargo/config`
343+
";
344+
assert_match(expected, &output);
345+
}
346+
312347
#[cargo_test]
313348
fn config_ambiguous_filename() {
314349
write_config_extless(

0 commit comments

Comments
 (0)