mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-11 01:34:32 +02:00
tests: use a nested attrset for buildbot
We need to optimise the buildbot attrs for nix-eval-jobs, however this doesn't make sense for `nix flake check` or `nix flake show`. Now that we aren't using the `checks` output, we don't _need_ to restrict ourselves to a flat set of test derivations anymore. This also simplifies our `tests` command, and means we no longer need to pre-compute the test attr names.
This commit is contained in:
parent
1463ec64d5
commit
db7c5364a5
3 changed files with 12 additions and 38 deletions
|
@ -59,26 +59,10 @@
|
|||
|
||||
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}.entries.${testName}";
|
||||
}) (builtins.attrNames checks'.${checkName}.entries)
|
||||
) names
|
||||
);
|
||||
in
|
||||
''
|
||||
export NIXVIM_SYSTEM=${system}
|
||||
export NIXVIM_NIX_COMMAND=${nix}
|
||||
export NIXVIM_TESTS=${pkgs.writers.writeJSON "tests.json" tests}
|
||||
${lib.getExe launchTest} "$@"
|
||||
'';
|
||||
}
|
||||
|
|
|
@ -40,7 +40,10 @@ group_size=20
|
|||
print_attrpath=false
|
||||
|
||||
mk_test_list() {
|
||||
jq -r 'keys[]' "${NIXVIM_TESTS}"
|
||||
nix eval ".#checks.$system.tests.entries" \
|
||||
--apply builtins.attrNames \
|
||||
--json |
|
||||
jq -r '.[]'
|
||||
}
|
||||
|
||||
while true; do
|
||||
|
@ -83,23 +86,6 @@ while true; do
|
|||
esac
|
||||
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
|
||||
}
|
||||
|
||||
build_group() {
|
||||
if ! "${NIXVIM_NIX_COMMAND}" build "${nix_args[@]}" --no-link --file . "$@"; then
|
||||
echo "Test failure" >&2
|
||||
|
@ -145,7 +131,11 @@ build_in_groups() {
|
|||
}
|
||||
|
||||
run_tests() {
|
||||
readarray -t test_list < <(get_tests "$@")
|
||||
readarray -t test_list < <(
|
||||
for test in "$@"; do
|
||||
echo "checks.${system}.tests.entries.${test}"
|
||||
done
|
||||
)
|
||||
if [[ $print_attrpath == true ]]; then
|
||||
echo
|
||||
echo "Full attr paths:"
|
||||
|
|
|
@ -61,12 +61,12 @@ let
|
|||
# Combined into a single link-farm derivation
|
||||
mainDrv.tests = linkFarm "tests" main;
|
||||
|
||||
# Grouped as a number of link-farms in the form { test-1, test-2, ... test-N }
|
||||
mainGrouped = lib.pipe main [
|
||||
# Grouped as a number of link-farms in the form { tests = { group-1, group-2, ... group-N }; }
|
||||
mainGrouped.tests = lib.pipe main [
|
||||
(helpers.groupListBySize 10)
|
||||
(lib.imap1 (
|
||||
i: group: rec {
|
||||
name = "test-${toString i}";
|
||||
name = "group-${toString i}";
|
||||
value = linkFarm name group;
|
||||
}
|
||||
))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue