Skip to content

Commit

Permalink
tests: aggregate all test derivations into one using a linkFarm
Browse files Browse the repository at this point in the history
  • Loading branch information
GaetanLepage committed Jan 4, 2024
1 parent 10d114f commit 9bc957a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 34 deletions.
39 changes: 19 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@
config.allowUnfree = true;
};
in {
checks =
(import ./tests {
checks = {
tests = import ./tests {
inherit pkgs;
inherit (pkgs) lib;
# Some nixvim supported plugins require the use of unfree packages.
Expand All @@ -75,27 +75,26 @@
config = configuration;
};
};
})
// {
lib-tests = import ./tests/lib-tests.nix {
inherit (pkgs) pkgs lib;
};
extra-args-tests = import ./tests/extra-args.nix {
inherit pkgs;
inherit (self.legacyPackages.${system}) makeNixvimWithModule;
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra = {
enable = true;
excludes = ["plugins/_sources"];
};
statix.enable = true;
};
lib-tests = import ./tests/lib-tests.nix {
inherit (pkgs) pkgs lib;
};
extra-args-tests = import ./tests/extra-args.nix {
inherit pkgs;
inherit (self.legacyPackages.${system}) makeNixvimWithModule;
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
alejandra = {
enable = true;
excludes = ["plugins/_sources"];
};
settings.statix.ignore = ["plugins/lsp/language-servers/rust-analyzer-config.nix"];
statix.enable = true;
};
settings.statix.ignore = ["plugins/lsp/language-servers/rust-analyzer-config.nix"];
};
};
devShells = {
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
Expand Down
46 changes: 32 additions & 14 deletions tests/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,36 @@
inherit lib pkgs;
root = ./test-sources;
};
in

exampleFiles = {
example = let
config = import ../example.nix {inherit pkgs;};
in
builtins.removeAttrs config.programs.nixvim [
# This is not available to standalone modules, only HM & NixOS Modules
"enable"
# This is purely an example, it does not reflect a real usage
"extraConfigLua"
"extraConfigVim"
];
};

# We attempt to build & execute all configurations
builtins.mapAttrs mkTestDerivation (testFiles
// {
example = let
config = import ../example.nix {inherit pkgs;};
in
builtins.removeAttrs config.programs.nixvim [
# This is not available to standalone modules, only HM & NixOS Modules
"enable"
# This is purely an example, it does not reflect a real usage
"extraConfigLua"
"extraConfigVim"
];
})
derivationList =
pkgs.lib.mapAttrsToList
(
name: path: {
inherit name;
path = mkTestDerivation name path;
}
)
(testFiles // exampleFiles);
in
pkgs.linkFarm "nixvim-tests" derivationList
# pkgs.linkFarm "nixvim-tests" [
# {
# name = "hello";
# path = pkgs.hello;
# }
# ]

0 comments on commit 9bc957a

Please sign in to comment.