new utility for generating bats-core tests #698
tohara-PandoLogic
started this conversation in
Show and tell
Replies: 1 comment
-
Interesting! Via Jupyter was one of the way I wondered whether we should be presenting and testing documentation when I ended up going with #694 |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I would like to highlight a new utility that can generate bats-core tests from bash file comments or plain text files. It also supports Jupyter notebooks using the Bash kernel
(see https://github.com/takluyver/bash_kernel). See
Here's is a simple example:
See the generated output at the end of this message.
The bats-pp utility was originally developed in support of testing my bash aliases and functions, but Bruno Limo has converted it into an independent project. In general, it supports testing command-line programs, checking either standard output or doing posthoc checks to produce testable output (e.g., file word counts).
The intention is similar in spirit to Python example-based tests from function docstrings. That is, the test specification shows the invocation and the expected output. Furthermore, the use of Jupiter notebooks allows for convenient maintenance of such tests. For example, if the programs change, the bats test files can be regenerated from the Jupyter notebook. For a variety of such notebooks, see https://github.com/tomasohara/shell-scripts/tree/aviyan-dev/tests.
Best,
Tom O'Hara
tomasohara@gmail.com
Generated bats-core test:
Beta Was this translation helpful? Give feedback.
All reactions