about summary refs log tree commit diff
path: root/pkgs/build-support/testers/hasPkgConfigModules/tests.nix
blob: bf992d040b4b38e784354c0640d97e2cee64bafd (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
54
55
56
57
58
59
60
# cd nixpkgs
# nix-build -A tests.testers.hasPkgConfigModules
{ lib, testers, miniz, zlib, openssl, runCommand }:

lib.recurseIntoAttrs {

  miniz-versions-match = testers.hasPkgConfigModules {
    package = miniz;
    versionCheck = true;
  };

  miniz-versions-mismatch = testers.testBuildFailure (testers.hasPkgConfigModules {
    package = miniz;
    version = "1.2.3";
    versionCheck = true;
  });

  zlib-has-zlib = testers.hasPkgConfigModules {
    package = zlib;
    moduleNames = [ "zlib" ];
  };

  zlib-has-meta-pkgConfigModules = testers.hasPkgConfigModules {
    package = zlib;
  };

  openssl-has-openssl = testers.hasPkgConfigModules {
    package = openssl;
    moduleNames = [ "openssl" ];
  };

  openssl-has-all-meta-pkgConfigModules = testers.hasPkgConfigModules {
    package = openssl;
  };

  zlib-does-not-have-ylib = runCommand "zlib-does-not-have-ylib" {
    failed = testers.testBuildFailure (
      testers.hasPkgConfigModules {
      package = zlib;
      moduleNames = [ "ylib" ];
      }
    );
  } ''
    echo 'it logs a relevant error message'
    {
      grep -F "pkg-config module ylib was not found" $failed/testBuildFailure.log
    }

    echo 'it logs which pkg-config modules are available, to be helpful'
    {
      # grep -v: the string zlib does also occur in a store path in an earlier message, which isn't particularly helpful
      grep -v "checking pkg-config module" < $failed/testBuildFailure.log \
        | grep -F "zlib"
    }

    # done
    touch $out
  '';

}