David PHAM-VAN

Add golden files diff

  1 +test/golden/* filter=lfs diff=lfs merge=lfs -text
@@ -43,5 +43,7 @@ printing/lcov.info @@ -43,5 +43,7 @@ printing/lcov.info
43 test/readme.dart 43 test/readme.dart
44 test/android 44 test/android
45 test/ios 45 test/ios
  46 +test/diff
46 47
47 ref 48 ref
  49 +!test/golden/*.pdf
@@ -4,6 +4,8 @@ addons: @@ -4,6 +4,8 @@ addons:
4 apt: 4 apt:
5 packages: 5 packages:
6 - lib32stdc++6 6 - lib32stdc++6
  7 + - poppler-utils
  8 + - imagemagick
7 install: 9 install:
8 - git clone https://github.com/flutter/flutter.git -b stable --depth 1 $HOME/flutter 10 - git clone https://github.com/flutter/flutter.git -b stable --depth 1 $HOME/flutter
9 - export PATH=$HOME/flutter/bin:$PATH 11 - export PATH=$HOME/flutter/bin:$PATH
@@ -73,6 +73,7 @@ test-pdf: $(FONTS) get-pdf .coverage @@ -73,6 +73,7 @@ test-pdf: $(FONTS) get-pdf .coverage
73 dart --enable-asserts --disable-service-auth-codes --enable-vm-service=$(COV_PORT) --pause-isolates-on-exit test/all_tests.dart 73 dart --enable-asserts --disable-service-auth-codes --enable-vm-service=$(COV_PORT) --pause-isolates-on-exit test/all_tests.dart
74 cd pdf; pub global run coverage:format_coverage --packages=.packages -i coverage.json --report-on lib --lcov --out lcov.info 74 cd pdf; pub global run coverage:format_coverage --packages=.packages -i coverage.json --report-on lib --lcov --out lcov.info
75 cd pdf; for EXAMPLE in $(shell cd pdf; find example -name '*.dart'); do dart $$EXAMPLE; done 75 cd pdf; for EXAMPLE in $(shell cd pdf; find example -name '*.dart'); do dart $$EXAMPLE; done
  76 + test/compare-pdf.sh pdf test/golden
76 77
77 test-printing: $(FONTS) get-printing .coverage 78 test-printing: $(FONTS) get-printing .coverage
78 cd printing/example; flutter test --coverage --coverage-path ../lcov.info 79 cd printing/example; flutter test --coverage --coverage-path ../lcov.info
@@ -107,12 +108,12 @@ publish-printing: format clean @@ -107,12 +108,12 @@ publish-printing: format clean
107 108
108 analyze-pdf: .pana 109 analyze-pdf: .pana
109 @find pdf -name pubspec.yaml -exec sed -i -e 's/^dependency_overrides:/_dependency_overrides:/g' '{}' ';' 110 @find pdf -name pubspec.yaml -exec sed -i -e 's/^dependency_overrides:/_dependency_overrides:/g' '{}' ';'
110 - @pub global run pana --no-warning --source path pdf 2> /dev/null | python pana_report.py 111 + @pub global run pana --no-warning --source path pdf 2> /dev/null | python test/pana_report.py
111 @find pdf -name pubspec.yaml -exec sed -i -e 's/^_dependency_overrides:/dependency_overrides:/g' '{}' ';' 112 @find pdf -name pubspec.yaml -exec sed -i -e 's/^_dependency_overrides:/dependency_overrides:/g' '{}' ';'
112 113
113 analyze-printing: .pana 114 analyze-printing: .pana
114 @find printing -name pubspec.yaml -exec sed -i -e 's/^dependency_overrides:/_dependency_overrides:/g' '{}' ';' 115 @find printing -name pubspec.yaml -exec sed -i -e 's/^dependency_overrides:/_dependency_overrides:/g' '{}' ';'
115 - @pub global run pana --no-warning --source path printing 2> /dev/null | python pana_report.py 116 + @pub global run pana --no-warning --source path printing 2> /dev/null | python test/pana_report.py
116 @find printing -name pubspec.yaml -exec sed -i -e 's/^_dependency_overrides:/dependency_overrides:/g' '{}' ';' 117 @find printing -name pubspec.yaml -exec sed -i -e 's/^_dependency_overrides:/dependency_overrides:/g' '{}' ';'
117 118
118 analyze: analyze-pdf analyze-printing 119 analyze: analyze-pdf analyze-printing
  1 +#!/bin/bash
  2 +
  3 +DST=$(dirname "$0")/diff
  4 +SRC=$1
  5 +GOLD=$2
  6 +ERROR=0
  7 +DPI=50
  8 +COMPARE=$(command -v compare)
  9 +
  10 +for PDF in "$SRC"/*.pdf; do
  11 + echo "Diffing $PDF"
  12 + G="$GOLD"/$(basename "$PDF")
  13 + if [ ! -f "$G" ]; then
  14 + echo " Golden image $G not found"
  15 + ERROR=1
  16 + continue
  17 + fi
  18 +
  19 + T=$(basename "$PDF" .pdf)
  20 + mkdir -p "$DST"/"$T"
  21 + pdftocairo "$PDF" -png -r "$DPI" "$DST"/"$T"/src 2> /dev/null
  22 + pdftocairo "$G" -png -r "$DPI" "$DST"/"$T"/gold 2> /dev/null
  23 +
  24 + for PNG in "$DST"/"$T"/gold*.png; do
  25 + S="$DST"/"$T"/src-"${PNG##*-}"
  26 + RES=$($COMPARE -metric AE "$PNG" "$S" null: 2>&1)
  27 + if [ "$RES" != "0" ]; then
  28 + D="$DST"/"$T"/diff-"${PNG##*-}"
  29 + $COMPARE "$PNG" "$S" -highlight-color red "$D"
  30 + echo " Differences in $PNG and $S => $D"
  31 + ERROR=1
  32 + fi
  33 + done
  34 +done
  35 +
  36 +if [ $ERROR -eq 0 ]; then
  37 + rm -rf "$DST"
  38 +fi
  39 +
  40 +exit $ERROR
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type