Simple tool to check basic cli tools.
clic 0.1.1
USAGE:
clic [FLAGS] [OPTIONS]
FLAGS:
-h, --help Prints help information
-q, --quiet
-V, --version
-v, --verbose
OPTIONS:
-c, --cmdline <cmdline> Command line to execute
-d, --dir <dir> Directory with spec files to execute
--expected-exit-code <expected-exit-code> Expected exit code from the executed program [default: 0]
-s, --spec <spec> Test spec file path
-t, --timeout <timeout> [default: 1s]
clic can verify a single spec file, or it can process all files (with a .spec sufffix) in a given directory.
The spec file is a simple text file, where each line contains an instruction.
Example spec file content:
# this is comment > program input expected output on stdout ! expected output on stderr
Lines with starts with a
#are comments and are ignored>are program inputs!are expected output on stderr- anything else are expected output on stdout
If the first line of the spec file starts with # clic, this line will parsed and used as clic arguments.
As an example we use the bc tool. In the spec file we define the program arguments,
and the interactive session:
# clic --cmdline 'bc -q'
> 3 * 9
27
> 3 / 0
! Runtime error (func=(main), adr=5): Divide by zero
> quit
to verify the spec file, exeucte clic with the file as an argument:
clic --spec doc/examples/bc.specvalidate spec: doc/examples/bc.spec Success
You can start clic with the --verbose flag to see what’s going on:
clic --spec doc/examples/bc.spec --verbosevalidate spec: doc/examples/bc.spec send to process stdin: 3 * 9 expect on stdout: 27 send to process stdin: 3 / 0 expect on stderr: Runtime error (func=(main), adr=5): Divide by zero send to process stdin: quit Success
If clic find’s a mismatch, it will stop the execution and print the difference.
When we run clic with this buggy spec file:
# clic --cmdline 'bc -q'
> 3 * 9
72
It will abort and displays the difference
# ignore that 'exit 0' - it's for my used doc setup
clic --spec doc/examples/bc-err.spec; exit 0validate spec: doc/examples/bc-err.spec Failure: Unexpected response for input: '3 * 9' expected: '72' acutal : '27'