diff options
author | Luke Elliott <luke.b.elliott@gmail.com> | 2023-02-20 09:45:48 +0000 |
---|---|---|
committer | Luke Elliott <luke.b.elliott@gmail.com> | 2023-09-06 16:06:00 +0100 |
commit | 2c2231173784ce41ed8cc28f8cdc516ffc53cf99 (patch) | |
tree | 38e2fae654b5d125cc0d8844bf4ab6765dc4fdc0 /data | |
parent | df24e36a62f8e6cb667f4beb1b43e99bd360269d (diff) | |
download | meson-2c2231173784ce41ed8cc28f8cdc516ffc53cf99.zip meson-2c2231173784ce41ed8cc28f8cdc516ffc53cf99.tar.gz meson-2c2231173784ce41ed8cc28f8cdc516ffc53cf99.tar.bz2 |
completions: bash: don't show json errors when completing "meson test".
E.g. "meson test<tab>"
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Diffstat (limited to 'data')
-rw-r--r-- | data/shell-completions/bash/meson | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/data/shell-completions/bash/meson b/data/shell-completions/bash/meson index 300c504..3dd16cc 100644 --- a/data/shell-completions/bash/meson +++ b/data/shell-completions/bash/meson @@ -469,14 +469,17 @@ _meson-test() { # number, can't be completed return ;; + --wrapper) _command_offset $COMP_CWORD return ;; + --gdb-path | -C) _filedir -d return ;; + --suite | --no-suite) for i in "${!COMP_WORDS[@]}"; do opt="${COMP_WORDS[i]}" @@ -488,31 +491,40 @@ _meson-test() { esac dir=. done - suites=($(python3 -c 'import sys, json; + + suites=$(meson introspect "$dir" --tests | python3 -c 'import sys, json; for test in json.load(sys.stdin): for suite in test["suite"]: print(suite) - ' <<< "$(meson introspect "$dir" --tests)")) -# TODO - COMPREPLY+=($(compgen -W "${suites[*]}" -- "$cur")) +' 2> /dev/null) +# TODO - what? + + if [[ $? == 0 ]]; then + COMPREPLY+=($(compgen -W "${suites[*]}" -- "$cur")) + fi return ;; + --logbase) # free string, can't be completed return ;; + --num-processes) # number, can't be completed return ;; + -t | --timeout-multiplier) # number, can't be completed return ;; + --setup) # TODO return ;; + --test-args) return ;; @@ -528,6 +540,7 @@ for test in json.load(sys.stdin): fi dir=. done + if [ ! -d "$dir/meson-private" ]; then _filedir -d fi @@ -542,11 +555,15 @@ for test in json.load(sys.stdin): esac dir=. done - tests=($(python3 -c 'import sys, json; + + tests=$(meson introspect "$dir" --tests | python3 -c 'import sys, json; for test in json.load(sys.stdin): print(test["name"]) -' <<< "$(meson introspect "$dir" --tests)")) - COMPREPLY+=($(compgen -W "${tests[*]}" -- "$cur")) +' 2> /dev/null) + + if [[ $? == 0 ]]; then + COMPREPLY+=($(compgen -W "${tests[*]}" -- "$cur")) + fi if [ -z "$cur" ]; then COMPREPLY+=($(compgen -P '--' -W '${longopts[*]}' -- "${cur:2}")) |