Skip to content

Commit

Permalink
fix up the can_test function
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfv committed Dec 4, 2024
1 parent d40027b commit 3285cd9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
32 changes: 26 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use rattler_conda_types::{
use rattler_solve::ChannelPriority;
use rattler_solve::SolveStrategy;
use rattler_virtual_packages::{VirtualPackage, VirtualPackageOverrides};
use recipe::parser::{find_outputs_from_src, Dependency};
use recipe::parser::{find_outputs_from_src, Dependency, TestType};
use selectors::SelectorConfig;
use system_tools::SystemTools;
use tool_configuration::{Configuration, TestStrategy};
Expand Down Expand Up @@ -371,8 +371,6 @@ pub async fn get_build_output(
}

fn can_test(output: &Output, all_output_names: &[&PackageName], done_outputs: &[Output]) -> bool {
let mut can_test = true;

let check_if_matches = |spec: &MatchSpec, output: &Output| -> bool {
if spec.name.as_ref() != Some(output.name()) {
return false;
Expand All @@ -399,14 +397,36 @@ fn can_test(output: &Output, all_output_names: &[&PackageName], done_outputs: &[
{
// this dependency might not be built yet
if !done_outputs.iter().any(|o| check_if_matches(dep.spec(), o)) {
can_test = false;
break;
return false;
}
}
}
}

// Also check that for all script tests
for test in output.recipe.tests() {
if let TestType::Command(command) = test {
for dep in command
.requirements
.build
.iter()
.chain(command.requirements.run.iter())
{
let dep_spec: MatchSpec = dep.parse().expect("Could not parse MatchSpec");
if all_output_names
.iter()
.any(|o| Some(*o) == dep_spec.name.as_ref())
{
// this dependency might not be built yet
if !done_outputs.iter().any(|o| check_if_matches(&dep_spec, o)) {
return false;
}
}
}
}
}

can_test
true
}

/// Runs build.
Expand Down
2 changes: 1 addition & 1 deletion src/package_test/run_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ impl CommandsTest {
) -> Result<(), TestError> {
let deps = self.requirements.clone();

let span = tracing::info_span!("Running script test");
let span = tracing::info_span!("Running script test for", recipe = pkg.to_string());
let _guard = span.enter();

let build_env = if !deps.build.is_empty() {
Expand Down

0 comments on commit 3285cd9

Please sign in to comment.