diff options
author | sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> | 2021-02-16 02:22:51 +0100 |
---|---|---|
committer | sternenseemann <sternenseemann@systemli.org> | 2021-02-25 19:52:33 +0100 |
commit | bd05126ea1ea109d23318c4e26f678ada65cdf2b (patch) | |
tree | cea96314372684d6cdfa765b52ee403fdf999cc4 /tests/profpatsch/programs/nman.nix | |
parent | a4e4ca8b9a5ad24787343d6e7bdd5be99776ecd2 (diff) |
tests/profpatsch/programs/nman: add nixos test for nman
We can't really do normal unit tests, since they'd be integration tests requiring nix. Recursive nix is also a bad idea in normal derivations, so we add a NixOS test for nman. Here we are also somewhat limited since we already need to have all store paths used by nman in /nix/store otherwise we'd need to access the network which would fail. However we can verify that nman only builds specific store paths before finding the desired man page this way.
Diffstat (limited to 'tests/profpatsch/programs/nman.nix')
-rw-r--r-- | tests/profpatsch/programs/nman.nix | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/tests/profpatsch/programs/nman.nix b/tests/profpatsch/programs/nman.nix new file mode 100644 index 00000000..12556fa5 --- /dev/null +++ b/tests/profpatsch/programs/nman.nix @@ -0,0 +1,53 @@ +{ nixpkgsPath, ... }: + +{ + name = "nman-test"; + + machine = { pkgs, lib, ... }: { + nix.nixPath = lib.mkForce [ + "nixpkgs=${pkgs.path}" + ]; + + documentation.man.enable = false; + + environment.systemPackages = [ + pkgs.mandoc + pkgs.vuizvui.profpatsch.nman + ]; + + # add all outputs of packages which are later requested + # by nman in tests. note that only a single output is + # added which allows us to test that nman accesses the + # right outputs first and is as lazy as possible + # (any other outputs need network to be realised). + system.extraDependencies = [ + pkgs.lowdown.man + pkgs.man-pages.out + pkgs.libunwind.devman + pkgs.w3m.out + ]; + + environment.variables = { + PAGER = "cat"; + }; + }; + + testScript = '' + # fmt: off + machine.start() + + # man pages which exist + machine.succeed("nman lowdown | grep LOWDOWN.1.") + machine.succeed("nman w3m | grep W3M.1.") + machine.succeed("nman lowdown 3 | grep LOWDOWN.3.") + machine.succeed("nman lowdown lowdown_html_rndr | grep LOWDOWN_HTML_RNDR.3.") + machine.succeed("nman mandoc 7 man | grep MAN.7.") + machine.succeed("nman libunwind unw_init_local | grep UNW_INIT_LOCAL.3.") + + # man pages which should not be found + machine.fail("nman aewukaishenaiugenaifesphg") + machine.fail("nman man-pages 50 realpath") + machine.fail("nman man-pages does-not-exist") + machine.fail("nman man-pages 3 does-not-exist") + ''; +} |