From 0dcb5345efd36a2a9fa99e060435a7e028e1b62a Mon Sep 17 00:00:00 2001 From: Ismo Puustinen Date: Tue, 21 Mar 2023 11:17:57 +0200 Subject: [PATCH] testutil: normalize test names. Signed-off-by: Ismo Puustinen --- crates/containerd-shim-wasm/src/sandbox/testutil.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/crates/containerd-shim-wasm/src/sandbox/testutil.rs b/crates/containerd-shim-wasm/src/sandbox/testutil.rs index a2c1f86d0..f2404ccf6 100644 --- a/crates/containerd-shim-wasm/src/sandbox/testutil.rs +++ b/crates/containerd-shim-wasm/src/sandbox/testutil.rs @@ -3,17 +3,28 @@ use super::{Error, Result}; use std::process::{Command, Stdio}; +fn normalize_test_name(test: &str) -> Result<&str> { + let closure_removed = test.trim_end_matches("::{{closure}}"); + + // More tests and validation here if needed. + + Ok(closure_removed) +} + /// Re-execs the current process with sudo and runs the given test. /// Unless this is run in a CI environment, this may prompt the user for a password. /// This is significantly faster than expecting the user to run the tests with sudo due to build and crate caching. pub fn run_test_with_sudo(test: &str) -> Result<()> { // This uses piped stdout/stderr. // This makes it so cargo doesn't mess up the caller's TTY. + + let normalized_test = normalize_test_name(test)?; + let mut cmd = Command::new("sudo") .arg("-E") .arg(std::fs::read_link("/proc/self/exe")?) .arg("--") - .arg(test) + .arg(normalized_test) .arg("--exact") .stdin(Stdio::inherit()) .stdout(Stdio::piped())