Skip to content

Commit

Permalink
run.py: allow python lambda expression for requires
Browse files Browse the repository at this point in the history
Add a new require type, "lambda" which will require the Python lambda
expression to return a truthy value.
  • Loading branch information
jasonish committed Jun 14, 2023
1 parent de752d2 commit c6ded9e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down

0 comments on commit c6ded9e

Please sign in to comment.