mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-04-24 22:30:03 +00:00
Fix zip extraction and bins::infer_bin_dir_template
(#869)
- Fix zip extraction code: Ensure dir is rwx and file is readable for curr user - Add more integration test for `ExtractedFiles` - Fix `bins::infer_bin_dir_template` introduced in #856 Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
460522f5bd
commit
01c8ecb778
4 changed files with 56 additions and 14 deletions
|
@ -204,6 +204,7 @@ mod test {
|
|||
)
|
||||
.unwrap();
|
||||
|
||||
// cargo-binstall
|
||||
let cargo_binstall_url = "https://github.com/cargo-bins/cargo-binstall/releases/download/v0.20.1/cargo-binstall-aarch64-unknown-linux-musl.tgz";
|
||||
|
||||
let extracted_files =
|
||||
|
@ -232,9 +233,10 @@ mod test {
|
|||
])
|
||||
);
|
||||
|
||||
// cargo-watch
|
||||
let cargo_watch_url = "https://github.com/watchexec/cargo-watch/releases/download/v8.4.0/cargo-watch-v8.4.0-aarch64-unknown-linux-gnu.tar.xz";
|
||||
|
||||
let extracted_files = Download::new(client, Url::parse(cargo_watch_url).unwrap())
|
||||
let extracted_files = Download::new(client.clone(), Url::parse(cargo_watch_url).unwrap())
|
||||
.and_extract(PkgFmt::Txz, tempdir().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
@ -276,5 +278,35 @@ mod test {
|
|||
assert!(!extracted_files.has_file(&dir.join("asdfcqwe")));
|
||||
|
||||
assert!(extracted_files.has_file(&dir.join("completions/zsh")));
|
||||
|
||||
// sccache, tgz and zip
|
||||
let sccache_config = [
|
||||
("https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-pc-windows-msvc.tar.gz", PkgFmt::Tgz),
|
||||
("https://github.com/mozilla/sccache/releases/download/v0.3.3/sccache-v0.3.3-x86_64-pc-windows-msvc.zip", PkgFmt::Zip),
|
||||
];
|
||||
|
||||
for (sccache_url, fmt) in sccache_config {
|
||||
let extracted_files = Download::new(client.clone(), Url::parse(sccache_url).unwrap())
|
||||
.and_extract(fmt, tempdir().unwrap())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let dir = Path::new("sccache-v0.3.3-x86_64-pc-windows-msvc");
|
||||
|
||||
assert_eq!(
|
||||
extracted_files.get_dir(Path::new(".")).unwrap(),
|
||||
&HashSet::from([dir.as_os_str().into()])
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
extracted_files.get_dir(dir).unwrap(),
|
||||
&HashSet::from_iter(
|
||||
["README.md", "LICENSE", "sccache.exe"]
|
||||
.iter()
|
||||
.map(OsStr::new)
|
||||
.map(Box::<OsStr>::from)
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue