mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-01 04:44:31 +02:00
flake-modules/devshell: update tests command with link-farm support
Since we're using link-farms, we need to access the underlying tests as `passthru.entries.*`.
This commit is contained in:
parent
69c2fa866e
commit
312db6b6e2
2 changed files with 40 additions and 5 deletions
|
@ -7,6 +7,7 @@
|
||||||
lib,
|
lib,
|
||||||
pkgs,
|
pkgs,
|
||||||
config,
|
config,
|
||||||
|
self',
|
||||||
system,
|
system,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
@ -44,9 +45,27 @@
|
||||||
|
|
||||||
text = builtins.readFile ./launch-test.sh;
|
text = builtins.readFile ./launch-test.sh;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
tests =
|
||||||
|
let
|
||||||
|
checks' = self'.checks;
|
||||||
|
names = builtins.filter (n: builtins.match "test-.*" n != null) (builtins.attrNames checks');
|
||||||
|
in
|
||||||
|
builtins.listToAttrs (
|
||||||
|
builtins.concatMap (
|
||||||
|
checkName:
|
||||||
|
map (testName: {
|
||||||
|
name = testName;
|
||||||
|
value = "${checkName}.passthru.entries.${testName}";
|
||||||
|
}) (builtins.attrNames checks'.${checkName}.passthru.entries)
|
||||||
|
) names
|
||||||
|
);
|
||||||
in
|
in
|
||||||
''
|
''
|
||||||
NIXVIM_SYSTEM=${system} NIXVIM_NIX_COMMAND=${nix} ${lib.getExe launchTest} "$@"
|
export NIXVIM_SYSTEM=${system}
|
||||||
|
export NIXVIM_NIX_COMMAND=${nix}
|
||||||
|
export NIXVIM_TESTS=${pkgs.writers.writeJSON "tests.json" tests}
|
||||||
|
${lib.getExe launchTest} "$@"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,8 +36,7 @@ nix_args=()
|
||||||
interactive=false
|
interactive=false
|
||||||
|
|
||||||
mk_test_list() {
|
mk_test_list() {
|
||||||
nix eval ".#checks.${system}" --apply builtins.attrNames --json |
|
jq -r 'keys[]' "${NIXVIM_TESTS}"
|
||||||
jq -r 'map(select(startswith("test-")))[]'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
|
@ -72,9 +71,26 @@ while true; do
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
|
get_tests() {
|
||||||
|
# Convert bash array to jq query
|
||||||
|
# e.g. (foo bar baz) => ."foo",."bar",."baz"
|
||||||
|
readarray -t queries < <(
|
||||||
|
for test in "$@"; do
|
||||||
|
echo '."'"$test"'"'
|
||||||
|
done
|
||||||
|
)
|
||||||
|
query=$(
|
||||||
|
IFS=,
|
||||||
|
echo "${queries[*]}"
|
||||||
|
)
|
||||||
|
for test in $(jq -r "${query}" "${NIXVIM_TESTS}"); do
|
||||||
|
echo "checks.${system}.${test}"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
run_tests() {
|
run_tests() {
|
||||||
# Add the prefix "checks.${system}." to each argument
|
readarray -t test_list < <(get_tests "$@")
|
||||||
if ! "${NIXVIM_NIX_COMMAND}" build "${nix_args[@]}" --no-link --file . "${@/#/checks.${system}.}"; then
|
if ! "${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
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue