Debian Codegraph @

test/t_parsing

raw ◀ ▶
Source reconstructed at patch state 0 of 1 — not the installed (fully patched) source.
1 Debian patch touch this file
1 #
2 # Part of the ht://Dig package <http://www.htdig.org/>
3 # Copyright (c) 1999-2004 The ht://Dig Group
4 # For copyright details, see the file COPYING in your distribution
5 # or the GNU Library General Public License (LGPL) version 2 or later
6 # <http://www.gnu.org/copyleft/lgpl.html>
7 #
8 # $Id: t_parsing,v 1.4 2004/05/28 13:15:30 lha Exp $
9 #
10
11
12 # Tests (or should eventually test) the following config attributes:
13 # description_meta_tag_names
14 # ignore_alt_text
15 # max_doc_size
16 # max_keywords
17 # max_meta_description_length
18 # max_description_length
19 # max_descriptions
20 # max_head_length
21 # noindex_end
22 # noindex_start
23 # external_parsers
24 # external_protocols
25 # use_meta_description
26
27
28 test_functions_action=--start-apache
29 . ./test_functions
30
31 config=$testdir/conf/htdig.conf.tmp
32 tmp=/tmp/t_htsearch$$
33
34 # set up config file with chosen non-default values
35 cp $testdir/conf/htdig.conf $config
36
37 try() {
38 comment="$1"
39 shift
40 query="$1"
41 shift
42 $htsearch -c $config "$query" > $tmp
43 for pattern
44 do
45 if grep "$pattern" $tmp > /dev/null
46 then :
47 else
48 $htsearch -v -c $config "$query" > /dev/null
49 echo "Output doesn't match \"$pattern\""
50 fail "$htsearch -c $config '$query' >> $tmp --
51 $comment"
52 fi
53 done
54 }
55
56
57 # Tests (or should eventually test) the following config attributes:
58 # description_meta_tag_names
59 # ignore_alt_text
60 # max_doc_size
61 # max_keywords
62 # max_meta_description_length
63 # max_description_length (May put in t_templates)
64 # max_descriptions (May put in t_templates)
65 # max_head_length
66 # noindex_end
67 # noindex_start
68 # external_parsers (TODO)
69 # external_protocols
70 # use_meta_description
71
72 $htdig "$@" -t -i -c $config || fail "Couldn't do first dig"
73 $htpurge -c $config || fail "Couldn't do first purge"
74
75 try "Search for alt text 'earth'" \
76 "words=earth" \
77 '1 matches' 'site3.html'
78
79 try "'claims and collections', unlimited doc size" \
80 "words=%22claims+and+collections%22" \
81 '1 matches' 'site4.html'
82
83 try "Search for keyword 'martial', default max_keywords" \
84 "words=martial" \
85 '1 matches' 'site2.html'
86
87 try "Search for 'service', default noindex_start/end" \
88 "words=technical" \
89 '1 matches' 'site%201.html'
90
91 set_attr use_meta_description true
92 try "Search for 'call handling' with default max_meta_description_length" \
93 "words=%22call+handling%22" \
94 '1 matches' 'script.html' 'call handling.*signalling'
95
96 set_attr ignore_alt_text true
97 set_attr max_doc_size 15112
98 set_attr max_keywords 5
99 set_attr noindex_start "'Software Distribution'"
100 set_attr noindex_end "'Contact Information'"
101 set_attr max_meta_description_length 80
102 set_attr description_meta_tag_names "description generator"
103 set_attr max_head_length 30
104
105 $htdig "$@" -t -i -c $config || fail "Couldn't do second dig"
106 $htpurge -c $config || fail "Couldn't do second purge"
107
108 try "Search for alt text 'earth' with ignore_alt_text=true" \
109 "words=earth" \
110 'No matches'
111
112 try "'claims and collections', max_doc_size 15112" \
113 "words=%22claims+and+collections%22" \
114 '1 matches' 'site4.html'
115
116 # (Martial is 6th keyword listed in site 2, but "Fu" is too short and omitted.)
117 try "Search for keyword 'martial', max_keywords = 5" \
118 "words=martial" \
119 'No matches'
120
121 # Only occurrence of "technical" is between noindex_start and _end in site 1
122 try "Search for 'technical', noindex_start=Software Distribution, noindex_end=Contact Information" \
123 "words=technical" \
124 'No matches'
125
126 # Visitor occurs after noindex_end
127 try "Search for 'visitor', noindex_start=Software Distribution, noindex_end=Contact Information" \
128 "words=visitor" \
129 '2 matches' 'site%201.html' 'site3.html'
130
131 # Displaying meta description instead of excerpt, check it is truncated
132 try "Search for 'call handling' with max_meta_description_length=80" \
133 "words=%22call+handling%22" \
134 '1 matches' 'script.html' 'means of<br>'
135
136 # Check <meta name="generator"...> counts as a description
137 try "Search for 'category', description_meta_tag_names includes 'generator'" \
138 "words=category" \
139 '1 matches' 'site3.html' 'FrontPage'
140
141 # Check that only specified number of bytes of header is stored.
142 # Header size is rounded up to contain the whole of the last word.
143 try "Search for 'also', max_head_length=30" \
144 "words=also" \
145 '4 matches' 'bad_local.htm' 'site2.html' 'script.html' 'site4.html' \
146 'WHERE.*Copyright<br>'
147
148 set_attr max_doc_size 15042
149 set_attr max_keywords 6
150 set_attr noindex_start "'software distribution'"
151 set_attr noindex_end "'contact information'"
152
153 $htdig "$@" -t -i -c $config || fail "Couldn't do third dig"
154 $htpurge -c $config || fail "Couldn't do third purge"
155
156 try "Search for keyword 'martial', max_keywords = 6" \
157 "words=martial" \
158 '1 matches' 'site2.html'
159
160 try "'claims and collections', max_doc_size 15042" \
161 "words=%22claims+and+collections%22" \
162 'No matches'
163
164 # Check noindex_start/end are case-insensitive
165 try "Search for 'technical', noindex_start=software distribution, noindex_end=contact information" \
166 "words=technical" \
167 'No matches'
168
169 PROTOCOL=my-protocol
170 echo '#!/bin/sh
171 echo "s 200"
172 echo "t text/html"
173 echo
174 echo "<html>$2</html>"' > $PROTOCOL
175 chmod 755 $PROTOCOL
176 set_attr external_protocols "echo: $PWD/$PROTOCOL"
177 set_attr start_url "echo:foo.html"
178 $htdig "$@" -t -i -c $config || fail "Couldn't do fourth dig"
179 try "trying external protocol echo" \
180 "words=foo" \
181 "1 matches" "echo:foo.html"
182
183
184 test_functions_action=--stop-apache
185 . ./test_functions
186
187 rm -f $tmp $PROTOCOL
188
189 exit 0