clitest for Mac
clitest – Command Line Tester
clitest — overview
clitest – Command Line Tester
clitest is a portable POSIX shell script that performs automatic testing in Unix command lines.
It's the same concept as in Python's doctest module: you document both the commands and their expected output, using the familiar interactive prompt format, and a specialized tool tests them.
In fact, the doctest official description can also be used for clitest: The doctest module searches for pieces of text that look like interactive Python sessions, and then executes those sessions to verify that they work exactly as shown. The clitest command searches for pieces of text that look like interactive Unix command lines, and then executes those command lines to verify that they work exactly as shown.
Download & install
The full program is just a single shell script file.
Save it, make it executable and move it to a $PATH directory:
Now check if everything is fine:
Docker image
You can also run clitest in a Docker container (more info in Docker Hub).
GitHub Actions
This repository doubles as a GitHub Action, so a workflow does not have to download and install the script itself:
clitest runs on the runner rather than in a container, so the test files can invoke anything the job has already built or installed.
Quick Intro
Save the commands and their expected output in a text file:
♦ examples/intro.txt
Use clitest to run these commands and check their output:
CLI Syntax
There's no syntax to learn.
The test files are identical to the good old command line interface (CLI) you're so familiar:
♦ examples/cut.txt
That's it.
Just paste your shell session inside a text file and you have a ready-to-use test suite.
There are more examples and instructions in the examples folder. For a real-life collection of hundreds of test files, see funcoeszz test files.
Testable Documentation
Clitest can also extract and run command lines from documentation, such as Markdown files. This very README.md file you are now reading is testable with clitest README.md. All the command lines inside it will be run and checked.
No more malfunctioning shell commands in your READMEs, you can have testable documentation.
Given the following Markdown sample document:
♦ examples/cut.md
It is a technical article, not a boring code-only test file. You can read its final (formatted) version here.
You can give this article to clitest, who will identify all the shell command lines inside it, run them and check if the results are the same.
Note the use of --prefix tab option, to inform clitest that the code blocks are prefixed by a tab in this Markdown file. For files with 4-spaces indented code blocks, use --prefix 4. When using non-indented fenced code blocks (), such as this README.md, no prefix option is needed.
Details
命令行测试器
How to install clitest
- Open Terminal (press ⌘ + Space and type “Terminal”).
- If Homebrew is not installed yet, run the command below first.
- Run this command:
Latest 10 releases
Last updated 2023-06-22; current version 0.5.0, with the latest 5 releases listed.
| Version | Released | Type | Size | macOS | Windows | Linux |
|---|---|---|---|---|---|---|
| 0.5.0 | 2023-06-22 | Stable | — | — | — | — |
| 0.4.0 | 2020-07-01 | Stable | — | — | — | — |
| 0.3.0 | 2016-11-02 | Stable | — | — | — | — |
| 0.2.0 | 2016-03-09 | Stable | — | — | — | — |
| 0.1.0 | 2016-03-09 | Stable | — | — | — | — |
Data from GitHub Releases; stable releases first, each group sorted newest first.
Prebuilt bottle platforms
Official Homebrew bottles cover:
- all
⚠️ No prebuilt bottle for Intel Macs; Intel users need brew install --build-from-source to build from source.
Compared with similar apps
Only public metadata is compared, with no subjective recommendation; see the compare pages for field-by-field comparisons.
| App | Version | License | Architecture | 30-day installs |
|---|---|---|---|---|
| clitest | 0.5.0 | MIT | CLI | 0 |
| openssl@4 | openssl-4.1.0 | Apache-2.0 | CLI | 494,798 |
| xz | v5.8.4 | 0BSD AND GPL-2.0-or-later | CLI | 346,605 |
| pkgconf | pkgconf-3.0.10 | ISC | CLI | 311,054 |
Similar apps: Command-line Tools
openssl@4
Cryptography and SSL/TLS Toolkitxz
General-purpose data compression with high compression ratiopkgconf
pkgconf is a program which helps to configure compiler and linker flags for development…node
Node.js is an open-source, cross-platform JavaScript runtime environment.gh
GitHub command-line toolcmake
CMake is a cross-platform, open-source build system generator.Categories: Command-line Tools