summaryrefslogtreecommitdiff
path: root/Auxiliary/bash-completion/ctest
blob: 3c629d203692a00266dde44ca4086379b51973d8 (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
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# bash completion for ctest(1)                             -*- shell-script -*-

_ctest()
{
    local cur prev words cword
    if type -t _init_completion >/dev/null; then
        _init_completion -n = || return
    else
        # manual initialization for older bash completion versions
        COMPREPLY=()
        cur="${COMP_WORDS[COMP_CWORD]}"
        prev="${COMP_WORDS[COMP_CWORD-1]}"
    fi

    case "$prev" in
        -C|--build-config)
            COMPREPLY=( $( compgen -W 'Debug Release RelWithDebInfo
                MinSizeRel' -- "$cur" ) )
            return
            ;;
        -j|--parallel)
            COMPREPLY=( $( compgen -W "{1..$(( $(_ncpus)*2 ))}" -- "$cur" ) )
            return
            ;;
        -O|--output-log|-A|--add-notes|--extra-submit)
            _filedir
            return
            ;;
        -L|--label-regex|-LE|--label-exclude)
            COMPREPLY=( $( compgen -W '$( ctest --print-labels 2>/dev/null |
                grep "^  " 2>/dev/null | cut -d" " -f 3 )' -- "$cur" ) )
            return
            ;;
        --track|-I|--tests-information|--max-width|--timeout|--stop-time)
            # argument required but no completions available
            return
            ;;
        -R|--tests-regex|-E|--exclude-regex)
            COMPREPLY=( $( compgen -W '$( ctest -N 2>/dev/null |
                grep "^  Test" 2>/dev/null | cut -d: -f 2 )' -- "$cur" ) )
            return
            ;;
        -D|--dashboard)
            if [[ $cur == @(Experimental|Nightly|Continuous)* ]]; then
                local model action
                action=${cur#@(Experimental|Nightly|Continuous)}
                model=${cur%"$action"}
                COMPREPLY=( $( compgen -W 'Start Update Configure Build Test
                    Coverage Submit MemCheck' -P "$model" -- "$action" ) )
            else
                COMPREPLY=( $( compgen -W 'Experimental Nightly Continuous' \
                -- "$cur" ) )
                compopt -o nospace
            fi
            return
            ;;
        -M|--test-model)
            COMPREPLY=( $( compgen -W 'Experimental Nightly Continuous' -- \
                "$cur" ) )
            return
            ;;
        -T|--test-action)
            COMPREPLY=( $( compgen -W 'Start Update Configure Build Test
                Coverage Submit MemCheck' -- "$cur" ) )
            return
            ;;
        -S|--script|-SP|--script-new-process)
            _filedir '@(cmake|ctest)'
            return
            ;;
        --interactive-debug-mode)
            COMPREPLY=( $( compgen -W '0 1' -- "$cur" ) )
            return
            ;;

        --help-command)
            COMPREPLY=( $( compgen -W '$( ctest --help-command-list 2>/dev/null|
                grep -v "^ctest version " )' -- "$cur" ) )
            return
            ;;
        --help-manual)
            COMPREPLY=( $( compgen -W '$( ctest --help-manual-list 2>/dev/null|
                grep -v "^ctest version " | sed -e "s/([0-9])$//" )' -- "$cur" ) )
            return
            ;;
        --help-module)
            COMPREPLY=( $( compgen -W '$( ctest --help-module-list 2>/dev/null|
                grep -v "^ctest version " )' -- "$cur" ) )
            return
            ;;
        --help-policy)
            COMPREPLY=( $( compgen -W '$( ctest --help-policy-list 2>/dev/null |
                grep -v "^ctest version " )' -- "$cur" ) )
            return
            ;;
        --help-property)
            COMPREPLY=( $( compgen -W '$( ctest --help-property-list \
                2>/dev/null | grep -v "^ctest version " )' -- "$cur" ) )
            return
            ;;
        --help-variable)
            COMPREPLY=( $( compgen -W '$( ctest --help-variable-list \
                2>/dev/null | grep -v "^ctest version " )' -- "$cur" ) )
            return
            ;;
         --preset)
            local IFS=$'\n'
            local quoted
            printf -v quoted %q "$cur"
            COMPREPLY=( $( compgen -W '$( ctest --list-presets 2>/dev/null |
                grep -o "^  \".*\"" | sed \
                -e "s/^  //g" \
                -e "s/\"//g" \
                -e "s/ /\\\\ /g" )' -- "$quoted" ) )
            return
            ;;
    esac

    if [[ "$cur" == -* ]]; then
        COMPREPLY=( $(compgen -W '$( _parse_help "$1" --help )' -- ${cur}) )
        [[ $COMPREPLY == *= ]] && compopt -o nospace
        [[ $COMPREPLY ]] && return
    fi

    _filedir
} &&
complete -F _ctest ctest

# ex: ts=4 sw=4 et filetype=sh