From adfef6ed6a57f5214eeaa55c055b4eb78d2826c2 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Mon, 19 Feb 2024 20:33:16 -0800 Subject: [PATCH] test/common: add skip_case_slow that skips unless RUN_SLOW env var is set --- src/openpower/test/common.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/openpower/test/common.py b/src/openpower/test/common.py index b3b89876..b11034a5 100644 --- a/src/openpower/test/common.py +++ b/src/openpower/test/common.py @@ -95,6 +95,26 @@ def skip_case_if(condition, reason): return skip_case(reason, __condition=condition) +def __is_run_slow_not_set(ta): + # allow RUN_SLOW being set to the empty string to act like it isn't set + return os.environ.get("RUN_SLOW", "") == "" + + +def skip_case_slow(reason): + """ + Conditionally skip a test case if the RUN_SLOW env var isn't set. + + Use like: + @skip_case_slow("my reason why it's slow") + + For use with TestAccumulatorBase + """ + # pass a function to run the test in TestAccumulatorBase.__init__ rather + # than at module load time. + return skip_case_if(__is_run_slow_not_set, + "RUN_SLOW env var not set; " + reason) + + def skip_case_if_flag(flag_name): """ Skip a test case if `flag_name in TestAccumulatorBase.flags`. -- 2.30.2