Update dependencies and enhance archive extraction support

- Bump version of the `depot` package from 0.15.2 to 0.16.0 in Cargo.toml and meson.build.
- Add new dependencies: `lz4_flex` and `lzma-rust2` in Cargo.toml and Cargo.lock.
- Implement support for extracting `.tar.lz4`, `.tar.lzma`, and `.tar.lzip` formats in the extractor module.
- Refactor archive extraction logic to streamline handling of various archive formats.
- Add tests for new archive formats to ensure extraction functionality works as expected.
This commit is contained in:
2026-03-10 20:09:03 -05:00
parent 7fad7c552b
commit ccd43fca6a
8 changed files with 607 additions and 243 deletions
+36 -2
View File
@@ -128,7 +128,7 @@ pub fn build(
crate::log_info!("Skipping tests: disabled by build.flags.skip_tests");
} else {
let test_targets = phase_targets(&flags.make_test_target, &flags.make_test_targets);
if !test_targets.is_empty() {
if !cmake_uses_default_ctest(flags) {
let joined = test_targets.join(" ");
crate::log_info!("Running cmake test target(s): {}...", joined);
let mut test_cmd = Command::new("cmake");
@@ -149,7 +149,20 @@ pub fn build(
anyhow::bail!("cmake test target(s) '{}' failed", joined);
}
} else {
crate::log_info!("Skipping tests: no build.flags.make_test_target(s) for cmake");
crate::log_info!("Running ctest...");
let mut test_cmd = Command::new("ctest");
test_cmd.current_dir(&build_dir);
test_cmd.arg("--test-dir").arg(&build_dir);
test_cmd.arg("-j").arg(num_cpus().to_string());
test_cmd.arg("--output-on-failure");
crate::builder::prepare_tool_command(&mut test_cmd, &env_vars);
let status = test_cmd
.status()
.with_context(|| format!("Failed to run ctest for {}", spec.package.name))?;
if !status.success() {
anyhow::bail!("ctest failed");
}
}
}
@@ -251,6 +264,10 @@ fn phase_targets(single: &str, many: &[String]) -> Vec<String> {
targets
}
fn cmake_uses_default_ctest(flags: &crate::package::BuildFlags) -> bool {
phase_targets(&flags.make_test_target, &flags.make_test_targets).is_empty()
}
fn cmake_generator_for_make_exec(make_exec: &str) -> Option<&'static str> {
let tool = Path::new(make_exec)
.file_name()
@@ -434,6 +451,23 @@ mod tests {
assert!(phase_targets("", &[]).is_empty());
}
#[test]
fn test_cmake_uses_default_ctest_without_explicit_targets() {
assert!(cmake_uses_default_ctest(&BuildFlags::default()));
let explicit_single = BuildFlags {
make_test_target: "test".into(),
..BuildFlags::default()
};
assert!(!cmake_uses_default_ctest(&explicit_single));
let explicit_many = BuildFlags {
make_test_targets: vec!["check".into()],
..BuildFlags::default()
};
assert!(!cmake_uses_default_ctest(&explicit_many));
}
#[test]
fn test_cmake_generator_for_make_exec_detects_ninja_and_make() {
assert_eq!(cmake_generator_for_make_exec("ninja"), Some("Ninja"));
+67
View File
@@ -83,6 +83,36 @@ pub fn build(
anyhow::bail!("ninja build failed");
}
if flags.skip_tests {
crate::log_info!("Skipping tests: disabled by build.flags.skip_tests");
} else {
let test_suites = meson_test_suites(flags);
if test_suites.is_empty() {
crate::log_info!("Running meson test...");
} else {
crate::log_info!("Running meson test suite(s): {}...", test_suites.join(" "));
}
let mut test_cmd = Command::new("meson");
test_cmd.current_dir(&build_dir);
test_cmd.arg("test");
test_cmd.arg("-C").arg(&build_dir);
test_cmd.arg("--num-processes").arg(num_cpus().to_string());
test_cmd.arg("--print-errorlogs");
for suite in &test_suites {
test_cmd.arg("--suite").arg(suite);
}
crate::builder::prepare_tool_command(&mut test_cmd, &env_vars);
let status = test_cmd
.status()
.with_context(|| format!("Failed to run meson test for {}", spec.package.name))?;
if !status.success() {
anyhow::bail!("meson test failed");
}
}
crate::source::hooks::run_post_compile_commands(spec, &actual_src, destdir)?;
state.mark_done(BuildStep::PostCompileDone)?;
} else {
@@ -146,6 +176,21 @@ fn resolve_build_dir(actual_src: &Path, flags: &crate::package::BuildFlags) -> P
}
}
fn meson_test_suites(flags: &crate::package::BuildFlags) -> Vec<String> {
let mut suites = Vec::new();
let single = flags.make_test_target.trim();
if !single.is_empty() {
suites.push(single.to_string());
}
for suite in &flags.make_test_targets {
let trimmed = suite.trim();
if !trimmed.is_empty() {
suites.push(trimmed.to_string());
}
}
suites
}
fn has_option(configure: &[String], long: &str) -> bool {
let prefix = format!("{long}=");
for arg in configure {
@@ -407,6 +452,28 @@ mod tests {
);
}
#[test]
fn test_meson_test_suites_uses_single_and_multiple_targets() {
let flags = BuildFlags {
make_test_target: "unit".to_string(),
make_test_targets: vec!["integration".to_string(), " smoke ".to_string()],
..BuildFlags::default()
};
assert_eq!(
meson_test_suites(&flags),
vec![
"unit".to_string(),
"integration".to_string(),
"smoke".to_string()
]
);
}
#[test]
fn test_meson_test_suites_empty_without_targets() {
assert!(meson_test_suites(&BuildFlags::default()).is_empty());
}
#[test]
fn test_resolve_actual_src_uses_source_subdir_under_source() -> Result<()> {
let src = tempdir()?;