Skip to content

Commit 14c7f5f

Browse files
committed
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 ```
1 parent f4a7447 commit 14c7f5f

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

flake/dev/devshell.nix

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@
6161
checkName:
6262
map (testName: {
6363
name = testName;
64-
value = "${checkName}.passthru.entries.${testName}";
65-
}) (builtins.attrNames checks'.${checkName}.passthru.entries)
64+
value = "${checkName}.entries.${testName}";
65+
}) (builtins.attrNames checks'.${checkName}.entries)
6666
) names
6767
);
6868
in

flake/dev/launch-test.sh

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,11 @@ Options:
1919
-l, --list: Display the list of tests and exit
2020
-s, --system <system>: Launch checks for "<system>" instead of "${NIXVIM_SYSTEM}".
2121
-i, --interactive: Pick interactively the tests. Can't be supplied if tests where passed.
22+
-a, --attr: Print full attrpath of the tests, instead of running them.
2223
EOF
2324
}
2425

25-
if ! OPTS=$(getopt -o "hlis:" -l "help,list,interactive,system:" -- "$@"); then
26+
if ! OPTS=$(getopt -o "hlis:a" -l "help,list,interactive,system:,attr" -- "$@"); then
2627
echo "Invalid options" >&2
2728
help
2829
exit 1
@@ -34,6 +35,7 @@ system=${NIXVIM_SYSTEM}
3435
specified_tests=()
3536
nix_args=()
3637
interactive=false
38+
print_attrpath=false
3739

3840
mk_test_list() {
3941
jq -r 'keys[]' "${NIXVIM_TESTS}"
@@ -57,6 +59,10 @@ while true; do
5759
system=$2
5860
shift 2
5961
;;
62+
-a | --attr)
63+
print_attrpath=true
64+
shift 1
65+
;;
6066
--)
6167
shift
6268
for arg in "$@"; do
@@ -90,7 +96,13 @@ get_tests() {
9096

9197
run_tests() {
9298
readarray -t test_list < <(get_tests "$@")
93-
if ! "${NIXVIM_NIX_COMMAND}" build "${nix_args[@]}" --no-link --file . "${test_list[@]}"; then
99+
if [[ $print_attrpath == true ]]; then
100+
echo
101+
echo "Full attr paths:"
102+
for test in "${test_list[@]}"; do
103+
echo "- $test"
104+
done
105+
elif ! "${NIXVIM_NIX_COMMAND}" build "${nix_args[@]}" --no-link --file . "${test_list[@]}"; then
94106
echo "Test failure" >&2
95107
exit 1
96108
fi
@@ -110,6 +122,10 @@ if [[ ${#specified_tests[@]} -eq 0 ]]; then
110122
readarray -t complete_test_list < <(mk_test_list)
111123
run_tests "${complete_test_list[@]}"
112124
else
113-
echo "Running ${#specified_tests[@]} tests: ${specified_tests[*]}" >&2
125+
verb="Running"
126+
if [[ $print_attrpath == true ]]; then
127+
verb="Printing"
128+
fi
129+
echo "$verb ${#specified_tests[@]} tests: ${specified_tests[*]}" >&2
114130
run_tests "${specified_tests[@]}"
115131
fi

0 commit comments

Comments
 (0)