Skip to content

Commit

Permalink
Add test for issue slusarz#38
Browse files Browse the repository at this point in the history
  • Loading branch information
edieterich committed Jan 4, 2023
1 parent f7f6458 commit 1e358a6
Show file tree
Hide file tree
Showing 8 changed files with 568 additions and 2 deletions.
9 changes: 7 additions & 2 deletions .github/actions/dovecot-fts-flatcurve-test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,21 @@ RUN apt-get update && apt-get install -y \
libexttextcat-dev \
libicu-dev \
libxapian-dev \
dovecot-imaptest
dovecot-imaptest \
libclucene-dev \
unzip \
poppler-utils

# We need to build Dovecot ourselves, since "standard" Dovecot does not
# come with necessary ICU libraries built-in
RUN mkdir /dovecot
RUN git clone --depth 1 --branch release-2.3 \
https://github.com/dovecot/core.git /dovecot/core
COPY patches /patches
RUN cd /dovecot/core && patch -p1 < /patches/fts-squat.patch
RUN cd /dovecot/core && \
./autogen.sh && \
PANDOC=false ./configure --with-stemmer --with-textcat --with-icu && \
PANDOC=false ./configure --with-stemmer --with-textcat --with-icu --with-lucene && \
make install

RUN git clone --depth 1 https://github.com/slusarz/dovecot-fts-flatcurve.git \
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
!include /dovecot/configs/dovecot.conf

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!include /dovecot/configs/dovecot.conf

mail_plugins = $mail_plugins fts fts_lucene

plugin {
fts = lucene
fts_lucene = whitespace_chars=@.
}

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
!include /dovecot/configs/dovecot.conf

mail_plugins = $mail_plugins fts fts_squat

plugin {
fts = squat
fts_squat = partial=4 full=10
}

plugin {
fts_decoder = decode2text
}

service decode2text {
executable = script /usr/local/libexec/dovecot/decode2text.sh
unix_listener decode2text {
mode = 0666
}
}
10 changes: 10 additions & 0 deletions .github/actions/dovecot-fts-flatcurve-test/fts-flatcurve-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -195,3 +195,13 @@ done
run_test "Testing virtual search" \
/dovecot/configs/dovecot.conf.virtual \
/dovecot/imaptest/virtual

run_test "Testing GitHub Issue #38 using Lucene" \
/dovecot/configs/dovecot.conf.issue-38-lucene \
/dovecot/imaptest/issue-38/issue-38
run_test "Testing GitHub Issue #38 using Squat" \
/dovecot/configs/dovecot.conf.issue-38-squat \
/dovecot/imaptest/issue-38/issue-38
run_test "Testing GitHub Issue #38 using Flatcurve" \
/dovecot/configs/dovecot.conf.issue-38-flatcurve \
/dovecot/imaptest/issue-38/issue-38

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
messages: all

ok search body bodybody
* search 1
ok search body attachment
* search 1
ok search or body bodybody header reply-to bodybody
* search 1
ok search or body attachment header reply-to attachment
* search 1
45 changes: 45 additions & 0 deletions .github/actions/dovecot-fts-flatcurve-test/patches/fts-squat.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
diff --git a/src/plugins/fts-squat/fts-backend-squat.c b/src/plugins/fts-squat/fts-backend-squat.c
index fbd7bbe156..ff6d429f61 100644
--- a/src/plugins/fts-squat/fts-backend-squat.c
+++ b/src/plugins/fts-squat/fts-backend-squat.c
@@ -21,7 +21,7 @@ struct squat_fts_backend {
struct squat_trie *trie;

unsigned int partial_len, full_len;
- bool refresh;
+ /* bool refresh; */
};

struct squat_fts_backend_update_context {
@@ -105,8 +105,9 @@ fts_backend_squat_set_box(struct squat_fts_backend *backend,
struct mailbox_status status;
const char *path;
enum squat_index_flags flags = 0;
- int ret;
+ /* int ret; */

+ /*
if (backend->box == box)
{
if (backend->refresh) {
@@ -117,8 +118,9 @@ fts_backend_squat_set_box(struct squat_fts_backend *backend,
}
return 0;
}
+ */
fts_backend_squat_unset_box(backend);
- backend->refresh = FALSE;
+ /* backend->refresh = FALSE; */
if (box == NULL)
return 0;

@@ -343,7 +345,8 @@ static int fts_backend_squat_refresh(struct fts_backend *_backend)
struct squat_fts_backend *backend =
(struct squat_fts_backend *)_backend;

- backend->refresh = TRUE;
+ /* backend->refresh = TRUE; */
+ fts_backend_squat_unset_box(backend);
return 0;
}

0 comments on commit 1e358a6

Please sign in to comment.