From 4436b7ee28b0318a96d98833d85d712c8a18850d Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Sat, 14 Aug 2021 09:49:17 +0100 Subject: bindings: Parse polyglot bindings Signed-off-by: Daniel Silverstone --- share/python/lib/daemon.yaml | 77 +++++++++++++++++++++-------- share/python/lib/files.yaml | 100 ++++++++++++++++++++++++++++---------- share/python/lib/runcmd.yaml | 96 ++++++++++++++++++++++++++---------- share/python/lib/runcmd_test.yaml | 8 ++- share/rust/lib/datadir.yaml | 8 ++- share/rust/lib/files.yaml | 100 ++++++++++++++++++++++++++++---------- share/rust/lib/runcmd.yaml | 88 ++++++++++++++++++++++++--------- 7 files changed, 354 insertions(+), 123 deletions(-) (limited to 'share') diff --git a/share/python/lib/daemon.yaml b/share/python/lib/daemon.yaml index f4a2f86..5cbc7d0 100644 --- a/share/python/lib/daemon.yaml +++ b/share/python/lib/daemon.yaml @@ -1,59 +1,94 @@ - given: there is no "{args:text}" process - function: daemon_no_such_process + impl: + python: + function: daemon_no_such_process - given: a daemon helper shell script {filename} - function: _daemon_shell_script + impl: + python: + function: _daemon_shell_script - when: I start "{path}{args:text}" as a background process as {name}, on port {port} - function: daemon_start_on_port + impl: + python: + function: daemon_start_on_port - when: I start "(?P[^ "]+)(?P[^"]*)" as a background process as (?P[^,]+), on port (?P\d+), with environment (?P.*) regex: true - function: daemon_start_on_port + impl: + python: + function: daemon_start_on_port - when: I try to start "{path}{args:text}" as {name}, on port {port} - function: _daemon_start_soonish - cleanup: _daemon_stop_soonish + impl: + python: + function: _daemon_start_soonish + cleanup: _daemon_stop_soonish - when: I try to start "(?P[^ "]+)(?P[^"]*)" as (?P[^,]+), on port (?P\d+), with environment (?P.*) regex: true - function: _daemon_start_soonish - cleanup: _daemon_stop_soonish + impl: + python: + function: _daemon_start_soonish + cleanup: _daemon_stop_soonish - when: I start "{path}{args:text}" as a background process as {name} - function: _daemon_start + impl: + python: + function: _daemon_start - when: I start "(?P[^ "]+)(?P[^"]*)" as a background process as (?P[^,]+), with environment (?P.*) regex: true - function: _daemon_start + impl: + python: + function: _daemon_start - when: I stop background process {name} - function: daemon_stop + impl: + python: + function: daemon_stop - when: daemon {name} has produced output - function: daemon_has_produced_output + impl: + python: + function: daemon_has_produced_output - then: a process "{args:text}" is running - function: daemon_process_exists + impl: + python: + function: daemon_process_exists - then: there is no "{args:text}" process - function: daemon_no_such_process + impl: + python: + function: daemon_no_such_process - then: starting daemon fails with "{message:text}" - function: daemon_start_fails_with + impl: + python: + function: daemon_start_fails_with - then: starting the daemon succeeds - function: daemon_start_succeeds + impl: + python: + function: daemon_start_succeeds - then: daemon {name} stdout is "{text:text}" - function: daemon_stdout_is + impl: + python: + function: daemon_stdout_is - then: daemon {name} stdout contains "{text:text}" - function: daemon_stdout_contains + impl: + python: + function: daemon_stdout_contains - then: daemon {name} stdout doesn't contain "{text:text}" - function: daemon_stdout_doesnt_contain + impl: + python: + function: daemon_stdout_doesnt_contain - then: daemon {name} stderr is "{text:text}" - function: daemon_stderr_is - + impl: + python: + function: daemon_stderr_is diff --git a/share/python/lib/files.yaml b/share/python/lib/files.yaml index f18b8cd..64a2d14 100644 --- a/share/python/lib/files.yaml +++ b/share/python/lib/files.yaml @@ -1,83 +1,133 @@ - given: file {filename} - function: files_create_from_embedded + impl: + python: + function: files_create_from_embedded types: filename: file - given: file {filename_on_disk} from {embedded_filename} - function: files_create_from_embedded_with_other_name + impl: + python: + function: files_create_from_embedded_with_other_name types: embedded_filename: file - given: file {filename} has modification time {year}-{month}-{day} {hour}:{minute}:{second} - function: files_touch_with_timestamp + impl: + python: + function: files_touch_with_timestamp - when: I write "(?P.*)" to file (?P\S+) regex: true - function: files_create_from_text + impl: + python: + function: files_create_from_text - when: I remember metadata for file {filename} - function: files_remember_metadata + impl: + python: + function: files_remember_metadata - when: I touch file {filename} - function: files_touch + impl: + python: + function: files_touch - then: file {filename} exists - function: files_file_exists + impl: + python: + function: files_file_exists - then: file {filename} does not exist - function: files_file_does_not_exist + impl: + python: + function: files_file_does_not_exist - then: only files (?P.+) exist - function: files_only_these_exist + impl: + python: + function: files_only_these_exist regex: true - then: file (?P\S+) contains "(?P.*)" regex: true - function: files_file_contains + impl: + python: + function: files_file_contains - then: file (?P\S+) matches regex /(?P.*)/ regex: true - function: files_file_matches_regex + impl: + python: + function: files_file_matches_regex - then: file (?P\S+) matches regex "(?P.*)" regex: true - function: files_file_matches_regex + impl: + python: + function: files_file_matches_regex - then: files {filename1} and {filename2} match - function: files_match + impl: + python: + function: files_match - then: file {filename} has same metadata as before - function: files_has_remembered_metadata + impl: + python: + function: files_has_remembered_metadata - then: file {filename} has different metadata from before - function: files_has_different_metadata + impl: + python: + function: files_has_different_metadata - then: file {filename} has changed from before - function: files_has_different_metadata + impl: + python: + function: files_has_different_metadata - then: file {filename} has a very recent modification time - function: files_mtime_is_recent + impl: + python: + function: files_mtime_is_recent - then: file {filename} has a very old modification time - function: files_mtime_is_ancient + impl: + python: + function: files_mtime_is_ancient - given: a directory {path} - function: files_make_directory + impl: + python: + function: files_make_directory - when: I create directory {path} - function: files_make_directory + impl: + python: + function: files_make_directory - when: I remove directory {path} - function: files_remove_directory + impl: + python: + function: files_remove_directory - then: directory {path} exists - function: files_directory_exists + impl: + python: + function: files_directory_exists - then: directory {path} does not exist - function: files_directory_does_not_exist + impl: + python: + function: files_directory_does_not_exist - then: directory {path} is empty - function: files_directory_is_empty + impl: + python: + function: files_directory_is_empty - then: directory {path} is not empty - function: files_directory_is_not_empty + impl: + python: + function: files_directory_is_not_empty diff --git a/share/python/lib/runcmd.yaml b/share/python/lib/runcmd.yaml index a5119d8..a01cfac 100644 --- a/share/python/lib/runcmd.yaml +++ b/share/python/lib/runcmd.yaml @@ -1,91 +1,135 @@ # Steps to run commands. - given: helper script {filename} for runcmd - function: runcmd_helper_script + impl: + python: + function: runcmd_helper_script - given: srcdir is in the PATH - function: runcmd_helper_srcdir_path + impl: + python: + function: runcmd_helper_srcdir_path - when: I run (?P\S+)(?P.*) regex: true - function: runcmd_step + impl: + python: + function: runcmd_step - when: I run, in (?P\S+), (?P\S+)(?P.*) regex: true - function: runcmd_step_in + impl: + python: + function: runcmd_step_in - when: I try to run (?P\S+)(?P.*) regex: true - function: runcmd_try_to_run + impl: + python: + function: runcmd_try_to_run - when: I try to run, in (?P\S+), (?P\S+)(?P.*) regex: true - function: runcmd_try_to_run_in + impl: + python: + function: runcmd_try_to_run_in # Steps to examine exit code of latest command. - then: exit code is {exit} - function: runcmd_exit_code_is + impl: + python: + function: runcmd_exit_code_is - then: exit code is not {exit} - function: runcmd_exit_code_is_not + impl: + python: + function: runcmd_exit_code_is_not - then: command is successful - function: runcmd_exit_code_is_zero + impl: + python: + function: runcmd_exit_code_is_zero - then: command fails - function: runcmd_exit_code_is_nonzero + impl: + python: + function: runcmd_exit_code_is_nonzero # Steps to examine stdout/stderr for exact content. - then: stdout is exactly "(?P.*)" regex: true - function: runcmd_stdout_is + impl: + python: + function: runcmd_stdout_is -- then: "stdout isn't exactly \"(?P.*)\"" +- then: 'stdout isn''t exactly "(?P.*)"' regex: true - function: runcmd_stdout_isnt + impl: + python: + function: runcmd_stdout_isnt - then: stderr is exactly "(?P.*)" regex: true - function: runcmd_stderr_is + impl: + python: + function: runcmd_stderr_is -- then: "stderr isn't exactly \"(?P.*)\"" +- then: 'stderr isn''t exactly "(?P.*)"' regex: true - function: runcmd_stderr_isnt + impl: + python: + function: runcmd_stderr_isnt # Steps to examine stdout/stderr for sub-strings. - then: stdout contains "(?P.*)" regex: true - function: runcmd_stdout_contains + impl: + python: + function: runcmd_stdout_contains -- then: "stdout doesn't contain \"(?P.*)\"" +- then: 'stdout doesn''t contain "(?P.*)"' regex: true - function: runcmd_stdout_doesnt_contain + impl: + python: + function: runcmd_stdout_doesnt_contain - then: stderr contains "(?P.*)" regex: true - function: runcmd_stderr_contains + impl: + python: + function: runcmd_stderr_contains -- then: "stderr doesn't contain \"(?P.*)\"" +- then: 'stderr doesn''t contain "(?P.*)"' regex: true - function: runcmd_stderr_doesnt_contain + impl: + python: + function: runcmd_stderr_doesnt_contain # Steps to match stdout/stderr against regular expressions. - then: stdout matches regex (?P.*) regex: true - function: runcmd_stdout_matches_regex + impl: + python: + function: runcmd_stdout_matches_regex - then: stdout doesn't match regex (?P.*) regex: true - function: runcmd_stdout_doesnt_match_regex + impl: + python: + function: runcmd_stdout_doesnt_match_regex - then: stderr matches regex (?P.*) regex: true - function: runcmd_stderr_matches_regex + impl: + python: + function: runcmd_stderr_matches_regex - then: stderr doesn't match regex (?P.*) regex: true - function: runcmd_stderr_doesnt_match_regex + impl: + python: + function: runcmd_stderr_doesnt_match_regex diff --git a/share/python/lib/runcmd_test.yaml b/share/python/lib/runcmd_test.yaml index 8ade220..2ad981e 100644 --- a/share/python/lib/runcmd_test.yaml +++ b/share/python/lib/runcmd_test.yaml @@ -1,5 +1,9 @@ - given: "executable script {filename} from {embedded}" - function: create_script_from_embedded + impl: + python: + function: create_script_from_embedded - when: "I prepend {dirname} to PATH" - function: runcmd_prepend_to_path + impl: + python: + function: runcmd_prepend_to_path diff --git a/share/rust/lib/datadir.yaml b/share/rust/lib/datadir.yaml index acd4ad4..f4c313b 100644 --- a/share/rust/lib/datadir.yaml +++ b/share/rust/lib/datadir.yaml @@ -4,10 +4,14 @@ # of the capabilities are worth exporting as steps - given: datadir has at least {bytes}B of space - function: subplotlib::steplibrary::datadir::datadir_has_enough_space + impl: + rust: + function: subplotlib::steplibrary::datadir::datadir_has_enough_space types: bytes: uint - given: datadir has at least {megabytes}M of space - function: subplotlib::steplibrary::datadir::datadir_has_enough_space_megabytes + impl: + rust: + function: subplotlib::steplibrary::datadir::datadir_has_enough_space_megabytes types: megabytes: uint diff --git a/share/rust/lib/files.yaml b/share/rust/lib/files.yaml index 5fa4f45..cabda12 100644 --- a/share/rust/lib/files.yaml +++ b/share/rust/lib/files.yaml @@ -2,88 +2,138 @@ # These bind the files step library for subplotlib - given: file {embedded_file} - function: subplotlib::steplibrary::files::create_from_embedded + impl: + rust: + function: subplotlib::steplibrary::files::create_from_embedded types: embedded_file: file - given: file {filename_on_disk} from {embedded_file} - function: subplotlib::steplibrary::files::create_from_embedded_with_other_name + impl: + rust: + function: subplotlib::steplibrary::files::create_from_embedded_with_other_name types: embedded_file: file - given: file (?P\S+) has modification time (?P\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}) regex: true - function: subplotlib::steplibrary::files::touch_with_timestamp + impl: + rust: + function: subplotlib::steplibrary::files::touch_with_timestamp types: mtime: text - when: I write "(?P.*)" to file (?P\S+) regex: true - function: subplotlib::steplibrary::files::create_from_text + impl: + rust: + function: subplotlib::steplibrary::files::create_from_text - when: I remember metadata for file {filename} - function: subplotlib::steplibrary::files::remember_metadata + impl: + rust: + function: subplotlib::steplibrary::files::remember_metadata - when: I touch file {filename} - function: subplotlib::steplibrary::files::touch + impl: + rust: + function: subplotlib::steplibrary::files::touch - then: file {filename} exists - function: subplotlib::steplibrary::files::file_exists + impl: + rust: + function: subplotlib::steplibrary::files::file_exists - then: file {filename} does not exist - function: subplotlib::steplibrary::files::file_does_not_exist + impl: + rust: + function: subplotlib::steplibrary::files::file_does_not_exist - then: only files (?P.+) exist - function: subplotlib::steplibrary::files::only_these_exist + impl: + rust: + function: subplotlib::steplibrary::files::only_these_exist regex: true - then: file (?P\S+) contains "(?P.*)" regex: true - function: subplotlib::steplibrary::files::file_contains + impl: + rust: + function: subplotlib::steplibrary::files::file_contains - then: file (?P\S+) matches regex /(?P.*)/ regex: true - function: subplotlib::steplibrary::files::file_matches_regex + impl: + rust: + function: subplotlib::steplibrary::files::file_matches_regex - then: file (?P\S+) matches regex "(?P.*)" regex: true - function: subplotlib::steplibrary::files::file_matches_regex + impl: + rust: + function: subplotlib::steplibrary::files::file_matches_regex - then: files {filename1} and {filename2} match - function: subplotlib::steplibrary::files::file_match + impl: + rust: + function: subplotlib::steplibrary::files::file_match - then: file {filename} has same metadata as before - function: subplotlib::steplibrary::files::has_remembered_metadata + impl: + rust: + function: subplotlib::steplibrary::files::has_remembered_metadata - then: file {filename} has different metadata from before - function: subplotlib::steplibrary::files::has_different_metadata + impl: + rust: + function: subplotlib::steplibrary::files::has_different_metadata - then: file {filename} has changed from before - function: subplotlib::steplibrary::files::has_different_metadata + impl: + rust: + function: subplotlib::steplibrary::files::has_different_metadata - then: file {filename} has a very recent modification time - function: subplotlib::steplibrary::files::mtime_is_recent + impl: + rust: + function: subplotlib::steplibrary::files::mtime_is_recent - then: file {filename} has a very old modification time - function: subplotlib::steplibrary::files::mtime_is_ancient + impl: + rust: + function: subplotlib::steplibrary::files::mtime_is_ancient - given: a directory {path} - function: subplotlib::steplibrary::files::make_directory + impl: + rust: + function: subplotlib::steplibrary::files::make_directory - when: I create directory {path} - function: subplotlib::steplibrary::files::make_directory + impl: + rust: + function: subplotlib::steplibrary::files::make_directory - when: I remove directory {path} - function: subplotlib::steplibrary::files::remove_directory + impl: + rust: + function: subplotlib::steplibrary::files::remove_directory - then: directory {path} exists - function: subplotlib::steplibrary::files::path_exists + impl: + rust: + function: subplotlib::steplibrary::files::path_exists - then: directory {path} does not exist - function: subplotlib::steplibrary::files::path_does_not_exist + impl: + rust: + function: subplotlib::steplibrary::files::path_does_not_exist - then: directory {path} is empty - function: subplotlib::steplibrary::files::path_is_empty + impl: + rust: + function: subplotlib::steplibrary::files::path_is_empty - then: directory {path} is not empty - function: subplotlib::steplibrary::files::path_is_not_empty + impl: + rust: + function: subplotlib::steplibrary::files::path_is_not_empty diff --git a/share/rust/lib/runcmd.yaml b/share/rust/lib/runcmd.yaml index fc2db6b..1043876 100644 --- a/share/rust/lib/runcmd.yaml +++ b/share/rust/lib/runcmd.yaml @@ -1,97 +1,141 @@ # Bindings for the runcmd steplibrary - given: helper script {script} for runcmd - function: subplotlib::steplibrary::runcmd::helper_script + impl: + rust: + function: subplotlib::steplibrary::runcmd::helper_script types: script: file - given: srcdir is in the PATH - function: subplotlib::steplibrary::runcmd::helper_srcdir_path + impl: + rust: + function: subplotlib::steplibrary::runcmd::helper_srcdir_path - when: I run (?P\S+)(?P.*) regex: true - function: subplotlib::steplibrary::runcmd::run + impl: + rust: + function: subplotlib::steplibrary::runcmd::run - when: I run, in (?P\S+), (?P\S+)(?P.*) regex: true - function: subplotlib::steplibrary::runcmd::run_in + impl: + rust: + function: subplotlib::steplibrary::runcmd::run_in - when: I try to run (?P\S+)(?P.*) regex: true - function: subplotlib::steplibrary::runcmd::try_to_run + impl: + rust: + function: subplotlib::steplibrary::runcmd::try_to_run - when: I try to run, in (?P\S+), (?P\S+)(?P.*) regex: true - function: subplotlib::steplibrary::runcmd::try_to_run_in + impl: + rust: + function: subplotlib::steplibrary::runcmd::try_to_run_in # Steps to examine exit code of latest command. - then: exit code is {exit} - function: subplotlib::steplibrary::runcmd::exit_code_is + impl: + rust: + function: subplotlib::steplibrary::runcmd::exit_code_is types: exit: int - then: exit code is not {exit} - function: subplotlib::steplibrary::runcmd::exit_code_is_not + impl: + rust: + function: subplotlib::steplibrary::runcmd::exit_code_is_not types: exit: int - then: command is successful - function: subplotlib::steplibrary::runcmd::exit_code_is_zero + impl: + rust: + function: subplotlib::steplibrary::runcmd::exit_code_is_zero - then: command fails - function: subplotlib::steplibrary::runcmd::exit_code_is_nonzero + impl: + rust: + function: subplotlib::steplibrary::runcmd::exit_code_is_nonzero # Steps to examine stdout/stderr for exact content. - then: stdout is exactly "(?P.*)" regex: true - function: subplotlib::steplibrary::runcmd::stdout_is + impl: + rust: + function: subplotlib::steplibrary::runcmd::stdout_is - then: 'stdout isn''t exactly "(?P.*)"' regex: true - function: subplotlib::steplibrary::runcmd::stdout_isnt + impl: + rust: + function: subplotlib::steplibrary::runcmd::stdout_isnt - then: stderr is exactly "(?P.*)" regex: true - function: subplotlib::steplibrary::runcmd::stderr_is + impl: + rust: + function: subplotlib::steplibrary::runcmd::stderr_is - then: 'stderr isn''t exactly "(?P.*)"' regex: true - function: subplotlib::steplibrary::runcmd::stderr_isnt + impl: + rust: + function: subplotlib::steplibrary::runcmd::stderr_isnt # Steps to examine stdout/stderr for sub-strings. - then: stdout contains "(?P.*)" regex: true - function: subplotlib::steplibrary::runcmd::stdout_contains + impl: + rust: + function: subplotlib::steplibrary::runcmd::stdout_contains - then: 'stdout doesn''t contain "(?P.*)"' regex: true - function: subplotlib::steplibrary::runcmd::stdout_doesnt_contain + impl: + rust: + function: subplotlib::steplibrary::runcmd::stdout_doesnt_contain - then: stderr contains "(?P.*)" regex: true - function: subplotlib::steplibrary::runcmd::stderr_contains + impl: + rust: + function: subplotlib::steplibrary::runcmd::stderr_contains - then: 'stderr doesn''t contain "(?P.*)"' regex: true - function: subplotlib::steplibrary::runcmd::stderr_doesnt_contain + impl: + rust: + function: subplotlib::steplibrary::runcmd::stderr_doesnt_contain # Steps to match stdout/stderr against regular expressions. - then: stdout matches regex (?P.*) regex: true - function: subplotlib::steplibrary::runcmd::stdout_matches_regex + impl: + rust: + function: subplotlib::steplibrary::runcmd::stdout_matches_regex - then: stdout doesn't match regex (?P.*) regex: true - function: subplotlib::steplibrary::runcmd::stdout_doesnt_match_regex + impl: + rust: + function: subplotlib::steplibrary::runcmd::stdout_doesnt_match_regex - then: stderr matches regex (?P.*) regex: true - function: subplotlib::steplibrary::runcmd::stderr_matches_regex + impl: + rust: + function: subplotlib::steplibrary::runcmd::stderr_matches_regex - then: stderr doesn't match regex (?P.*) regex: true - function: subplotlib::steplibrary::runcmd::stderr_doesnt_match_regex + impl: + rust: + function: subplotlib::steplibrary::runcmd::stderr_doesnt_match_regex -- cgit v1.2.1