]> git.donarmstrong.com Git - lilypond.git/blob - scripts/auxiliar/make-regtest-pngs.sh
Script for running pixel-based regtest comparisons
[lilypond.git] / scripts / auxiliar / make-regtest-pngs.sh
1 #!/bin/sh
2
3 #  Make PNG files from regtests
4 #
5 #  Usage:  ./make-regtest-pngs.sh -j CPUs -o/-n
6 #
7 #    where -j specifies the number of parallel processes to run
8 #    (normally CPUs+1).  e.g.:
9 #
10 #    ./make-regtest-pngs.sh -j9
11 #
12 #   -o means build an old regtest set - the PNGs go in the old-regtest-results
13 #   directory
14 #
15 #   -n means build a new regtest set - the PNGs go in the new-regtest-results
16 #   directory
17
18 cpu_count=1
19
20 while getopts "j:on" opts; do
21     if [ "$opts" = "j" ]; then
22         cpu_count=$OPTARG
23     fi
24
25     if [ "$opts" = "o" ]; then
26         file_loc="old-regtest-results"
27     fi
28
29     if [ "$opts" = "n" ]; then
30         file_loc="new-regtest-results"
31         do_compare="y"
32     fi
33 done
34
35 if [ -z "$file_loc" ]; then
36     echo "Must specify old (-o) or new (-n) regtest PNG creation on command line"
37     exit 1
38 fi
39
40 rm -rf $LILYPOND_BUILD_DIR/out-png-check/$file_loc
41 mkdir -p $LILYPOND_BUILD_DIR/out-png-check/$file_loc
42 cd $LILYPOND_BUILD_DIR/out-png-check/$file_loc
43 ls $LILYPOND_GIT/input/regression/*.ly > dir.txt
44 $LILYPOND_BUILD_DIR/out/bin/lilypond --png --relocate \
45     -dinclude-settings=$LILYPOND_GIT/scripts/auxiliar/NoTagline.ly \
46     -djob-count=$cpu_count -dread-file-list "dir.txt"
47 rm -rf dir.txt
48 rm -rf *.log
49
50 if [ -n "$do_compare" ]; then
51     cd ..
52     rm -rf regtest-diffs
53     mkdir -p regtest-diffs
54     diff_count=0
55     for filename in new-regtest-results/*.png; do
56         trimFile=$(basename $filename)
57         if [ -e old-regtest-results/$trimFile ]; then
58             convert new-regtest-results/$trimFile -level 50%  NewTest.png
59             convert old-regtest-results/$trimFile -level 50%  OldTest.png
60             difference=$(compare -metric AE NewTest.png OldTest.png null: 2>&1 )
61             if [ $? -gt 0 ];then
62                 difference=9999
63             fi
64             if [ $difference -gt 1 ];then
65                 echo $trimFile": "$difference" differences"
66                 compare -dissimilarity-threshold 1 \
67                     new-regtest-results/$trimFile \
68                     old-regtest-results/$trimFile  regtest-diffs/$trimFile
69                 convert regtest-diffs/$trimFile -trim regtest-diffs/$trimFile
70                 diff_count=$(($diff_count+1))
71             fi
72         else
73             echo "old-regtest-results/"$trimFile" does not exist"
74         fi
75     done
76     rm -rf NewTest.png
77     rm -rf OldTest.png
78     echo $diff_count "differences found."
79 fi