tests/man: add tests for man-db/mandoc

This commit is contained in:
Thiago Kenji Okada
2026-04-29 22:23:12 +01:00
committed by Austin Horstman
parent f02e422b3e
commit 7914f8d7d7
6 changed files with 120 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
{
config = {
test.asserts.assertions.expected = [
''
man-db and mandoc can't be used as the man page viewer at the same time!
''
];
programs.man = {
enable = true;
man-db.enable = true;
mandoc.enable = true;
};
};
}

View File

@@ -2,6 +2,11 @@
{
man-apropos = ./apropos.nix;
man-assertion = ./assertion.nix;
man-disabled-man-db = ./disabled-man-db.nix;
man-disabled-mandoc = ./disabled-mandoc.nix;
man-extra-config = ./extra-config.nix;
man-mandoc = ./mandoc.nix;
man-no-manpath = ./no-manpath.nix;
man-no-caches-without-package = ./no-caches-without-package.nix;
}

View File

@@ -0,0 +1,14 @@
{
config = {
programs.man = {
enable = false;
man-db.enable = true;
mandoc.enable = false;
generateCaches = true;
};
nmt.script = ''
assertPathNotExists home-files/.manpath
'';
};
}

View File

@@ -0,0 +1,31 @@
{
config = {
programs.man = {
enable = false;
man-db.enable = false;
mandoc.enable = true;
generateCaches = true;
};
test.stubs = {
mandoc = {
outPath = null;
buildScript = ''
mkdir -p $out/bin
touch $out/bin/{man,makewhatis}
chmod +x $out/bin/*
'';
};
};
nmt.script = ''
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
assertPathNotExists home-files/.manpath
assertPathNotExists home-files/.local/share/mandoc/man
assertFileExists "$hmSessVars"
assertFileNotRegex "$hmSessVars" 'MANPATH='
'';
};
}

View File

@@ -0,0 +1,24 @@
{ lib, options, ... }:
{
config = {
test.asserts.warnings.expected = [
"The option `programs.man.extraConfig' defined in ${lib.showFiles options.programs.man.extraConfig.files} has been renamed to `programs.man.man-db.extraConfig'."
];
programs.man = {
enable = true;
generateCaches = true;
extraConfig = ''
MANDATORY_MANPATH /usr/man
SECTION 1 n l 8
'';
};
nmt.script = ''
assertFileExists home-files/.manpath
assertFileContains home-files/.manpath 'MANDATORY_MANPATH /usr/man'
assertFileContains home-files/.manpath 'SECTION 1 n l 8'
'';
};
}

View File

@@ -0,0 +1,31 @@
{
config = {
programs.man = {
enable = true;
man-db.enable = false;
mandoc.enable = true;
generateCaches = true;
};
test.stubs = {
mandoc = {
outPath = null;
buildScript = ''
mkdir -p $out/bin
touch $out/bin/{man,makewhatis}
chmod +x $out/bin/*
'';
};
};
nmt.script = ''
hmSessVars=home-path/etc/profile.d/hm-session-vars.sh
assertLinkExists home-files/.local/share/mandoc/man
assertFileExists $hmSessVars
assertFileContains $hmSessVars \
'export MANPATH="/home/hm-user/.local/share/mandoc/man''${MANPATH:+:}$MANPATH"'
'';
};
}