Skip to content

Commit

Permalink
Merge pull request containers#890 from ckyrouac/tmt-single-test
Browse files Browse the repository at this point in the history
tmt: Add TMT_TEST env variable to specify single test to run
  • Loading branch information
ckyrouac authored Nov 8, 2024
2 parents 821e68c + 66b5aaa commit 4cf27d9
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions xtask/src/xtask.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ fn update_generated(sh: &Shell) -> Result<()> {
}

#[context("test-integration")]
fn test_tmt(sh: &Shell) -> Result<()> {
fn all_plan_files(sh: &Shell) -> Result<Vec<(u32, String)>> {
// We need to split most of our tests into separate plans because tmt doesn't
// support automatic isolation. (xref)
let mut all_plan_files =
Expand Down Expand Up @@ -187,13 +187,25 @@ fn test_tmt(sh: &Shell) -> Result<()> {
})?;
all_plan_files.sort_by_key(|v| v.0);
println!("Discovered plans: {all_plan_files:?}");
Ok(all_plan_files)
}

#[context("test-integration")]
fn test_tmt(sh: &Shell) -> Result<()> {
let mut tests = all_plan_files(sh)?;
if let Ok(name) = std::env::var("TMT_TEST") {
tests.retain(|x| x.1.as_str() == name);
if tests.is_empty() {
anyhow::bail!("Failed to match test: {name}");
}
}

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

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

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

0 comments on commit 4cf27d9

Please sign in to comment.