Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at gcc-offload 138 lines 3.6 kB view raw
1{ 2 lib, 3 php, 4 runCommand, 5}: 6 7let 8 runTest = 9 name: body: 10 runCommand name { } '' 11 testFailed= 12 checking() { 13 echo -n "Checking $1... " > /dev/stderr 14 } 15 ok() { 16 echo ok > /dev/stderr 17 } 18 nok() { 19 echo fail > /dev/stderr 20 testFailed=1 21 } 22 23 ${body} 24 25 if test -n "$testFailed"; then 26 exit 1 27 fi 28 29 touch $out 30 ''; 31 32 check = cond: if cond then "ok" else "nok"; 33in 34{ 35 withExtensions-enables-previously-disabled-extensions = runTest "php-test-withExtensions-enables-previously-disabled-extensions" '' 36 php="${php}" 37 38 checking "that imagick is not present by default" 39 $php/bin/php -r 'exit(extension_loaded("imagick") ? 1 : 0);' && ok || nok 40 41 phpWithImagick="${php.withExtensions ({ all, ... }: [ all.imagick ])}" 42 checking "that imagick extension is present when enabled" 43 $phpWithImagick/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok 44 ''; 45 46 overrideAttrs-preserves-enabled-extensions = 47 let 48 customPhp = (php.withExtensions ({ all, ... }: [ all.imagick ])).overrideAttrs (attrs: { 49 postInstall = 50 attrs.postInstall or "" 51 + '' 52 touch "$out/oApee-was-here" 53 ''; 54 }); 55 in 56 runTest "php-test-overrideAttrs-preserves-enabled-extensions" '' 57 php="${customPhp}" 58 phpUnwrapped="${customPhp.unwrapped}" 59 60 checking "if overrides took hold" 61 test -f "$phpUnwrapped/oApee-was-here" && ok || nok 62 63 checking "if imagick extension is still present" 64 $php/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok 65 66 checking "if imagick extension is linked against the overridden PHP" 67 echo $php 68 $php/bin/php -r 'exit(extension_loaded("imagick") ? 0 : 1);' && ok || nok 69 ''; 70 71 unwrapped-overrideAttrs-stacks = 72 let 73 customPhp = lib.pipe php.unwrapped [ 74 ( 75 pkg: 76 pkg.overrideAttrs (attrs: { 77 postInstall = 78 attrs.postInstall or "" 79 + '' 80 touch "$out/oAs-first" 81 ''; 82 }) 83 ) 84 85 ( 86 pkg: 87 pkg.overrideAttrs (attrs: { 88 postInstall = 89 attrs.postInstall or "" 90 + '' 91 touch "$out/oAs-second" 92 ''; 93 }) 94 ) 95 ]; 96 in 97 runTest "php-test-unwrapped-overrideAttrs-stacks" '' 98 checking "if first override remained" 99 ${check (builtins.match ".*oAs-first.*" customPhp.postInstall != null)} 100 101 checking "if second override is there" 102 ${check (builtins.match ".*oAs-second.*" customPhp.postInstall != null)} 103 ''; 104 105 wrapped-overrideAttrs-stacks = 106 let 107 customPhp = lib.pipe php [ 108 ( 109 pkg: 110 pkg.overrideAttrs (attrs: { 111 postInstall = 112 attrs.postInstall or "" 113 + '' 114 touch "$out/oAs-first" 115 ''; 116 }) 117 ) 118 119 ( 120 pkg: 121 pkg.overrideAttrs (attrs: { 122 postInstall = 123 attrs.postInstall or "" 124 + '' 125 touch "$out/oAs-second" 126 ''; 127 }) 128 ) 129 ]; 130 in 131 runTest "php-test-wrapped-overrideAttrs-stacks" '' 132 checking "if first override remained" 133 ${check (builtins.match ".*oAs-first.*" customPhp.unwrapped.postInstall != null)} 134 135 checking "if second override is there" 136 ${check (builtins.match ".*oAs-second.*" customPhp.unwrapped.postInstall != null)} 137 ''; 138}