test: rename and update lib32 installation tests to reflect changes in path handling

This commit is contained in:
2026-03-15 23:05:24 -05:00
parent 99ceacdb64
commit 4ac242ed7b
3 changed files with 6 additions and 104 deletions
+2 -97
View File
@@ -181,7 +181,6 @@ pub(crate) fn install_destdir_path(
pub(crate) fn stage_lib32_install_tree(staging_destdir: &Path, destdir: &Path) -> Result<()> {
let lib_rel = lib32_stage_source_rel(staging_destdir)?;
copy_install_tree_preserving_links(staging_destdir, destdir, Some(&lib_rel))?;
copy_tree_preserving_links(&staging_destdir.join(&lib_rel), &destdir.join("usr/lib32"))
}
@@ -241,84 +240,6 @@ fn copy_tree_preserving_links(src: &Path, dst: &Path) -> Result<()> {
Ok(())
}
fn copy_install_tree_preserving_links(
src: &Path,
dst: &Path,
relocated_lib_rel: Option<&Path>,
) -> Result<()> {
fs::create_dir_all(dst)
.with_context(|| format!("Failed to create destination dir: {}", dst.display()))?;
for entry in WalkDir::new(src) {
let entry = entry?;
let rel = entry
.path()
.strip_prefix(src)
.with_context(|| format!("Failed to strip prefix: {}", src.display()))?;
if should_skip_staged_install_entry(rel, relocated_lib_rel) {
continue;
}
let target = dst.join(rel);
if entry.file_type().is_dir() {
fs::create_dir_all(&target)
.with_context(|| format!("Failed to create dir: {}", target.display()))?;
continue;
}
if let Some(parent) = target.parent() {
fs::create_dir_all(parent)
.with_context(|| format!("Failed to create dir: {}", parent.display()))?;
}
if entry.file_type().is_symlink() {
let link_target = fs::read_link(entry.path())
.with_context(|| format!("Failed to read symlink: {}", entry.path().display()))?;
#[cfg(unix)]
{
use std::os::unix::fs as unix_fs;
unix_fs::symlink(&link_target, &target).with_context(|| {
format!(
"Failed to create symlink {} -> {}",
target.display(),
link_target.display()
)
})?;
}
#[cfg(not(unix))]
{
anyhow::bail!(
"Symlink-preserving lib32 staging copy is only supported on unix hosts"
);
}
} else {
fs::copy(entry.path(), &target).with_context(|| {
format!(
"Failed to copy {} to {}",
entry.path().display(),
target.display()
)
})?;
}
}
Ok(())
}
fn should_skip_staged_install_entry(rel: &Path, relocated_lib_rel: Option<&Path>) -> bool {
if rel.as_os_str().is_empty() {
return false;
}
if rel.starts_with(Path::new(crate::shell_helpers::INTERNAL_DEPOT_DIR)) {
return true;
}
relocated_lib_rel.is_some_and(|lib_rel| rel.starts_with(lib_rel))
}
fn lib32_stage_source_rel(staging_destdir: &Path) -> Result<PathBuf> {
let staged_lib32 = PathBuf::from("usr/lib32");
if staging_destdir.join(&staged_lib32).exists() {
@@ -1064,13 +985,6 @@ mod tests {
fs::create_dir_all(staging.join("usr/bin"))?;
fs::write(staging.join("usr/lib32/libfoo.so.1"), "lib32")?;
fs::write(staging.join("usr/bin/foo"), "bin")?;
fs::create_dir_all(staging.join(crate::shell_helpers::INTERNAL_DEPOT_DIR))?;
fs::write(
staging
.join(crate::shell_helpers::INTERNAL_DEPOT_DIR)
.join("internal.txt"),
"skip",
)?;
stage_lib32_install_tree(&staging, &dest)?;
@@ -1078,13 +992,7 @@ mod tests {
fs::read_to_string(dest.join("usr/lib32/libfoo.so.1"))?,
"lib32"
);
assert_eq!(fs::read_to_string(dest.join("usr/bin/foo"))?, "bin");
assert!(
!dest
.join(crate::shell_helpers::INTERNAL_DEPOT_DIR)
.join("internal.txt")
.exists()
);
assert!(!dest.join("usr/bin/foo").exists());
Ok(())
}
@@ -1112,10 +1020,7 @@ mod tests {
fs::read_link(dest.join("usr/lib32/libfoo.so"))?,
PathBuf::from("libfoo.so.1")
);
assert_eq!(
fs::read_to_string(dest.join("usr/share/man/man1/foo.1"))?,
"manpage"
);
assert!(!dest.join("usr/share/man/man1/foo.1").exists());
assert!(!dest.join("usr/lib").exists());
Ok(())
}