Skip to content

Commit

Permalink
tests: test migration with fake files
Browse files Browse the repository at this point in the history
  • Loading branch information
mistydemeo committed Apr 17, 2024
1 parent 918005c commit 3eedce9
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions cargo-dist/tests/gallery/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,22 @@ impl DistResult {
}
std::fs::create_dir_all(&tempdir).unwrap();

let expected_bin_dir = Utf8PathBuf::from(expected_bin_dir);
let bin_dir = tempdir.join(&expected_bin_dir);
// Test generating fake old binaries within the older
// flat directory structure, allowing us to simulate
// performing a migration
if !expected_bin_dir
.components()
.any(|d| d.as_str() == ".cargo")
{
let root = bin_dir.parent().unwrap();
for bin_name in ctx.repo.bins {
let old_path = root.join(bin_name);
std::fs::File::create(old_path).unwrap();
}
}

// Run the installer script with:
//
// HOME="{tempdir}" (for install-path=~/... and install-path=CARGO_HOME)
Expand All @@ -700,8 +716,6 @@ impl DistResult {
tempdir.join(".zshrc"),
];
let receipt_file = tempdir.join(format!(".config/{app_name}/{app_name}-receipt.json"));
let expected_bin_dir = Utf8PathBuf::from(expected_bin_dir);
let bin_dir = tempdir.join(expected_bin_dir);
let env_dir = bin_dir.parent().unwrap();
let env_script = env_dir.join("env");

Expand Down

0 comments on commit 3eedce9

Please sign in to comment.