2025-05-03 22:23:05 +02:00
|
|
|
{
|
|
|
|
|
pkgs,
|
|
|
|
|
lib ? pkgs.lib,
|
|
|
|
|
self ? "",
|
|
|
|
|
...
|
|
|
|
|
}: {
|
2025-05-03 22:05:29 +02:00
|
|
|
mkTest = {
|
|
|
|
|
type ? "unit",
|
|
|
|
|
name,
|
|
|
|
|
description ? "",
|
|
|
|
|
expected ? null,
|
|
|
|
|
actual ? null,
|
|
|
|
|
actualDrv ? null,
|
|
|
|
|
pos ? null,
|
2025-05-03 22:23:05 +02:00
|
|
|
}: let
|
|
|
|
|
fileRelative = lib.removePrefix ((toString self) + "/") pos.file;
|
|
|
|
|
in {
|
2025-05-03 22:05:29 +02:00
|
|
|
inherit type name description expected actual;
|
2025-05-04 21:53:51 +02:00
|
|
|
# discard string context, otherwise it's being built instantly which we don't want
|
|
|
|
|
actualDrv = builtins.unsafeDiscardStringContext (actualDrv.drvPath or "");
|
2025-05-03 22:05:29 +02:00
|
|
|
pos =
|
|
|
|
|
if pos == null
|
|
|
|
|
then ""
|
2025-05-03 22:23:05 +02:00
|
|
|
else "${fileRelative}:${toString pos.line}:${toString pos.column}";
|
2025-05-03 22:05:29 +02:00
|
|
|
};
|
|
|
|
|
mkSuite = name: tests: {
|
|
|
|
|
inherit name tests;
|
|
|
|
|
};
|
|
|
|
|
exportSuites = suites: let
|
|
|
|
|
suitesList =
|
|
|
|
|
if builtins.isList suites
|
|
|
|
|
then suites
|
|
|
|
|
else [suites];
|
|
|
|
|
testsMapped = builtins.toJSON suitesList;
|
|
|
|
|
in
|
|
|
|
|
pkgs.runCommand "tests.json" {} ''
|
|
|
|
|
echo '${testsMapped}' > $out
|
|
|
|
|
'';
|
|
|
|
|
}
|