summaryrefslogtreecommitdiff
path: root/share
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-03-22 11:08:26 +0200
committerLars Wirzenius <liw@liw.fi>2022-03-25 07:22:50 +0200
commit0b7adc238746b3d4c974775a8b13fbb81cb2eda9 (patch)
tree71227fd349377e79d66e7986524d318de767f474 /share
parent641a1cddce0fd7bdbb9416bb2f0bbfa55048620f (diff)
downloadsubplot-0b7adc238746b3d4c974775a8b13fbb81cb2eda9.tar.gz
refactor(lib/files.yaml): re-order step bindings meaningfully
Keep related/similar steps together. Add comments to act as section headings. Sponsored-by: author
Diffstat (limited to 'share')
-rw-r--r--share/common/lib/files.yaml132
1 files changed, 71 insertions, 61 deletions
diff --git a/share/common/lib/files.yaml b/share/common/lib/files.yaml
index 40c092a..cf85cfa 100644
--- a/share/common/lib/files.yaml
+++ b/share/common/lib/files.yaml
@@ -1,4 +1,6 @@
-# Bindings for the files steps
+# Bindings for the lib/files step library
+
+# Create or modify files.
- given: file {embedded_file}
impl:
@@ -18,90 +20,90 @@
types:
embedded_file: file
-- given: file (?P<filename>\S+) has modification time (?P<mtime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})
+- when: I write "(?P<text>.*)" to file (?P<filename>\S+)
regex: true
impl:
rust:
- function: subplotlib::steplibrary::files::touch_with_timestamp
+ function: subplotlib::steplibrary::files::create_from_text
python:
- function: files_touch_with_timestamp
- types:
- mtime: text
+ function: files_create_from_text
-- when: I write "(?P<text>.*)" to file (?P<filename>\S+)
- regex: true
+# Manage directories (distinct from files).
+
+- given: a directory {path}
impl:
rust:
- function: subplotlib::steplibrary::files::create_from_text
+ function: subplotlib::steplibrary::files::make_directory
python:
- function: files_create_from_text
+ function: files_make_directory
-- when: I remember metadata for file {filename}
+- when: I create directory {path}
impl:
rust:
- function: subplotlib::steplibrary::files::remember_metadata
+ function: subplotlib::steplibrary::files::make_directory
python:
- function: files_remember_metadata
+ function: files_make_directory
-- when: I touch file {filename}
+- when: I remove directory {path}
impl:
rust:
- function: subplotlib::steplibrary::files::touch
+ function: subplotlib::steplibrary::files::remove_directory
python:
- function: files_touch
+ function: files_remove_directory
-- then: file {filename} exists
+- then: directory {path} exists
impl:
rust:
- function: subplotlib::steplibrary::files::file_exists
+ function: subplotlib::steplibrary::files::path_exists
python:
- function: files_file_exists
+ function: files_directory_exists
-- then: file {filename} does not exist
+- then: directory {path} does not exist
impl:
rust:
- function: subplotlib::steplibrary::files::file_does_not_exist
+ function: subplotlib::steplibrary::files::path_does_not_exist
python:
- function: files_file_does_not_exist
+ function: files_directory_does_not_exist
-- then: only files (?P<filenames>.+) exist
+- then: directory {path} is empty
impl:
rust:
- function: subplotlib::steplibrary::files::only_these_exist
+ function: subplotlib::steplibrary::files::path_is_empty
python:
- function: files_only_these_exist
- regex: true
+ function: files_directory_is_empty
-- then: file (?P<filename>\S+) contains "(?P<data>.*)"
- regex: true
+- then: directory {path} is not empty
impl:
rust:
- function: subplotlib::steplibrary::files::file_contains
+ function: subplotlib::steplibrary::files::path_is_not_empty
python:
- function: files_file_contains
+ function: files_directory_is_not_empty
-- then: file (?P<filename>\S+) matches regex /(?P<regex>.*)/
+# File metadata management and testing.
+
+- given: file (?P<filename>\S+) has modification time (?P<mtime>\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2})
regex: true
impl:
rust:
- function: subplotlib::steplibrary::files::file_matches_regex
+ function: subplotlib::steplibrary::files::touch_with_timestamp
python:
- function: files_file_matches_regex
+ function: files_touch_with_timestamp
+ types:
+ mtime: text
-- then: file (?P<filename>\S+) matches regex "(?P<regex>.*)"
- regex: true
+- when: I remember metadata for file {filename}
impl:
rust:
- function: subplotlib::steplibrary::files::file_matches_regex
+ function: subplotlib::steplibrary::files::remember_metadata
python:
- function: files_file_matches_regex
+ function: files_remember_metadata
-- then: files {filename1} and {filename2} match
+- when: I touch file {filename}
impl:
rust:
- function: subplotlib::steplibrary::files::file_match
+ function: subplotlib::steplibrary::files::touch
python:
- function: files_match
+ function: files_touch
- then: file {filename} has same metadata as before
impl:
@@ -138,51 +140,59 @@
python:
function: files_mtime_is_ancient
-- given: a directory {path}
+# Testing file existence.
+
+- then: file {filename} exists
impl:
rust:
- function: subplotlib::steplibrary::files::make_directory
+ function: subplotlib::steplibrary::files::file_exists
python:
- function: files_make_directory
+ function: files_file_exists
-- when: I create directory {path}
+- then: file {filename} does not exist
impl:
rust:
- function: subplotlib::steplibrary::files::make_directory
+ function: subplotlib::steplibrary::files::file_does_not_exist
python:
- function: files_make_directory
+ function: files_file_does_not_exist
-- when: I remove directory {path}
+- then: only files (?P<filenames>.+) exist
impl:
rust:
- function: subplotlib::steplibrary::files::remove_directory
+ function: subplotlib::steplibrary::files::only_these_exist
python:
- function: files_remove_directory
+ function: files_only_these_exist
+ regex: true
-- then: directory {path} exists
+# Tests on file content.
+
+- then: file (?P<filename>\S+) contains "(?P<data>.*)"
+ regex: true
impl:
rust:
- function: subplotlib::steplibrary::files::path_exists
+ function: subplotlib::steplibrary::files::file_contains
python:
- function: files_directory_exists
+ function: files_file_contains
-- then: directory {path} does not exist
+- then: file (?P<filename>\S+) matches regex /(?P<regex>.*)/
+ regex: true
impl:
rust:
- function: subplotlib::steplibrary::files::path_does_not_exist
+ function: subplotlib::steplibrary::files::file_matches_regex
python:
- function: files_directory_does_not_exist
+ function: files_file_matches_regex
-- then: directory {path} is empty
+- then: file (?P<filename>\S+) matches regex "(?P<regex>.*)"
+ regex: true
impl:
rust:
- function: subplotlib::steplibrary::files::path_is_empty
+ function: subplotlib::steplibrary::files::file_matches_regex
python:
- function: files_directory_is_empty
+ function: files_file_matches_regex
-- then: directory {path} is not empty
+- then: files {filename1} and {filename2} match
impl:
rust:
- function: subplotlib::steplibrary::files::path_is_not_empty
+ function: subplotlib::steplibrary::files::file_match
python:
- function: files_directory_is_not_empty
+ function: files_match