David PHAM-VAN

Add golden files diff

test/golden/* filter=lfs diff=lfs merge=lfs -text
... ...
... ... @@ -43,5 +43,7 @@ printing/lcov.info
test/readme.dart
test/android
test/ios
test/diff
ref
!test/golden/*.pdf
... ...
... ... @@ -4,6 +4,8 @@ addons:
apt:
packages:
- lib32stdc++6
- poppler-utils
- imagemagick
install:
- git clone https://github.com/flutter/flutter.git -b stable --depth 1 $HOME/flutter
- export PATH=$HOME/flutter/bin:$PATH
... ...
... ... @@ -73,6 +73,7 @@ test-pdf: $(FONTS) get-pdf .coverage
dart --enable-asserts --disable-service-auth-codes --enable-vm-service=$(COV_PORT) --pause-isolates-on-exit test/all_tests.dart
cd pdf; pub global run coverage:format_coverage --packages=.packages -i coverage.json --report-on lib --lcov --out lcov.info
cd pdf; for EXAMPLE in $(shell cd pdf; find example -name '*.dart'); do dart $$EXAMPLE; done
test/compare-pdf.sh pdf test/golden
test-printing: $(FONTS) get-printing .coverage
cd printing/example; flutter test --coverage --coverage-path ../lcov.info
... ... @@ -107,12 +108,12 @@ publish-printing: format clean
analyze-pdf: .pana
@find pdf -name pubspec.yaml -exec sed -i -e 's/^dependency_overrides:/_dependency_overrides:/g' '{}' ';'
@pub global run pana --no-warning --source path pdf 2> /dev/null | python pana_report.py
@pub global run pana --no-warning --source path pdf 2> /dev/null | python test/pana_report.py
@find pdf -name pubspec.yaml -exec sed -i -e 's/^_dependency_overrides:/dependency_overrides:/g' '{}' ';'
analyze-printing: .pana
@find printing -name pubspec.yaml -exec sed -i -e 's/^dependency_overrides:/_dependency_overrides:/g' '{}' ';'
@pub global run pana --no-warning --source path printing 2> /dev/null | python pana_report.py
@pub global run pana --no-warning --source path printing 2> /dev/null | python test/pana_report.py
@find printing -name pubspec.yaml -exec sed -i -e 's/^_dependency_overrides:/dependency_overrides:/g' '{}' ';'
analyze: analyze-pdf analyze-printing
... ...
#!/bin/bash
DST=$(dirname "$0")/diff
SRC=$1
GOLD=$2
ERROR=0
DPI=50
COMPARE=$(command -v compare)
for PDF in "$SRC"/*.pdf; do
echo "Diffing $PDF"
G="$GOLD"/$(basename "$PDF")
if [ ! -f "$G" ]; then
echo " Golden image $G not found"
ERROR=1
continue
fi
T=$(basename "$PDF" .pdf)
mkdir -p "$DST"/"$T"
pdftocairo "$PDF" -png -r "$DPI" "$DST"/"$T"/src 2> /dev/null
pdftocairo "$G" -png -r "$DPI" "$DST"/"$T"/gold 2> /dev/null
for PNG in "$DST"/"$T"/gold*.png; do
S="$DST"/"$T"/src-"${PNG##*-}"
RES=$($COMPARE -metric AE "$PNG" "$S" null: 2>&1)
if [ "$RES" != "0" ]; then
D="$DST"/"$T"/diff-"${PNG##*-}"
$COMPARE "$PNG" "$S" -highlight-color red "$D"
echo " Differences in $PNG and $S => $D"
ERROR=1
fi
done
done
if [ $ERROR -eq 0 ]; then
rm -rf "$DST"
fi
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