mirror of
https://github.com/nix-community/nixvim.git
synced 2025-07-31 08:05:23 +02:00
tests: simplify fetch-tests slightly
Simplify by reducing the number of transformations done to the test-files' test-case modules attr. Since `pkgs.linkFarm` can accept _either_ a list or an attrset, we don't need to transform the attrset into a list.
This commit is contained in:
parent
1c879ec3aa
commit
975af6a498
2 changed files with 23 additions and 30 deletions
|
@ -5,26 +5,25 @@
|
|||
helpers,
|
||||
}:
|
||||
let
|
||||
# Import a test file into the form { name = ""; file = ""; modules = []; }
|
||||
# Import a test file into the form { name = ""; file = ""; cases = {}; }
|
||||
handleTestFile =
|
||||
file: namespace:
|
||||
let
|
||||
fnOrAttrs = import file;
|
||||
in
|
||||
{
|
||||
inherit file;
|
||||
name = lib.strings.concatStringsSep "-" namespace;
|
||||
cases =
|
||||
if builtins.isFunction fnOrAttrs then
|
||||
# Call the function
|
||||
fnOrAttrs { inherit pkgs lib helpers; }
|
||||
else
|
||||
fnOrAttrs;
|
||||
in
|
||||
{
|
||||
inherit file;
|
||||
name = lib.strings.concatStringsSep "-" namespace;
|
||||
modules = lib.mapAttrsToList (name: module: { inherit name module; }) cases;
|
||||
};
|
||||
|
||||
# Recurse into all directories, extracting files as we find them.
|
||||
# This returns a list of { name; file; modules; } attrsets.
|
||||
# This returns a list of { name; file; cases; } attrsets.
|
||||
fetchTests =
|
||||
path: namespace:
|
||||
let
|
||||
|
@ -50,5 +49,4 @@ let
|
|||
builtins.concatLists
|
||||
];
|
||||
in
|
||||
# A list of the form [ { name = "..."; modules = [ /* test case modules */ ]; } ]
|
||||
fetchTests root [ ]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue