diff options
author | Lars Wirzenius <liw@liw.fi> | 2022-03-24 07:41:47 +0200 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2022-03-25 07:22:50 +0200 |
commit | 2937d00329ec9fbd632ffdd9265183919172905d (patch) | |
tree | d539bc85ed4b794b96ada0c869a06590b206545b /share | |
parent | 0b7adc238746b3d4c974775a8b13fbb81cb2eda9 (diff) | |
download | subplot-2937d00329ec9fbd632ffdd9265183919172905d.tar.gz |
feat: add "file doesn't contain" step to lib/files, Python and Rust
Sponsored-by: author
Diffstat (limited to 'share')
-rw-r--r-- | share/common/lib/files.yaml | 8 | ||||
-rw-r--r-- | share/python/lib/files.py | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/share/common/lib/files.yaml b/share/common/lib/files.yaml index cf85cfa..e4d9b6b 100644 --- a/share/common/lib/files.yaml +++ b/share/common/lib/files.yaml @@ -174,6 +174,14 @@ python: function: files_file_contains +- then: file (?P<filename>\S+) doesn't contain "(?P<data>.*)" + regex: true + impl: + rust: + function: subplotlib::steplibrary::files::file_doesnt_contain + python: + function: files_file_doesnt_contain + - then: file (?P<filename>\S+) matches regex /(?P<regex>.*)/ regex: true impl: diff --git a/share/python/lib/files.py b/share/python/lib/files.py index fe94ed2..3ea5877 100644 --- a/share/python/lib/files.py +++ b/share/python/lib/files.py @@ -85,6 +85,14 @@ def files_file_contains(ctx, filename=None, data=None): assert_eq(data in actual, True) +def files_file_doesnt_contain(ctx, filename=None, data=None): + assert_eq = globals()["assert_eq"] + with open(filename, "rb") as f: + actual = f.read() + actual = actual.decode("UTF-8") + assert_eq(data in actual, False) + + def files_file_matches_regex(ctx, filename=None, regex=None): assert_eq = globals()["assert_eq"] with open(filename) as f: |