test/common: add skip_case_slow that skips unless RUN_SLOW env var is set
authorJacob Lifshay <programmerjake@gmail.com>
Tue, 20 Feb 2024 04:33:16 +0000 (20:33 -0800)
committerJacob Lifshay <programmerjake@gmail.com>
Tue, 20 Feb 2024 04:33:16 +0000 (20:33 -0800)
src/openpower/test/common.py

index b3b89876398b49e3bbdbd5d388d21d58b1eb8623..b11034a5a3fba85f009a9a9251fe603ccbb5eeb3 100644 (file)
@@ -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`.