mirror of
https://github.com/nix-community/nixvim.git
synced 2025-06-21 08:35:43 +02:00
tests: move test derivations to tests/default.nix
Move the previous `default.nix` to `main.nix` so that `default.nix` can be used for defining the set of all test derivations. `main.nix` is imported by `default.nix`, but is only responsible for the tests built from `tests/test-sources/`.
This commit is contained in:
parent
3c7b6ae5d1
commit
990ef039f7
3 changed files with 129 additions and 105 deletions
|
@ -1,57 +1,27 @@
|
||||||
{ self, helpers, ... }:
|
{
|
||||||
|
self,
|
||||||
|
lib,
|
||||||
|
helpers,
|
||||||
|
...
|
||||||
|
}:
|
||||||
{
|
{
|
||||||
perSystem =
|
perSystem =
|
||||||
{
|
{
|
||||||
pkgs,
|
pkgs,
|
||||||
pkgsUnfree,
|
pkgsUnfree,
|
||||||
system,
|
system,
|
||||||
makeNixvimWithModule,
|
|
||||||
self',
|
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
|
||||||
inherit (self'.legacyPackages) nixvimConfiguration;
|
|
||||||
in
|
|
||||||
{
|
{
|
||||||
checks = {
|
checks = import ../tests {
|
||||||
extra-args-tests = import ../tests/extra-args.nix {
|
inherit
|
||||||
inherit pkgs;
|
helpers
|
||||||
inherit makeNixvimWithModule;
|
lib
|
||||||
};
|
pkgs
|
||||||
|
pkgsUnfree
|
||||||
extend = import ../tests/extend.nix { inherit pkgs makeNixvimWithModule; };
|
self
|
||||||
|
system
|
||||||
extra-files = import ../tests/extra-files.nix { inherit pkgs makeNixvimWithModule; };
|
;
|
||||||
|
};
|
||||||
enable-except-in-tests = import ../tests/enable-except-in-tests.nix {
|
|
||||||
inherit pkgs makeNixvimWithModule;
|
|
||||||
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
|
|
||||||
};
|
|
||||||
|
|
||||||
failing-tests = pkgs.callPackage ../tests/failing-tests.nix {
|
|
||||||
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
|
|
||||||
};
|
|
||||||
|
|
||||||
no-flake = import ../tests/no-flake.nix {
|
|
||||||
inherit system;
|
|
||||||
inherit (self.lib.${system}.check) mkTestDerivationFromNvim;
|
|
||||||
nixvim = "${self}";
|
|
||||||
};
|
|
||||||
|
|
||||||
lib-tests = import ../tests/lib-tests.nix {
|
|
||||||
inherit pkgs helpers;
|
|
||||||
inherit (pkgs) lib;
|
|
||||||
};
|
|
||||||
|
|
||||||
maintainers = import ../tests/maintainers.nix { inherit pkgs; };
|
|
||||||
|
|
||||||
plugins-by-name = pkgs.callPackage ../tests/plugins-by-name.nix { inherit nixvimConfiguration; };
|
|
||||||
|
|
||||||
generated = pkgs.callPackage ../tests/generated.nix { };
|
|
||||||
|
|
||||||
package-options = pkgs.callPackage ../tests/package-options.nix { inherit nixvimConfiguration; };
|
|
||||||
|
|
||||||
lsp-all-servers = pkgs.callPackage ../tests/lsp-servers.nix { inherit nixvimConfiguration; };
|
|
||||||
} // import ../tests { inherit pkgs pkgsUnfree helpers; };
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,65 +1,53 @@
|
||||||
{
|
{
|
||||||
lib ? pkgs.lib,
|
|
||||||
helpers,
|
|
||||||
pkgs,
|
pkgs,
|
||||||
pkgsUnfree,
|
pkgsUnfree,
|
||||||
|
helpers,
|
||||||
|
lib,
|
||||||
|
system,
|
||||||
|
self, # The flake instance
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
fetchTests = import ./fetch-tests.nix { inherit lib pkgs helpers; };
|
inherit (self.legacyPackages.${system})
|
||||||
test-derivation = import ../lib/tests.nix { inherit pkgs lib; };
|
makeNixvimWithModule
|
||||||
inherit (test-derivation) mkTestDerivationFromNixvimModule;
|
nixvimConfiguration
|
||||||
|
;
|
||||||
moduleToTest =
|
|
||||||
file: name: module:
|
|
||||||
mkTestDerivationFromNixvimModule {
|
|
||||||
inherit name;
|
|
||||||
module = {
|
|
||||||
_file = file;
|
|
||||||
imports = [ module ];
|
|
||||||
};
|
|
||||||
pkgs = pkgsUnfree;
|
|
||||||
};
|
|
||||||
|
|
||||||
# List of files containing configurations
|
|
||||||
testFiles = fetchTests ./test-sources;
|
|
||||||
|
|
||||||
exampleFiles = {
|
|
||||||
name = "examples";
|
|
||||||
file = ../example.nix;
|
|
||||||
cases =
|
|
||||||
let
|
|
||||||
config = import ../example.nix { inherit pkgs; };
|
|
||||||
in
|
|
||||||
{
|
|
||||||
main = 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"
|
|
||||||
];
|
|
||||||
};
|
|
||||||
};
|
|
||||||
in
|
in
|
||||||
# We attempt to build & execute all configurations
|
{
|
||||||
lib.pipe (testFiles ++ [ exampleFiles ]) [
|
extra-args-tests = import ./extra-args.nix {
|
||||||
(builtins.map (
|
inherit pkgs;
|
||||||
{
|
inherit makeNixvimWithModule;
|
||||||
name,
|
};
|
||||||
file,
|
extend = import ./extend.nix { inherit pkgs makeNixvimWithModule; };
|
||||||
cases,
|
extra-files = import ./extra-files.nix { inherit pkgs makeNixvimWithModule; };
|
||||||
}:
|
enable-except-in-tests = import ./enable-except-in-tests.nix {
|
||||||
{
|
inherit pkgs makeNixvimWithModule;
|
||||||
inherit name;
|
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
|
||||||
path = pkgs.linkFarm name (builtins.mapAttrs (moduleToTest file) cases);
|
};
|
||||||
}
|
failing-tests = pkgs.callPackage ./failing-tests.nix {
|
||||||
))
|
inherit (self.lib.${system}.check) mkTestDerivationFromNixvimModule;
|
||||||
(helpers.groupListBySize 10)
|
};
|
||||||
(lib.imap1 (
|
no-flake = import ./no-flake.nix {
|
||||||
i: group: rec {
|
inherit system;
|
||||||
name = "test-${toString i}";
|
inherit (self.lib.${system}.check) mkTestDerivationFromNvim;
|
||||||
value = pkgs.linkFarm name group;
|
nixvim = "${self}";
|
||||||
}
|
};
|
||||||
))
|
lib-tests = import ./lib-tests.nix {
|
||||||
builtins.listToAttrs
|
inherit pkgs helpers;
|
||||||
]
|
inherit (pkgs) lib;
|
||||||
|
};
|
||||||
|
maintainers = import ./maintainers.nix { inherit pkgs; };
|
||||||
|
plugins-by-name = pkgs.callPackage ./plugins-by-name.nix { inherit nixvimConfiguration; };
|
||||||
|
generated = pkgs.callPackage ./generated.nix { };
|
||||||
|
package-options = pkgs.callPackage ./package-options.nix { inherit nixvimConfiguration; };
|
||||||
|
lsp-all-servers = pkgs.callPackage ./lsp-servers.nix { inherit nixvimConfiguration; };
|
||||||
|
}
|
||||||
|
# Tests generated from ./test-sources
|
||||||
|
# Grouped as a number of link-farms in the form { test-1, test-2, ... test-N }
|
||||||
|
// import ./main.nix {
|
||||||
|
inherit
|
||||||
|
lib
|
||||||
|
pkgs
|
||||||
|
pkgsUnfree
|
||||||
|
helpers
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
66
tests/main.nix
Normal file
66
tests/main.nix
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# Collects the various test modules in tests/test-sources/ and groups them into a number of test derivations
|
||||||
|
{
|
||||||
|
lib ? pkgs.lib,
|
||||||
|
helpers,
|
||||||
|
pkgs,
|
||||||
|
pkgsUnfree,
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
fetchTests = import ./fetch-tests.nix { inherit lib pkgs helpers; };
|
||||||
|
test-derivation = import ../lib/tests.nix { inherit pkgs lib; };
|
||||||
|
inherit (test-derivation) mkTestDerivationFromNixvimModule;
|
||||||
|
|
||||||
|
moduleToTest =
|
||||||
|
file: name: module:
|
||||||
|
mkTestDerivationFromNixvimModule {
|
||||||
|
inherit name;
|
||||||
|
module = {
|
||||||
|
_file = file;
|
||||||
|
imports = [ module ];
|
||||||
|
};
|
||||||
|
pkgs = pkgsUnfree;
|
||||||
|
};
|
||||||
|
|
||||||
|
# List of files containing configurations
|
||||||
|
testFiles = fetchTests ./test-sources;
|
||||||
|
|
||||||
|
exampleFiles = {
|
||||||
|
name = "examples";
|
||||||
|
file = ../example.nix;
|
||||||
|
cases =
|
||||||
|
let
|
||||||
|
config = import ../example.nix { inherit pkgs; };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
main = 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"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
# We attempt to build & execute all configurations
|
||||||
|
lib.pipe (testFiles ++ [ exampleFiles ]) [
|
||||||
|
(builtins.map (
|
||||||
|
{
|
||||||
|
name,
|
||||||
|
file,
|
||||||
|
cases,
|
||||||
|
}:
|
||||||
|
{
|
||||||
|
inherit name;
|
||||||
|
path = pkgs.linkFarm name (builtins.mapAttrs (moduleToTest file) cases);
|
||||||
|
}
|
||||||
|
))
|
||||||
|
(helpers.groupListBySize 10)
|
||||||
|
(lib.imap1 (
|
||||||
|
i: group: rec {
|
||||||
|
name = "test-${toString i}";
|
||||||
|
value = pkgs.linkFarm name group;
|
||||||
|
}
|
||||||
|
))
|
||||||
|
builtins.listToAttrs
|
||||||
|
]
|
Loading…
Add table
Add a link
Reference in a new issue