Skip to content

Commit 56ac76e

Browse files
committed
xtask: Fix sorting stability for tests
Tests with equal numbers were getting unstable sorting, causing the generated file to flap. Signed-off-by: Colin Walters <walters@verbum.org>
1 parent 7e59942 commit 56ac76e

3 files changed

Lines changed: 27 additions & 14 deletions

File tree

crates/xtask/src/tmt.rs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ struct TmtMetadata {
834834
tmt: serde_yaml::Value,
835835
}
836836

837-
#[derive(Debug)]
837+
#[derive(Debug, Eq, PartialEq)]
838838
struct TestDef {
839839
number: u32,
840840
name: String,
@@ -845,6 +845,20 @@ struct TestDef {
845845
tmt: serde_yaml::Value,
846846
}
847847

848+
impl Ord for TestDef {
849+
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
850+
self.number
851+
.cmp(&other.number)
852+
.then_with(|| self.name.cmp(&other.name))
853+
}
854+
}
855+
856+
impl PartialOrd for TestDef {
857+
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
858+
Some(self.cmp(other))
859+
}
860+
}
861+
848862
/// Generate tmt/plans/integration.fmf from test definitions
849863
#[context("Updating TMT integration.fmf")]
850864
pub(crate) fn update_integration() -> Result<()> {
@@ -925,8 +939,7 @@ pub(crate) fn update_integration() -> Result<()> {
925939
});
926940
}
927941

928-
// Sort tests by number
929-
tests.sort_by_key(|t| t.number);
942+
tests.sort();
930943

931944
// Generate single tests.fmf file using structured YAML
932945
let tests_dir = Utf8Path::new("tmt/tests");

tmt/plans/integration.fmf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ execute:
7171
test:
7272
- /tmt/tests/tests/test-22-logically-bound-install
7373

74-
/plan-23-usroverlay:
75-
summary: Execute tests for bootc usrover
74+
/plan-23-install-outside-container:
75+
summary: Execute tests for installing outside of a container
7676
discover:
7777
how: fmf
7878
test:
79-
- /tmt/tests/tests/test-23-usroverlay
79+
- /tmt/tests/tests/test-23-install-outside-container
8080

81-
/plan-23-install-outside-container:
82-
summary: Execute tests for installing outside of a container
81+
/plan-23-usroverlay:
82+
summary: Execute tests for bootc usrover
8383
discover:
8484
how: fmf
8585
test:
86-
- /tmt/tests/tests/test-23-install-outside-container
86+
- /tmt/tests/tests/test-23-usroverlay
8787

8888
/plan-24-image-upgrade-reboot:
8989
summary: Execute local upgrade tests

tmt/tests/tests.fmf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,16 @@
2121
duration: 30m
2222
test: nu booted/test-logically-bound-install.nu
2323

24-
/test-23-usroverlay:
25-
summary: Execute tests for bootc usrover
26-
duration: 30m
27-
test: nu booted/test-usroverlay.nu
28-
2924
/test-23-install-outside-container:
3025
summary: Execute tests for installing outside of a container
3126
duration: 30m
3227
test: nu booted/test-install-outside-container.nu
3328

29+
/test-23-usroverlay:
30+
summary: Execute tests for bootc usrover
31+
duration: 30m
32+
test: nu booted/test-usroverlay.nu
33+
3434
/test-24-image-upgrade-reboot:
3535
summary: Execute local upgrade tests
3636
duration: 30m

0 commit comments

Comments
 (0)