Skip to content

Commit 066b291

Browse files
committed
test: lockfile path test refactoring
- win/mac fix
1 parent c25dcf0 commit 066b291

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

tests/testsuite/lockfile_path.rs

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
33
use std::fs;
44

5-
use snapbox::str;
6-
75
use cargo_test_support::registry::RegistryBuilder;
86
use cargo_test_support::{
97
basic_bin_manifest, cargo_test, project, symlink_supported, Execs, ProjectBuilder,
@@ -177,15 +175,21 @@ fn assert_broken_symlink(
177175
assert!(!p.root().join(src).is_dir());
178176
let registry = RegistryBuilder::new().http_api().http_index().build();
179177

178+
let err_msg = if !cfg!(windows) {
179+
"File exists (os error 17)"
180+
} else {
181+
"Cannot create a file when that file already exists. (os error 183)"
182+
};
183+
184+
180185
make_execs(&mut p.cargo(command), lockfile_path_argument.to_string())
181186
.with_status(101)
182-
.with_stderr_data(str![[r#"
183-
[ERROR] Failed to create lockfile-path parent directory somedir/link
187+
.with_stderr_data(&format!(
188+
r#"[ERROR] Failed to create lockfile-path parent directory somedir/link
184189
185190
Caused by:
186-
File exists (os error 17)
187-
188-
"#]])
191+
{}
192+
"#, err_msg))
189193
.replace_crates_io(registry.index_url())
190194
.run();
191195
}
@@ -210,15 +214,22 @@ fn assert_loop_symlink(
210214
assert!(!p.root().join(src).is_dir());
211215
let registry = RegistryBuilder::new().http_api().http_index().build();
212216

217+
let err_msg = if cfg!(windows) {
218+
"The name of the file cannot be resolved by the system. (os error 1921)"
219+
} else if cfg!(target_os = "macos") {
220+
"Too many levels of symbolic links (os error 62)"
221+
} else {
222+
"Too many levels of symbolic links (os error 40)"
223+
};
224+
213225
make_execs(&mut p.cargo(command), lockfile_path_argument.to_string())
214226
.with_status(101)
215-
.with_stderr_data(str![[r#"
216-
[ERROR] Failed to fetch lock file's parent path metadata somedir/link
227+
.with_stderr_data(&format!(
228+
r#"[ERROR] Failed to fetch lock file's parent path metadata somedir/link
217229
218230
Caused by:
219-
Too many levels of symbolic links (os error 40)
220-
221-
"#]])
231+
{}
232+
"#, err_msg))
222233
.replace_crates_io(registry.index_url())
223234
.run();
224235
}

0 commit comments

Comments
 (0)