about summary refs log tree commit diff
path: root/tests/profpatsch/programs/nman.nix
blob: 12556fa503664d4063118477d773ab7b78c44b65 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
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")
  '';
}