mirror of
https://github.com/sstephenson/bats.git
synced 2024-11-17 03:32:27 +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
|
#!/usr/bin/env bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
version() {
|
||||||
|
echo "Bats 0.1.0"
|
||||||
|
}
|
||||||
|
|
||||||
resolve_link() {
|
resolve_link() {
|
||||||
$(type -p greadlink readlink | head -1) "$1"
|
$(type -p greadlink readlink | head -1) "$1"
|
||||||
}
|
}
|
||||||
|
@ -31,9 +35,16 @@ BATS_LIBEXEC="$(abs_dirname "$0")"
|
||||||
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
|
export BATS_PREFIX="$(abs_dirname "$BATS_LIBEXEC")"
|
||||||
export PATH="$BATS_LIBEXEC:$PATH"
|
export PATH="$BATS_LIBEXEC:$PATH"
|
||||||
|
|
||||||
|
if [ "$1" = "-v" ] || [ "$1" = "--version" ]; then
|
||||||
|
version
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
filename="$1"
|
filename="$1"
|
||||||
if [ -z "$filename" ]; then
|
if [ -z "$filename" ]; then
|
||||||
echo "usage: $0 <filename>" >&2
|
{ version
|
||||||
|
echo "usage: $0 <filename>"
|
||||||
|
} >&2
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
shift
|
shift
|
||||||
|
|
|
@ -10,7 +10,13 @@ teardown() {
|
||||||
@test "no arguments prints usage instructions" {
|
@test "no arguments prints usage instructions" {
|
||||||
run bats
|
run bats
|
||||||
[ $status -eq 1 ]
|
[ $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" {
|
@test "invalid filename prints an error" {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user