From 7f091079ce834775abcd4840ca42122727f4593e Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 29 Jan 2021 20:48:00 +0100 Subject: fix(nix/runTestsuite): wrap runTestsuite into derivation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously we would throw or return `{}`, which doesn’t integrate nicely into our CI; thus, let’s wrap it into a derivation which either fails the build or doesn’t. Change-Id: I65880d86b8393094661e57a0b32aafe748bf1dd5 Reviewed-on: https://cl.tvl.fyi/c/depot/+/2462 Reviewed-by: sterni Tested-by: BuildkiteCI --- nix/runTestsuite/default.nix | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) (limited to 'nix') diff --git a/nix/runTestsuite/default.nix b/nix/runTestsuite/default.nix index 0105eb6fc946..6d2befc863fe 100644 --- a/nix/runTestsuite/default.nix +++ b/nix/runTestsuite/default.nix @@ -26,7 +26,17 @@ # will fail the second it group because true is not false. let - inherit (depot.nix.yants) sum struct string any unit defun list; + inherit (depot.nix.yants) + sum + struct + string + any + defun + list + drv + ; + + bins = depot.nix.getBins pkgs.coreutils [ "printf" "touch" ]; # rewrite the builtins.partition result # to use `ok` and `err` instead of `right` and `wrong`. @@ -83,7 +93,7 @@ let # and print the result of the test suite. # # Takes a test suite name as first argument. - runTestsuite = defun [ string (list ItResult) unit ] + runTestsuite = defun [ string (list ItResult) drv ] (name: itResults: let goodAss = ass: { @@ -105,12 +115,20 @@ let res = goodIts itResults; in if res.err == [] - then {} - # TODO(Profpatsch): pretty printing of results - # and probably also somewhat easier to read output - else throw - ( "testsuite ${name} failed!\n" - + lib.generators.toPretty {} res)); + then depot.nix.runExecline.local "testsuite-${name}-successful" {} [ + "importas" "out" "out" + "if" [ bins.printf "%s\n" "testsuite ${name} successful!" ] + bins.touch "$out" + ] + else depot.nix.runExecline.local "testsuite-${name}-failed" {} [ + "importas" "out" "out" + "if" [ + bins.printf "%s\n%s\n" + "testsuite ${name} failed!" + (lib.generators.toPretty {} res) + ] + "exit" "1" + ]); in { inherit -- cgit 1.4.1