diff options
Diffstat (limited to 'share/common')
-rw-r--r-- | share/common/lib/files.yaml | 58 | ||||
-rw-r--r-- | share/common/lib/runcmd.yaml | 65 |
2 files changed, 122 insertions, 1 deletions
diff --git a/share/common/lib/files.yaml b/share/common/lib/files.yaml index cb39b96..689a5f3 100644 --- a/share/common/lib/files.yaml +++ b/share/common/lib/files.yaml @@ -10,6 +10,9 @@ function: files_create_from_embedded types: embedded_file: file + doc: | + Create a file on disk from an embedded file in the subplot + document. The created file has the same name as the embedded file. - given: file {filename_on_disk} from {embedded_file} impl: @@ -20,6 +23,9 @@ types: filename_on_disk: path embedded_file: file + doc: | + Create a file on disk from an embedded file in the subplot + document. Set the name of the created file. - when: I write "{text}" to file {filename} impl: @@ -30,6 +36,8 @@ types: filename: path text: text + doc: | + Create a file on disk with the given content. # Manage directories (distinct from files). @@ -41,6 +49,8 @@ function: files_make_directory types: path: path + doc: | + Create a directory on disk. - when: I create directory {path} impl: @@ -50,6 +60,8 @@ function: files_make_directory types: path: path + doc: | + Create a directory on disk. - when: I remove directory {path} impl: @@ -59,6 +71,8 @@ function: files_remove_directory types: path: path + doc: | + Remove a directory on disk. - then: directory {path} exists impl: @@ -68,6 +82,8 @@ function: files_directory_exists types: path: path + doc: | + Check that a directory exists. - then: directory {path} does not exist impl: @@ -77,6 +93,8 @@ function: files_directory_does_not_exist types: path: path + doc: | + Check that a directory does not exist. - then: directory {path} is empty impl: @@ -86,6 +104,8 @@ function: files_directory_is_empty types: path: path + doc: | + Check that a directory exists and does not contain anything. - then: directory {path} is not empty impl: @@ -95,6 +115,8 @@ function: files_directory_is_not_empty types: path: path + doc: | + Check that a directory exists and contains something. # File metadata management and testing. @@ -108,6 +130,8 @@ types: filename: path mtime: text + doc: | + Create a file with specific modification time. - when: I remember metadata for file {filename} impl: @@ -117,6 +141,8 @@ function: files_remember_metadata types: filename: path + doc: | + Remember the metadata of a file. - when: I touch file {filename} impl: @@ -126,6 +152,8 @@ function: files_touch types: filename: path + doc: | + Update the modification time of a file to be current time. - then: file {filename} has same metadata as before impl: @@ -135,6 +163,9 @@ function: files_has_remembered_metadata types: filename: path + doc: | + Check that a file has the same metadata as remembered from + earlier. - then: file {filename} has different metadata from before impl: @@ -144,6 +175,8 @@ function: files_has_different_metadata types: filename: path + doc: | + Check that a file metadata has changed from earlier. - then: file {filename} has changed from before impl: @@ -153,6 +186,8 @@ function: files_has_different_metadata types: filename: path + doc: | + Check that file metadata has changed from before. - then: file {filename} has a very recent modification time impl: @@ -162,6 +197,8 @@ function: files_mtime_is_recent types: filename: path + doc: | + Check that file modification time is recent. - then: file {filename} has a very old modification time impl: @@ -171,6 +208,8 @@ function: files_mtime_is_ancient types: filename: path + doc: | + Check that file modification is far in the past. # Testing file existence. @@ -182,6 +221,8 @@ function: files_file_exists types: filename: path + doc: | + Check that a file exist. - then: file {filename} does not exist impl: @@ -191,6 +232,8 @@ function: files_file_does_not_exist types: filename: path + doc: | + Check that a file does not exist. - then: only files (?P<filenames>.+) exist impl: @@ -199,6 +242,10 @@ python: function: files_only_these_exist regex: true + types: + filenames: text + doc: | + Check that the test directory only contains specific files. # Tests on file content. @@ -211,6 +258,8 @@ types: filename: path data: text + doc: | + Check that a file contains a string. - then: file {filename} doesn't contain "{data}" impl: @@ -221,6 +270,8 @@ types: filename: path data: text + doc: | + Check that a file does not contain a string. - then: file {filename} matches regex /{regex}/ impl: @@ -231,6 +282,8 @@ types: filename: path regex: text + doc: | + Check that file content matches a regular expression. - then: file {filename} matches regex "{regex}" impl: @@ -241,6 +294,8 @@ types: filename: path regex: text + doc: | + Check that file content matches a regular expression. - then: files {filename1} and {filename2} match impl: @@ -251,4 +306,5 @@ types: filename1: path filename2: path - + doc: | + Check that two files have the same content. diff --git a/share/common/lib/runcmd.yaml b/share/common/lib/runcmd.yaml index 7be2c05..b20eac8 100644 --- a/share/common/lib/runcmd.yaml +++ b/share/common/lib/runcmd.yaml @@ -8,6 +8,8 @@ function: subplotlib::steplibrary::runcmd::helper_script types: script: file + doc: | + Install a helper script from an embedded file. - given: srcdir is in the PATH impl: @@ -15,6 +17,10 @@ function: runcmd_helper_srcdir_path rust: function: subplotlib::steplibrary::runcmd::helper_srcdir_path + doc: | + Make sure the source directory of the project being testes is on + the shell PATH. This makes it easy for tests to invoke programs + from the source tree. - when: I run {argv0}{args:text} impl: @@ -22,6 +28,8 @@ function: runcmd_step rust: function: subplotlib::steplibrary::runcmd::run + doc: | + Run a program, and make sure it succeeds. - when: I run, in {dirname}, {argv0}{args} impl: @@ -33,6 +41,9 @@ dirname: path argv0: word args: text + doc: | + Change to a different directory and run a program, and make sure + it succeeds; - when: I try to run {argv0}{args:text} impl: @@ -40,6 +51,9 @@ function: runcmd_try_to_run rust: function: subplotlib::steplibrary::runcmd::try_to_run + doc: | + Run a program, but allow it to fail. Other steps can check if it + succeeded. - when: I try to run, in {dirname}, {argv0}{args} impl: @@ -51,6 +65,9 @@ dirname: path argv0: word args: text + doc: | + Change to a different directory and run a program, but allow it to + fail. Other steps can check if it succeeded. # Steps to examine exit code of latest command. @@ -62,6 +79,9 @@ function: subplotlib::steplibrary::runcmd::exit_code_is types: exit: int + doc: | + Make sure the latest command run by `lib/runcmd` had a specific + exit code. - then: exit code is not {exit} impl: @@ -71,6 +91,9 @@ function: subplotlib::steplibrary::runcmd::exit_code_is_not types: exit: int + doc: | + Make sure the latest command run by `lib/runcmd` did not have a + specific exit code. - then: command is successful impl: @@ -78,6 +101,9 @@ function: runcmd_exit_code_is_zero rust: function: subplotlib::steplibrary::runcmd::exit_code_is_zero + doc: | + Make sure the latest command run by `lib/runcmd` indicated the + command succeeded. - then: command fails impl: @@ -85,6 +111,9 @@ function: runcmd_exit_code_is_nonzero rust: function: subplotlib::steplibrary::runcmd::exit_code_is_nonzero + doc: | + Make sure the latest command run by `lib/runcmd` indicated the + command failed. # Steps to examine stdout/stderr for exact content. @@ -94,6 +123,9 @@ function: runcmd_stdout_is rust: function: subplotlib::steplibrary::runcmd::stdout_is + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` is exactly as desired. - then: 'stdout isn''t exactly "{text:text}"' impl: @@ -101,6 +133,9 @@ function: runcmd_stdout_isnt rust: function: subplotlib::steplibrary::runcmd::stdout_isnt + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` is different from what is not wanted. - then: stderr is exactly "{text:text}" impl: @@ -108,6 +143,9 @@ function: runcmd_stderr_is rust: function: subplotlib::steplibrary::runcmd::stderr_is + doc: | + Make sure the standard error output of the latest command run by + `lib/runcmd` is exactly as desired. - then: 'stderr isn''t exactly "{text:text}"' impl: @@ -115,6 +153,9 @@ function: runcmd_stderr_isnt rust: function: subplotlib::steplibrary::runcmd::stderr_isnt + doc: | + Make sure the standard error output of the latest command run by + `lib/runcmd` is different from what is not wanted. # Steps to examine stdout/stderr for sub-strings. @@ -124,6 +165,9 @@ function: runcmd_stdout_contains rust: function: subplotlib::steplibrary::runcmd::stdout_contains + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` contains the desired sub-string. - then: 'stdout doesn''t contain "{text:text}"' impl: @@ -131,6 +175,9 @@ function: runcmd_stdout_doesnt_contain rust: function: subplotlib::steplibrary::runcmd::stdout_doesnt_contain + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` does not contain the sub-string. - then: stderr contains "{text:text}" impl: @@ -138,6 +185,9 @@ function: runcmd_stderr_contains rust: function: subplotlib::steplibrary::runcmd::stderr_contains + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` contains the desired sub-string. - then: 'stderr doesn''t contain "{text:text}"' impl: @@ -145,6 +195,9 @@ function: runcmd_stderr_doesnt_contain rust: function: subplotlib::steplibrary::runcmd::stderr_doesnt_contain + doc: | + Make sure the standard error output of the latest command run by + `lib/runcmd` does not contain the sub-string. # Steps to match stdout/stderr against regular expressions. @@ -154,6 +207,9 @@ function: runcmd_stdout_matches_regex rust: function: subplotlib::steplibrary::runcmd::stdout_matches_regex + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` matches the desired regular expression. - then: stdout doesn't match regex {regex:text} impl: @@ -161,6 +217,9 @@ function: runcmd_stdout_doesnt_match_regex rust: function: subplotlib::steplibrary::runcmd::stdout_doesnt_match_regex + doc: | + Make sure the standard output of the latest command run by + `lib/runcmd` does not match a regular expression. - then: stderr matches regex {regex:text} impl: @@ -168,6 +227,9 @@ function: runcmd_stderr_matches_regex rust: function: subplotlib::steplibrary::runcmd::stderr_matches_regex + doc: | + Make sure the standard error output of the latest command run by + `lib/runcmd` matches the desired regular expression. - then: stderr doesn't match regex {regex:text} impl: @@ -175,3 +237,6 @@ function: runcmd_stderr_doesnt_match_regex rust: function: subplotlib::steplibrary::runcmd::stderr_doesnt_match_regex + doc: | + Make sure the standard error output of the latest command run by + `lib/runcmd` does not match a regular expression. |