1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Add some eval tests

Not how I would recommend to do it, because I'm forcefully trying
to avoid adding dependencies to flake-parts.
Other projects should not follow this restriction.
This commit is contained in:
Robert Hensing 2022-11-27 16:06:43 +00:00
parent d591857e9d
commit c742f6f25a
2 changed files with 67 additions and 0 deletions

View file

@ -26,6 +26,10 @@
};
};
checks.eval-tests =
let tests = import ./tests/eval-tests.nix;
in tests.runTests pkgs.emptyFile // { internals = tests; };
};
flake = {
# for repl exploration / debug

63
dev/tests/eval-tests.nix Normal file
View file

@ -0,0 +1,63 @@
rec {
f-p = builtins.getFlake (toString ../..);
f-p-lib = f-p.lib;
inherit (f-p-lib) mkFlake;
inherit (f-p.inputs.nixpkgs-lib) lib;
pkg = system: name: derivation {
name = name;
builder = "no-builder";
system = system;
};
empty = mkFlake
{ self = { }; }
{
systems = [ ];
};
example1 = mkFlake
{ self = { }; }
{
systems = [ "a" "b" ];
perSystem = { system, ... }: {
packages.hello = pkg system "hello";
};
};
runTests = ok:
assert empty == {
apps = { };
checks = { };
darwinModules = { };
devShells = { };
formatter = { };
legacyPackages = { };
nixosConfigurations = { };
nixosModules = { };
overlays = { };
packages = { };
};
assert example1 == {
apps = { a = { }; b = { }; };
checks = { a = { }; b = { }; };
darwinModules = { };
devShells = { a = { }; b = { }; };
formatter = { };
legacyPackages = { a = { }; b = { }; };
nixosConfigurations = { };
nixosModules = { };
overlays = { };
packages = {
a = { hello = pkg "a" "hello"; };
b = { hello = pkg "b" "hello"; };
};
};
ok;
result = runTests "ok";
}