2021-07-02 22:36:30 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
{
|
|
|
|
options.test.asserts = {
|
|
|
|
warnings = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Whether warning asserts are enabled.";
|
|
|
|
};
|
|
|
|
|
|
|
|
expected = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
description = ''
|
|
|
|
List of expected warnings.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
assertions = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = true;
|
|
|
|
description = "Whether assertion asserts are enabled.";
|
|
|
|
};
|
|
|
|
|
|
|
|
expected = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
description = ''
|
|
|
|
List of expected assertions.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.test.asserts.warnings.enable {
|
|
|
|
home.file = {
|
|
|
|
"asserts/warnings.actual".text = concatStringsSep ''
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
--
|
|
|
|
'' config.warnings;
|
|
|
|
};
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
nmt.script = ''
|
|
|
|
assertFileContent \
|
|
|
|
home-files/asserts/warnings.actual \
|
|
|
|
${
|
|
|
|
pkgs.writeText "warnings.expected" (concatStringsSep ''
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
--
|
|
|
|
'' config.test.asserts.warnings.expected)
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
(mkIf config.test.asserts.assertions.enable {
|
|
|
|
home.file = {
|
|
|
|
"asserts/assertions.actual".text = concatStringsSep ''
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
--
|
|
|
|
'' (map (x: x.message) (filter (x: !x.assertion) config.assertions));
|
|
|
|
};
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
nmt.script = ''
|
|
|
|
assertFileContent \
|
|
|
|
home-files/asserts/assertions.actual \
|
|
|
|
${
|
|
|
|
pkgs.writeText "assertions.expected" (concatStringsSep ''
|
2021-07-02 22:36:30 +00:00
|
|
|
|
2021-11-04 16:42:44 +00:00
|
|
|
--
|
|
|
|
'' config.test.asserts.assertions.expected)
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
];
|
2021-07-02 22:36:30 +00:00
|
|
|
}
|