diff options
Diffstat (limited to 'subplotlib')
-rw-r--r-- | subplotlib/src/steplibrary/files.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/subplotlib/src/steplibrary/files.rs b/subplotlib/src/steplibrary/files.rs index fd84e1c..b94155f 100644 --- a/subplotlib/src/steplibrary/files.rs +++ b/subplotlib/src/steplibrary/files.rs @@ -232,6 +232,21 @@ pub fn file_contains(context: &Datadir, filename: &str, data: &str) { } } +/// Check if a file lacks a given sequence of characters +/// +/// # `then file (?P<filename>\S+) does not contain "(?P<data>.*)"` +/// +/// This will load the content of the named file and ensure it lacks the given string. +/// Note: this assumes everything is utf-8 encoded. If not, things will fail. +#[step] +pub fn file_doesnt_contain(context: &Datadir, filename: &str, data: &str) { + let full_path = context.canonicalise_filename(filename)?; + let body = fs::read_to_string(full_path)?; + if body.contains(data) { + throw!("unexpected file content found"); + } +} + /// Check if a file's content matches the given regular expression /// /// # `then file (?P<filename>\S+) matches regex /(?P<regex>.*)/` |