From c6ded9ec0bb5e25c332f4416f37e41b6379fbe86 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Wed, 14 Jun 2023 10:49:47 -0700 Subject: [PATCH] run.py: allow python lambda expression for requires Add a new require type, "lambda" which will require the Python lambda expression to return a truthy value. --- README.md | 4 ++++ run.py | 3 +++ 2 files changed, 7 insertions(+) diff --git a/README.md b/README.md index 674e4803b..be5b2afa6 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,10 @@ requires: - command2 - ... + # Require the output of a Python expression to be true. For example, + # this will run on all platforms other than win32. + lambda: "sys.platform != win32" + skip: # Skip a test if a feature is present, with a message that is logged. - feature: RUST diff --git a/run.py b/run.py index af79c1360..8e2f1acee 100755 --- a/run.py +++ b/run.py @@ -365,6 +365,9 @@ def check_requires(requires, suricata_config: SuricataConfig): elif key == "pcap": # A valid requires argument, but not verified here. pass + elif key == "lambda": + if not eval(requires["lambda"]): + raise UnsatisfiedRequirementError(requires["lambda"]) else: raise Exception("unknown requires types: %s" % (key))