fix(nix/runTestsuite): wrap runTestsuite into derivation
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
This commit is contained in:
parent
e7ad8143e4
commit
7f091079ce
1 changed files with 26 additions and 8 deletions
|
@ -26,7 +26,17 @@
|
||||||
# will fail the second it group because true is not false.
|
# will fail the second it group because true is not false.
|
||||||
|
|
||||||
let
|
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
|
# rewrite the builtins.partition result
|
||||||
# to use `ok` and `err` instead of `right` and `wrong`.
|
# to use `ok` and `err` instead of `right` and `wrong`.
|
||||||
|
@ -83,7 +93,7 @@ let
|
||||||
# and print the result of the test suite.
|
# and print the result of the test suite.
|
||||||
#
|
#
|
||||||
# Takes a test suite name as first argument.
|
# Takes a test suite name as first argument.
|
||||||
runTestsuite = defun [ string (list ItResult) unit ]
|
runTestsuite = defun [ string (list ItResult) drv ]
|
||||||
(name: itResults:
|
(name: itResults:
|
||||||
let
|
let
|
||||||
goodAss = ass: {
|
goodAss = ass: {
|
||||||
|
@ -105,12 +115,20 @@ let
|
||||||
res = goodIts itResults;
|
res = goodIts itResults;
|
||||||
in
|
in
|
||||||
if res.err == []
|
if res.err == []
|
||||||
then {}
|
then depot.nix.runExecline.local "testsuite-${name}-successful" {} [
|
||||||
# TODO(Profpatsch): pretty printing of results
|
"importas" "out" "out"
|
||||||
# and probably also somewhat easier to read output
|
"if" [ bins.printf "%s\n" "testsuite ${name} successful!" ]
|
||||||
else throw
|
bins.touch "$out"
|
||||||
( "testsuite ${name} failed!\n"
|
]
|
||||||
+ lib.generators.toPretty {} res));
|
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 {
|
in {
|
||||||
inherit
|
inherit
|
||||||
|
|
Loading…
Reference in a new issue