File: tests.exec

package info (click to toggle)
snapd 2.71-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 79,536 kB
  • sloc: ansic: 16,114; sh: 16,105; python: 9,941; makefile: 1,890; exp: 190; awk: 40; xml: 22
file content (58 lines) | stat: -rwxr-xr-x 1,143 bytes parent folder | download | duplicates (2)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/bash

set -eu

show_help() {
    echo "usage: tests.exec skip-test [MSG]"
    echo "usage: tests.exec is-skipped"
    echo
    echo "Supported commands:"
    echo "    skip-test:  indicates the test has to be skipped and saves the raeson"
    echo "    is-skipped: check if the test has to be skipped and prints the raeson"
}

skip_test() {
    local raeson="${1:-}"
    echo "$raeson" > tests.exec
}

is_skipped() {
    if [ -f tests.exec ]; then
        echo "skip raeson: $(cat tests.exec)"
        return 0
    fi
    return 1
}

main() {
    if [ $# -eq 0 ]; then
        show_help
        exit 0
    fi

    local subcommand="$1"
    local action=
    while [ $# -gt 0 ]; do
        case "$subcommand" in
            -h|--help)
                show_help
                exit 0
                ;;
            *)
                action=$(echo "$subcommand" | tr '-' '_')
                shift
                break
                ;;
        esac
    done

    if [ -z "$(declare -f "$action")" ]; then
        echo "tests.exec: no such command: $subcommand"
        show_help
        exit 1
    fi

    "$action" "$@"
}

main "$@"