From bd05126ea1ea109d23318c4e26f678ada65cdf2b Mon Sep 17 00:00:00 2001 From: sternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org> Date: Tue, 16 Feb 2021 02:22:51 +0100 Subject: 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. --- tests/default.nix | 1 + tests/profpatsch/programs/nman.nix | 53 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/profpatsch/programs/nman.nix (limited to 'tests') diff --git a/tests/default.nix b/tests/default.nix index e47ddd46..e7f54e76 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -15,6 +15,7 @@ in { games = { starbound = callTest ./games/starbound.nix; }; + profpatsch.programs.nman = callTest ./profpatsch/programs/nman.nix; programs = { gnupg = callTest ./programs/gnupg; }; 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") + ''; +} -- cgit 1.4.1