nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1# cd nixpkgs
2# nix-build -A tests.testers.hasPkgConfigModules
3{
4 lib,
5 testers,
6 miniz,
7 zlib,
8 openssl,
9 runCommand,
10}:
11
12lib.recurseIntoAttrs {
13
14 miniz-versions-match = testers.hasPkgConfigModules {
15 package = miniz;
16 versionCheck = true;
17 };
18
19 miniz-versions-mismatch = testers.testBuildFailure (
20 testers.hasPkgConfigModules {
21 package = miniz;
22 version = "1.2.3"; # Deliberately-incorrect version number
23 versionCheck = true;
24 }
25 );
26
27 miniz-no-versionCheck = testers.hasPkgConfigModules {
28 package = miniz;
29 version = "1.2.3"; # Deliberately-incorrect version number
30 };
31
32 zlib-has-zlib = testers.hasPkgConfigModules {
33 package = zlib;
34 moduleNames = [ "zlib" ];
35 };
36
37 zlib-has-meta-pkgConfigModules = testers.hasPkgConfigModules {
38 package = zlib;
39 };
40
41 openssl-has-openssl = testers.hasPkgConfigModules {
42 package = openssl;
43 moduleNames = [ "openssl" ];
44 };
45
46 openssl-has-all-meta-pkgConfigModules = testers.hasPkgConfigModules {
47 package = openssl;
48 };
49
50 zlib-does-not-have-ylib =
51 runCommand "zlib-does-not-have-ylib"
52 {
53 failed = testers.testBuildFailure (
54 testers.hasPkgConfigModules {
55 package = zlib;
56 moduleNames = [ "ylib" ];
57 }
58 );
59 }
60 ''
61 echo 'it logs a relevant error message'
62 {
63 grep -F "pkg-config module ylib was not found" $failed/testBuildFailure.log
64 }
65
66 echo 'it logs which pkg-config modules are available, to be helpful'
67 {
68 # grep -v: the string zlib does also occur in a store path in an earlier message, which isn't particularly helpful
69 grep -v "checking pkg-config module" < $failed/testBuildFailure.log \
70 | grep -F "zlib"
71 }
72
73 # done
74 touch $out
75 '';
76
77}