Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 44e73a4

Browse files
committed
Fix regression tests of unaccent to work without UTF8 support
The tests of unaccent rely on UTF8 characters, and unlike any other test suite in the tree (fuzzystrmatch, citext, hstore, etc.), they would fail if run on a database that does not support UTF8 encoding. This commit fixes the tests of unaccent so as these are skipped when run on a database without UTF8 support, using the same method as the other test suits based on \if, getdatabaseencoding() and an alternate output file. This has been broken for a long time, but nobody has complained about that either, so no backpatch is done. This can be reproduced with something like REGRESS_OPTS="--no-locale --encoding=sql_ascii", for instance. To defend against that, this module's Makefile and meson.build enforced a UTF8 encoding without locales, but it did not offer protection for options given by REGRESS_OPTS. This switch makes this regression test suite more consistent with all the others, as well. Reviewed-by: Peter Eisentraut Discussion: https://postgr.es/m/ZIq1HUnIV2ksW85x@paquier.xyz
1 parent 72df1d3 commit 44e73a4

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

contrib/unaccent/Makefile

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,6 @@ PGFILEDESC = "unaccent - text search dictionary that removes accents"
1212

1313
REGRESS = unaccent
1414

15-
# We need a UTF8 database
16-
ENCODING = UTF8
17-
NO_LOCALE = 1
18-
1915
ifdef USE_PGXS
2016
PG_CONFIG = pg_config
2117
PGXS := $(shell $(PG_CONFIG) --pgxs)

contrib/unaccent/expected/unaccent.out

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
/*
2+
* This test must be run in a database with UTF-8 encoding,
3+
* because other encodings don't support all the characters used.
4+
*/
5+
SELECT getdatabaseencoding() <> 'UTF8'
6+
AS skip_test \gset
7+
\if :skip_test
8+
\quit
9+
\endif
110
CREATE EXTENSION unaccent;
2-
-- must have a UTF8 database
3-
SELECT getdatabaseencoding();
4-
getdatabaseencoding
5-
---------------------
6-
UTF8
7-
(1 row)
8-
911
SET client_encoding TO 'UTF8';
1012
SELECT unaccent('foobar');
1113
unaccent
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*
2+
* This test must be run in a database with UTF-8 encoding,
3+
* because other encodings don't support all the characters used.
4+
*/
5+
SELECT getdatabaseencoding() <> 'UTF8'
6+
AS skip_test \gset
7+
\if :skip_test
8+
\quit

contrib/unaccent/meson.build

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,5 @@ tests += {
3737
'sql': [
3838
'unaccent',
3939
],
40-
'regress_args': ['--no-locale', '--encoding=UTF8'],
4140
},
4241
}

contrib/unaccent/sql/unaccent.sql

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
1-
CREATE EXTENSION unaccent;
1+
/*
2+
* This test must be run in a database with UTF-8 encoding,
3+
* because other encodings don't support all the characters used.
4+
*/
5+
6+
SELECT getdatabaseencoding() <> 'UTF8'
7+
AS skip_test \gset
8+
\if :skip_test
9+
\quit
10+
\endif
211

3-
-- must have a UTF8 database
4-
SELECT getdatabaseencoding();
12+
CREATE EXTENSION unaccent;
513

614
SET client_encoding TO 'UTF8';
715

0 commit comments

Comments
 (0)