| 1 |
# |
| •2 |
# Part of the ht://Dig package <https://htdig.sourceforge.net/> |
| 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_htsearch,v 1.14 2004/05/28 13:15:30 lha Exp $ |
| 9 |
# |
| 10 |
|
| 11 |
test_functions_action=--start-apache |
| 12 |
. ./test_functions |
| 13 |
|
| 14 |
config=$testdir/conf/htdig.conf |
| 15 |
tmp=/tmp/t_htsearch$$ |
| 16 |
|
| 17 |
$htdig "$@" -t -i -c $config |
| 18 |
$htpurge -c $config |
| 19 |
|
| 20 |
test_functions_action=--stop-apache |
| 21 |
. ./test_functions |
| 22 |
|
| 23 |
try() { |
| 24 |
comment="$1" |
| 25 |
shift |
| 26 |
query="$1" |
| 27 |
shift |
| 28 |
$htsearch -c $config "$query" > $tmp |
| 29 |
for pattern |
| 30 |
do |
| 31 |
if grep "$pattern" $tmp > /dev/null |
| 32 |
then : |
| 33 |
else |
| 34 |
$htsearch -v -c $config "$query" > /dev/null |
| 35 |
echo "Output doesn't match \"$pattern\"" |
| 36 |
fail "$htsearch -c $config '$query' >> $tmp -- |
| 37 |
$comment" |
| 38 |
fi |
| 39 |
done |
| 40 |
} |
| 41 |
|
| 42 |
try "Simple search for 'also'" \ |
| 43 |
"words=also" \ |
| 44 |
'4 matches' 'bad_local.htm' 'site2.html' 'script.html' 'site4.html' |
| 45 |
|
| 46 |
try "Implicit and search with two words 'also movies'" \ |
| 47 |
"method=and&words=also+movies" \ |
| 48 |
'1 match' 'site2.html' |
| 49 |
|
| 50 |
try "Explicit and search with two words 'also movies'" \ |
| 51 |
"method=boolean&words=also+and+movies" \ |
| 52 |
'1 match' 'site2.html' |
| 53 |
|
| 54 |
try "Implicit or search for 'also distribution'" \ |
| 55 |
"method=or&words=also+distribution" \ |
| 56 |
'5 matches' 'bad_local.htm' 'site2.html' 'script.html' 'site4.html' 'site%201.html' |
| 57 |
|
| 58 |
try "Explicit or search for 'also distribution'" \ |
| 59 |
"method=boolean&words=also+or+distribution" \ |
| 60 |
'5 matches' 'bad_local.htm' 'site2.html' 'script.html' 'site4.html' 'site%201.html' |
| 61 |
|
| 62 |
try "Boolean and/or mixed 'also or distribution and ltd'" \ |
| 63 |
"method=boolean&words=also+or+distribution+and+ltd" \ |
| 64 |
'5 matches' 'bad_local.htm' 'site2.html' 'script.html' 'site4.html' 'site%201.html' |
| 65 |
|
| 66 |
try "Boolean explicit priority '(also or distribution) and ltd'" \ |
| 67 |
"method=boolean&words=(also+or+distribution)+and+ltd" \ |
| 68 |
'2 matches' 'script.html' 'site%201.html' |
| 69 |
|
| 70 |
try "Wildcard search for '*'" \ |
| 71 |
"method=and&words=*" \ |
| 72 |
'10 matches' 'set1/bad_local.htm' 'set1/title.html' 'set1/site2.html' 'set1/script.html' 'set1/"' 'set1/site3.html' 'set1/site4.html' 'set1/site%201.html' 'set1/sub%2520dir/' 'set1/sub%2520dir/empty%20file.html' |
| 73 |
|
| 74 |
try "Phrase search for '\"who offer\" and \"loans to graduate\"'" \ |
| 75 |
"method=boolean&words=%22who+offer%22+and+%22loans+to+graduate%22" \ |
| 76 |
'1 match' 'site4.html' |
| 77 |
|
| 78 |
try "Phrase search for 'may be deferred' -- stop words at start" \ |
| 79 |
"method=boolean&words=%22may+be+deferred%22" \ |
| 80 |
'1 match' 'site4.html' '<strong>may be deferred</strong>' |
| 81 |
|
| 82 |
try "Phrase search for 'Repayment may be' -- stop words at end" \ |
| 83 |
"method=boolean&words=%22Repayment+may+be%22" \ |
| 84 |
'1 match' 'site4.html' '<strong>Repayment may be</strong>' |
| 85 |
|
| 86 |
# This test fails |
| 87 |
# |
| 88 |
#try "Phrase search for 'may be' -- all stop words" \ |
| 89 |
# "method=boolean&words=%22may+be%22" \ |
| 90 |
# '1 match' 'site4.html' |
| 91 |
|
| 92 |
try "Phrase search for 'Repayment may be deferred' -- stop words in middle" \ |
| 93 |
"method=boolean&words=%22Repayment+may+be+deferred%22" \ |
| 94 |
'1 match' 'site4.html' '<strong>Repayment may be deferred</strong>' |
| 95 |
|
| 96 |
try "Phrase search for 'Repayment deferred' -- phrase interrupted by stop words" \ |
| 97 |
"method=boolean&words=%22Repayment+deferred%22" \ |
| 98 |
'No match' |
| 99 |
|
| 100 |
try "Syntax error: finishing with 'and'" \ |
| 101 |
"method=boolean&words=also+and" \ |
| 102 |
'Expected a search word, a quoted phrase or a boolean expression between () at the end' |
| 103 |
|
| 104 |
try "Syntax error: excess open brackets" \ |
| 105 |
"method=boolean&words=(also+or+distribution" \ |
| 106 |
"Expected ')' at the end" |
| 107 |
|
| 108 |
try "Syntax error: excess close brackets" \ |
| 109 |
"method=boolean&words=also+or+distribution)" \ |
| 110 |
"Expected end of expression instead of ')'" |
| 111 |
|
| 112 |
try "Syntax error: missing end quote" \ |
| 113 |
"method=boolean&words=also+or+%22distribution" \ |
| 114 |
'Expected quotes at the end' |
| 115 |
|
| 116 |
try "Unrestricted search for 'group'" \ |
| 117 |
"method=and&words=group" \ |
| 118 |
'4 matches' 'script.html' 'bad_local.htm' 'site3.html' 'site4.html' |
| 119 |
|
| 120 |
try "Field-restricted search for 'author:group'" \ |
| 121 |
"method=and&words=author:group" \ |
| 122 |
'1 match' 'script.html' |
| 123 |
|
| 124 |
try "Field-restricted search for 'text:group'" \ |
| 125 |
"method=and&words=text:group" \ |
| 126 |
'3 matches' 'bad_local.htm' 'site3.html' 'site4.html' |
| 127 |
|
| 128 |
try "Checking prefix parsing using 'text: group'" \ |
| 129 |
"method=and&words=text:%20group" \ |
| 130 |
'1 match' 'script.html' |
| 131 |
|
| 132 |
try "Checking prefix parsing using 'text::group'" \ |
| 133 |
"method=and&words=text::group" \ |
| 134 |
'1 match' 'script.html' |
| 135 |
|
| 136 |
try "Checking prefix parsing using 'unknown:group'" \ |
| 137 |
"method=any&words=unknown:group" \ |
| 138 |
'5 matches' 'script.html' 'bad_local.htm' 'site3.html' 'site4.html' 'set1/"' |
| 139 |
|
| 140 |
try "Field-restricted search for 'descr:cost'" \ |
| 141 |
"method=and&words=descr:cost" \ |
| 142 |
'1 match' 'script.html' |
| 143 |
|
| 144 |
config=$testdir/conf/htdig.conf3 |
| 145 |
|
| 146 |
try "Testing boolean_keywords and search_rewrite_urls" \ |
| 147 |
"method=boolean&words=also+ou+distribution+et+ltd" \ |
| 148 |
'5 matches' 'bad_local.htm' 'place2.html' 'script.html' 'place4.html' 'place%201.html' |
| 149 |
|
| 150 |
try "Testing boolean_syntax_errors" \ |
| 151 |
"method=boolean&words=ou+distribution" \ |
| 152 |
"Attendait un mot au lieu de '|' ou 'ou'" |
| 153 |
|
| 154 |
try "Testing htdig's noindex_start/end overlapping" \ |
| 155 |
"words=considered" \ |
| 156 |
'1 match' 'script.html' |
| 157 |
|
| 158 |
try "Testing htdig's noindex_start/end nested" \ |
| 159 |
"words=neglected" \ |
| 160 |
'No match' |
| 161 |
|
| 162 |
rm -f $tmp |
| 163 |
|
| 164 |
exit 0 |