tesseract: fix passthru override (#440938)

authored by

Aleksana and committed by
GitHub
5097cd69 32d4ae8f

+32 -24
+32 -24
pkgs/applications/graphics/tesseract/wrapper.nix
··· 58 passthru = { inherit tesseractBase languages tessdata; }; 59 60 # Only run test when all languages are available 61 - test = lib.optionalAttrs (enableLanguages == null) { 62 - tests.default = 63 - runCommand "tesseract-test-ocr" 64 - { 65 - buildInputs = [ 66 - tesseractWithData 67 - imagemagick 68 - ]; 69 - } 70 - '' 71 - text="hello nix" 72 73 - convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 \ 74 - -fill black -annotate +5+20 "$text" /tmp/test-img.png 2>/dev/null 75 - ocrResult=$(tesseract /tmp/test-img.png - | tr -d "\f") 76 77 - if [[ $ocrResult != $text ]]; then 78 - echo "OCR test failed" 79 - echo "expected: '$text'" 80 - echo "actual: '$ocrResult'" 81 - exit 1 82 - fi 83 - touch $out 84 - ''; 85 - }; 86 87 tesseract = 88 - (if enableLanguages == [ ] then tesseractBase else tesseractWithData) // passthru // test; 89 in 90 if enableLanguagesHash == null then 91 tesseract
··· 58 passthru = { inherit tesseractBase languages tessdata; }; 59 60 # Only run test when all languages are available 61 + test = 62 + runCommand "tesseract-test-ocr" 63 + { 64 + buildInputs = [ 65 + tesseractWithData 66 + imagemagick 67 + ]; 68 + } 69 + '' 70 + text="hello nix" 71 72 + convert -size 400x40 xc:white -font 'DejaVu-Sans' -pointsize 20 \ 73 + -fill black -annotate +5+20 "$text" /tmp/test-img.png 2>/dev/null 74 + ocrResult=$(tesseract /tmp/test-img.png - | tr -d "\f") 75 76 + if [[ $ocrResult != $text ]]; then 77 + echo "OCR test failed" 78 + echo "expected: '$text'" 79 + echo "actual: '$ocrResult'" 80 + exit 1 81 + fi 82 + touch $out 83 + ''; 84 85 tesseract = 86 + (if enableLanguages == [ ] then tesseractBase else tesseractWithData).overrideAttrs 87 + (old: { 88 + passthru = 89 + (old.passthru or { }) 90 + // passthru 91 + // lib.optionalAttrs (enableLanguages == null) { 92 + tests = (old.passthru.tests or { }) // { 93 + default = test; 94 + }; 95 + }; 96 + }); 97 in 98 if enableLanguagesHash == null then 99 tesseract