https://github.com/kanga333/cliassert
Simple command line assertion tool.
https://github.com/kanga333/cliassert
assert cli shell testing testing-tools
Last synced: about 2 months ago
JSON representation
Simple command line assertion tool.
- Host: GitHub
- URL: https://github.com/kanga333/cliassert
- Owner: kanga333
- License: mit
- Created: 2018-05-21T12:32:08.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2019-05-25T09:04:32.000Z (about 7 years ago)
- Last Synced: 2025-04-10T17:00:14.606Z (about 1 year ago)
- Topics: assert, cli, shell, testing, testing-tools
- Language: Go
- Homepage:
- Size: 29.3 KB
- Stars: 2
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cliassert
[](travis)
[](coverralls)
[](https://github.com/kanga333/cliassert/blob/master/LICENSE)
## Description
Simple command line assertion tool.
## Synopsis
```text
cliassert [ -assertion-case value ] command
```
## Examples
You can test the result of command execution.
```console
% cliassert -stdout-contain ok echo case-is-ok
% echo $?
0
```
If the test fails, details will be displayed on stderr.
```console
% cliassert -stdout-contain ok echo case-is-ng
[failure] stdout should contain ok.
% echo $?
1
```
Multiple tests can be set.
If the `-v` option is added, the details of the success case will also be displayed.
```console
% cliassert -v -stdout-contain case -stdout-contain ok echo case-is-ng
[exit-status] 0
[stdout]
case-is-ng
[stderr]
---
[success] stdout should contain case.
[failure] stdout should contain ok.
2 cases, 1 failures.
```
You can pass the standard output of a command to standard output using the `pass` option.
```console
% cliassert -pass -exit-status 0 echo pass
pass
```
You can also use pipe.
```console
% echo pipe | cliassert -stdout-contain pipe
```
## Options
```text
-exit-status value
String equal to exit-status
-pass
Pass stdout of command to stdout
-stderr-contain value
String contained in stderr
-stderr-match value
Regex matching stderr
-stderr-not-contain value
String not contained in stderr
-stderr-not-match value
Regex not matching stderr
-stdout-contain value
String contained in stdout
-stdout-match value
Regex matching stdout
-stdout-not-contain value
String not contained in stdout
-stdout-not-match value
Regex not matching stdout
-v Show verbose
```