mirror of
https://github.com/sstephenson/bats.git
synced 2024-12-26 06:29:47 +01:00
Add -v/--version
This commit is contained in:
parent
841d417b11
commit
d591867b35
13
libexec/bats
13
libexec/bats
|
@ -1,6 +1,10 @@
|
|||
#!/usr/bin/env bash
|
||||
set -e
|
||||
|
||||
version() {
|
||||
echo "Bats 0.1.0"
|
||||
}
|
||||
|
||||
resolve_link() {
|
||||
$(type -p greadlink readlink | head -1) "$1"
|
||||
}
|
||||
|
@ -31,9 +35,16 @@ BATS_LIBEXEC="$(abs_dirname "$0")"
|
|||
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
|
||||
export PATH="$BATS_LIBEXEC:$PATH"
|
||||
|
||||
if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
|
||||
version
|
||||
exit 0
|
||||
fi
|
||||
|
||||
filename="$1"
|
||||
if [ -z "$filename" ]; then
|
||||
echo "usage: $0 <filename>" >&2
|
||||
{ version
|
||||
echo "usage: $0 <filename>"
|
||||
} >&2
|
||||
exit 1
|
||||
else
|
||||
shift
|
||||
|
|
|
@ -10,7 +10,13 @@ teardown() {
|
|||
@test "no arguments prints usage instructions" {
|
||||
run bats
|
||||
[ $status -eq 1 ]
|
||||
[ $(expr "$output" : "usage:") -ne 0 ]
|
||||
[ $(expr "${lines[1]}" : "usage:") -ne 0 ]
|
||||
}
|
||||
|
||||
@test "-v and --version print version number" {
|
||||
run bats -v
|
||||
[ $status -eq 0 ]
|
||||
[ $(expr "$output" : "Bats [0-9][0-9.]*") -ne 0 ]
|
||||
}
|
||||
|
||||
@test "invalid filename prints an error" {
|
||||
|
|
Loading…
Reference in New Issue
Block a user