Improve scriptindex diagnostic messages
[xapian.git] / xapian-applications / omega / omegatest
blob66f51f07a00cce04a9d10d2fa43f16abb11be890
1 #!/bin/sh
2 # omegatest: Test omega CGI
4 # Copyright (C) 2015,2016,2017,2018 Olly Betts
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
19 # USA
20 set -e
22 : ${OMEGA=./omega}
23 : ${SCRIPTINDEX=./scriptindex}
25 # Suppress HTTP Content-Type header.
26 SERVER_PROTOCOL=INCLUDED
27 export SERVER_PROTOCOL
29 # Set up an empty database.
30 TEST_DB=test-db
31 rm -rf "$TEST_DB"
32 echo 'inmemory' > "$TEST_DB"
34 # Simple template which just shows the parsed query.
35 TEST_TEMPLATE=test-template
36 printf '$querydescription' > "$TEST_TEMPLATE"
38 TEST_INDEXSCRIPT=test-indexscript
40 OMEGA_CONFIG_FILE=test-omega.conf
41 export OMEGA_CONFIG_FILE
42 cat > "$OMEGA_CONFIG_FILE" <<__END__
43 database_dir .
44 template_dir .
45 log_dir tmplog
46 default_template $TEST_TEMPLATE
47 default_db $TEST_DB
48 __END__
50 failed=0
52 testcase() {
53 expected=$1
54 shift
55 # If there are no positional parameters, pass one as otherwise omega will
56 # wait for parameters on stdin.
57 [ "$#" != 0 ] || { set x dummy; shift; }
58 output=`$FAKETIME ${FAKE_NOW+"$FAKE_NOW"} "$OMEGA" "$@"`
59 if [ "$output" != "$expected" ] ; then
60 echo "$OMEGA $@:"
61 echo " expected: «$expected»"
62 echo " received: «$output»"
63 failed=`expr $failed + 1`
67 qtestcase() {
68 expected="Query($1)"
69 shift
70 testcase "$expected" "$@"
73 FAKETIME=
74 unset FAKE_NOW
76 # Test a few simple things.
77 qtestcase 'Zsimpl@1' P=simple
78 qtestcase '(chocolate@1 FILTER Tconfectionary/fudge)' P=Chocolate B=Tconfectionary/fudge
80 # Test date value ranges.
81 qtestcase 'VALUE_RANGE 0 2 ~' DATEVALUE=0 START=2000
82 qtestcase 'VALUE_RANGE 0 2 ~' DATEVALUE=0 START=200001
83 qtestcase 'VALUE_RANGE 0 2 ~' DATEVALUE=0 START=20000101
84 qtestcase 'VALUE_LE 1 1~' DATEVALUE=1 END=1999
85 qtestcase 'VALUE_LE 1 1~' DATEVALUE=1 END=199912
86 qtestcase 'VALUE_LE 1 1~' DATEVALUE=1 END=19991231
87 qtestcase 'VALUE_RANGE 2 201 ~' DATEVALUE=2 START=2010
88 qtestcase 'VALUE_RANGE 2 201 ~' DATEVALUE=2 START=201001
89 qtestcase 'VALUE_RANGE 2 201 ~' DATEVALUE=2 START=20100101
90 qtestcase 'VALUE_LE 3 198~' DATEVALUE=3 END=1989
91 qtestcase 'VALUE_LE 3 198~' DATEVALUE=3 END=198912
92 qtestcase 'VALUE_LE 3 198~' DATEVALUE=3 END=19891231
93 qtestcase 'VALUE_RANGE 4 1974 ~' DATEVALUE=4 START=1974
94 qtestcase 'VALUE_RANGE 4 1974 ~' DATEVALUE=4 START=197401
95 qtestcase 'VALUE_RANGE 4 1974 ~' DATEVALUE=4 START=19740101
96 qtestcase 'VALUE_LE 5 1974~' DATEVALUE=5 END=1974
97 qtestcase 'VALUE_LE 5 1974~' DATEVALUE=5 END=197412
98 qtestcase 'VALUE_LE 5 1974~' DATEVALUE=5 END=19741231
99 qtestcase 'VALUE_RANGE 6 20151 ~' DATEVALUE=6 START=201510
100 qtestcase 'VALUE_RANGE 6 20151 ~' DATEVALUE=6 START=20151001
101 qtestcase 'VALUE_LE 7 19870~' DATEVALUE=7 END=198709
102 qtestcase 'VALUE_LE 7 19870~' DATEVALUE=7 END=19870930
103 qtestcase 'VALUE_RANGE 8 201512 ~' DATEVALUE=8 START=201512
104 qtestcase 'VALUE_RANGE 8 201512 ~' DATEVALUE=8 START=20151201
105 qtestcase 'VALUE_LE 9 201511~' DATEVALUE=9 END=201511
106 qtestcase 'VALUE_LE 9 201511~' DATEVALUE=9 END=20151130
107 qtestcase 'VALUE_RANGE 10 2015021 ~' DATEVALUE=10 START=20150210
108 qtestcase 'VALUE_RANGE 10 2000022 ~' DATEVALUE=10 START=20000220
109 qtestcase 'VALUE_LE 11 19840401~' DATEVALUE=11 END=19840401
110 qtestcase 'VALUE_LE 11 19881128~' DATEVALUE=11 END=19881128
112 # Leap year tests:
113 qtestcase 'VALUE_LE 1 201502~' DATEVALUE=1 END=20150228
114 qtestcase 'VALUE_LE 1 198802~' DATEVALUE=1 END=19880229
115 qtestcase 'VALUE_LE 1 19880228~' DATEVALUE=1 END=19880228
116 qtestcase 'VALUE_LE 1 200002~' DATEVALUE=1 END=20000229
117 qtestcase 'VALUE_LE 1 20000228~' DATEVALUE=1 END=20000228
118 # FIXME: These two currently require 64-bit time_t:
119 #qtestcase 'VALUE_LE 1 190002~' DATEVALUE=1 END=19000228
120 #qtestcase 'VALUE_LE 1 210002~' DATEVALUE=1 END=21000228
122 # Month starts and ends:
123 qtestcase 'VALUE_RANGE 0 2015 201501~' DATEVALUE=0 START=20150101 END=20150131
124 qtestcase 'VALUE_RANGE 0 2015 20150130~' DATEVALUE=0 START=20150101 END=20150130
125 qtestcase 'VALUE_RANGE 0 201502 201502~' DATEVALUE=0 START=20150201 END=20150228
126 qtestcase 'VALUE_RANGE 0 201502 20150227~' DATEVALUE=0 START=20150201 END=20150227
127 qtestcase 'VALUE_RANGE 0 201503 201503~' DATEVALUE=0 START=20150301 END=20150331
128 qtestcase 'VALUE_RANGE 0 201503 20150330~' DATEVALUE=0 START=20150301 END=20150330
129 qtestcase 'VALUE_RANGE 0 201504 201504~' DATEVALUE=0 START=20150401 END=20150430
130 qtestcase 'VALUE_RANGE 0 201504 2015042~' DATEVALUE=0 START=20150401 END=20150429
131 qtestcase 'VALUE_RANGE 0 201505 201505~' DATEVALUE=0 START=20150501 END=20150531
132 qtestcase 'VALUE_RANGE 0 201505 20150530~' DATEVALUE=0 START=20150501 END=20150530
133 qtestcase 'VALUE_RANGE 0 201506 201506~' DATEVALUE=0 START=20150601 END=20150630
134 qtestcase 'VALUE_RANGE 0 201506 2015062~' DATEVALUE=0 START=20150601 END=20150629
135 qtestcase 'VALUE_RANGE 0 201507 201507~' DATEVALUE=0 START=20150701 END=20150731
136 qtestcase 'VALUE_RANGE 0 201507 20150730~' DATEVALUE=0 START=20150701 END=20150730
137 qtestcase 'VALUE_RANGE 0 201508 201508~' DATEVALUE=0 START=20150801 END=20150831
138 qtestcase 'VALUE_RANGE 0 201508 20150830~' DATEVALUE=0 START=20150801 END=20150830
139 qtestcase 'VALUE_RANGE 0 201509 20150~' DATEVALUE=0 START=20150901 END=20150930
140 qtestcase 'VALUE_RANGE 0 201509 2015092~' DATEVALUE=0 START=20150901 END=20150929
141 qtestcase 'VALUE_RANGE 0 20151 201510~' DATEVALUE=0 START=20151001 END=20151031
142 qtestcase 'VALUE_RANGE 0 20151 20151030~' DATEVALUE=0 START=20151001 END=20151030
143 qtestcase 'VALUE_RANGE 0 201511 201511~' DATEVALUE=0 START=20151101 END=20151130
144 qtestcase 'VALUE_RANGE 0 201511 2015112~' DATEVALUE=0 START=20151101 END=20151129
145 qtestcase 'VALUE_RANGE 0 201512 2015~' DATEVALUE=0 START=20151201 END=20151231
146 qtestcase 'VALUE_RANGE 0 201512 20151230~' DATEVALUE=0 START=20151201 END=20151230
148 # Forward spans:
149 qtestcase 'VALUE_RANGE 0 20151104 20151106~' DATEVALUE=0 START=20151104 SPAN=3
150 qtestcase 'VALUE_RANGE 0 20141104 20151103~' DATEVALUE=0 START=20141104 SPAN=365
152 # Backward spans:
153 qtestcase 'VALUE_RANGE 0 20151104 20151106~' DATEVALUE=0 END=20151106 SPAN=3
154 qtestcase 'VALUE_RANGE 0 20141104 20151103~' DATEVALUE=0 END=20151103 SPAN=365
156 # Check that if START, END and SPAN are all passed, START is ignored:
157 qtestcase 'VALUE_RANGE 0 20151104 20151106~' DATEVALUE=0 START=19700101 END=20151106 SPAN=3
159 # Tests of term-based date range filtering:
161 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999) OR Dlatest)' END=19991231
162 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989) OR Dlatest)' END=19891231
163 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974) OR Dlatest)' END=19741231
164 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR M198701 OR M198702 OR M198703 OR M198704 OR M198705 OR M198706 OR M198707 OR M198708 OR M198709) OR Dlatest)' END=19870930
165 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999 OR Y2000 OR Y2001 OR Y2002 OR Y2003 OR Y2004 OR Y2005 OR Y2006 OR Y2007 OR Y2008 OR Y2009 OR Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR M201511) OR Dlatest)' END=20151130
166 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR M198401 OR M198402 OR M198403 OR D19840401) OR Dlatest)' END=19840401
167 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR M198801 OR M198802 OR M198803 OR M198804 OR M198805 OR M198806 OR M198807 OR M198808 OR M198809 OR M198810 OR D19881101 OR D19881102 OR D19881103 OR D19881104 OR D19881105 OR D19881106 OR D19881107 OR D19881108 OR D19881109 OR D19881110 OR D19881111 OR D19881112 OR D19881113 OR D19881114 OR D19881115 OR D19881116 OR D19881117 OR D19881118 OR D19881119 OR D19881120 OR D19881121 OR D19881122 OR D19881123 OR D19881124 OR D19881125 OR D19881126 OR D19881127 OR D19881128) OR Dlatest)' END=19881128
169 # Leap year tests:
170 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999 OR Y2000 OR Y2001 OR Y2002 OR Y2003 OR Y2004 OR Y2005 OR Y2006 OR Y2007 OR Y2008 OR Y2009 OR Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR M201501 OR M201502) OR Dlatest)' END=20150228
171 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR M198801 OR M198802) OR Dlatest)' END=19880229
172 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR M198801 OR D19880201 OR D19880202 OR D19880203 OR D19880204 OR D19880205 OR D19880206 OR D19880207 OR D19880208 OR D19880209 OR D19880210 OR D19880211 OR D19880212 OR D19880213 OR D19880214 OR D19880215 OR D19880216 OR D19880217 OR D19880218 OR D19880219 OR D19880220 OR D19880221 OR D19880222 OR D19880223 OR D19880224 OR D19880225 OR D19880226 OR D19880227 OR D19880228) OR Dlatest)' END=19880228
173 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999 OR M200001 OR M200002) OR Dlatest)' END=20000229
174 qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999 OR M200001 OR D20000201 OR D20000202 OR D20000203 OR D20000204 OR D20000205 OR D20000206 OR D20000207 OR D20000208 OR D20000209 OR D20000210 OR D20000211 OR D20000212 OR D20000213 OR D20000214 OR D20000215 OR D20000216 OR D20000217 OR D20000218 OR D20000219 OR D20000220 OR D20000221 OR D20000222 OR D20000223 OR D20000224 OR D20000225 OR D20000226 OR D20000227 OR D20000228) OR Dlatest)' END=20000228
175 # FIXME: These two currently require 64-bit time_t:
176 #qtestcase 'Dlatest' END=19000228 # Assumed start is 19700101
177 #qtestcase '((Y1970 OR Y1971 OR Y1972 OR Y1973 OR Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999 OR Y2000 OR Y2001 OR Y2002 OR Y2003 OR Y2004 OR Y2005 OR Y2006 OR Y2007 OR Y2008 OR Y2009 OR Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR Y2015 OR Y2016 OR Y2017 OR Y2018 OR Y2019 OR Y2020 OR Y2021 OR Y2022 OR Y2023 OR Y2024 OR Y2025 OR Y2026 OR Y2027 OR Y2028 OR Y2029 OR Y2030 OR Y2031 OR Y2032 OR Y2033 OR Y2034 OR Y2035 OR Y2036 OR Y2037 OR Y2038 OR Y2039 OR Y2040 OR Y2041 OR Y2042 OR Y2043 OR Y2044 OR Y2045 OR Y2046 OR Y2047 OR Y2048 OR Y2049 OR Y2050 OR Y2051 OR Y2052 OR Y2053 OR Y2054 OR Y2055 OR Y2056 OR Y2057 OR Y2058 OR Y2059 OR Y2060 OR Y2061 OR Y2062 OR Y2063 OR Y2064 OR Y2065 OR Y2066 OR Y2067 OR Y2068 OR Y2069 OR Y2070 OR Y2071 OR Y2072 OR Y2073 OR Y2074 OR Y2075 OR Y2076 OR Y2077 OR Y2078 OR Y2079 OR Y2080 OR Y2081 OR Y2082 OR Y2083 OR Y2084 OR Y2085 OR Y2086 OR Y2087 OR Y2088 OR Y2089 OR Y2090 OR Y2091 OR Y2092 OR Y2093 OR Y2094 OR Y2095 OR Y2096 OR Y2097 OR Y2098 OR Y2099 OR M210001 OR M210002) OR Dlatest)' END=21000228
179 # Month starts and ends:
180 qtestcase '(M201501 OR Dlatest)' START=20150101 END=20150131
181 qtestcase '((D20150101 OR D20150102 OR D20150103 OR D20150104 OR D20150105 OR D20150106 OR D20150107 OR D20150108 OR D20150109 OR D20150110 OR D20150111 OR D20150112 OR D20150113 OR D20150114 OR D20150115 OR D20150116 OR D20150117 OR D20150118 OR D20150119 OR D20150120 OR D20150121 OR D20150122 OR D20150123 OR D20150124 OR D20150125 OR D20150126 OR D20150127 OR D20150128 OR D20150129 OR D20150130) OR Dlatest)' START=20150101 END=20150130
182 qtestcase '(M201502 OR Dlatest)' START=20150201 END=20150228
183 qtestcase '((D20150201 OR D20150202 OR D20150203 OR D20150204 OR D20150205 OR D20150206 OR D20150207 OR D20150208 OR D20150209 OR D20150210 OR D20150211 OR D20150212 OR D20150213 OR D20150214 OR D20150215 OR D20150216 OR D20150217 OR D20150218 OR D20150219 OR D20150220 OR D20150221 OR D20150222 OR D20150223 OR D20150224 OR D20150225 OR D20150226 OR D20150227) OR Dlatest)' START=20150201 END=20150227
184 qtestcase '(M201503 OR Dlatest)' START=20150301 END=20150331
185 qtestcase '((D20150301 OR D20150302 OR D20150303 OR D20150304 OR D20150305 OR D20150306 OR D20150307 OR D20150308 OR D20150309 OR D20150310 OR D20150311 OR D20150312 OR D20150313 OR D20150314 OR D20150315 OR D20150316 OR D20150317 OR D20150318 OR D20150319 OR D20150320 OR D20150321 OR D20150322 OR D20150323 OR D20150324 OR D20150325 OR D20150326 OR D20150327 OR D20150328 OR D20150329 OR D20150330) OR Dlatest)' START=20150301 END=20150330
186 qtestcase '(M201504 OR Dlatest)' START=20150401 END=20150430
187 qtestcase '((D20150401 OR D20150402 OR D20150403 OR D20150404 OR D20150405 OR D20150406 OR D20150407 OR D20150408 OR D20150409 OR D20150410 OR D20150411 OR D20150412 OR D20150413 OR D20150414 OR D20150415 OR D20150416 OR D20150417 OR D20150418 OR D20150419 OR D20150420 OR D20150421 OR D20150422 OR D20150423 OR D20150424 OR D20150425 OR D20150426 OR D20150427 OR D20150428 OR D20150429) OR Dlatest)' START=20150401 END=20150429
188 qtestcase '(M201505 OR Dlatest)' START=20150501 END=20150531
189 qtestcase '((D20150501 OR D20150502 OR D20150503 OR D20150504 OR D20150505 OR D20150506 OR D20150507 OR D20150508 OR D20150509 OR D20150510 OR D20150511 OR D20150512 OR D20150513 OR D20150514 OR D20150515 OR D20150516 OR D20150517 OR D20150518 OR D20150519 OR D20150520 OR D20150521 OR D20150522 OR D20150523 OR D20150524 OR D20150525 OR D20150526 OR D20150527 OR D20150528 OR D20150529 OR D20150530) OR Dlatest)' START=20150501 END=20150530
190 qtestcase '(M201506 OR Dlatest)' START=20150601 END=20150630
191 qtestcase '((D20150601 OR D20150602 OR D20150603 OR D20150604 OR D20150605 OR D20150606 OR D20150607 OR D20150608 OR D20150609 OR D20150610 OR D20150611 OR D20150612 OR D20150613 OR D20150614 OR D20150615 OR D20150616 OR D20150617 OR D20150618 OR D20150619 OR D20150620 OR D20150621 OR D20150622 OR D20150623 OR D20150624 OR D20150625 OR D20150626 OR D20150627 OR D20150628 OR D20150629) OR Dlatest)' START=20150601 END=20150629
192 qtestcase '(M201507 OR Dlatest)' START=20150701 END=20150731
193 qtestcase '((D20150701 OR D20150702 OR D20150703 OR D20150704 OR D20150705 OR D20150706 OR D20150707 OR D20150708 OR D20150709 OR D20150710 OR D20150711 OR D20150712 OR D20150713 OR D20150714 OR D20150715 OR D20150716 OR D20150717 OR D20150718 OR D20150719 OR D20150720 OR D20150721 OR D20150722 OR D20150723 OR D20150724 OR D20150725 OR D20150726 OR D20150727 OR D20150728 OR D20150729 OR D20150730) OR Dlatest)' START=20150701 END=20150730
194 qtestcase '(M201508 OR Dlatest)' START=20150801 END=20150831
195 qtestcase '((D20150801 OR D20150802 OR D20150803 OR D20150804 OR D20150805 OR D20150806 OR D20150807 OR D20150808 OR D20150809 OR D20150810 OR D20150811 OR D20150812 OR D20150813 OR D20150814 OR D20150815 OR D20150816 OR D20150817 OR D20150818 OR D20150819 OR D20150820 OR D20150821 OR D20150822 OR D20150823 OR D20150824 OR D20150825 OR D20150826 OR D20150827 OR D20150828 OR D20150829 OR D20150830) OR Dlatest)' START=20150801 END=20150830
196 qtestcase '(M201509 OR Dlatest)' START=20150901 END=20150930
197 qtestcase '((D20150901 OR D20150902 OR D20150903 OR D20150904 OR D20150905 OR D20150906 OR D20150907 OR D20150908 OR D20150909 OR D20150910 OR D20150911 OR D20150912 OR D20150913 OR D20150914 OR D20150915 OR D20150916 OR D20150917 OR D20150918 OR D20150919 OR D20150920 OR D20150921 OR D20150922 OR D20150923 OR D20150924 OR D20150925 OR D20150926 OR D20150927 OR D20150928 OR D20150929) OR Dlatest)' START=20150901 END=20150929
198 qtestcase '(M201510 OR Dlatest)' START=20151001 END=20151031
199 qtestcase '((D20151001 OR D20151002 OR D20151003 OR D20151004 OR D20151005 OR D20151006 OR D20151007 OR D20151008 OR D20151009 OR D20151010 OR D20151011 OR D20151012 OR D20151013 OR D20151014 OR D20151015 OR D20151016 OR D20151017 OR D20151018 OR D20151019 OR D20151020 OR D20151021 OR D20151022 OR D20151023 OR D20151024 OR D20151025 OR D20151026 OR D20151027 OR D20151028 OR D20151029 OR D20151030) OR Dlatest)' START=20151001 END=20151030
200 qtestcase '(M201511 OR Dlatest)' START=20151101 END=20151130
201 qtestcase '((D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128 OR D20151129) OR Dlatest)' START=20151101 END=20151129
202 qtestcase '(M201512 OR Dlatest)' START=20151201 END=20151231
203 qtestcase '((D20151201 OR D20151202 OR D20151203 OR D20151204 OR D20151205 OR D20151206 OR D20151207 OR D20151208 OR D20151209 OR D20151210 OR D20151211 OR D20151212 OR D20151213 OR D20151214 OR D20151215 OR D20151216 OR D20151217 OR D20151218 OR D20151219 OR D20151220 OR D20151221 OR D20151222 OR D20151223 OR D20151224 OR D20151225 OR D20151226 OR D20151227 OR D20151228 OR D20151229 OR D20151230) OR Dlatest)' START=20151201 END=20151230
205 # Forward spans:
206 qtestcase '((D20151104 OR D20151105 OR D20151106 OR D20151107) OR Dlatest)' START=20151104 SPAN=3
207 qtestcase '((D20141104 OR D20141105 OR D20141106 OR D20141107 OR D20141108 OR D20141109 OR D20141110 OR D20141111 OR D20141112 OR D20141113 OR D20141114 OR D20141115 OR D20141116 OR D20141117 OR D20141118 OR D20141119 OR D20141120 OR D20141121 OR D20141122 OR D20141123 OR D20141124 OR D20141125 OR D20141126 OR D20141127 OR D20141128 OR D20141129 OR D20141130 OR M201412 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104) OR Dlatest)' START=20141104 SPAN=365
209 # Backward spans:
210 qtestcase '((D20151103 OR D20151104 OR D20151105 OR D20151106) OR Dlatest)' END=20151106 SPAN=3
211 qtestcase '((D20141103 OR D20141104 OR D20141105 OR D20141106 OR D20141107 OR D20141108 OR D20141109 OR D20141110 OR D20141111 OR D20141112 OR D20141113 OR D20141114 OR D20141115 OR D20141116 OR D20141117 OR D20141118 OR D20141119 OR D20141120 OR D20141121 OR D20141122 OR D20141123 OR D20141124 OR D20141125 OR D20141126 OR D20141127 OR D20141128 OR D20141129 OR D20141130 OR M201412 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103) OR Dlatest)' END=20151103 SPAN=365
213 # Check that if START, END and SPAN are all passed, START is ignored:
214 qtestcase '((D20151103 OR D20151104 OR D20151105 OR D20151106) OR Dlatest)' START=19700101 END=20151106 SPAN=3
216 # Check combining of filter terms:
217 qtestcase '(Horg AND Len)' B=Len B=Horg
218 qtestcase '(Len OR Lde)' B=Len B=Lde
219 qtestcase '((Horg OR Hcom) AND (Len OR Lfr))' B=Len B=Lfr B=Horg B=Hcom
221 # Check combining of filter terms with filter_op set:
222 printf '$setmap{nonexclusiveprefix,L,1,XAND,1}$setmap{boolprefix,lang,L,and,XAND,host,H,year,Y}$querydescription' > "$TEST_TEMPLATE"
223 qtestcase 'Len' B=Len
224 qtestcase '0 * Len' P=lang:en
225 qtestcase 'XANDtest' B=XANDtest
226 qtestcase '0 * XANDtest' P=and:test
227 qtestcase '(Len AND XANDtest)' B=Len B=XANDtest
228 qtestcase '0 * (Len AND XANDtest)' P='lang:en and:test'
229 qtestcase '(Len AND Lde)' B=Len B=Lde
230 qtestcase '0 * (Len AND Lde)' P='lang:en lang:de'
231 qtestcase '((Horg OR Hcom) AND (Len AND Lfr))' B=Len B=Lfr B=Horg B=Hcom
232 qtestcase '0 * ((Len AND Lfr) AND (Horg OR Hcom))' P='lang:en lang:fr host:org host:com'
233 qtestcase '((XANDa AND XANDb AND XANDc) AND (Y1998 OR Y2001))' B=Y1998 B=Y2001 B=XANDa B=XANDb B=XANDc
234 qtestcase '0 * (((XANDa AND XANDb) AND XANDc) AND (Y1998 OR Y2001))' P='year:1998 year:2001 and:a and:b and:c'
236 # Check combining of filters around CGI parameter 'N':
237 qtestcase '(Ztruth@1 AND_NOT Epdf)' P=truth N=Epdf
238 qtestcase '(Ztruth@1 AND_NOT (Ehtm OR Epdf))' P=truth N=Epdf N=Ehtm
239 qtestcase '(Ztruth@1 AND_NOT (Ehtm OR Epdf OR Lde OR Lfr))' P=truth N=Lfr N=Epdf N=Ehtm N=Lde
240 qtestcase '((Ztruth@1 FILTER (Lfr AND Lzh)) AND_NOT (Lde OR Len))' P=truth N=Lde N=Len B=Lfr B=Lzh
241 qtestcase '((Ztruth@1 FILTER Lfr) AND_NOT (Ehtm OR Epdf))' P=truth N=Epdf N=Ehtm B=Lfr
242 qtestcase '(<alldocuments> AND_NOT (Len OR Lfr))' N=Lfr N=Len
243 qtestcase '(VALUE_RANGE 0 2015 201501~ AND_NOT Len)' DATEVALUE=0 START=20150101 END=20150131 N=Len
245 # If faketime is available and works, test cases where the output depends on
246 # "now".
247 set +e
248 out=`faketime -f '1980-12-08 00:00:00' date +%Y 2>&1`
249 rc=$?
250 set -e
251 if [ "$rc:$out" = "0:1980" ] ; then
252 TZ=UTC
253 export TZ
254 FAKETIME='faketime -f'
255 FAKE_NOW='2015-11-28 06:07:08'
256 qtestcase 'VALUE_RANGE 0 20151127060709 20151128060708' DATEVALUE=0 SPAN=1
258 # Tests of term-based date range filtering:
259 qtestcase '((Y2000 OR Y2001 OR Y2002 OR Y2003 OR Y2004 OR Y2005 OR Y2006 OR Y2007 OR Y2008 OR Y2009 OR Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128) OR Dlatest)' START=20000101
260 qtestcase '((Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128) OR Dlatest)' START=20100101
261 qtestcase '((Y1974 OR Y1975 OR Y1976 OR Y1977 OR Y1978 OR Y1979 OR Y1980 OR Y1981 OR Y1982 OR Y1983 OR Y1984 OR Y1985 OR Y1986 OR Y1987 OR Y1988 OR Y1989 OR Y1990 OR Y1991 OR Y1992 OR Y1993 OR Y1994 OR Y1995 OR Y1996 OR Y1997 OR Y1998 OR Y1999 OR Y2000 OR Y2001 OR Y2002 OR Y2003 OR Y2004 OR Y2005 OR Y2006 OR Y2007 OR Y2008 OR Y2009 OR Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128) OR Dlatest)' START=19740101
262 qtestcase '((M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128) OR Dlatest)' START=20151001
263 # Date range with start after end:
264 qtestcase 'Dlatest' START=201512
265 qtestcase 'Dlatest' START=20151201
266 qtestcase '((D20150210 OR D20150211 OR D20150212 OR D20150213 OR D20150214 OR D20150215 OR D20150216 OR D20150217 OR D20150218 OR D20150219 OR D20150220 OR D20150221 OR D20150222 OR D20150223 OR D20150224 OR D20150225 OR D20150226 OR D20150227 OR D20150228 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128) OR Dlatest)' START=20150210
267 qtestcase '((D20000220 OR D20000221 OR D20000222 OR D20000223 OR D20000224 OR D20000225 OR D20000226 OR D20000227 OR D20000228 OR D20000229 OR M200003 OR M200004 OR M200005 OR M200006 OR M200007 OR M200008 OR M200009 OR M200010 OR M200011 OR M200012 OR Y2001 OR Y2002 OR Y2003 OR Y2004 OR Y2005 OR Y2006 OR Y2007 OR Y2008 OR Y2009 OR Y2010 OR Y2011 OR Y2012 OR Y2013 OR Y2014 OR M201501 OR M201502 OR M201503 OR M201504 OR M201505 OR M201506 OR M201507 OR M201508 OR M201509 OR M201510 OR D20151101 OR D20151102 OR D20151103 OR D20151104 OR D20151105 OR D20151106 OR D20151107 OR D20151108 OR D20151109 OR D20151110 OR D20151111 OR D20151112 OR D20151113 OR D20151114 OR D20151115 OR D20151116 OR D20151117 OR D20151118 OR D20151119 OR D20151120 OR D20151121 OR D20151122 OR D20151123 OR D20151124 OR D20151125 OR D20151126 OR D20151127 OR D20151128) OR Dlatest)' START=20000220
268 FAKETIME=
269 unset FAKE_NOW
270 else
271 if [ "$rc" = 127 ] ; then
272 echo "Skipping testcases which need 'faketime' tool installed"
273 else
274 echo "Skipping testcases which need 'faketime' tool - it's installed but doesn't work"
278 # Test stem_all and stem_strategy.
279 printf '$if{$cgi{stem_all},$set{stem_all,$cgi{stem_all}}}$if{$cgi{stem_strategy},$set{stem_strategy,$cgi{stem_strategy}}}$querydescription' > "$TEST_TEMPLATE"
280 qtestcase '((capitalised@1 AND tests@2) AND Zstem@3)' P='Capitalised "tests" stemmed'
281 qtestcase '(nearing@1 NEAR 11 distances@2)' P='nearing NEAR distances'
282 qtestcase '((capitalis@1 AND test@2) AND stem@3)' P='Capitalised "tests" stemmed' stem_all=true
283 qtestcase '(near@1 NEAR 11 distanc@2)' P='nearing NEAR distances' stem_all=true
284 qtestcase '((capitalis@1 AND test@2) AND stem@3)' P='Capitalised "tests" stemmed' stem_strategy=all
285 qtestcase '(near@1 NEAR 11 distanc@2)' P='nearing NEAR distances' stem_strategy=all
286 qtestcase '((Zcapitalis@1 AND Ztest@2) AND Zstem@3)' P='Capitalised "tests" stemmed' stem_strategy=all_z
287 qtestcase '(Znear@1 NEAR 11 Zdistanc@2)' P='nearing NEAR distances' stem_strategy=all_z
288 qtestcase '((capitalised@1 AND tests@2) AND stemmed@3)' P='Capitalised "tests" stemmed' stem_strategy=none
289 qtestcase '(nearing@1 NEAR 11 distances@2)' P='nearing NEAR distances' stem_strategy=none
290 qtestcase '((capitalised@1 AND tests@2) AND Zstem@3)' P='Capitalised "tests" stemmed' stem_strategy=some
291 qtestcase '(nearing@1 NEAR 11 distances@2)' P='nearing NEAR distances' stem_strategy=some
292 qtestcase '((capitalised@1 AND tests@2) AND Zstem@3)' P='Capitalised "tests" stemmed' stem_strategy=some_full_pos
293 qtestcase '(Znear@1 NEAR 11 Zdistanc@2)' P='nearing NEAR distances' stem_strategy=some_full_pos
294 qtestcase '((capitalised@1 AND tests@2) AND Zstem@3)' P='Capitalised "tests" stemmed' stem_strategy=some stem_all=true
295 qtestcase '(nearing@1 NEAR 11 distances@2)' P='nearing NEAR distances' stem_strategy=some stem_all=true
297 # Feature tests for $contains.
298 printf '$contains{$cgi{a},$cgi{b}}' > "$TEST_TEMPLATE"
299 testcase '6' P=text a=fish b="Hello fish"
300 testcase '' P=text a="Example" b="random"
302 NEWLINE='
305 # Feature tests for boolprefix and prefix maps.
306 printf '$set{stemmer,}$setmap{boolprefix,lang,L,host,H}$setmap{prefix,,XDEFAULT}$querydescription' > "$TEST_TEMPLATE"
307 qtestcase '((XDEFAULTfoo@1 AND XDEFAULTbar@2) FILTER (Hexample.org AND Lzh))' P='host:example.org foo bar lang:zh'
309 # Feature tests for $cond.
310 printf '$cond{$cgi{one},1,$cgi{two},2,$cgi{three},3}' > "$TEST_TEMPLATE"
311 testcase '1' one=true
312 testcase '2' two=true
313 testcase '3' three=true
314 testcase '' nothing=true
315 testcase '1' one=true two=true three=true
316 testcase '2' two=true three=true
317 printf '$cond{$cgi{one},1,$cgi{two},2,$cgi{alt}}' > "$TEST_TEMPLATE"
318 testcase '1' one=true
319 testcase '2' two=true
320 testcase 'none' alt=none
321 # Check evaluation is lazy.
322 printf '$cond{$cgi{one},$seterror{err1},$cgi{two},2,$cgi{alt}}$error' > "$TEST_TEMPLATE"
323 testcase 'err1' one=true
324 testcase '2' two=true
325 testcase 'none' alt=none
326 printf '$cond{$cgi{one},1,$cgi{two},$seterror{err2},$cgi{alt}}$error' > "$TEST_TEMPLATE"
327 testcase '1' one=true
328 testcase 'err2' two=true
329 testcase 'none' alt=none
330 printf '$cond{$cgi{one},1,$cgi{two},2,$seterror{erralt}}$error' > "$TEST_TEMPLATE"
331 testcase '1' one=true
332 testcase '2' two=true
333 testcase 'erralt' alt=none
335 # Feature tests for $switch.
336 printf '$switch{$cgi{x},1,one,2,two}' > "$TEST_TEMPLATE"
337 testcase 'one' x=1
338 testcase 'two' x=2
339 testcase '' x=3
340 printf '$switch{$cgi{x},1,one,2,two,default}' > "$TEST_TEMPLATE"
341 testcase 'one' x=1
342 testcase 'two' x=2
343 testcase 'default' x=3
344 # Check evaluation is lazy.
345 printf '$switch{$cgi{x},1,$seterror{err1},2,two}$error' > "$TEST_TEMPLATE"
346 testcase 'err1' x=1
347 testcase 'two' x=2
348 testcase '' x=3
349 printf '$switch{$cgi{x},1,one,2,$seterror{err2},default}$error' > "$TEST_TEMPLATE"
350 testcase 'one' x=1
351 testcase 'err2' x=2
352 testcase 'default' x=3
353 printf '$switch{$cgi{x},1,one,2,two,$seterror{errdefault}}$error' > "$TEST_TEMPLATE"
354 testcase 'one' x=1
355 testcase 'two' x=2
356 testcase 'errdefault' x=3
358 # Feature tests for $map.
359 printf '$list{$map{$split{-,$cgi{a}},$list{$map{$split{,$cgi{b}},$_},-}},|}' > "$TEST_TEMPLATE"
360 testcase '1-2-3|1-2-3' P=text a=ab-cd b=123
361 printf '$list{$map{$split{-,$cgi{a}},$set{__,$_}$list{$map{$split{,$cgi{b}},$opt{__}$_},-}},|}' > "$TEST_TEMPLATE"
362 testcase 'a1-a2-a3|b1-b2-b3' P=text a=a-b b=123
363 printf '$list{$map{$split{-,$cgi{a}},$list{$map{$split{$_,$cgi{b}},$_},-}},|}' > "$TEST_TEMPLATE"
364 testcase '1-2,3|1:2-3' P=text a=':-,' b='1:2,3'
365 # Check that the outer $_ is restored after the inner $map.
366 printf '$list{$map{$split{-,$cgi{a}},$list{$map{$split{,$cgi{b}},$_},-}$_},|}' > "$TEST_TEMPLATE"
367 testcase '1-2-3a|1-2-3b' P=text a='a-b' b='123'
369 # Feature tests for $match.
370 printf '$match{$cgi{a},$cgi{b},$cgi{c}}' > "$TEST_TEMPLATE"
371 testcase 'true' P=text a="ab*c+" b="ac"
372 testcase '' P=text a="acb" b="abc"
373 testcase 'true' P=text a="[A-Z]bcD" b="abcd" c="i"
374 testcase '' P=text a="[A-Z]bcD" b="abcd"
375 testcase 'true' P=text a="^abc$" b="${NEWLINE}abc${NEWLINE}def" c="m"
376 testcase '' P=text a="^abc$" b="${NEWLINE}abc${NEWLINE}def"
377 testcase 'true' P=text a="abc." b="abc${NEWLINE}" c="s"
378 testcase '' P=text a="abc." b="abc${NEWLINE}"
379 testcase 'true' P=text a=" ABC #test_comment " b="ABC" c="x"
380 testcase '' P=text a=" ABC #test_comment " b="ABC"
382 # Feature tests for $sort.
383 printf '$list{$sort{$split{|,$cgi{input}}},|}' > "$TEST_TEMPLATE"
384 testcase 'pineapple' input="pineapple"
385 testcase 'apple|banana|coconut' input="coconut|banana|apple"
386 testcase '1|b|b|c' input="b|c|b|1"
387 printf '$list{$sort{$split{|,$cgi{input}},$cgi{opt}},|}' > "$TEST_TEMPLATE"
388 testcase 'pineapple' input="pineapple" opt=
389 testcase 'pineapple' input="pineapple" opt=r
390 testcase 'pineapple' input="pineapple" opt=ru
391 testcase '1|b|c' input="b|c|b|1" opt=u
392 testcase 'c|b|b|1' input="b|c|b|1" opt=r
393 testcase 'c|b|1' input="b|c|b|1" opt=ur
394 testcase '-2|-.01|+99.99|+999|.0|0.0|.1|1|2|3|3.0|3.01|12|23|30' input='+999|2|1|12|23|3|30|3.01|3.0|.1|.0|0.0|-2|-.01|+99.99' opt=n
395 testcase '-2|-.01|+999|.1|1|2|3|3.01|12|23|30' input='+999|2|1|12|23|3|30|3.01|3.0|.1|.0|0.0|-2|-.01|+99.99' opt=nu
396 testcase '-2|-.01|+99.99|.1|1|2|3.0|3.01|12|23|30' input='+99.99|-.01|-2|0.0|.0|.1|3.0|3.01|30|3|23|12|1|2|+999' opt=nu
397 testcase '30|23|12|3.01|3.0|3|2|1|.1|0.0|.0|+999|+99.99|-.01|-2' input='+999|2|1|12|23|3|30|3.01|3.0|.1|.0|0.0|-2|-.01|+99.99' opt=nr
398 testcase '30|23|12|3.01|3|2|1|.1|+999|-.01|-2' input='+999|2|1|12|23|3|30|3.01|3.0|.1|.0|0.0|-2|-.01|+99.99' opt=nur
399 testcase '30|23|12|3.01|3.0|2|1|.1|+99.99|-.01|-2' input='+99.99|-.01|-2|0.0|.0|.1|3.0|3.01|30|3|23|12|1|2|+999' opt=nur
400 testcase 't 42|t 42:|t 42:1|t 42:09|t 42:9|t 42:11|t 42~' input='t 42:1|t 42|t 42:11|t 42:9|t 42~|t 42:|t 42:09' opt='#'
401 testcase 'A7R1:2|A7R2:6|A7R2:9|A7R2:11|A7R2:19|A7R2:47A|A7R11:1|AA|R7:1.09|R7:4A|R7:6|R7:7A|R7:404|R7:444-10|R7:1521' \
402 input='A7R1:2|R7:1521|AA|R7:4A|R7:7A|A7R2:9|R7:444-10|A7R2:6|R7:1.09|A7R2:47A|A7R11:1|R7:6|A7R2:11|R7:404|A7R2:19' \
403 opt='#'
404 testcase '30|23|12|3|03|2|1|01|0|00' input='2|1|23|12|23|3|30|0|00|0|01|03' opt='#ru'
405 testcase 'Exception: Unknown $sort option: x' input="b|c|b|1" opt=urx
406 testcase 'Exception: Invalid $sort option combination: n#' input="b|c" opt='n#'
407 testcase 'Exception: Invalid $sort option combination: #rn' input="b|1" opt='#rn'
409 # Feature tests for $terms.
410 printf 'text : index\nhost : boolean=H\nfoo : boolean=XFOO' > "$TEST_INDEXSCRIPT"
411 rm -rf "$TEST_DB"
412 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
413 text=This is some text.
414 host=example.org
415 foo=bar
417 printf '$hitlist{$list{$if{$eq{$cgi{prefix},null},$terms,$terms{$cgi{prefix}}},|}}' > "$TEST_TEMPLATE"
418 testcase 'Ztext' P=text B=Hexample.org B=Hexample.com prefix=null
419 testcase 'Hexample.org|Ztext' P=text B=Hexample.org B=Hexample.com prefix=
420 testcase 'Hexample.org' P=text B=Hexample.org B=Hexample.com prefix=H
421 testcase 'Ztext' P=text B=Hexample.org B=Hexample.com prefix=Z
422 testcase '' P=text B=Hexample.org B=Hexample.com prefix=E
424 printf '$msizelower $msize $msizeupper $msizeexact' > "$TEST_TEMPLATE"
425 testcase '1 1 1 true' P=this
426 testcase '1 1 1 true' P='Some text'
427 testcase '0 0 0 true' P=potato
429 printf '$set{weighting,coord}$hitlist{$weight.}' > "$TEST_TEMPLATE"
430 testcase '' P=aardvark
431 testcase '1.000000.' P=texting
432 testcase '' P='texting while driving'
433 testcase '' P='texting while driving' DEFAULTOP=AND
434 testcase '1.000000.' P='texting while driving' DEFAULTOP=OR
435 testcase '2.000000.' P='Some text'
436 # "this" and "is" are stopwords.
437 testcase '2.000000.' P='This is some text'
438 testcase '4.000000.' P='"This" "is" some text'
439 testcase '4.000000.' P='+This +is some text'
440 testcase '4.000000.' P='"This is some text"'
442 printf '$set{weightingpurefilter,coord}$hitlist{$weight.}' > "$TEST_TEMPLATE"
443 testcase '' B=XFOOfoo
444 testcase '1.000000.' B=Hexample.org
445 testcase '' B=Hexample.org B=XFOOfoo
446 testcase '1.000000.' B=Hexample.org B=Hexample.net
447 testcase '2.000000.' B=Hexample.org B=XFOObar
448 testcase '3.000000.' B=Hexample.org B=XFOObar B=XFOObar
450 printf '$filters' > "$TEST_TEMPLATE"
451 testcase 'Hexample.net~Hexample.org~.~~' B=Hexample.org B=Hexample.net
452 testcase '!Gmisc.test~.~~' N=Gmisc.test
453 testcase 'Hexample.net~Hexample.org~!Gmisc.test~.~~' B=Hexample.org B=Hexample.net N=Gmisc.test
454 testcase '.20040612~~~1~' DATEVALUE=1 START=20040612
455 testcase '.20040612~~~1~2' DATEVALUE=1 START=20040612 COLLAPSE=2
456 testcase '.20040612~~30~2' START=20040612 SPAN=30 COLLAPSE=2
457 testcase '.20040612~20160412~' START=20040612 END=20160412
458 testcase '.~~~2' COLLAPSE=2
459 testcase '.~~'
460 testcase '.~~1' SORT=1
461 testcase '.~~1f' SORT=+1
462 testcase '.~~1' SORT=-1
463 testcase '.~~1-2+3-27' SORT=+1-2+03,-27
464 testcase '.~~' SORTREVERSE=1
465 testcase '.~~1f' SORT=1 SORTREVERSE=1
466 testcase '.~~1' SORT=+1 SORTREVERSE=1
467 testcase '.~~1f' SORT=-1 SORTREVERSE=1
468 testcase '.~~1-2+3-27f' SORT=+1-2+03,-27 SORTREVERSE=1
469 testcase '.~~' SORTAFTER=1
470 testcase '.~~1R' SORT=1 SORTAFTER=1
471 testcase '.~~1F' SORT=+1 SORTAFTER=1
472 testcase '.~~1R' SORT=-1 SORTAFTER=1
473 testcase '.~~1-2+3-27R' SORT=+1-2+03,-27 SORTAFTER=1
474 testcase '.~~' SORTREVERSE=1 SORTAFTER=1
475 testcase '.~~1F' SORT=1 SORTREVERSE=1 SORTAFTER=1
476 testcase '.~~1R' SORT=+1 SORTREVERSE=1 SORTAFTER=1
477 testcase '.~~1F' SORT=-1 SORTREVERSE=1 SORTAFTER=1
478 testcase '.~~1-2+3-27F' SORT=+1-2+03,-27 SORTREVERSE=1 SORTAFTER=1
479 testcase '.~~X' DOCIDORDER=A # Buggy, but kept for compatibility.
480 testcase '.~~D' DOCIDORDER=D
481 testcase '.~~' DOCIDORDER=X # Buggy, but kept for compatibility.
482 testcase '.~~' DOCIDORDER=x # Buggy, but kept for compatibility.
484 tab=`printf '\t'`
485 printf '$cgi{AZ}|$cgi{AZ B}|$cgi{AZ.x}|$cgi{AZ.y}|$cgi{[}|$cgi{#}' > "$TEST_TEMPLATE"
486 testcase 'AZ|||||' AZ.x=3 AZ.y=4
487 testcase 'B|||||' 'AZ B.x=5' 'AZ B.y=12'
488 testcase 'B|||||' "AZ${tab}B.x=5" "AZ${tab}B.y=12"
489 testcase '||||2 ]|' '[ 2 ].x=123'
490 testcase '||||2 ]|' "[${tab}2 ].x=123"
491 testcase "||||2${tab}]|" "[ 2${tab}].x=123"
492 testcase "||||2${tab}]|" "[${tab}2${tab}].x=123"
493 testcase '|||||12' '12.x=37'
494 testcase 'DE|||||' 'AZ BC=DE'
495 testcase 'DE|||||' 'AZ B C=DE'
496 testcase 'DE|||||' "AZ${tab}BC=DE"
497 testcase 'DE|||||' "AZ B${tab}C=DE"
498 testcase 'DE|||||' "AZ${tab}B C=DE"
499 testcase 'DE|||||' "AZ${tab}B${tab}C=DE"
501 printf '$cgi{Search}|$cgi{Type}|$cgi{Search Type}' > "$TEST_TEMPLATE"
502 testcase 'Discover-List||' 'Search Type=Discover-List'
504 printf '$cgiparams' > "$TEST_TEMPLATE"
505 # We can't test the "no cgi parameters" case via testcase, as it passes a
506 # "dummy" parameter if there aren't any real ones.
507 #testcase ""
508 testcase "" =1
509 testcase "ABC" ABC=1
510 testcase "ABC" ABC=1 ABC=2
511 testcase "A${tab}AZ${tab}Z" A=1 A=2 A=3 AZ=1 AZ=2 Z=xxx
512 testcase "${tab}abc" =1 abc=1
513 testcase "${tab}abc${tab}def" =1 abc=1 def=7
515 # Feature tests for $highlight{}.
516 printf '$highlight{$cgi{text},$cgi{list}}' > "$TEST_TEMPLATE"
517 testcase 'A <b style="color:black;background-color:#ffff66">list</b> of <b style="color:black;background-color:#99ff99">words</b>' list="list${tab}words" text="A list of words"
519 printf '$highlight{$cgi{text},$cgi{list},$cgi{open}}' > "$TEST_TEMPLATE"
520 testcase 'A list of <b>words</b>' list="words" text="A list of words" open="<b>"
521 testcase 'A list of <span>words</span>' list="words" text="A list of words" open="<span>"
523 printf '$highlight{$cgi{text},$cgi{list},$cgi{open},$cgi{close}}' > "$TEST_TEMPLATE"
524 testcase 'A list of <b>words</b>' list="words" text="A list of words" open="<b>" close="</b>"
525 testcase 'A *list* of *words*' list="words${tab}list" text="A list of words" open="*" close="*"
527 # Test setting seterror and mset size, should not run the query after setting error.
528 printf '$if{$cgi{ERR},$seterror{$cgi{ERR}}}$msize$if{$error,!$error!}' > "$TEST_TEMPLATE"
529 testcase '1' P=text
530 testcase '0!boo!' P=text ERR=boo
532 # Test arguments inside seterror are evaluated
533 printf '$set{error,sample error}$seterror{$opt{error}}$msize$if{$error,!$error!}' > "$TEST_TEMPLATE"
534 testcase '0!sample error!' P=text
536 # Test error message doesn't get sent through HTML entity encoding.
537 printf '$seterror{{ "error": true, "error_message": "Parameter cannot be > 9" }}$if{$error,$error}' > "$TEST_TEMPLATE"
538 testcase '{ "error": true, "error_message": "Parameter cannot be > 9" }' P=text
540 # Test msize when error set after running query, should not affect running of query.
541 printf '$last$if{$cgi{ERR},$seterror{$cgi{ERR}}}$msize$if{$error,!$error!}' > "$TEST_TEMPLATE"
542 testcase '11' P=text
543 testcase '11!boo!' P=text ERR=boo
545 # Feature tests for $uniq and $unique{}.
546 printf '$list{$uniq{$split{$cgi{text}}},:}|$list{$unique{$split{$cgi{text}}},:}' > "$TEST_TEMPLATE"
547 testcase '|' text=''
548 testcase 'foo|foo' text='foo'
549 testcase 'apple:banana:cherry|apple:banana:cherry' text='apple apple banana banana banana cherry'
550 testcase 'a:b:r:a:c:a:d:a:b:r:a|a:b:r:c:d' text='a b r a c a d a b r a'
551 testcase 'x:y:z:y|x:y:z' text='x y z z y'
553 # Regression test - $map with one argument wasn't rejected cleanly.
554 printf '$map{foo}' > "$TEST_TEMPLATE"
555 testcase 'Exception: too few arguments to $map'
557 # Feature tests for scriptindex hextobin action.
558 printf 'hex : hextobin value=0' > "$TEST_INDEXSCRIPT"
559 rm -rf "$TEST_DB"
560 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
561 hex=
563 hex=41
565 hex=54657374
567 hex=4b696C6c
569 printf '$list{$map{$split{$cgi{DOCIDS}},$value{0,$_}},|}' > "$TEST_TEMPLATE"
570 testcase '|A|Test|Kill' DOCIDS='1 2 3 4'
572 # Feature test error cases for scriptindex hextobin action.
573 rm -rf "$TEST_DB"
574 echo hex=7g |\
575 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null |\
576 grep -q ":1: error: hextobin: input must be all hex digits" ||\
577 { echo "scriptindex hextobin didn't give error for bad hex digit";\
578 failed=`expr $failed + 1`; }
579 echo hex=404 |\
580 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null |\
581 grep -q ":1: error: hextobin: input must have even length" ||\
582 { echo "scriptindex hextobin didn't give error for odd length hex string";\
583 failed=`expr $failed + 1`; }
584 testcase '7g|404' DOCIDS='1 2'
586 # Test useless action warnings.
587 printf 'foo : index weight=2' > "$TEST_INDEXSCRIPT"
588 rm -rf "$TEST_DB"
589 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
590 | grep -q ":1:13: warning: Index action 'weight' has no effect" ; then
591 : # OK
592 else
593 echo "scriptindex didn't give expected warning for useless 'weight' action"
594 failed=`expr $failed + 1`
596 printf 'foo : weight=2 weight=3 index' > "$TEST_INDEXSCRIPT"
597 rm -rf "$TEST_DB"
598 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
599 | grep -q ":1:7: warning: Index action 'weight' has no effect" ; then
600 : # OK
601 else
602 echo "scriptindex didn't give expected warning for useless 'weight' action"
603 failed=`expr $failed + 1`
605 printf 'foo : index lower' > "$TEST_INDEXSCRIPT"
606 rm -rf "$TEST_DB"
607 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
608 | grep -q ":1:13: warning: Index action 'lower' has no effect" ; then
609 : # OK
610 else
611 echo "scriptindex didn't give expected warning for useless 'lower' action"
612 failed=`expr $failed + 1`
615 # Test bad fieldname errors.
616 printf 'foo *bar : index' > "$TEST_INDEXSCRIPT"
617 rm -rf "$TEST_DB"
618 rc=0
619 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
620 if [ $rc -eq 0 ] ; then
621 echo "scriptindex didn't exit with non-zero return code on bad fieldname"
622 failed=`expr $failed + 1`
623 elif printf '%s' "$out" \
624 | grep -q ":1:5: error: field name must start with alphanumeric" ; then
625 : # OK
626 else
627 echo "scriptindex didn't give expected error for a bad fieldname"
628 failed=`expr $failed + 1`
630 printf 'foo b!ar : index' > "$TEST_INDEXSCRIPT"
631 rm -rf "$TEST_DB"
632 rc=0
633 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
634 if [ $rc -eq 0 ] ; then
635 echo "scriptindex didn't exit with non-zero return code on bad fieldname"
636 failed=`expr $failed + 1`
637 elif printf '%s' "$out" \
638 | grep -q ":1:6: error: bad character '!' in fieldname" ; then
639 : # OK
640 else
641 echo "scriptindex didn't give expected error for a bad fieldname"
642 failed=`expr $failed + 1`
645 # Test unwanted action argument.
646 printf 'foo : spell=test index' > "$TEST_INDEXSCRIPT"
647 rm -rf "$TEST_DB"
648 rc=0
649 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
650 if [ $rc -eq 0 ] ; then
651 echo "scriptindex didn't exit with non-zero return code on unwanted action argument"
652 failed=`expr $failed + 1`
653 elif printf '%s' "$out" \
654 | grep -q ":1:12: error: Index action 'spell' doesn't take an argument" ; then
655 : # OK
656 else
657 echo "scriptindex didn't give expected error for unwanted action argument"
658 failed=`expr $failed + 1`
661 # Test missing closing quote.
662 printf 'foo : index="XFOO' > "$TEST_INDEXSCRIPT"
663 rm -rf "$TEST_DB"
664 rc=0
665 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
666 if [ $rc -eq 0 ] ; then
667 echo "scriptindex didn't exit with non-zero return code for missing closing quote"
668 failed=`expr $failed + 1`
669 elif printf '%s' "$out" \
670 | grep -q ":1:18: error: No closing quote" ; then
671 : # OK
672 else
673 echo "scriptindex didn't give expected error for missing closing quote"
674 failed=`expr $failed + 1`
677 # Feature tests for termprefix and unprefix.
678 printf '$termprefix{$cgi{B}}|$unprefix{$cgi{B}}' > "$TEST_TEMPLATE"
679 testcase '|' B=''
680 testcase '|something' B='something'
681 testcase '|42' B='42'
682 testcase '|3bad' B='3bad'
683 testcase '|&something' B='&something'
684 testcase '|:something' B=':something'
685 testcase 'H|example.org' B='Hexample.org'
686 testcase 'K|tag' B='Ktag'
687 testcase 'K|Capital' B='KCapital'
688 testcase 'K|:colon-tag' B='K:colon-tag'
689 testcase 'K|:Capital' B='K:Capital'
690 testcase 'XCOLOUR|red' B='XCOLOURred'
691 testcase 'XPUNC|:colon' B='XPUNC::colon'
692 testcase 'XPUNC|internal:colon' B='XPUNC:internal:colon'
693 testcase 'XPUNC|:Colon' B='XPUNC::Colon'
694 testcase 'XCASE|Upper' B='XCASE:Upper'
695 testcase 'XCASE|TITLE' B='XCASE:TITLE'
696 testcase 'XNUM|42' B='XNUM42'
697 testcase 'XNUM|3bad' B='XNUM3bad'
699 # Test to make sure out generate_sample function in sample.cc
700 # Doesn't run into negative memory access
701 printf '$truncate{$cgi{input},$cgi{maxlen},$cgi{ind},$cgi{ind2}}$seterror{$opt{error}}' > "$TEST_TEMPLATE"
702 testcase 'w...' input='wwwwww' maxlen=4 ind='...' ind2='...'
703 testcase '' input='s' maxlen=0 ind='...' ind2='...'
705 # Simple tests of $subdb and $subid.
706 rm -rf "$TEST_DB"
707 printf 'inmemory' > "$TEST_DB"
708 printf 'inmemory' > "${TEST_DB}2"
709 printf '$subdb{$cgi{ID}}|$subid{$cgi{ID}}' > "$TEST_TEMPLATE"
710 testcase "$TEST_DB|1" ID=1
711 testcase "$TEST_DB|1" ID=1 DB="$TEST_DB/${TEST_DB}2"
712 testcase "${TEST_DB}2|1" ID=2 DB="$TEST_DB/${TEST_DB}2"
713 testcase "${TEST_DB}|2" ID=3 DB="$TEST_DB/${TEST_DB}2"
714 rm -rf "${TEST_DB}2"
716 # Feature tests of scriptindex.
717 printf 'uuid : boolean=Q unique=Q\nguid : boolean=G unique=G' > "$TEST_INDEXSCRIPT"
718 rm -rf "$TEST_DB"
719 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null < /dev/null 2>&1; then
720 echo "scriptindex didn't reject 'unique' action being used more than once"
721 failed=`expr $failed + 1`
724 # Test we check for hash's argument being an integer (new in 1.4.6).
725 printf 'url : hash=37.3 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
726 rm -rf "$TEST_DB"
727 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
728 | grep -q ":1:14: warning: Index action 'hash' takes an integer argument" ; then
729 : # OK
730 else
731 echo "scriptindex didn't reject 'hash' with a non-integer argument"
732 failed=`expr $failed + 1`
735 # Test we give a helpful error for an action with a digit in (regression
736 # test for fix in 1.4.6).
738 # This used to give the confusing:
739 # Unknown index action ''
740 printf 'url : index4' > "$TEST_INDEXSCRIPT"
741 rm -rf "$TEST_DB"
742 rc=0
743 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
744 if [ $rc -eq 0 ] ; then
745 echo "scriptindex didn't exit with non-zero return code for bad index action with a digit"
746 failed=`expr $failed + 1`
747 elif printf '%s' "$out" \
748 | grep -q ":1:7: error: Unknown index action 'index4'" ; then
749 : # OK
750 else
751 echo "scriptindex didn't give expected error for bad index action with a digit"
752 failed=`expr $failed + 1`
755 # Test we give a helpful error if an = sign is missed out before an optional
756 # numeric argument (regression test for fix in 1.4.6).
758 # This used to give the confusing:
759 # Unknown index action ''
760 printf 'url : hash 42' > "$TEST_INDEXSCRIPT"
761 rm -rf "$TEST_DB"
762 rc=0
763 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
764 if [ $rc -eq 0 ] ; then
765 echo "scriptindex didn't exit with non-zero return code for a missing equals sign"
766 failed=`expr $failed + 1`
767 elif printf '%s' "$out" \
768 | grep -q ":1:12: error: Unknown index action '42'" ; then
769 : # OK
770 else
771 echo "scriptindex didn't give expected error for a missing equals sign"
772 failed=`expr $failed + 1`
775 # Test we warn about spaces before and after '='.
777 # This has never been documented as supported, and was deprecated in 1.4.6
778 # because it resulted in this quietly using hash as the field name, which is
779 # probably not what was intended:
781 # url : field= hash boolean=Q unique=Q
782 printf 'url : field= hash boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
783 rm -rf "$TEST_DB"
784 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
785 | grep -q ":1:13: warning: putting spaces between '=' and the argument is deprecated" ; then
786 : # OK
787 else
788 echo "scriptindex didn't give expected warning for space after '='"
789 failed=`expr $failed + 1`
791 printf 'url : field =link' > "$TEST_INDEXSCRIPT"
792 rm -rf "$TEST_DB"
793 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
794 | grep -q ":1:12: warning: putting spaces between the action and '=' is deprecated" ; then
795 : # OK
796 else
797 echo "scriptindex didn't give expected warning for space before '='"
798 failed=`expr $failed + 1`
801 # Feature tests for datevalue command scriptindex.
802 printf 'DATE : field parsedate=%%Y%%m%%d valuepacked=13\n' > "$TEST_INDEXSCRIPT"
803 rm -rf "$TEST_DB"
804 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
805 DATE=19891204
807 printf '$field{DATE,1}|$unpack{$value{13,1}}|$date{$unpack{$value{13,1}}}' > "$TEST_TEMPLATE"
808 testcase '19891204|628732800|1989-12-04' P=text
810 # Feature tests for datevalue command scriptindex where format contains space.
811 printf 'DATE : field parsedate="%%Y%%m%%d %%T" valuepacked=13\n' > "$TEST_INDEXSCRIPT"
812 rm -rf "$TEST_DB"
813 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 <<'END'
814 DATE=20161202 12:04:22.000000
816 printf '$unpack{$value{13,1}}|$date{$unpack{$value{13,1}}}' > "$TEST_TEMPLATE"
817 testcase '1480680262|2016-12-02' P=text
819 # Feature tests for quoted argument.
820 printf 'DATE : field=" spaces " date="yyyymmdd"\nTEXT: index\n' > "$TEST_INDEXSCRIPT"
821 rm -rf "$TEST_DB"
822 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
823 DATE=19891204
824 TEXT=This is sample text.
825 NEXT=work
827 printf '$freq{D19891204}|$field{ spaces ,1}' > "$TEST_TEMPLATE"
828 testcase '1|19891204' P=text
829 # Use $time to force the match to run.
830 printf '$if{$time,$freq{D19891204}}|$field{ spaces ,1}' > "$TEST_TEMPLATE"
831 testcase '1|19891204' P=
833 # Regression test that a closing " with junk after is flagged.
834 printf 'date : field="test"index' > "$TEST_INDEXSCRIPT"
835 rm -rf "$TEST_DB"
836 rc=0
837 out=`$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1` || rc=$?
838 if [ $rc -eq 0 ] ; then
839 echo "scriptindex didn't exit with non-zero return code for junk after closing quote"
840 failed=`expr $failed + 1`
841 elif printf '%s' "$out" \
842 | grep -q ":1:20: error: Unexpected character 'i' after closing quote" ; then
843 : # OK
844 else
845 echo "scriptindex didn't give expected error for junk after closing quote"
846 failed=`expr $failed + 1`
849 # Test we warn about useless actions.
850 printf 'date : field parsedate=%%Y%%m%%d' > "$TEST_INDEXSCRIPT"
851 rm -rf "$TEST_DB"
852 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
853 | grep -q ":1:14: warning: Index action 'parsedate' has no effect" ; then
854 : # OK
855 else
856 echo "scriptindex didn't give expected warning for useless 'parsedate'"
857 failed=`expr $failed + 1`
860 # The 'hash' action should require its argument is >= 6, so test 5 is rejected.
861 printf 'url : hash=5 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
862 rm -rf "$TEST_DB"
863 if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null > /dev/null 2>&1 ; then
864 echo "scriptindex didn't reject 'hash=5'"
865 failed=`expr $failed + 1`
868 # And that 6 is accepted.
869 printf 'url : hash=6 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
870 rm -rf "$TEST_DB"
871 if echo 'url=http://xapian.org' | $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 ; then
872 : # OK
873 else
874 echo "scriptindex rejected 'hash=6'"
875 failed=`expr $failed + 1`
878 # Regression test to check hash works without argument (it was failing with an
879 # assertion in unreleased versions prior to 1.4.6).
880 printf 'url : hash boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
881 rm -rf "$TEST_DB"
882 if echo 'url=http://xapian.org' | $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 ; then
883 : # OK
884 else
885 echo "scriptindex rejected 'hash'"
886 failed=`expr $failed + 1`
889 # Test the same actions for multiple fields works (briefly broken in git master
890 # before 1.5.0).
891 printf 'tag1 tag2 tag3 : boolean=T field' > "$TEST_INDEXSCRIPT"
892 rm -rf "$TEST_DB"
893 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
894 tag1=one
895 tag2=two
896 tag3=three
898 printf '$hitlist{$list{$terms{T},|}/$field{tag1}|$field{tag2}|$field{tag3}}' > "$TEST_TEMPLATE"
899 testcase 'Tone/one|two|three' B=Tone
900 testcase 'Tthree|Ttwo/one|two|three' B=Ttwo B=Tthree
902 rm "$OMEGA_CONFIG_FILE" "$TEST_INDEXSCRIPT" "$TEST_TEMPLATE"
903 rm -rf "$TEST_DB"
904 if [ "$failed" = 0 ] ; then
905 exit 0
907 echo "Failed $failed test(s)"
908 exit 1