Skip to content

Commit 66b5aaa

Browse files
committed
tmt: Add TMT_TEST env variable to specify single test to run
e.g. `TMT_TEST=test-21-logically-bound-switch make test-tmt` will run all the tmt setup code then run test-21-logically-bound-switch. This is useful when developing a test. Signed-off-by: Chris Kyrouac <[email protected]>
1 parent 821e68c commit 66b5aaa

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

xtask/src/xtask.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ fn update_generated(sh: &Shell) -> Result<()> {
155155
}
156156

157157
#[context("test-integration")]
158-
fn test_tmt(sh: &Shell) -> Result<()> {
158+
fn all_plan_files(sh: &Shell) -> Result<Vec<(u32, String)>> {
159159
// We need to split most of our tests into separate plans because tmt doesn't
160160
// support automatic isolation. (xref)
161161
let mut all_plan_files =
@@ -187,13 +187,25 @@ fn test_tmt(sh: &Shell) -> Result<()> {
187187
})?;
188188
all_plan_files.sort_by_key(|v| v.0);
189189
println!("Discovered plans: {all_plan_files:?}");
190+
Ok(all_plan_files)
191+
}
192+
193+
#[context("test-integration")]
194+
fn test_tmt(sh: &Shell) -> Result<()> {
195+
let mut tests = all_plan_files(sh)?;
196+
if let Ok(name) = std::env::var("TMT_TEST") {
197+
tests.retain(|x| x.1.as_str() == name);
198+
if tests.is_empty() {
199+
anyhow::bail!("Failed to match test: {name}");
200+
}
201+
}
190202

191203
cmd!(sh, "cargo run -p tests-integration run-vm prepare-tmt").run()?;
192204

193205
// pull some small images that are used for LBI installation tests
194206
cmd!(sh, "podman pull {TEST_IMAGES...}").run()?;
195207

196-
for (_prio, name) in all_plan_files {
208+
for (_prio, name) in tests {
197209
// cc https://pagure.io/testcloud/pull-request/174
198210
cmd!(sh, "rm -vf /var/tmp/tmt/testcloud/images/disk.qcow2").run()?;
199211
let verbose_enabled = std::env::var("TMT_VERBOSE")

0 commit comments

Comments
 (0)