feat: general improvements and add junit "error" and "skipped" support

This commit is contained in:
technofab 2025-05-04 21:54:17 +02:00
parent 5ae5c2dd45
commit 0a1bbae2c3
5 changed files with 181 additions and 105 deletions

View file

@ -14,27 +14,39 @@ in {
}: let
nixtests-lib = import ./. {inherit pkgs self;};
in {
options.testSuites = mkOption {
type = types.attrsOf (types.listOf types.attrs);
options.nixtest = mkOption {
type = types.submodule ({...}: {
options = {
skip = mkOption {
type = types.str;
default = "";
description = "Which tests to skip (regex)";
};
suites = mkOption {
type = types.attrsOf (types.listOf types.attrs);
default = {};
};
};
});
default = {};
};
config.legacyPackages = rec {
"nixtests" = let
suites = map (suiteName: let
tests = builtins.getAttr suiteName config.testSuites;
tests = builtins.getAttr suiteName config.nixtest.suites;
in
nixtests-lib.mkSuite
suiteName
(map (test: nixtests-lib.mkTest test) tests))
(builtins.attrNames config.testSuites);
(builtins.attrNames config.nixtest.suites);
in
nixtests-lib.exportSuites suites;
"nixtests:run" = let
program = pkgs.callPackage ./../package.nix {};
in
pkgs.writeShellScriptBin "nixtests:run" ''
${program}/bin/nixtest --tests=${nixtests} "$@"
${program}/bin/nixtest --tests=${nixtests} --skip="${config.nixtest.skip}" "$@"
'';
};
}