Skip to content

Commit

Permalink
Skip conformance tests that require Docker when Docker is not installed
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Levick <[email protected]>
  • Loading branch information
rylev committed Jul 23, 2024
1 parent 9e7c62d commit 328e990
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions tests/conformance-tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,22 @@ pub fn run_test(
conformance_tests::config::Precondition::TcpEcho => {
services.push("tcp-echo");
}
conformance_tests::config::Precondition::Redis => services.push("redis"),
conformance_tests::config::Precondition::Mqtt => services.push("mqtt"),
conformance_tests::config::Precondition::Redis => {
if is_docker_installed() {
services.push("redis")
} else {
// Skip the test if docker is not installed.
return Ok(());
}
}
conformance_tests::config::Precondition::Mqtt => {
if is_docker_installed() {
services.push("mqtt")
} else {
// Skip the test if docker is not installed.
return Ok(());
}
}
conformance_tests::config::Precondition::KeyValueStore(_) => {}
conformance_tests::config::Precondition::Sqlite => {}
}
Expand Down Expand Up @@ -57,3 +71,12 @@ pub fn run_test(
}
Ok(())
}

/// Whether or not docker is installed on the system.
fn is_docker_installed() -> bool {
std::process::Command::new("docker")
.arg("--version")
.output()
.map(|output| output.status.success())
.unwrap_or(false)
}

0 comments on commit 328e990

Please sign in to comment.