2020-12-30 16:20:47 +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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2021-02-07 20:52:16 +00:00
|
|
|
|
|
|
|
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.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2020-12-30 16:20:47 +00:00
|
|
|
};
|
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
config = mkMerge [
|
|
|
|
(mkIf config.test.asserts.warnings.enable {
|
|
|
|
home.file = {
|
|
|
|
"asserts/warnings.actual".text = concatStringsSep ''
|
2020-12-30 16:20:47 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
--
|
|
|
|
'' config.warnings;
|
|
|
|
};
|
2021-02-07 20:52:16 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
nmt.script = ''
|
|
|
|
assertFileContent \
|
|
|
|
home-files/asserts/warnings.actual \
|
|
|
|
${
|
|
|
|
pkgs.writeText "warnings.expected" (concatStringsSep ''
|
2021-02-07 20:52:16 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
--
|
|
|
|
'' config.test.asserts.warnings.expected)
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
2020-12-30 16:20:47 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
(mkIf config.test.asserts.assertions.enable {
|
|
|
|
home.file = {
|
|
|
|
"asserts/assertions.actual".text = concatStringsSep ''
|
2020-12-30 16:20:47 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
--
|
|
|
|
'' (map (x: x.message) (filter (x: !x.assertion) config.assertions));
|
|
|
|
};
|
2021-02-07 20:52:16 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
nmt.script = ''
|
|
|
|
assertFileContent \
|
|
|
|
home-files/asserts/assertions.actual \
|
|
|
|
${
|
|
|
|
pkgs.writeText "assertions.expected" (concatStringsSep ''
|
2021-02-07 20:52:16 +00:00
|
|
|
|
2021-10-09 00:10:35 +00:00
|
|
|
--
|
|
|
|
'' config.test.asserts.assertions.expected)
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
})
|
|
|
|
];
|
2020-12-30 16:20:47 +00:00
|
|
|
}
|