OSDN Git Service

設定変更。
[wordring-tm/wordring-tm.git] / third-party / tidy-html5-master / test / cmp.sh
1 #!/bin/sh
2 #< cmp.sh - 20140805
3 # If you have the tidied HTML output from two version of 'tidy' then 
4 # this can COMPARE the files ONE BY ONE
5 #
6 BN=`basename $0`
7
8 TMPDIR1=$1
9 TMPDIR2=$2
10 OUTLOG="temp.diff"
11
12 usage()
13 {
14         echo ""
15         echo "Usage: ./$BN directory1 directory2"
16         echo ""
17         echo "$BN: If you have the tidied HTML output from two version of 'tidy' then "
18         echo "$BN: this can COMPARE the html files ONE BY ONE, output to $OUTLOG"
19         echo ""
20 }
21
22 if [ -z "$TMPDIR1" ] || [ -z "$TMPDIR2" ] || [ "$TMPDIR1" = "--help" ] || [ "$TMPDIR1" = "-h" ] || [ "$TMPDIR1" = "-?" ]; then
23         usage
24         exit 1
25 fi
26
27
28 if [ ! -d "$TMPDIR1" ]; then
29         usage
30         echo "$BN: Can NOT locate directory '$TMPDIR1'!"
31         exit 1
32 fi
33
34 if [ ! -d "$TMPDIR2" ]; then
35         usage
36         exit 1
37 fi
38
39 shift
40 shift
41
42 TMPCNT1=0
43 TMPCNT2=0
44 SAMECNT=0
45 DIFFCNT=0
46
47 for fil in $TMPDIR1/*.html; do
48         TMPCNT1=`expr $TMPCNT1 + 1`
49 done
50
51 for fil in $TMPDIR2/*.html; do
52         TMPCNT2=`expr $TMPCNT2 + 1`
53 done
54
55 echo "$BN: Found $TMPCNT1 html files in $TMPDIR1"
56 echo "$BN: Found $TMPCNT2 html files in $TMPDIR2"
57
58 if [ -f "$OUTLOG" ]; then
59         rm -f $OUTLOG
60 fi
61
62 echo "$BN: Found $TMPCNT1 html files in $TMPDIR1" >> $OUTLOG
63 echo "$BN: Found $TMPCNT2 html files in $TMPDIR2" >> $OUTLOG
64
65 for fil in $TMPDIR1/*.html; do
66         bfil=`basename $fil`
67         if [ -f "$TMPDIR2/$bfil" ]; then
68                 diff -uw $TMPDIR1/$bfil $TMPDIR2/$bfil >> $OUTLOG
69                 if [ "$?" = "0" ]; then
70                         echo "diff -uw $TMPDIR1/$bfil $TMPDIR2/$bfil are the SAME" >> $OUTLOG
71                         SAMECNT=`expr $SAMECNT + 1`
72                 else
73                         DIFFCNT=`expr $DIFFCNT + 1`
74                 fi
75         else
76                 echo "$BN: File $bfil not found the 2" >> $OUTLOG
77         fi
78 done
79 TOTCNT=`expr $SAMECNT + $DIFFCNT`
80 echo "$BN: Of the $TOTCNT compares made, $SAMECNT are the SAME, $DIFFCNT are DIFFERENT"
81 echo "$BN: Of the $TOTCNT compares made, $SAMECNT are the SAME, $DIFFCNT are DIFFERENT" >> $OUTLOG
82
83 echo "$BN: Results are in $OUTLOG"
84
85
86 # eof
87