Skip to content

Commit 913e9cc

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 0a2d771 commit 913e9cc

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

xtask/src/xtask.rs

Lines changed: 15 additions & 3 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 =
@@ -186,14 +186,26 @@ fn test_tmt(sh: &Shell) -> Result<()> {
186186
Ok(acc)
187187
})?;
188188
all_plan_files.sort_by_key(|v| v.0);
189-
println!("Discovered plans: {all_plan_files:?}");
189+
Ok(all_plan_files)
190+
}
191+
192+
#[context("test-integration")]
193+
fn test_tmt(sh: &Shell) -> Result<()> {
194+
let tests = match std::env::var("TMT_TEST") {
195+
Ok(test) => {
196+
vec![(0, test)]
197+
}
198+
Err(_) => all_plan_files(sh)?,
199+
};
200+
201+
println!("Discovered plans: {tests:?}");
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)