7 runTest = name: body: runCommand name { } ''
10 echo -n "Checking $1... " > /dev/stderr
16 echo fail > /dev/stderr
22 if test -n "$testFailed"; then
29 check = cond: if cond then "ok" else "nok";
32 withExtensions-enables-previously-disabled-extensions = runTest "php-test-withExtensions-enables-previously-disabled-extensions" ''
35 checking "that imagick is not present by default"
36 $php/bin/php -r 'exit(extension_loaded("imagick") ? 1 : 0);' && ok || nok
38 phpWithImagick="${php.withExtensions ({ all, ... }: [ all.imagick ])}"
39 checking "that imagick extension is present when enabled"
40 $phpWithImagick/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok
43 overrideAttrs-preserves-enabled-extensions =
46 (php.withExtensions ({ all, ... }: [ all.imagick ])).overrideAttrs (attrs: {
47 postInstall = attrs.postInstall or "" + ''
48 touch "$out/oApee-was-here"
52 runTest "php-test-overrideAttrs-preserves-enabled-extensions" ''
54 phpUnwrapped="${customPhp.unwrapped}"
56 checking "if overrides took hold"
57 test -f "$phpUnwrapped/oApee-was-here" && ok || nok
59 checking "if imagick extension is still present"
60 $php/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok
62 checking "if imagick extension is linked against the overridden PHP"
64 $php/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok
67 unwrapped-overrideAttrs-stacks =
70 lib.pipe php.unwrapped [
71 (pkg: pkg.overrideAttrs (attrs: {
72 postInstall = attrs.postInstall or "" + ''
73 touch "$out/oAs-first"
77 (pkg: pkg.overrideAttrs (attrs: {
78 postInstall = attrs.postInstall or "" + ''
79 touch "$out/oAs-second"
84 runTest "php-test-unwrapped-overrideAttrs-stacks" ''
85 checking "if first override remained"
86 ${check (builtins.match ".*oAs-first.*" customPhp.postInstall != null)}
88 checking "if second override is there"
89 ${check (builtins.match ".*oAs-second.*" customPhp.postInstall != null)}
92 wrapped-overrideAttrs-stacks =
96 (pkg: pkg.overrideAttrs (attrs: {
97 postInstall = attrs.postInstall or "" + ''
98 touch "$out/oAs-first"
102 (pkg: pkg.overrideAttrs (attrs: {
103 postInstall = attrs.postInstall or "" + ''
104 touch "$out/oAs-second"
109 runTest "php-test-wrapped-overrideAttrs-stacks" ''
110 checking "if first override remained"
111 ${check (builtins.match ".*oAs-first.*" customPhp.unwrapped.postInstall != null)}
113 checking "if second override is there"
114 ${check (builtins.match ".*oAs-second.*" customPhp.unwrapped.postInstall != null)}