From 987ab8cfd2c83c2bb7cea7cee026dbfee3eb8b6b Mon Sep 17 00:00:00 2001 From: "David E. Wheeler" Date: Thu, 8 Feb 2024 15:51:56 -0500 Subject: [PATCH] Reauire Lucy 0.6.2 Add regression tests to ensure it no longer chokes on null bytes. Fixes pgxn/pgxn-api#23 and pgxn/pgxn-api#23. Stop skipping tests against Lucy 0.002002, which is no longer supported. Add developer dependencies and drop for Perl 5.10. Timestamp for v0.11.1. --- .github/workflows/ci.yml | 2 +- Build.PL | 18 ++++++--- Changes | 8 +++- README.md | 5 ++- t/base.t | 82 +++++++++++++++++++++++----------------- 5 files changed, 71 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 172f9e9..213e459 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: os: [[🐧, ubuntu], [🍎, macos]] # [🪟, windows] - perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12', '5.10' ] + perl: [ '5.38', '5.36', '5.34', '5.32', '5.30', '5.28', '5.26', '5.24', '5.22', '5.20', '5.18', '5.16', '5.14', '5.12' ] name: 🧅 Perl ${{ matrix.perl }} on ${{ matrix.os[0] }} ${{ matrix.os[1] }} runs-on: ${{ matrix.os[1] }}-latest steps: diff --git a/Build.PL b/Build.PL index a984d5e..a8d6fd8 100644 --- a/Build.PL +++ b/Build.PL @@ -33,9 +33,6 @@ $class->new( license => 'perl', create_makefile_pl => 'traditional', configure_requires => { 'Module::Build' => '0.4209' }, - build_requires => { - 'Module::Build' => '0.4209', - }, test_requires => { 'File::Path' => '2.08', 'File::Spec::Functions' => 0, @@ -44,14 +41,23 @@ $class->new( requires => { 'Carp' => 0, 'File::Spec' => 0, - 'Lucy' => '0.2.1', - 'perl' => '5.10.0', + 'Lucy' => '0.6.2', + 'perl' => '5.12.0', }, meta_merge => { resources => { homepage => 'https://metacpan.org/dist/PGXN-API-Searcher', bugtracker => 'https://github.com/pgxn/pgxn-api-searcher/issues/', repository => 'https://github.com/pgxn/pgxn-api-searcher/', - } + }, + prereqs => { + develop => { + requires => { + 'Test::Pod' => '1.41', + 'Test::Pod::Coverage' => '1.06', + 'Test::Spelling' => '0.25', + }, + }, + }, }, )->create_build_script; diff --git a/Changes b/Changes index 5bd9748..0864766 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,12 @@ Revision history for Perl extension PGXN-API-Searcher. -0.11.1 +0.11.1 2024-02-08T21:21:37Z + - Require Lucy v0.6.2. + - Added regression tests to ensure Lucy no longer chokes on null bytes + in the query (pgxn/pgxn-api#23). + - Restored test that skipped running to avoid a bug in Lucy 0.002002. + - Added developer dependencies. + - Dropped support for Perl 5.10. 0.11.0 2024-02-06T23:37:09Z - Converted the version from a v-string to a string to make diff --git a/README.md b/README.md index c41dc25..9bff6ec 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,8 @@ which is generated by PGXN::API. So if you use that module to create an API server, you can use its index with this module. In fact, it uses *this* module to serve the search API. -INSTALLATION +Installation +------------ To install this module, type the following: @@ -29,7 +30,7 @@ Dependencies PGXN-API-Searcher requires the following modules: * perl 5.12.0 -* Lucy 0.2.1 +* Lucy 0.5.2 Copyright and License --------------------- diff --git a/t/base.t b/t/base.t index 406bfe9..39e1174 100644 --- a/t/base.t +++ b/t/base.t @@ -3,8 +3,8 @@ use strict; use warnings; use utf8; -use Test::More tests => 37; -#use Test::More 'no_plan'; +use Test::More tests => 41; +# use Test::More 'no_plan'; use Lucy::Plan::Schema; use Lucy::Plan::FullTextType; use Lucy::Analysis::PolyAnalyzer; @@ -276,37 +276,32 @@ like delete $res->{hits}[0]{score}, qr/^\d+[.]\d+$/, like delete $res->{hits}[1]{score}, qr/^\d+[.]\d+$/, 'Second hit score should look like a score'; -TODO: { - # Hack to work around bug in Lucy 0.2.2. - local $TODO = 'Lucy 0.2.2 is broken' if Lucy->VERSION == 0.002002; - - is_deeply $res, { - query => "ordered pair", - limit => 50, - offset => 0, - count => 2, - hits => [ - { - abstract => "A key/value pair data type", - date => "2010-10-18T15:24:21Z", - dist => "pair", - excerpt => "This is the pair README file. Here you will find all thingds related to pair, including installation information", - user => "theory", - user_name => "David E. Wheeler", - version => "0.1.0", - }, - { - abstract => "A semantic version data type", - date => "2010-10-18T15:24:21Z", - dist => "semver", - excerpt => "README for the semver distribion. Installation instructions", - user => "roger", - user_name => "Roger Davidson", - version => "2.1.3", - }, - ], - }, 'Should have results for simple search'; -} +is_deeply $res, { + query => "ordered pair", + limit => 50, + offset => 0, + count => 2, + hits => [ + { + abstract => "A key/value pair data type", + date => "2010-10-18T15:24:21Z", + dist => "pair", + excerpt => "This is the pair README file. Here you will find all thingds related to pair, including installation information", + user => "theory", + user_name => "David E. Wheeler", + version => "0.1.0", + }, + { + abstract => "A semantic version data type", + date => "2010-10-18T15:24:21Z", + dist => "semver", + excerpt => "README for the semver distribion. Installation instructions", + user => "roger", + user_name => "Roger Davidson", + version => "2.1.3", + }, + ], +}, 'Should have results for simple search'; # Test offset. ok $res = $search->search( @@ -447,7 +442,6 @@ is_deeply $res, { ], }, 'Should have expected structure for extensions'; - ok $res = $search->search( query => 'Davidson', in => 'users' ), 'Seach users'; like delete $res->{hits}[0]{score}, qr/^\d+[.]\d+$/, 'The score should look like a score'; @@ -466,3 +460,23 @@ is_deeply $res, { ], }, 'Should have expected structure for users'; +# Regressions. +for my $spec ( + # https://github.com/pgxn/pgxn-api/issues/23 + { + name => 'issue 23', + query => "json%00'%7C%7CSLeeP(3)%26%26'1", # "json\0'||SLeeP(3)&&'1" + in => 'docs', + }, + # https://github.com/pgxn/pgxn-api/issues/26 + { + name => 'issue 26', + query => "..%00", # "..\0" + in => 'docs', + } +) { + ok $res = $search->search( query => $spec->{query}, in => $spec->{in} ), + "Search $spec->{name}"; + is_deeply $res, { count => 0, hits => [], limit => 50, offset => 0, query => $spec->{query} }, + "Should have empty structure for $spec->{name}"; +}