"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "omegatest" between
xapian-omega-1.4.18.tar.xz and xapian-omega-1.4.19.tar.xz

About: Xapian Omega is an application built on Xapian, consisting of indexers and a CGI search frontend.

omegatest  (xapian-omega-1.4.18.tar.xz):omegatest  (xapian-omega-1.4.19.tar.xz)
#!/bin/sh #!/bin/sh
# omegatest: Test omega CGI # omegatest: Test omega CGI
# #
# Copyright (C) 2015,2016,2017,2018,2019,2020 Olly Betts # Copyright (C) 2015,2016,2017,2018,2019,2020,2021 Olly Betts
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as # modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the # published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version. # License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
skipping to change at line 397 skipping to change at line 397
else else
if [ "$rc" = 127 ] ; then if [ "$rc" = 127 ] ; then
echo "Skipping testcases which need 'faketime' tool installed" echo "Skipping testcases which need 'faketime' tool installed"
elif [ -z "$FAKETIME" ] ; then elif [ -z "$FAKETIME" ] ; then
echo "Skipping testcases which need 'faketime' tool - \$FAKETIME is empty " echo "Skipping testcases which need 'faketime' tool - \$FAKETIME is empty "
else else
echo "Skipping testcases which need 'faketime' tool - it's installed but doesn't work" echo "Skipping testcases which need 'faketime' tool - it's installed but doesn't work"
fi fi
fi fi
# Check clamping of out of range dates:
printf '%s\n' 'DATE : field valuepacked=0' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
DATE=0
DATE=1617069804
END
qtestcase 'VALUE_LE 0 V\x84o\xff' START.0=10010101 END.0=20151230
qtestcase 'VALUE_RANGE 0 V\x83\x1e\x80 \xff\xff\xff\xff' START.0=20151230 END.0=
21060301
qtestcase 'VALUE_LE 0 \xff\xff\xff\xff' START.0=19691230 END.0=21060301
# Test stem_all and stem_strategy. # Test stem_all and stem_strategy.
printf '$if{$cgi{stem_all},$set{stem_all,$cgi{stem_all}}}$if{$cgi{stem_strategy} ,$set{stem_strategy,$cgi{stem_strategy}}}$querydescription' > "$TEST_TEMPLATE" printf '$if{$cgi{stem_all},$set{stem_all,$cgi{stem_all}}}$if{$cgi{stem_strategy} ,$set{stem_strategy,$cgi{stem_strategy}}}$querydescription' > "$TEST_TEMPLATE"
qtestcase '(capitalised@1 AND tests@2 AND Zstem@3)' P='Capitalised "tests" stemm ed' qtestcase '(capitalised@1 AND tests@2 AND Zstem@3)' P='Capitalised "tests" stemm ed'
qtestcase '(nearing@1 NEAR 11 distances@2)' P='nearing NEAR distances' qtestcase '(nearing@1 NEAR 11 distances@2)' P='nearing NEAR distances'
qtestcase '(capitalis@1 AND test@2 AND stem@3)' P='Capitalised "tests" stemmed' stem_all=true qtestcase '(capitalis@1 AND test@2 AND stem@3)' P='Capitalised "tests" stemmed' stem_all=true
qtestcase '(near@1 NEAR 11 distanc@2)' P='nearing NEAR distances' stem_all=true qtestcase '(near@1 NEAR 11 distanc@2)' P='nearing NEAR distances' stem_all=true
qtestcase '(capitalis@1 AND test@2 AND stem@3)' P='Capitalised "tests" stemmed' stem_strategy=all qtestcase '(capitalis@1 AND test@2 AND stem@3)' P='Capitalised "tests" stemmed' stem_strategy=all
qtestcase '(near@1 NEAR 11 distanc@2)' P='nearing NEAR distances' stem_strategy= all qtestcase '(near@1 NEAR 11 distanc@2)' P='nearing NEAR distances' stem_strategy= all
qtestcase '(Zcapitalis@1 AND Ztest@2 AND Zstem@3)' P='Capitalised "tests" stemme d' stem_strategy=all_z qtestcase '(Zcapitalis@1 AND Ztest@2 AND Zstem@3)' P='Capitalised "tests" stemme d' stem_strategy=all_z
qtestcase '(Znear@1 NEAR 11 Zdistanc@2)' P='nearing NEAR distances' stem_strateg y=all_z qtestcase '(Znear@1 NEAR 11 Zdistanc@2)' P='nearing NEAR distances' stem_strateg y=all_z
skipping to change at line 562 skipping to change at line 574
testcase 'A7R1:2|A7R2:6|A7R2:9|A7R2:11|A7R2:19|A7R2:47A|A7R11:1|AA|R7:1.09|R7:4 A|R7:6|R7:7A|R7:404|R7:444-10|R7:1521' \ testcase 'A7R1:2|A7R2:6|A7R2:9|A7R2:11|A7R2:19|A7R2:47A|A7R11:1|AA|R7:1.09|R7:4 A|R7:6|R7:7A|R7:404|R7:444-10|R7:1521' \
input='A7R1:2|R7:1521|AA|R7:4A|R7:7A|A7R2:9|R7:444-10|A7R2:6|R7:1.09|A7R2:47 A|A7R11:1|R7:6|A7R2:11|R7:404|A7R2:19' \ input='A7R1:2|R7:1521|AA|R7:4A|R7:7A|A7R2:9|R7:444-10|A7R2:6|R7:1.09|A7R2:47 A|A7R11:1|R7:6|A7R2:11|R7:404|A7R2:19' \
opt='#' opt='#'
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' 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'
testcase 'Exception: Unknown $sort option: x' input="b|c|b|1" opt=urx testcase 'Exception: Unknown $sort option: x' input="b|c|b|1" opt=urx
testcase 'Exception: Invalid $sort option combination: n#' input="b|c" opt='n#' testcase 'Exception: Invalid $sort option combination: n#' input="b|c" opt='n#'
testcase 'Exception: Invalid $sort option combination: #rn' input="b|1" opt='#rn ' testcase 'Exception: Invalid $sort option combination: #rn' input="b|1" opt='#rn '
# Regression test to test suppression of Content-Type header for early # Regression test to test suppression of Content-Type header for early
# exception. # exception.
rm -rf "$TEST_DB"
echo 'inmemory' > "$TEST_DB"
testcase 'Exception: DocNotFoundError: Docid 1 not found' MORELIKE=1 testcase 'Exception: DocNotFoundError: Docid 1 not found' MORELIKE=1
# Regression test for $sort bug fixed in 1.4.12. # Regression test for $sort bug fixed in 1.4.12.
# Check $sort doesn't ensure_match (or ensure_query). # Check $sort doesn't ensure_match (or ensure_query).
printf '$sort{test} $addfilter{Test}$querydescription' > "$TEST_TEMPLATE" printf '$sort{test} $addfilter{Test}$querydescription' > "$TEST_TEMPLATE"
testcase 'test Query(Test)' testcase 'test Query(Test)'
# Feature tests for $keys. # Feature tests for $keys.
printf '$setmap{x,bee,1,eel,6,dog,4,ant,2,fox,5,cat,3}/$list{$keys{x},|}/$keys{n osuch}/' > "$TEST_TEMPLATE" printf '$setmap{x,bee,1,eel,6,dog,4,ant,2,fox,5,cat,3}/$list{$keys{x},|}/$keys{n osuch}/' > "$TEST_TEMPLATE"
testcase '/ant|bee|cat|dog|eel|fox//' testcase '/ant|bee|cat|dog|eel|fox//'
skipping to change at line 709 skipping to change at line 723
# Test error message doesn't get sent through HTML entity encoding. # Test error message doesn't get sent through HTML entity encoding.
printf '$seterror{{ "error": true, "error_message": "Parameter cannot be > 9" }} $if{$error,$error}' > "$TEST_TEMPLATE" printf '$seterror{{ "error": true, "error_message": "Parameter cannot be > 9" }} $if{$error,$error}' > "$TEST_TEMPLATE"
testcase '{ "error": true, "error_message": "Parameter cannot be > 9" }' P=text testcase '{ "error": true, "error_message": "Parameter cannot be > 9" }' P=text
# Test msize when error set after running query, should not affect running of qu ery. # Test msize when error set after running query, should not affect running of qu ery.
printf '$last$if{$cgi{ERR},$seterror{$cgi{ERR}}}$msize$if{$error,!$error!}' > "$ TEST_TEMPLATE" printf '$last$if{$cgi{ERR},$seterror{$cgi{ERR}}}$msize$if{$error,!$error!}' > "$ TEST_TEMPLATE"
testcase '11' P=text testcase '11' P=text
testcase '11!boo!' P=text ERR=boo testcase '11!boo!' P=text ERR=boo
# Feature tests for $base64{}
printf '$base64{$cgi{in}}' > "$TEST_TEMPLATE"
testcase '' in=""
testcase 'IQ==' in='!'
testcase 'T2s=' in='Ok'
testcase 'aGA+aGA/' in='h`>h`?'
testcase 'YmFzZTY0IHRlc3Q=' in='base64 test'
# Regression test: $setrelevant crashed with no argument list prior to 1.4.16. # Regression test: $setrelevant crashed with no argument list prior to 1.4.16.
printf '$setrelevant$or{$error,No error}' > "$TEST_TEMPLATE" printf '$setrelevant$or{$error,No error}' > "$TEST_TEMPLATE"
testcase 'Exception: too few arguments to $setrelevant' P=text testcase 'Exception: too few arguments to $setrelevant' P=text
printf '$setrelevant{}$or{$error,No error}' > "$TEST_TEMPLATE" printf '$setrelevant{}$or{$error,No error}' > "$TEST_TEMPLATE"
testcase 'No error' P=text testcase 'No error' P=text
# Feature tests for $uniq and $unique{}. # Feature tests for $uniq and $unique{}.
printf '$list{$uniq{$split{$cgi{text}}},:}|$list{$unique{$split{$cgi{text}}},:}' > "$TEST_TEMPLATE" printf '$list{$uniq{$split{$cgi{text}}},:}|$list{$unique{$split{$cgi{text}}},:}' > "$TEST_TEMPLATE"
testcase '|' text='' testcase '|' text=''
testcase 'foo|foo' text='foo' testcase 'foo|foo' text='foo'
skipping to change at line 765 skipping to change at line 787
# "of" is excluded because it's a stopword. # "of" is excluded because it's a stopword.
testcase 'Query((Zwrite@1 OR Zthree@2 OR Zpiec@3))|writing OR three OR piece' MO RELIKE='Qc3' testcase 'Query((Zwrite@1 OR Zthree@2 OR Zpiec@3))|writing OR three OR piece' MO RELIKE='Qc3'
# Test with absent term. # Test with absent term.
testcase 'Query()|' MORELIKE='Qx9' testcase 'Query()|' MORELIKE='Qx9'
# Test multiple MORELIKE parameters. We need to include the dummy document for # Test multiple MORELIKE parameters. We need to include the dummy document for
# any terms to get a positive weight and be returned. # any terms to get a positive weight and be returned.
testcase 'Query((Zsecond@1 OR Zfirst@2 OR Zdocument@3))|second OR first OR docum ent' MORELIKE=1 MORELIKE=2 MORELIKE=4 testcase 'Query((Zsecond@1 OR Zfirst@2 OR Zdocument@3))|second OR first OR docum ent' MORELIKE=1 MORELIKE=2 MORELIKE=4
testcase 'Query((Zsecond@1 OR Zfirst@2 OR Zdocument@3))|second OR first OR docum ent' MORELIKE=Qa1 MORELIKE=2 MORELIKE=4 testcase 'Query((Zsecond@1 OR Zfirst@2 OR Zdocument@3))|second OR first OR docum ent' MORELIKE=Qa1 MORELIKE=2 MORELIKE=4
testcase 'Query((Zsecond@1 OR Zfirst@2 OR Zdocument@3))|second OR first OR docum ent' MORELIKE=Qa1 MORELIKE=Qb2 MORELIKE=Qdummy testcase 'Query((Zsecond@1 OR Zfirst@2 OR Zdocument@3))|second OR first OR docum ent' MORELIKE=Qa1 MORELIKE=Qb2 MORELIKE=Qdummy
# Feature tests for split command scriptindex. # Feature tests for scriptindex `index` and `indexnopos` actions.
printf '%s\n' 't : index=XT' 'n : indexnopos=XN' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
t=positional text
n=no pos here
END
printf '$msize' > "$TEST_TEMPLATE"
testcase '1' P.XT='"positional text"'
testcase '1' P.XN='no AND pos'
testcase '0' P.XN='"no pos"'
# Feature tests for scriptindex `split` action.
printf 'STATUS : field split=| field=SPLITSTATUS\nSTATUS : field=x' > "$TEST_IND EXSCRIPT" printf 'STATUS : field split=| field=SPLITSTATUS\nSTATUS : field=x' > "$TEST_IND EXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=PENDING|REVIEW STATUS=PENDING|REVIEW
END END
printf '$field{STATUS,1}/$field{x,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_T EMPLATE" printf '$field{STATUS,1}/$field{x,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_T EMPLATE"
testcase 'PENDING|REVIEW/PENDING|REVIEW/PENDING,REVIEW' P=text testcase 'PENDING|REVIEW/PENDING|REVIEW/PENDING,REVIEW' P=text
# Feature tests for split dedup command scriptindex. # Feature test for scriptindex `split` action with `dedup` operation.
printf 'STATUS : field split=|,dedup field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split=|,dedup field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=REVIEW|PENDING|PENDING|REVIEW STATUS=REVIEW|PENDING|PENDING|REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE"
testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,PENDING' P=text testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,PENDING' P=text
# Feature tests for split sort command scriptindex. # Feature test for scriptindex `split` action with `sort` operation.
printf 'STATUS : field split=|,sort field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split=|,sort field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=REVIEW|PENDING|PENDING|REVIEW STATUS=REVIEW|PENDING|PENDING|REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE"
testcase 'REVIEW|PENDING|PENDING|REVIEW/PENDING,PENDING,REVIEW,REVIEW' P=text testcase 'REVIEW|PENDING|PENDING|REVIEW/PENDING,PENDING,REVIEW,REVIEW' P=text
# Feature tests for split none command scriptindex. # Feature test for scriptindex `split` action with `none` operation.
printf 'STATUS : field split=|,none field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split=|,none field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=REVIEW|PENDING|PENDING|REVIEW STATUS=REVIEW|PENDING|PENDING|REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE"
testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,PENDING,PENDING,REVIEW' P=text testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,PENDING,PENDING,REVIEW' P=text
# Feature tests for split prefixes command scriptindex. # Feature test for scriptindex `split` action with `prefixes` operation.
printf 'STATUS : field split=|,prefixes field=SPLITSTATUS\n' > "$TEST_INDEXSCRIP T" printf 'STATUS : field split=|,prefixes field=SPLITSTATUS\n' > "$TEST_INDEXSCRIP T"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=REVIEW|PENDING|PENDING|REVIEW STATUS=REVIEW|PENDING|PENDING|REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE"
testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,REVIEW|PENDING,REVIEW|PENDING|PEN DING,REVIEW|PENDING|PENDING|REVIEW' P=text testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,REVIEW|PENDING,REVIEW|PENDING|PEN DING,REVIEW|PENDING|PENDING|REVIEW' P=text
# Feature tests for split prefixes command scriptindex. # Feature tests for scriptindex `split` action with no explicit operation.
printf 'STATUS : field split=|,prefixes field=SPLITSTATUS\n' > "$TEST_INDEXSCRIP
T"
rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=REVIEW|PENDING|PENDING|REVIEW
END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE"
testcase 'REVIEW|PENDING|PENDING|REVIEW/REVIEW,REVIEW|PENDING,REVIEW|PENDING|PEN
DING,REVIEW|PENDING|PENDING|REVIEW' P=text
# Feature tests for split command scriptindex without operation argument.
printf 'STATUS : field split=| field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split=| field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=PENDING|REVIEW|PENDING|REVIEW STATUS=PENDING|REVIEW|PENDING|REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},$.}' > "$TEST_TEMPLATE"
testcase 'PENDING|REVIEW|PENDING|REVIEW/PENDING,REVIEW,PENDING,REVIEW' P=text testcase 'PENDING|REVIEW|PENDING|REVIEW/PENDING,REVIEW,PENDING,REVIEW' P=text
# Feature test for multi-character split delimiter. # Feature test for scriptindex `split` action with multi-character delimiter.
printf 'STATUS : field split=$. field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split=$. field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=PENDING$.$.REVIEW,PENDING$.REVIEW STATUS=PENDING$.$.REVIEW,PENDING$.REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE"
testcase 'PENDING$.$.REVIEW,PENDING$.REVIEW/PENDING|REVIEW,PENDING|REVIEW' P=tex t testcase 'PENDING$.$.REVIEW,PENDING$.REVIEW/PENDING|REVIEW,PENDING|REVIEW' P=tex t
# Feature test for multi-character split delimiter with potential overlap. # Feature test for scriptindex `split` action with multi-character delimiter
# with potential overlap.
printf 'STATUS : field split=:: field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split=:: field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=::Foo::::Bar:Baz:::Hello:: STATUS=::Foo::::Bar:Baz:::Hello::
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE"
testcase '::Foo::::Bar:Baz:::Hello::/Foo|Bar:Baz|:Hello' P=text testcase '::Foo::::Bar:Baz:::Hello::/Foo|Bar:Baz|:Hello' P=text
# Feature test for multi-character split delimiter for prefixes type. # Feature test for scriptindex `split` action with multi-character delimiter
# with `prefixes` operation.
printf 'STATUS : field split=::,prefixes field=SPLITSTATUS\n' > "$TEST_INDEXSCRI PT" printf 'STATUS : field split=::,prefixes field=SPLITSTATUS\n' > "$TEST_INDEXSCRI PT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=::Foo::::Bar:Baz:::Hello:: STATUS=::Foo::::Bar:Baz:::Hello::
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE"
testcase '::Foo::::Bar:Baz:::Hello::/::Foo|::Foo::|::Foo::::Bar:Baz|::Foo::::Bar :Baz:::Hello|::Foo::::Bar:Baz:::Hello::' P=text testcase '::Foo::::Bar:Baz:::Hello::/::Foo|::Foo::|::Foo::::Bar:Baz|::Foo::::Bar :Baz:::Hello|::Foo::::Bar:Baz:::Hello::' P=text
# Feature tests for split command with "," delimiter passed , with double quotes . # Feature test for scriptindex `split` action with quoted `,` delimiter.
printf 'STATUS : field split="," field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT" printf 'STATUS : field split="," field=SPLITSTATUS\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
STATUS=PENDING,REVIEW,PENDING,REVIEW STATUS=PENDING,REVIEW,PENDING,REVIEW
END END
printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE" printf '$field{STATUS,1}/$list{$field{SPLITSTATUS,1},|}' > "$TEST_TEMPLATE"
testcase 'PENDING,REVIEW,PENDING,REVIEW/PENDING|REVIEW|PENDING|REVIEW' P=text testcase 'PENDING,REVIEW,PENDING,REVIEW/PENDING|REVIEW|PENDING|REVIEW' P=text
# Feature test for nested split command. # Feature test for nested scriptindex `split` action.
printf 'in : split=; field=one lower split="," field=two\nin : field' > "$TEST_I NDEXSCRIPT" printf 'in : split=; field=one lower split="," field=two\nin : field' > "$TEST_I NDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
in=a,b,c;10,21,32;XY,YZ in=a,b,c;10,21,32;XY,YZ
END END
printf '$field{in,1}/$list{$field{one,1},|}/$list{$field{two,1},|}' > "$TEST_TEM PLATE" printf '$field{in,1}/$list{$field{one,1},|}/$list{$field{two,1},|}' > "$TEST_TEM PLATE"
testcase 'a,b,c;10,21,32;XY,YZ/a,b,c|10,21,32|XY,YZ/a|b|c|10|21|32|xy|yz' P=text testcase 'a,b,c;10,21,32;XY,YZ/a,b,c|10,21,32|XY,YZ/a|b|c|10|21|32|xy|yz' P=text
# Feature tests for scriptindex hextobin action. # Feature tests for scriptindex `hextobin` action.
printf 'hex : hextobin value=0' > "$TEST_INDEXSCRIPT" printf 'hex : hextobin value=0' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
hex= hex=
hex=41 hex=41
hex=54657374 hex=54657374
hex=4b696C6c hex=4b696C6c
END END
printf '$list{$map{$split{$cgi{DOCIDS}},$value{0,$_}},|}' > "$TEST_TEMPLATE" printf '$list{$map{$split{$cgi{DOCIDS}},$value{0,$_}},|}' > "$TEST_TEMPLATE"
testcase '|A|Test|Kill' DOCIDS='1 2 3 4' testcase '|A|Test|Kill' DOCIDS='1 2 3 4'
# Feature test error cases for scriptindex hextobin action. # Feature test error cases for scriptindex `hextobin` action.
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
echo hex=7g |\ echo hex=7g |\
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null |\ $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null |\
grep -q ":1: error: hextobin: input must be all hex digits" ||\ grep -q ":1: error: hextobin: input must be all hex digits" ||\
{ echo "scriptindex hextobin didn't give error for bad hex digit";\ { echo "scriptindex hextobin didn't give error for bad hex digit";\
failed=`expr $failed + 1`; } failed=`expr $failed + 1`; }
echo hex=404 |\ echo hex=404 |\
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null |\ $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null |\
grep -q ":1: error: hextobin: input must have even length" ||\ grep -q ":1: error: hextobin: input must have even length" ||\
{ echo "scriptindex hextobin didn't give error for odd length hex string";\ { echo "scriptindex hextobin didn't give error for odd length hex string";\
failed=`expr $failed + 1`; } failed=`expr $failed + 1`; }
testcase '7g|404' DOCIDS='1 2' testcase '7g|404' DOCIDS='1 2'
# Feature test for scriptindex `spell` action.
printf '%s\n' 's : spell index' 'n : index' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
printf '%s\n\n' 's=some words test' 'n=tent'|$SCRIPTINDEX "$TEST_DB" "$TEST_INDE
XSCRIPT" > /dev/null
printf '$set{flag_spelling_correction,true}$suggestion' > "$TEST_TEMPLATE"
testcase 'some test' P='home nest'
testcase 'a test' P='a tent'
testcase '' P='gent'
# Feature tests for scriptindex `squash` and `ltrim`/`rtrim`/`trim` actions.
printf 'squash : squash field\nltrim : ltrim field\nrtrim : rtrim field\ntrim :
trim field\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
whitespace_test=`printf "\t lots\v\fof\t whitespace\f "`
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<END
squash=$whitespace_test
ltrim=$whitespace_test
rtrim=$whitespace_test
trim=$whitespace_test
squash=a b
ltrim=a b
rtrim=a b
trim=a b
squash=xyz
ltrim=xyz
rtrim=xyz
trim=xyz
END
printf '$json{$field{$cgi{F},$cgi{ID}}}' > "$TEST_TEMPLATE"
testcase 'lots of whitespace' F=squash ID=1
testcase 'lots\u000b\fof\t whitespace\f ' F=ltrim ID=1
testcase '\t lots\u000b\fof\t whitespace' F=rtrim ID=1
testcase 'lots\u000b\fof\t whitespace' F=trim ID=1
for f in squash ltrim rtrim trim ; do
testcase 'a b' F=$f ID=2
testcase 'xyz' F=$f ID=3
done
# Feature tests for scriptindex `truncate` action.
printf 'x : field=x truncate=9 field=9 truncate=3 field=3 truncate=2 field=2 tru
ncate=1 field=1 truncate=0 field=0\n' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<END
x=really long field
x=xö xxxxö x
x=ö xxxxö x
x=x x xx🥝 x
x=a test
x=tri
x=du
x=1
x=
END
printf '$foreach{$split{1 2 3 4 5 6 7 8 9},$set{d,$_}$list{$map{$split{x 9 3 2 1
0},$field{$_,$opt{d}}},|}:}' > "$TEST_TEMPLATE"
testcase 'really long field|really|rea|re|r|:xö xxxxö x|xö|xö|x|x|:ö xxxxö x|ö x
xxxö|ö|ö||:x x xx🥝 x|x x|x x|x|x|:a test|a test|a|a|a|:tri|tri|tri|tr|t|:du|du|d
u|du|d|:1|1|1|1|1|:|||||:'
# Feature tests for scriptindex `unhtml` action.
printf '%s\n' 't : unhtml field=h' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
t=<b>No</b>table
t=<p>foo</p>d<p>bar<B>b</B></p>
END
printf '$list{$map{$split{$cgi{DOCIDS}},$field{h,$_}},|}' > "$TEST_TEMPLATE"
testcase "`printf 'Notable|foo\rd\rbarb'`" DOCIDS='1 2'
# Feature test for scriptindex `weight` action.
printf '%s\n' 't : index' 'w : weight=2 index' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
printf '%s\n\n' 't=test' 'w=test' 't=test test test'|$SCRIPTINDEX "$TEST_DB" "$T
EST_INDEXSCRIPT" > /dev/null
printf '|$hitlist{$id|}' > "$TEST_TEMPLATE"
testcase '|3|2|1|' P=test
# Test useless action warnings. # Test useless action warnings.
printf 'foo : index weight=2' > "$TEST_INDEXSCRIPT" printf 'foo : index weight=2' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \ if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
| grep -q ":1:13: warning: Index action 'weight' has no effect" ; then | grep -q ":1:13: warning: Index action 'weight' has no effect" ; then
: # OK : # OK
else else
echo "scriptindex didn't give expected warning for useless 'weight' action" echo "scriptindex didn't give expected warning for useless 'weight' action"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
skipping to change at line 993 skipping to change at line 1102
echo "scriptindex didn't exit with non-zero return code for missing closing quote" echo "scriptindex didn't exit with non-zero return code for missing closing quote"
failed=`expr $failed + 1` failed=`expr $failed + 1`
elif printf '%s' "$out" \ elif printf '%s' "$out" \
| grep -q ":1:18: error: No closing quote" ; then | grep -q ":1:18: error: No closing quote" ; then
: # OK : # OK
else else
echo "scriptindex didn't give expected error for missing closing quote" echo "scriptindex didn't give expected error for missing closing quote"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Feature tests for termprefix and unprefix. # Feature tests for scriptindex `termprefix` and `unprefix` actions.
printf '$termprefix{$cgi{B}}|$unprefix{$cgi{B}}' > "$TEST_TEMPLATE" printf '$termprefix{$cgi{B}}|$unprefix{$cgi{B}}' > "$TEST_TEMPLATE"
testcase '|' B='' testcase '|' B=''
testcase '|something' B='something' testcase '|something' B='something'
testcase '|42' B='42' testcase '|42' B='42'
testcase '|3bad' B='3bad' testcase '|3bad' B='3bad'
testcase '|&something' B='&something' testcase '|&something' B='&something'
testcase '|:something' B=':something' testcase '|:something' B=':something'
testcase 'H|example.org' B='Hexample.org' testcase 'H|example.org' B='Hexample.org'
testcase 'K|tag' B='Ktag' testcase 'K|tag' B='Ktag'
testcase 'K|Capital' B='KCapital' testcase 'K|Capital' B='KCapital'
skipping to change at line 1015 skipping to change at line 1124
testcase 'K|:Capital' B='K:Capital' testcase 'K|:Capital' B='K:Capital'
testcase 'XCOLOUR|red' B='XCOLOURred' testcase 'XCOLOUR|red' B='XCOLOURred'
testcase 'XPUNC|:colon' B='XPUNC::colon' testcase 'XPUNC|:colon' B='XPUNC::colon'
testcase 'XPUNC|internal:colon' B='XPUNC:internal:colon' testcase 'XPUNC|internal:colon' B='XPUNC:internal:colon'
testcase 'XPUNC|:Colon' B='XPUNC::Colon' testcase 'XPUNC|:Colon' B='XPUNC::Colon'
testcase 'XCASE|Upper' B='XCASE:Upper' testcase 'XCASE|Upper' B='XCASE:Upper'
testcase 'XCASE|TITLE' B='XCASE:TITLE' testcase 'XCASE|TITLE' B='XCASE:TITLE'
testcase 'XNUM|42' B='XNUM42' testcase 'XNUM|42' B='XNUM42'
testcase 'XNUM|3bad' B='XNUM3bad' testcase 'XNUM|3bad' B='XNUM3bad'
# Test to make sure out generate_sample function in sample.cc # Regression test for $truncate with maxlen < the length of the indicator
# Doesn't run into negative memory access # string.
printf '$truncate{$cgi{input},$cgi{maxlen},$cgi{ind},$cgi{ind2}}$seterror{$opt{e rror}}' > "$TEST_TEMPLATE" printf '$truncate{$cgi{input},$cgi{maxlen},$cgi{ind},$cgi{ind2}}$seterror{$opt{e rror}}' > "$TEST_TEMPLATE"
testcase 'w...' input='wwwwww' maxlen=4 ind='...' ind2='...' testcase 'w...' input='wwwwww' maxlen=4 ind='...' ind2='...'
testcase '' input='s' maxlen=0 ind='...' ind2='...' testcase '' input='s' maxlen=0 ind='...' ind2='...'
# Test $subdb and $subid. # Test $subdb and $subid.
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
printf 'inmemory' > "$TEST_DB" printf 'inmemory' > "$TEST_DB"
printf 'inmemory' > "${TEST_DB}2" printf 'inmemory' > "${TEST_DB}2"
printf 'inmemory\ninmemory\n' > "${TEST_DB}3" printf 'inmemory\ninmemory\n' > "${TEST_DB}3"
printf '$subdb{$cgi{ID}}|$subid{$cgi{ID}}' > "$TEST_TEMPLATE" printf '$subdb{$cgi{ID}}|$subid{$cgi{ID}}' > "$TEST_TEMPLATE"
skipping to change at line 1066 skipping to change at line 1175
testcase '[], [], ["B4","K9"], ["a","\"b\"","c:\\"], [4,9,25,49]' testcase '[], [], ["B4","K9"], ["a","\"b\"","c:\\"], [4,9,25,49]'
# Feature tests for $jsonbool # Feature tests for $jsonbool
printf '%s' '$jsonbool{} $jsonbool{$eq{a,b}} $jsonbool{x} $jsonbool{0}' > "$TEST _TEMPLATE" printf '%s' '$jsonbool{} $jsonbool{$eq{a,b}} $jsonbool{x} $jsonbool{0}' > "$TEST _TEMPLATE"
testcase 'false false true true' testcase 'false false true true'
# Feature tests for $jsonobject # Feature tests for $jsonobject
printf '%s' '$jsonobject{foo}' > "$TEST_TEMPLATE" printf '%s' '$jsonobject{foo}' > "$TEST_TEMPLATE"
testcase '{}' testcase '{}'
printf '%s' '$setmap{foo,Han,Solo}$jsonobject{foo}' > "$TEST_TEMPLATE" printf '%s' '$setmap{foo,Han,Solo}$jsonobject{foo}' > "$TEST_TEMPLATE"
testcase '{ testcase '{"Han":"Solo"}'
"Han": "Solo"
}'
printf '%s' '$setmap{foo,key 1,value1,key"2,value\2,key3,value3}$jsonobject{foo} ' > "$TEST_TEMPLATE" printf '%s' '$setmap{foo,key 1,value1,key"2,value\2,key3,value3}$jsonobject{foo} ' > "$TEST_TEMPLATE"
testcase '{ testcase '{"key 1":"value1","key\"2":"value\\2","key3":"value3"}'
"key 1": "value1",
"key\"2": "value\\2",
"key3": "value3"
}'
printf '%s' '$setmap{foo,key 1,1,key"2,$split{1 2},key3,$split{2 3 5}}$jsonobjec t{foo,,$jsonarray{$_,$add{$_,1}}}' > "$TEST_TEMPLATE" printf '%s' '$setmap{foo,key 1,1,key"2,$split{1 2},key3,$split{2 3 5}}$jsonobjec t{foo,,$jsonarray{$_,$add{$_,1}}}' > "$TEST_TEMPLATE"
testcase '{ testcase '{"key 1":[2],"key\"2":[2,3],"key3":[3,4,6]}'
"key 1": [2],
"key\"2": [2,3],
"key3": [3,4,6]
}'
printf '%s' '$setmap{foo,key 1,,key"2,1,key3,0}$jsonobject{foo,$upper{$_},$jsona rray{$_,$add{$_}}}' > "$TEST_TEMPLATE" printf '%s' '$setmap{foo,key 1,,key"2,1,key3,0}$jsonobject{foo,$upper{$_},$jsona rray{$_,$add{$_}}}' > "$TEST_TEMPLATE"
testcase '{ testcase '{"KEY 1":[],"KEY\"2":[1],"KEY3":[0]}'
"KEY 1": [],
"KEY\"2": [1],
"KEY3": [0]
}'
# Feature tests for $stoplist # Feature tests for $stoplist
printf '%s' '$setmap{prefix,foo,XFOO}[$list{$stoplist,|}]' > "$TEST_TEMPLATE" printf '%s' '$setmap{prefix,foo,XFOO}[$list{$stoplist,|}]' > "$TEST_TEMPLATE"
testcase '[a|the]' P.XFOO='the test' P='a test' testcase '[a|the]' P.XFOO='the test' P='a test'
# Feature tests for $unstem # Feature tests for $unstem
printf '%s' '$setmap{prefix,foo,XFOO}[$list{$unstem{$cgi{TERM}},|}]' > "$TEST_TE MPLATE" printf '%s' '$setmap{prefix,foo,XFOO}[$list{$unstem{$cgi{TERM}},|}]' > "$TEST_TE MPLATE"
testcase '[pots|pot|potting]' P.XFOO='(foo:pot OR luck) (potting OR shed)' P='fl ower OR foo:pots' TERM=ZXFOOpot testcase '[pots|pot|potting]' P.XFOO='(foo:pot OR luck) (potting OR shed)' P='fl ower OR foo:pots' TERM=ZXFOOpot
# Feature tests of scriptindex. # Feature tests of scriptindex.
# Regression test: non-zero exit status for unknown option. # Regression test: non-zero exit status for unknown option.
if $SCRIPTINDEX --to-be-or-not-to-be "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null < /dev/null 2>&1; then if $SCRIPTINDEX --to-be-or-not-to-be "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null < /dev/null 2>&1; then
echo "scriptindex didn't give error for unknown option" echo "scriptindex didn't give error for unknown option"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Regression test: error given for multiple unique actions. # Regression test: error given for multiple `unique` actions.
printf 'uuid : boolean=Q unique=Q\nguid : boolean=G unique=G' > "$TEST_INDEXSCRI PT" printf 'uuid : boolean=Q unique=Q\nguid : boolean=G unique=G' > "$TEST_INDEXSCRI PT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null < /dev/null 2>&1; the n if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null < /dev/null 2>&1; the n
echo "scriptindex didn't reject 'unique' action being used more than once" echo "scriptindex didn't reject 'unique' action being used more than once"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Test we check for hash's argument being an integer (new in 1.4.6). # Test we check for hash's argument being an integer (new in 1.4.6).
printf 'url : hash=37.3 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT" printf 'url : hash=37.3 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
skipping to change at line 1166 skipping to change at line 1261
| grep -q ":1:12: error: Unknown index action '42'" ; then | grep -q ":1:12: error: Unknown index action '42'" ; then
: # OK : # OK
else else
echo "scriptindex didn't give expected error for a missing equals sign" echo "scriptindex didn't give expected error for a missing equals sign"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Test we warn about spaces before and after '='. # Test we warn about spaces before and after '='.
# #
# This has never been documented as supported, and was deprecated in 1.4.6 # This has never been documented as supported, and was deprecated in 1.4.6
# because it resulted in this quietly using hash as the field name, which is # because it resulted in this quietly using `hash` as the field name, which is
# probably not what was intended: # probably not what was intended:
# #
# url : field= hash boolean=Q unique=Q # url : field= hash boolean=Q unique=Q
printf 'url : field= hash boolean=Q unique=Q' > "$TEST_INDEXSCRIPT" printf 'url : field= hash boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \ if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
| grep -q ":1:13: warning: putting spaces between '=' and the argument is de precated" ; then | grep -q ":1:13: warning: putting spaces between '=' and the argument is de precated" ; then
: # OK : # OK
else else
echo "scriptindex didn't give expected warning for space after '='" echo "scriptindex didn't give expected warning for space after '='"
skipping to change at line 1189 skipping to change at line 1284
printf 'url : field =link' > "$TEST_INDEXSCRIPT" printf 'url : field =link' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \ if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
| grep -q ":1:12: warning: putting spaces between the action and '=' is depr ecated" ; then | grep -q ":1:12: warning: putting spaces between the action and '=' is depr ecated" ; then
: # OK : # OK
else else
echo "scriptindex didn't give expected warning for space before '='" echo "scriptindex didn't give expected warning for space before '='"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Feature tests for date action. # Feature tests for scriptindex `date` action.
printf '%s\n' 'd : date=unix' 'g : date=unixutc' > "$TEST_INDEXSCRIPT" printf '%s\n' 'd : date=unix' 'g : date=unixutc' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
# date=unix works in the current timezone, so set that explicitly so the # `date=unix` works in the current timezone, so set that explicitly so the
# build doesn't fail if run in a timezone which is behind UTC. # build doesn't fail if run in a timezone which is behind UTC.
TZ=UTC $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' TZ=UTC $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
d= d=
d=0 d=0
d=1541478429 d=1541478429
END END
printf '$list{$map{$range{1,3},$list{$allterms{$_}, }},|}' > "$TEST_TEMPLATE" printf '$list{$map{$range{1,3},$list{$allterms{$_}, }},|}' > "$TEST_TEMPLATE"
testcase '|D19700101 M197001 Y1970|D20181106 M201811 Y2018' testcase '|D19700101 M197001 Y1970|D20181106 M201811 Y2018'
# date=unixutc should always work in UTC regardless of the current timezone. # `date=unixutc` should always work in UTC regardless of the current timezone.
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
g= g=
g=0 g=0
g=1541478429 g=1541478429
END END
testcase '|D19700101 M197001 Y1970|D20181106 M201811 Y2018' testcase '|D19700101 M197001 Y1970|D20181106 M201811 Y2018'
# Check nested $hitlist{} doesn't result in an infinite loop. # Check nested $hitlist{} doesn't result in an infinite loop.
# Regression test for bug fixed in 1.4.12. # Regression test for bug fixed in 1.4.12.
printf '<|$hitlist{$id(:$hitlist{$id:})|}>' > "$TEST_TEMPLATE" printf '<|$hitlist{$id(:$hitlist{$id:})|}>' > "$TEST_TEMPLATE"
testcase '<|2(:2:3:)|3(:2:3:)|>' B=Y1970 B=Y2018 testcase '<|2(:2:3:)|3(:2:3:)|>' B=Y1970 B=Y2018
# Feature tests for parsedate action. # Feature tests for scriptindex `parsedate` action.
printf '%s\n' 'DATE : field parsedate=%Y%m%d valuepacked=13' > "$TEST_INDEXSCRIP T" printf '%s\n' 'DATE : field parsedate=%Y%m%d valuepacked=13' > "$TEST_INDEXSCRIP T"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
DATE=19891204 DATE=19891204
END END
printf '$field{DATE,1}|$unpack{$value{13,1}}|$date{$unpack{$value{13,1}}}' > "$T EST_TEMPLATE" printf '$field{DATE,1}|$unpack{$value{13,1}}|$date{$unpack{$value{13,1}}}' > "$T EST_TEMPLATE"
testcase '19891204|628732800|1989-12-04' P=text testcase '19891204|628732800|1989-12-04' P=text
# Feature tests for parsedate action. # Feature tests for scriptindex `parsedate` action.
printf '%s\n' \ printf '%s\n' \
'DATE: parsedate="%Y%m%d %T" field=time' \ 'DATE: parsedate="%Y%m%d %T" field=time' \
'TIME_T: parsedate=%s field=time' > "$TEST_INDEXSCRIPT" 'TIME_T: parsedate=%s field=time' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 <<'END'
DATE=20161202 12:04:22.000000 DATE=20161202 12:04:22.000000
TIME_T=1480680263 TIME_T=1480680263
END END
printf '$field{time,$cgi{id}}' > "$TEST_TEMPLATE" printf '$field{time,$cgi{id}}' > "$TEST_TEMPLATE"
# Test format which contains a space. # Test format which contains a space.
testcase '1480680262' id=1 testcase '1480680262' id=1
# Regression test - we used to add on the local timezone offset. # Regression test - we used to add on the local timezone offset.
testcase '1480680263' id=2 testcase '1480680263' id=2
if grep -q 'define HAVE_STRUCT_TM_TM_GMTOFF 1' config.h ; then if grep -q 'define HAVE_STRUCT_TM_TM_GMTOFF 1' config.h ; then
# Feature tests for parsedate action. # Feature tests for scriptindex `parsedate` action.
printf '%s\n' 'DATE: parsedate="%Y%m%d %T %z" field=time' > "$TEST_INDEXSCRIPT " printf '%s\n' 'DATE: parsedate="%Y%m%d %T %z" field=time' > "$TEST_INDEXSCRIPT "
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
echo 'DATE=20161202 21:34:22 +0930' | \ echo 'DATE=20161202 21:34:22 +0930' | \
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1
printf '$field{time,$cgi{id}}' > "$TEST_TEMPLATE" printf '$field{time,$cgi{id}}' > "$TEST_TEMPLATE"
# Test that timezone adjustment is applied. # Test that timezone adjustment is applied.
testcase '1480680262' id=1 testcase '1480680262' id=1
else else
echo "Skipping testcases which need tm_gmtoff member in struct tm" echo "Skipping testcases which need tm_gmtoff member in struct tm"
fi fi
# Feature tests for load action. # Feature tests for scriptindex `valuenumeric` action.
printf '%s\n' 'n : field valuenumeric=0' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
n=0
n=1.75
n=-1000000000
END
printf '$list{$map{$range{1,3},$url{$value{0,$_}}},:}' > "$TEST_TEMPLATE"
testcase '%80:%A3:%1F%A4FS%60'
# Feature tests for scriptindex `load` action.
printf '%s\n' 'file : load field' > "$TEST_INDEXSCRIPT" printf '%s\n' 'file : load field' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
rc=0 rc=0
out=`echo 'file='|$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null | | rc=$?` out=`echo 'file='|$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" 2>&1 > /dev/null | | rc=$?`
if [ $rc -ne 0 ] ; then if [ $rc -ne 0 ] ; then
echo "scriptindex gave error for empty filename in load action" echo "scriptindex gave error for empty filename in load action"
printf '%s\n' "$out" printf '%s\n' "$out"
failed=`expr $failed + 1` failed=`expr $failed + 1`
else else
case $out in case $out in
*':1: warning: Empty filename in LOAD action') ;; *':1: warning: Empty filename in LOAD action') ;;
*) *)
echo "scriptindex didn't give expected warning for empty filename in load action" echo "scriptindex didn't give expected warning for empty filename in load action"
printf '%s\n' "$out" printf '%s\n' "$out"
failed=`expr $failed + 1` failed=`expr $failed + 1`
;; ;;
esac esac
fi fi
# Feature tests for quoted arguments. # Feature tests for quoted arguments.
printf 'DATE : field=" spaces " date="yyyymmdd"\nTEXT: index\n' > "$TEST_INDEX SCRIPT" printf 'DATE : field=" spaces " date="yyyymmdd"\nTEXT: index="S"\n' > "$TEST_I NDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
DATE=19891204 DATE=19891204
TEXT=This is sample text. TEXT=This is sample text.
NEXT=work NEXT=work
END END
printf '$freq{D19891204}|$field{ spaces ,1}' > "$TEST_TEMPLATE" printf '$freq{D19891204}|$field{ spaces ,1}' > "$TEST_TEMPLATE"
testcase '1|19891204' P=text testcase '1|19891204' P.S=text
# Use $time to force the match to run. # Use $time to force the match to run.
printf '$if{x$time,$freq{D19891204}}|$field{ spaces ,1}' > "$TEST_TEMPLATE" printf '$if{x$time,$freq{D19891204}}|$field{ spaces ,1}' > "$TEST_TEMPLATE"
testcase '1|19891204' P= testcase '1|19891204' P=
# Feature tests for escaping in quoted arguments. # Feature tests for escaping in quoted arguments.
printf '%s\n' 'esc : field="\tesca\x70e,test\\\""' > "$TEST_INDEXSCRIPT" printf '%s\n' 'esc : field="\tesca\x70e,test\\\""' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END' $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null <<'END'
esc=test esc=test
END END
skipping to change at line 1355 skipping to change at line 1463
printf 'date : field parsedate=%%Y%%m%%d' > "$TEST_INDEXSCRIPT" printf 'date : field parsedate=%%Y%%m%%d' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \ if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null 2>&1 \
| grep -q ":1:14: warning: Index action 'parsedate' has no effect" ; then | grep -q ":1:14: warning: Index action 'parsedate' has no effect" ; then
: # OK : # OK
else else
echo "scriptindex didn't give expected warning for useless 'parsedate'" echo "scriptindex didn't give expected warning for useless 'parsedate'"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Test 'gap' action inserts a termpos gap. # Test scriptindex `gap` action inserts a termpos gap.
printf 'text : index gap=5' > "$TEST_INDEXSCRIPT" printf 'text : index gap=5' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
printf 'text=%s\n' foo bar baz|$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /de v/null printf 'text=%s\n' foo bar baz|$SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /de v/null
echo '|$hitlist{$id|}' > "$TEST_TEMPLATE" echo '|$hitlist{$id|}' > "$TEST_TEMPLATE"
testcase '|' 'P="foo bar"' testcase '|' 'P="foo bar"'
testcase '|' 'P=foo NEAR/5 bar' testcase '|' 'P=foo NEAR/5 bar'
testcase '|' 'P=foo NEAR/11 baz' testcase '|' 'P=foo NEAR/11 baz'
testcase '|1|' 'P=foo NEAR/6 bar' testcase '|1|' 'P=foo NEAR/6 bar'
testcase '|1|' 'P=foo NEAR/12 baz' testcase '|1|' 'P=foo NEAR/12 baz'
# The 'hash' action should require its argument is >= 6, so test 5 is rejected. # The scriptindex `hash` action should require its argument is >= 6, so test 5
# is rejected.
printf 'url : hash=5 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT" printf 'url : hash=5 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null > /dev/null 2>&1 ; th en if $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" < /dev/null > /dev/null 2>&1 ; th en
echo "scriptindex didn't reject 'hash=5'" echo "scriptindex didn't reject 'hash=5'"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# And that 6 is accepted. # And that 6 is accepted.
printf 'url : hash=6 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT" printf 'url : hash=6 boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if echo 'url=http://xapian.org' | $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 ; then if echo 'url=http://xapian.org' | $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 ; then
: # OK : # OK
else else
echo "scriptindex rejected 'hash=6'" echo "scriptindex rejected 'hash=6'"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Regression test to check hash works without argument (it was failing with an # Regression test to check `hash` works without argument (it was failing with
# assertion in unreleased versions prior to 1.4.6). # an assertion in unreleased versions prior to 1.4.6).
printf 'url : hash boolean=Q unique=Q' > "$TEST_INDEXSCRIPT" printf 'url : hash boolean=Q unique=Q' > "$TEST_INDEXSCRIPT"
rm -rf "$TEST_DB" rm -rf "$TEST_DB"
if echo 'url=http://xapian.org' | $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 ; then if echo 'url=http://xapian.org' | $SCRIPTINDEX "$TEST_DB" "$TEST_INDEXSCRIPT" > /dev/null 2>&1 ; then
: # OK : # OK
else else
echo "scriptindex rejected 'hash'" echo "scriptindex rejected 'hash'"
failed=`expr $failed + 1` failed=`expr $failed + 1`
fi fi
# Test the same actions for multiple fields works (briefly broken in git master # Test the same actions for multiple fields works (briefly broken in git master
 End of changes. 38 change blocks. 
61 lines changed or deleted 176 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)