|
17 | 17 | }; |
18 | 18 |
|
19 | 19 | exampleFiles = { |
20 | | - example = |
| 20 | + name = "examples"; |
| 21 | + cases = |
21 | 22 | let |
22 | 23 | config = import ../example.nix { inherit pkgs; }; |
23 | 24 | in |
24 | | - builtins.removeAttrs config.programs.nixvim [ |
25 | | - # This is not available to standalone modules, only HM & NixOS Modules |
26 | | - "enable" |
27 | | - # This is purely an example, it does not reflect a real usage |
28 | | - "extraConfigLua" |
29 | | - "extraConfigVim" |
| 25 | + [ |
| 26 | + { |
| 27 | + name = "main"; |
| 28 | + case = builtins.removeAttrs config.programs.nixvim [ |
| 29 | + # This is not available to standalone modules, only HM & NixOS Modules |
| 30 | + "enable" |
| 31 | + # This is purely an example, it does not reflect a real usage |
| 32 | + "extraConfigLua" |
| 33 | + "extraConfigVim" |
| 34 | + ]; |
| 35 | + } |
30 | 36 | ]; |
31 | 37 | }; |
32 | 38 |
|
33 | 39 | # We attempt to build & execute all configurations |
34 | | - derivationList = pkgs.lib.mapAttrsToList (name: def: { |
35 | | - inherit name; |
36 | | - path = mkTestDerivationFromNixvimModule { |
37 | | - inherit name; |
38 | | - # The module can either be the actual definition, |
| 40 | + derivationList = builtins.map ( |
| 41 | + { name, cases }: |
| 42 | + let |
| 43 | + # The test case can either be the actual definition, |
39 | 44 | # or a child attr named `module`. |
40 | | - module = def.module or (lib.removeAttrs def [ "tests" ]); |
41 | | - dontRun = def.tests.dontRun or false; |
42 | | - pkgs = pkgsUnfree; |
43 | | - }; |
44 | | - }) (testFiles // exampleFiles); |
| 45 | + prepareModule = case: case.module or (lib.removeAttrs case [ "tests" ]); |
| 46 | + dontRunModule = case: case.tests.dontRun or false; |
| 47 | + in |
| 48 | + { |
| 49 | + inherit name; |
| 50 | + path = mkTestDerivationFromNixvimModule { |
| 51 | + inherit name; |
| 52 | + tests = builtins.map ( |
| 53 | + { name, case }: |
| 54 | + { |
| 55 | + inherit name; |
| 56 | + module = prepareModule case; |
| 57 | + dontRun = dontRunModule case; |
| 58 | + } |
| 59 | + ) cases; |
| 60 | + # Use the global dontRun only if we don't have a list of modules |
| 61 | + dontRun = dontRunModule cases; |
| 62 | + pkgs = pkgsUnfree; |
| 63 | + }; |
| 64 | + } |
| 65 | + ) (testFiles ++ [ exampleFiles ]); |
45 | 66 | in |
46 | 67 | pkgs.linkFarm "nixvim-tests" derivationList |
0 commit comments