Skip to content

Commit c30bebf

Browse files
committed
assure there are no archive file-name clashes across crates (#384)
1 parent a240d66 commit c30bebf

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/tools/src/lib.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ pub fn hex_to_id(hex: &str) -> git_hash::ObjectId {
2929
pub fn fixture_path(path: impl AsRef<Path>) -> PathBuf {
3030
PathBuf::from("tests").join("fixtures").join(path.as_ref())
3131
}
32+
33+
pub fn crate_under_test() -> String {
34+
std::env::current_dir()
35+
.expect("CWD is valid")
36+
.file_name()
37+
.expect("typical cargo invocation")
38+
.to_string_lossy()
39+
.into_owned()
40+
}
41+
3242
pub fn fixture_bytes(path: impl AsRef<Path>) -> Vec<u8> {
3343
match std::fs::read(fixture_path(path.as_ref())) {
3444
Ok(res) => res,
@@ -97,7 +107,9 @@ pub fn scripted_fixture_repo_read_only_with_args(
97107

98108
let script_basename = script_name.file_stem().unwrap_or(script_name.as_os_str());
99109
let archive_file_path = fixture_path(
100-
Path::new("generated-archives").join(format!("{}.tar.xz", script_basename.to_str().expect("valid UTF-8"))),
110+
Path::new("generated-archives")
111+
.join(crate_under_test())
112+
.join(format!("{}.tar.xz", script_basename.to_str().expect("valid UTF-8"))),
101113
);
102114
let script_result_directory = fixture_path(
103115
Path::new("generated-do-not-edit")

0 commit comments

Comments
 (0)