2
1
mirror of https://github.com/kdabir/has.git synced 2024-09-18 17:01:29 +02:00

add utilities hub and zip

- [x] add custom processing for `hub` and `zip`
- [x]  add tests for `hub` and `zip`
This commit is contained in:
Virgil 2019-05-21 08:13:36 +10:00
parent 96c3afe771
commit f1ee3f7e7c
2 changed files with 29 additions and 6 deletions

View File

@ -144,14 +144,16 @@ teardown() {
}
@test "testing archiving commands" {
run $has tar unzip gzip xz unar pv
run $has tar unzip gzip xz unar pv zip
[ "$status" -eq 0 ]
[ "$(echo "${output}" | grep "tar")" ]
[ "$(echo "${output}" | grep "unzip")" ]
[ "$(echo "${output}" | grep "xz")" ]
[ "$(echo "${output}" | grep "unar")" ]
[ "$(echo "${output}" | grep "pv")" ]
[ "$(echo "${lines[0]}" | grep "tar")" ]
[ "$(echo "${lines[1]}" | grep "unzip")" ]
[ "$(echo "${lines[2]}" | grep "gzip")" ]
[ "$(echo "${lines[3]}" | grep "xz")" ]
[ "$(echo "${lines[4]}" | grep "unar")" ]
[ "$(echo "${lines[5]}" | grep "pv")" ]
[ "$(echo "${lines[6]}" | grep "zip")" ]
}
@test "testing coreutils commands" {
@ -162,3 +164,12 @@ teardown() {
[ "$(echo "${lines[5]}" | grep "file")" ]
[ "$(echo "${lines[6]}" | grep "gnu_coreutils")" ]
}
@test "testing hub version is different to git version" {
run $has hub git
[ "$status" -eq 0 ]
[ "$(echo "${lines[0]}" | grep "hub")" ]
[ "$(echo "${lines[1]}" | grep "git")" ]
[ ! "${lines[0]##*\ }" = "${lines[1]##*\ }" ]
}

12
has
View File

@ -154,6 +154,18 @@ __detect(){
# readlink (GNU coreutils) 8.28
gnu_coreutils) __dynamic_detect--version readlink ;;
## hub uses --version but version string is on second line, or third if HUB_VERBOSE set
hub)
version=$(HUB_VERBOSE='' hub --version 2>&1 | sed -n 2p | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
status=$?
;;
## zip uses -v but version string is on second line
zip)
version=$(zip -v 2>&1 | sed -n 2p | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
status=$?
;;
has)
version=$(has 2>&1 | grep -Eo "${REGEX_SIMPLE_VERSION}" | head -1)
status=$?