mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
flake-modules/dev: format launch-test.sh
This commit is contained in:
parent
9317537848
commit
901e8760d0
1 changed files with 41 additions and 41 deletions
|
@ -2,11 +2,11 @@
|
||||||
|
|
||||||
: "${NIXVIM_NIX_COMMAND:=nix}"
|
: "${NIXVIM_NIX_COMMAND:=nix}"
|
||||||
if [[ -z ${NIXVIM_SYSTEM+x} ]]; then
|
if [[ -z ${NIXVIM_SYSTEM+x} ]]; then
|
||||||
NIXVIM_SYSTEM=$(nix eval --raw --impure --expr "builtins.currentSystem")
|
NIXVIM_SYSTEM=$(nix eval --raw --impure --expr "builtins.currentSystem")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
cat <<EOF
|
cat <<EOF
|
||||||
Usage: tests [OPTIONS] [tests...]
|
Usage: tests [OPTIONS] [tests...]
|
||||||
|
|
||||||
If tests are passed on the command line only these will be launched
|
If tests are passed on the command line only these will be launched
|
||||||
|
@ -19,9 +19,9 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! OPTS=$(getopt -o "hli" -l "help,list,interactive" -- "$@"); then
|
if ! OPTS=$(getopt -o "hli" -l "help,list,interactive" -- "$@"); then
|
||||||
echo "Invalid options" >&2
|
echo "Invalid options" >&2
|
||||||
help
|
help
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval set -- "$OPTS"
|
eval set -- "$OPTS"
|
||||||
|
@ -30,54 +30,54 @@ specified_tests=()
|
||||||
interactive=false
|
interactive=false
|
||||||
|
|
||||||
mk_test_list() {
|
mk_test_list() {
|
||||||
nix eval ".#checks.${NIXVIM_SYSTEM}" --apply builtins.attrNames --json |
|
nix eval ".#checks.${NIXVIM_SYSTEM}" --apply builtins.attrNames --json |
|
||||||
jq -r 'map(select(startswith("test-")))[]'
|
jq -r 'map(select(startswith("test-")))[]'
|
||||||
}
|
}
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-h | --help)
|
-h | --help)
|
||||||
help
|
help
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-l | --list)
|
-l | --list)
|
||||||
mk_test_list
|
mk_test_list
|
||||||
exit 0
|
exit 0
|
||||||
;;
|
;;
|
||||||
-i | --interactive)
|
-i | --interactive)
|
||||||
interactive=true
|
interactive=true
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
specified_tests=("$@")
|
specified_tests=("$@")
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
run_tests() {
|
run_tests() {
|
||||||
# Add the prefix "checks.${system}." to each argument
|
# Add the prefix "checks.${system}." to each argument
|
||||||
if ! "${NIXVIM_NIX_COMMAND}" build --no-link --file . "${@/#/checks.${NIXVIM_SYSTEM}.}"; then
|
if ! "${NIXVIM_NIX_COMMAND}" build --no-link --file . "${@/#/checks.${NIXVIM_SYSTEM}.}"; then
|
||||||
echo "Test failure" >&2
|
echo "Test failure" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ $interactive = true && ${#specified_tests[@]} -ne 0 ]]; then
|
if [[ $interactive == true && ${#specified_tests[@]} -ne 0 ]]; then
|
||||||
echo "Can't use --interactive with tests on the command line" >&2
|
echo "Can't use --interactive with tests on the command line" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $interactive = true ]]; then
|
if [[ $interactive == true ]]; then
|
||||||
test_name=$(mk_test_list | fzf) || exit $?
|
test_name=$(mk_test_list | fzf) || exit $?
|
||||||
specified_tests+=("$test_name")
|
specified_tests+=("$test_name")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${#specified_tests[@]} -eq 0 ]]; then
|
if [[ ${#specified_tests[@]} -eq 0 ]]; then
|
||||||
readarray -t complete_test_list < <(mk_test_list)
|
readarray -t complete_test_list < <(mk_test_list)
|
||||||
run_tests "${complete_test_list[@]}"
|
run_tests "${complete_test_list[@]}"
|
||||||
else
|
else
|
||||||
echo "Running ${#specified_tests[@]} tests: ${specified_tests[*]}" >&2
|
echo "Running ${#specified_tests[@]} tests: ${specified_tests[*]}" >&2
|
||||||
run_tests "${specified_tests[@]}"
|
run_tests "${specified_tests[@]}"
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue