packages/tracker3/0001-tests-Adapt-FTS-snippet-tests-to-run-before-after-SQ.patch

133 lines
5.7 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Carlos Garnacho <carlosg@gnome.org>
Date: Sat, 20 May 2023 11:42:09 +0200
Subject: [PATCH] tests: Adapt FTS snippet tests to run before/after SQLite
3.42.0
This SQLite version fixes a small bug in the FTS5 snippet function
that affects our output checks here. Concretely, it might ignore
the specified number of output words with repeated matched terms.
It is good that we have FTS tests, but we do not need to test for
this behavior specifically. Adapt the tests so that we keep their
spirit but bypass the SQLite behavior change. The snippet-4 test
coincided too much on it and had to be dropped, it's a minor loss
though.
This fixes the test suite with SQLite >= 3.42.0.
Closes: https://gitlab.gnome.org/GNOME/tracker/-/issues/405
---
tests/fts/functions/snippet-1.out | 2 +-
tests/fts/functions/snippet-2.out | 2 +-
tests/fts/functions/snippet-2.rq | 2 +-
tests/fts/functions/snippet-3.out | 2 +-
tests/fts/functions/snippet-4.out | 6 +++---
tests/fts/functions/snippet-4.rq | 2 +-
tests/fts/functions/snippet-5.out | 4 ----
tests/fts/functions/snippet-5.rq | 1 -
tests/fts/functions/snippet-data.rq | 2 +-
tests/fts/tracker-fts-test.c | 2 +-
10 files changed, 10 insertions(+), 15 deletions(-)
delete mode 100644 tests/fts/functions/snippet-5.out
delete mode 100644 tests/fts/functions/snippet-5.rq
diff --git a/tests/fts/functions/snippet-1.out b/tests/fts/functions/snippet-1.out
index db1fae0c225f..9cb9c0ca9865 100644
--- a/tests/fts/functions/snippet-1.out
+++ b/tests/fts/functions/snippet-1.out
@@ -1,4 +1,4 @@
"http://www.example.org/test#1" "bananas lemons lemons"
-"http://www.example.org/test#2" "bananas bananas lemons"
+"http://www.example.org/test#2" "bananas bandanas lemons"
"http://www.example.org/test#4" "bananas lemons"
"http://www.example.org/test#3" "bananas"
diff --git a/tests/fts/functions/snippet-2.out b/tests/fts/functions/snippet-2.out
index 8cdc6f4b8e10..5174b6bf6404 100644
--- a/tests/fts/functions/snippet-2.out
+++ b/tests/fts/functions/snippet-2.out
@@ -1,4 +1,4 @@
"http://www.example.org/test#1" ">>>bananas<<< lemons lemons"
-"http://www.example.org/test#2" ">>>bananas<<< >>>bananas<<< lemons"
+"http://www.example.org/test#2" ">>>bananas<<< >>>bandanas<<< lemons"
"http://www.example.org/test#4" ">>>bananas<<< lemons"
"http://www.example.org/test#3" ">>>bananas<<<"
diff --git a/tests/fts/functions/snippet-2.rq b/tests/fts/functions/snippet-2.rq
index 59cd8c3064f1..d6ce1f05f4c3 100644
--- a/tests/fts/functions/snippet-2.rq
+++ b/tests/fts/functions/snippet-2.rq
@@ -1 +1 @@
-SELECT ?u fts:snippet(?u, '>>>', '<<<') { ?u fts:match 'bananas' } order by desc fts:rank(?u)
+SELECT ?u fts:snippet(?u, '>>>', '<<<') { ?u fts:match 'ban' } order by desc fts:rank(?u)
diff --git a/tests/fts/functions/snippet-3.out b/tests/fts/functions/snippet-3.out
index 9c869b89afd5..03f28af07454 100644
--- a/tests/fts/functions/snippet-3.out
+++ b/tests/fts/functions/snippet-3.out
@@ -1,4 +1,4 @@
"http://www.example.org/test#1" ">>>bananas<<<..."
-"http://www.example.org/test#2" ">>>bananas<<< >>>bananas<<<..."
+"http://www.example.org/test#2" ">>>bananas<<<..."
"http://www.example.org/test#4" ">>>bananas<<<..."
"http://www.example.org/test#3" ">>>bananas<<<"
diff --git a/tests/fts/functions/snippet-4.out b/tests/fts/functions/snippet-4.out
index e3650f67a7e7..b7e42e2f1777 100644
--- a/tests/fts/functions/snippet-4.out
+++ b/tests/fts/functions/snippet-4.out
@@ -1,4 +1,4 @@
"http://www.example.org/test#1"
-"http://www.example.org/test#2" ">>>bananas<<< >>>bananas<<<..."
-"http://www.example.org/test#4" ">>>bananas<<<..."
-"http://www.example.org/test#3" ">>>bananas<<<..."
+"http://www.example.org/test#2"
+"http://www.example.org/test#4"
+"http://www.example.org/test#3"
diff --git a/tests/fts/functions/snippet-4.rq b/tests/fts/functions/snippet-4.rq
index 1b542b57c4cd..564f52d01e6c 100644
--- a/tests/fts/functions/snippet-4.rq
+++ b/tests/fts/functions/snippet-4.rq
@@ -1 +1 @@
-SELECT ?u fts:snippet(?u, '>>>', '<<<', '...', 0) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
+SELECT ?u fts:snippet(?u, '>>>', '<<<', '...', -1) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/fts/functions/snippet-5.out b/tests/fts/functions/snippet-5.out
deleted file mode 100644
index b7e42e2f1777..000000000000
--- a/tests/fts/functions/snippet-5.out
+++ /dev/null
@@ -1,4 +0,0 @@
-"http://www.example.org/test#1"
-"http://www.example.org/test#2"
-"http://www.example.org/test#4"
-"http://www.example.org/test#3"
diff --git a/tests/fts/functions/snippet-5.rq b/tests/fts/functions/snippet-5.rq
deleted file mode 100644
index 564f52d01e6c..000000000000
--- a/tests/fts/functions/snippet-5.rq
+++ /dev/null
@@ -1 +0,0 @@
-SELECT ?u fts:snippet(?u, '>>>', '<<<', '...', -1) { ?u fts:match 'bananas' } order by desc fts:rank(?u)
diff --git a/tests/fts/functions/snippet-data.rq b/tests/fts/functions/snippet-data.rq
index 2a8ffb1c0836..5aa3006af940 100644
--- a/tests/fts/functions/snippet-data.rq
+++ b/tests/fts/functions/snippet-data.rq
@@ -1,6 +1,6 @@
INSERT {
test:1 a test:A ; test:p "bananas lemons lemons" .
- test:2 a test:A ; test:p "bananas bananas lemons" .
+ test:2 a test:A ; test:p "bananas bandanas lemons" .
test:3 a test:A ; test:o "bananas" .
test:4 a test:A ; test:p "bananas" ; test:o "bananas lemons" .
diff --git a/tests/fts/tracker-fts-test.c b/tests/fts/tracker-fts-test.c
index fd2308c4b8eb..4a1d6f55662e 100644
--- a/tests/fts/tracker-fts-test.c
+++ b/tests/fts/tracker-fts-test.c
@@ -42,7 +42,7 @@ const TestInfo tests[] = {
{ "input/fts3input", 3 },
{ "functions/rank", 2 },
{ "functions/offsets", 3 },
- { "functions/snippet", 5 },
+ { "functions/snippet", 4 },
{ NULL }
};