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

Commit f140007

Browse files
committed
Run UTF8-requiring collation tests by default
The tests collate.icu.utf8 and collate.linux.utf8 were previously only run when explicitly selected via EXTRA_TESTS. They require a UTF8 database, because the error messages in the expected files refer to that, and they use some non-ASCII characters in the tests. Since users can select any locale and encoding for the regression test run, it was not possible to include these tests automatically. To fix, use psql's \if facility to check various prerequisites such as platform and the server encoding and quit the tests at the very beginning if the configuration is not adequate. We then need to maintain alternative expected files for these tests, but they are very tiny and never need to change after this. These two tests are now run automatically as part of the regression tests. Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us> Discussion: https://www.postgresql.org/message-id/flat/052295c2-a2e1-9a21-bd36-8fbff8686cf3%402ndquadrant.com
1 parent 870b1d6 commit f140007

9 files changed

+55
-10
lines changed

doc/src/sgml/regress.sgml

-8
Original file line numberDiff line numberDiff line change
@@ -363,14 +363,6 @@ make check LANG=C ENCODING=EUC_JP
363363
<screen>
364364
make check EXTRA_TESTS=numeric_big
365365
</screen>
366-
To run the collation tests:
367-
<screen>
368-
make check EXTRA_TESTS='collate.linux.utf8 collate.icu.utf8' LANG=en_US.utf8
369-
</screen>
370-
The <literal>collate.linux.utf8</literal> test works only on Linux/glibc
371-
platforms. The <literal>collate.icu.utf8</literal> test only works when
372-
support for ICU was built. Both tests will only succeed when run in a
373-
database that uses UTF-8 encoding.
374366
</para>
375367
</sect2>
376368

src/test/regress/expected/collate.icu.utf8.out

+7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
/*
22
* This test is for ICU collations.
33
*/
4+
/* skip test if not UTF8 server encoding or no ICU collations installed */
5+
SELECT getdatabaseencoding() <> 'UTF8' OR
6+
(SELECT count(*) FROM pg_collation WHERE collprovider = 'i') = 0
7+
AS skip_test \gset
8+
\if :skip_test
9+
\quit
10+
\endif
411
SET client_encoding TO UTF8;
512
CREATE SCHEMA collate_tests;
613
SET search_path = collate_tests;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* This test is for ICU collations.
3+
*/
4+
/* skip test if not UTF8 server encoding or no ICU collations installed */
5+
SELECT getdatabaseencoding() <> 'UTF8' OR
6+
(SELECT count(*) FROM pg_collation WHERE collprovider = 'i') = 0
7+
AS skip_test \gset
8+
\if :skip_test
9+
\quit

src/test/regress/expected/collate.linux.utf8.out

+7
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@
33
* locales is installed. It must be run in a database with UTF-8 encoding,
44
* because other encodings don't support all the characters used.
55
*/
6+
SELECT getdatabaseencoding() <> 'UTF8' OR
7+
(SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR
8+
version() !~ 'linux-gnu'
9+
AS skip_test \gset
10+
\if :skip_test
11+
\quit
12+
\endif
613
SET client_encoding TO UTF8;
714
CREATE SCHEMA collate_tests;
815
SET search_path = collate_tests;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/*
2+
* This test is for Linux/glibc systems and assumes that a full set of
3+
* locales is installed. It must be run in a database with UTF-8 encoding,
4+
* because other encodings don't support all the characters used.
5+
*/
6+
SELECT getdatabaseencoding() <> 'UTF8' OR
7+
(SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR
8+
version() !~ 'linux-gnu'
9+
AS skip_test \gset
10+
\if :skip_test
11+
\quit

src/test/regress/parallel_schedule

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ test: brin gin gist spgist privileges init_privs security_label collate matview
7878
# ----------
7979
# Another group of parallel tests
8080
# ----------
81-
test: create_table_like alter_generic alter_operator misc async dbsize misc_functions sysviews tsrf tidscan
81+
test: create_table_like alter_generic alter_operator misc async dbsize misc_functions sysviews tsrf tidscan collate.icu.utf8
8282

8383
# rules cannot run concurrently with any test that creates
8484
# a view or rule in the public schema
85-
test: rules psql psql_crosstab amutils stats_ext
85+
# collate.*.utf8 tests cannot be run in parallel with each other
86+
test: rules psql psql_crosstab amutils stats_ext collate.linux.utf8
8687

8788
# run by itself so it can run parallel workers
8889
test: select_parallel

src/test/regress/serial_schedule

+2
Original file line numberDiff line numberDiff line change
@@ -133,11 +133,13 @@ test: misc_functions
133133
test: sysviews
134134
test: tsrf
135135
test: tidscan
136+
test: collate.icu.utf8
136137
test: rules
137138
test: psql
138139
test: psql_crosstab
139140
test: amutils
140141
test: stats_ext
142+
test: collate.linux.utf8
141143
test: select_parallel
142144
test: write_parallel
143145
test: publication

src/test/regress/sql/collate.icu.utf8.sql

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@
22
* This test is for ICU collations.
33
*/
44

5+
/* skip test if not UTF8 server encoding or no ICU collations installed */
6+
SELECT getdatabaseencoding() <> 'UTF8' OR
7+
(SELECT count(*) FROM pg_collation WHERE collprovider = 'i') = 0
8+
AS skip_test \gset
9+
\if :skip_test
10+
\quit
11+
\endif
12+
513
SET client_encoding TO UTF8;
614

715
CREATE SCHEMA collate_tests;

src/test/regress/sql/collate.linux.utf8.sql

+8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44
* because other encodings don't support all the characters used.
55
*/
66

7+
SELECT getdatabaseencoding() <> 'UTF8' OR
8+
(SELECT count(*) FROM pg_collation WHERE collname IN ('de_DE', 'en_US', 'sv_SE', 'tr_TR') AND collencoding = pg_char_to_encoding('UTF8')) <> 4 OR
9+
version() !~ 'linux-gnu'
10+
AS skip_test \gset
11+
\if :skip_test
12+
\quit
13+
\endif
14+
715
SET client_encoding TO UTF8;
816

917
CREATE SCHEMA collate_tests;

0 commit comments

Comments
 (0)