mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 00:25:42 +02:00
dev/tests: add --attr
option to print full attrpath of tests
Allows using the `tests` devshell command to discover the full attrpath of a test. e.g. ``` $ tests --attr modules-lsp plugins-by-name-lazygit Printing 2 tests: modules-lsp plugins-by-name-lazygit Full attr paths: - checks.x86_64-linux.test-2.entries.modules-lsp - checks.x86_64-linux.test-18.entries.plugins-by-name-lazygit ```
This commit is contained in:
parent
f4a7447d27
commit
14c7f5f896
2 changed files with 21 additions and 5 deletions
|
@ -61,8 +61,8 @@
|
||||||
checkName:
|
checkName:
|
||||||
map (testName: {
|
map (testName: {
|
||||||
name = testName;
|
name = testName;
|
||||||
value = "${checkName}.passthru.entries.${testName}";
|
value = "${checkName}.entries.${testName}";
|
||||||
}) (builtins.attrNames checks'.${checkName}.passthru.entries)
|
}) (builtins.attrNames checks'.${checkName}.entries)
|
||||||
) names
|
) names
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
|
|
|
@ -19,10 +19,11 @@ Options:
|
||||||
-l, --list: Display the list of tests and exit
|
-l, --list: Display the list of tests and exit
|
||||||
-s, --system <system>: Launch checks for "<system>" instead of "${NIXVIM_SYSTEM}".
|
-s, --system <system>: Launch checks for "<system>" instead of "${NIXVIM_SYSTEM}".
|
||||||
-i, --interactive: Pick interactively the tests. Can't be supplied if tests where passed.
|
-i, --interactive: Pick interactively the tests. Can't be supplied if tests where passed.
|
||||||
|
-a, --attr: Print full attrpath of the tests, instead of running them.
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! OPTS=$(getopt -o "hlis:" -l "help,list,interactive,system:" -- "$@"); then
|
if ! OPTS=$(getopt -o "hlis:a" -l "help,list,interactive,system:,attr" -- "$@"); then
|
||||||
echo "Invalid options" >&2
|
echo "Invalid options" >&2
|
||||||
help
|
help
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -34,6 +35,7 @@ system=${NIXVIM_SYSTEM}
|
||||||
specified_tests=()
|
specified_tests=()
|
||||||
nix_args=()
|
nix_args=()
|
||||||
interactive=false
|
interactive=false
|
||||||
|
print_attrpath=false
|
||||||
|
|
||||||
mk_test_list() {
|
mk_test_list() {
|
||||||
jq -r 'keys[]' "${NIXVIM_TESTS}"
|
jq -r 'keys[]' "${NIXVIM_TESTS}"
|
||||||
|
@ -57,6 +59,10 @@ while true; do
|
||||||
system=$2
|
system=$2
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
-a | --attr)
|
||||||
|
print_attrpath=true
|
||||||
|
shift 1
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
for arg in "$@"; do
|
for arg in "$@"; do
|
||||||
|
@ -90,7 +96,13 @@ get_tests() {
|
||||||
|
|
||||||
run_tests() {
|
run_tests() {
|
||||||
readarray -t test_list < <(get_tests "$@")
|
readarray -t test_list < <(get_tests "$@")
|
||||||
if ! "${NIXVIM_NIX_COMMAND}" build "${nix_args[@]}" --no-link --file . "${test_list[@]}"; then
|
if [[ $print_attrpath == true ]]; then
|
||||||
|
echo
|
||||||
|
echo "Full attr paths:"
|
||||||
|
for test in "${test_list[@]}"; do
|
||||||
|
echo "- $test"
|
||||||
|
done
|
||||||
|
elif ! "${NIXVIM_NIX_COMMAND}" build "${nix_args[@]}" --no-link --file . "${test_list[@]}"; then
|
||||||
echo "Test failure" >&2
|
echo "Test failure" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
@ -110,6 +122,10 @@ 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
|
verb="Running"
|
||||||
|
if [[ $print_attrpath == true ]]; then
|
||||||
|
verb="Printing"
|
||||||
|
fi
|
||||||
|
echo "$verb ${#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