From 71ab8bb480aec3d80061f0fbdae9e3ea6e45e266 Mon Sep 17 00:00:00 2001 From: Miquel Sabaté Solà Date: Tue, 1 Sep 2026 00:01:32 +0200 Subject: vnf-tests: allow to conditionally run tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miquel Sabaté Solà --- tests/vnf-tests/src/main.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/tests/vnf-tests/src/main.rs b/tests/vnf-tests/src/main.rs index 3ef35b0..a0bf1fa 100644 --- a/tests/vnf-tests/src/main.rs +++ b/tests/vnf-tests/src/main.rs @@ -51,6 +51,15 @@ fn parse_arguments() -> Args { res } +// Returns true if the test identified by 'id' should be run. +fn should_run(id: &str) -> bool { + let value = std::env::var("VNF_TEST") + .unwrap_or_else(|_| "".to_string()) + .to_lowercase(); + + value.is_empty() || value == id +} + // Returns true if the 'VERBOSE' environment variable is either set to 'true' // or '1', false otherwise. fn verbose() -> bool { @@ -147,10 +156,16 @@ fn main() { die("you have to provide a path to the tests/ directory".to_string()); } - if let Err(e) = run_break_mark_test(&args.file) { - die(e) + // And tests! + + if should_run("break_mark") { + if let Err(e) = run_break_mark_test(&args.file) { + die(e) + } } - if let Err(e) = run_joypad_test(&args.file) { - die(e) + if should_run("joypad") { + if let Err(e) = run_joypad_test(&args.file) { + die(e) + } } } -- cgit v1.2.3