tests: cleanup test_util module

We can remove the `tests` module as the entire file is only
available when running tests.

Follow-up of #7130 / 1f13165fae.

Signed-off-by: Philipp Schuster <philipp.schuster@cyberus-technology.de>
On-behalf-of: SAP philipp.schuster@sap.com
This commit is contained in:
Philipp Schuster
2025-06-13 13:48:06 +02:00
committed by Bo Chen
parent 9d8bda20e5
commit 53e9c94e68
3 changed files with 17 additions and 17 deletions
+1 -1
View File
@@ -1142,7 +1142,7 @@ mod tests {
use std::cmp::Ordering; use std::cmp::Ordering;
use super::*; use super::*;
use crate::test_util::tests::assert_args_sorted; use crate::test_util::assert_args_sorted;
#[test] #[test]
fn test_cli_args_sorted() { fn test_cli_args_sorted() {
+1 -1
View File
@@ -907,7 +907,7 @@ mod unit_tests {
PayloadConfig, RngConfig, VmConfig, PayloadConfig, RngConfig, VmConfig,
}; };
use crate::test_util::tests::assert_args_sorted; use crate::test_util::assert_args_sorted;
use crate::{create_app, get_cli_options_sorted, prepare_default_values}; use crate::{create_app, get_cli_options_sorted, prepare_default_values};
fn get_vm_config_from_vec(args: &[&str]) -> VmConfig { fn get_vm_config_from_vec(args: &[&str]) -> VmConfig {
+15 -15
View File
@@ -3,22 +3,22 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#[cfg(test)] //! Test utilities.
pub mod tests {
use std::cmp::Ordering;
use clap::Arg; use std::cmp::Ordering;
pub fn assert_args_sorted<'a, F: Fn() -> R, R: Iterator<Item = &'a Arg>>(get_base_iter: F) { use clap::Arg;
let iter = get_base_iter().zip(get_base_iter().skip(1));
for (arg, next) in iter { /// Ensures that all [`Arg`]s are sorted alphabetically.
assert_ne!( pub fn assert_args_sorted<'a, F: Fn() -> R, R: Iterator<Item = &'a Arg>>(get_base_iter: F) {
arg.get_id().cmp(next.get_id()), let iter = get_base_iter().zip(get_base_iter().skip(1));
Ordering::Greater, for (arg, next) in iter {
"args not alphabetically sorted: arg={}, next={}", assert_ne!(
arg.get_id(), arg.get_id().cmp(next.get_id()),
next.get_id() Ordering::Greater,
); "args not alphabetically sorted: arg={}, next={}",
} arg.get_id(),
next.get_id()
);
} }
} }