diff options
author | Profpatsch <mail@profpatsch.de> | 2021-01-29T19·48+0100 |
---|---|---|
committer | Profpatsch <mail@profpatsch.de> | 2021-01-30T11·44+0000 |
commit | 7f091079ce834775abcd4840ca42122727f4593e (patch) | |
tree | 690ef27dd2df8013fa02d7d5830561a3aeb23557 /nix | |
parent | e7ad8143e43d56773f683f1d1d5a3bca9b1dbe6d (diff) |
fix(nix/runTestsuite): wrap runTestsuite into derivation r/2161
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 <sternenseemann@systemli.org> Tested-by: BuildkiteCI
Diffstat (limited to 'nix')
-rw-r--r-- | nix/runTestsuite/default.nix | 34 |
1 files changed, 26 insertions, 8 deletions
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 |