Skip to content

Commit 328e990

Browse files
committed
Skip conformance tests that require Docker when Docker is not installed
Signed-off-by: Ryan Levick <[email protected]>
1 parent 9e7c62d commit 328e990

File tree

1 file changed

+25
-2
lines changed
  • tests/conformance-tests/src

1 file changed

+25
-2
lines changed

tests/conformance-tests/src/lib.rs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,22 @@ pub fn run_test(
1515
conformance_tests::config::Precondition::TcpEcho => {
1616
services.push("tcp-echo");
1717
}
18-
conformance_tests::config::Precondition::Redis => services.push("redis"),
19-
conformance_tests::config::Precondition::Mqtt => services.push("mqtt"),
18+
conformance_tests::config::Precondition::Redis => {
19+
if is_docker_installed() {
20+
services.push("redis")
21+
} else {
22+
// Skip the test if docker is not installed.
23+
return Ok(());
24+
}
25+
}
26+
conformance_tests::config::Precondition::Mqtt => {
27+
if is_docker_installed() {
28+
services.push("mqtt")
29+
} else {
30+
// Skip the test if docker is not installed.
31+
return Ok(());
32+
}
33+
}
2034
conformance_tests::config::Precondition::KeyValueStore(_) => {}
2135
conformance_tests::config::Precondition::Sqlite => {}
2236
}
@@ -57,3 +71,12 @@ pub fn run_test(
5771
}
5872
Ok(())
5973
}
74+
75+
/// Whether or not docker is installed on the system.
76+
fn is_docker_installed() -> bool {
77+
std::process::Command::new("docker")
78+
.arg("--version")
79+
.output()
80+
.map(|output| output.status.success())
81+
.unwrap_or(false)
82+
}

0 commit comments

Comments
 (0)