From d4311c073cf54f7efd311ee470ed986976d0eea1 Mon Sep 17 00:00:00 2001 From: Dusk Banks Date: Thu, 20 Apr 2023 09:04:14 +0000 Subject: [PATCH] dev/tests: Implement stronger flake mocking tests --- dev/tests/eval-tests.nix | 71 +++++++++++++++++++++++++--------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/dev/tests/eval-tests.nix b/dev/tests/eval-tests.nix index c5a093ce..11dc6c35 100644 --- a/dev/tests/eval-tests.nix +++ b/dev/tests/eval-tests.nix @@ -26,7 +26,8 @@ in result; strongEvalTests.callFlake = { ... } @ flake: let - sourceInfo = flake.sourceInfo or { }; + sourceInfo = { outPath = "/unknown_eval-tests_flake"; } // + flake.sourceInfo or { }; inputs = flake.inputs or { }; outputs = flake.outputs (inputs // { self = result; }); result = outputs // sourceInfo // { @@ -59,6 +60,25 @@ in systems = [ ]; }; }; + weakEvalTests.emptyResult = { + apps = { }; + checks = { }; + devShells = { }; + formatter = { }; + legacyPackages = { }; + nixosConfigurations = { }; + nixosModules = { }; + overlays = { }; + packages = { }; + }; + strongEvalTests.emptyResult = let + _type = "flake"; + inputs.flake-parts = evalTests.flake-parts; + inputs.self = { }; + outputs = evalTests.weakEvalTests.emptyResult; + sourceInfo.outPath = "/unknown_eval-tests_flake"; + result = outputs // sourceInfo // { inherit _type inputs outputs sourceInfo; }; + in result; example1 = evalTests.callFlake { inputs.flake-parts = evalTests.flake-parts; @@ -70,6 +90,28 @@ in }; }; }; + weakEvalTests.example1Result = { + apps = { a = { }; b = { }; }; + checks = { a = { }; b = { }; }; + devShells = { a = { }; b = { }; }; + formatter = { }; + legacyPackages = { a = { }; b = { }; }; + nixosConfigurations = { }; + nixosModules = { }; + overlays = { }; + packages = { + a = { hello = evalTests.pkg "a" "hello"; }; + b = { hello = evalTests.pkg "b" "hello"; }; + }; + }; + strongEvalTests.example1Result = let + _type = "flake"; + inputs.flake-parts = evalTests.flake-parts; + inputs.self = { }; + outputs = evalTests.weakEvalTests.example1Result; + sourceInfo.outPath = "/unknown_eval-tests_flake"; + result = outputs // sourceInfo // { inherit _type inputs outputs sourceInfo; }; + in result; packagesNonStrictInDevShells = evalTests.callFlake { inputs.flake-parts = evalTests.flake-parts; @@ -161,32 +203,9 @@ in runTests = ok: - assert evalTests.empty == { - apps = { }; - checks = { }; - devShells = { }; - formatter = { }; - legacyPackages = { }; - nixosConfigurations = { }; - nixosModules = { }; - overlays = { }; - packages = { }; - }; + assert evalTests.empty == evalTests.emptyResult; - assert evalTests.example1 == { - apps = { a = { }; b = { }; }; - checks = { a = { }; b = { }; }; - devShells = { a = { }; b = { }; }; - formatter = { }; - legacyPackages = { a = { }; b = { }; }; - nixosConfigurations = { }; - nixosModules = { }; - overlays = { }; - packages = { - a = { hello = evalTests.pkg "a" "hello"; }; - b = { hello = evalTests.pkg "b" "hello"; }; - }; - }; + assert evalTests.example1 == evalTests.example1Result; # - exported package becomes part of overlay. # - perSystem is invoked for the right system, when system is non-memoized