summaryrefslogtreecommitdiff
path: root/test/run
blob: 408c33ace767207b1e3dd06ec8f14de23112a6ad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash
# Run test of specified tool.
# The first directory of the first file (first argument ending with .exp) is
# used as the `tool' specification.
# Usage: ./run [FILE]...
# Example run: ./run unit/_get_cword.exp unit/compgen.exp


# Process arguments
# @param $1  Name of variable to return `tool' name
# @param $2  Name of variable to return processed arguments
# @param $@  Arguments to process
process_args() {
    local arg
    for arg in "${@:3}"; do
        case "$arg" in
            completion/*.exp|unit/*.exp)
                [[ ${!1} ]] || printf -v $1 "${arg%%/*}"
                eval $2[\${#$2[@]}]=\""${arg#*/}"\"
                ;;
            *)
                eval $2[\${#$2[@]}]=\""$arg"\"
        esac
    done
}

args=()
process_args tool args "$@"
runtest --outdir log --tool $tool "${args[@]}" 

unset -v args tool