summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorPeter Eisentraut2019-07-31 07:42:15 +0000
committerPeter Eisentraut2019-07-31 07:46:51 +0000
commitf140007050a2ba874b85c4578d8417828f4b64b6 (patch)
tree4fdc2d0a1a8854438191f59d106a7745b75dbf56 /src/test
parent870b1d6800cc2173ab672449047efbc30bdc1b57 (diff)
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 <[email protected]> Discussion: https://www.postgresql.org/message-id/flat/052295c2-a2e1-9a21-bd36-8fbff8686cf3%402ndquadrant.com
Diffstat (limited to 'src/test')
-rw-r--r--src/test/regress/expected/collate.icu.utf8.out7
-rw-r--r--src/test/regress/expected/collate.icu.utf8_1.out9
-rw-r--r--src/test/regress/expected/collate.linux.utf8.out7
-rw-r--r--src/test/regress/expected/collate.linux.utf8_1.out11
-rw-r--r--src/test/regress/parallel_schedule5
-rw-r--r--src/test/regress/serial_schedule2
-rw-r--r--src/test/regress/sql/collate.icu.utf8.sql8
-rw-r--r--src/test/regress/sql/collate.linux.utf8.sql8
8 files changed, 55 insertions, 2 deletions
diff --git a/src/test/regress/expected/collate.icu.utf8.out b/src/test/regress/expected/collate.icu.utf8.out
index 01bd9fb5dd7..51262e0bf44 100644
--- a/src/test/regress/expected/collate.icu.utf8.out
+++ b/src/test/regress/expected/collate.icu.utf8.out
@@ -1,6 +1,13 @@
/*
* This test is for ICU collations.
*/
+/* skip test if not UTF8 server encoding or no ICU collations installed */
+SELECT getdatabaseencoding() <> 'UTF8' OR
+ (SELECT count(*) FROM pg_collation WHERE collprovider = 'i') = 0
+ AS skip_test \gset
+\if :skip_test
+\quit
+\endif
SET client_encoding TO UTF8;
CREATE SCHEMA collate_tests;
SET search_path = collate_tests;
diff --git a/src/test/regress/expected/collate.icu.utf8_1.out b/src/test/regress/expected/collate.icu.utf8_1.out
new file mode 100644
index 00000000000..a6a33b39aba
--- /dev/null
+++ b/src/test/regress/expected/collate.icu.utf8_1.out
@@ -0,0 +1,9 @@
+/*
+ * This test is for ICU collations.
+ */
+/* skip test if not UTF8 server encoding or no ICU collations installed */
+SELECT getdatabaseencoding() <> 'UTF8' OR
+ (SELECT count(*) FROM pg_collation WHERE collprovider = 'i') = 0
+ AS skip_test \gset
+\if :skip_test
+\quit
diff --git a/src/test/regress/expected/collate.linux.utf8.out b/src/test/regress/expected/collate.linux.utf8.out
index 619688f851a..ad56ff9caa3 100644
--- a/src/test/regress/expected/collate.linux.utf8.out
+++ b/src/test/regress/expected/collate.linux.utf8.out
@@ -3,6 +3,13 @@
* locales is installed. It must be run in a database with UTF-8 encoding,
* because other encodings don't support all the characters used.
*/
+SELECT getdatabaseencoding() <> 'UTF8' OR
+ (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
+ version() !~ 'linux-gnu'
+ AS skip_test \gset
+\if :skip_test
+\quit
+\endif
SET client_encoding TO UTF8;
CREATE SCHEMA collate_tests;
SET search_path = collate_tests;
diff --git a/src/test/regress/expected/collate.linux.utf8_1.out b/src/test/regress/expected/collate.linux.utf8_1.out
new file mode 100644
index 00000000000..ede5fdb5dcc
--- /dev/null
+++ b/src/test/regress/expected/collate.linux.utf8_1.out
@@ -0,0 +1,11 @@
+/*
+ * This test is for Linux/glibc systems and assumes that a full set of
+ * locales is installed. It must be run in a database with UTF-8 encoding,
+ * because other encodings don't support all the characters used.
+ */
+SELECT getdatabaseencoding() <> 'UTF8' OR
+ (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
+ version() !~ 'linux-gnu'
+ AS skip_test \gset
+\if :skip_test
+\quit
diff --git a/src/test/regress/parallel_schedule b/src/test/regress/parallel_schedule
index 8fb55f045e6..fc0f14122bb 100644
--- a/src/test/regress/parallel_schedule
+++ b/src/test/regress/parallel_schedule
@@ -78,11 +78,12 @@ test: brin gin gist spgist privileges init_privs security_label collate matview
# ----------
# Another group of parallel tests
# ----------
-test: create_table_like alter_generic alter_operator misc async dbsize misc_functions sysviews tsrf tidscan
+test: create_table_like alter_generic alter_operator misc async dbsize misc_functions sysviews tsrf tidscan collate.icu.utf8
# rules cannot run concurrently with any test that creates
# a view or rule in the public schema
-test: rules psql psql_crosstab amutils stats_ext
+# collate.*.utf8 tests cannot be run in parallel with each other
+test: rules psql psql_crosstab amutils stats_ext collate.linux.utf8
# run by itself so it can run parallel workers
test: select_parallel
diff --git a/src/test/regress/serial_schedule b/src/test/regress/serial_schedule
index a39ca1012a3..68ac56acdb2 100644
--- a/src/test/regress/serial_schedule
+++ b/src/test/regress/serial_schedule
@@ -133,11 +133,13 @@ test: misc_functions
test: sysviews
test: tsrf
test: tidscan
+test: collate.icu.utf8
test: rules
test: psql
test: psql_crosstab
test: amutils
test: stats_ext
+test: collate.linux.utf8
test: select_parallel
test: write_parallel
test: publication
diff --git a/src/test/regress/sql/collate.icu.utf8.sql b/src/test/regress/sql/collate.icu.utf8.sql
index 2be7759c92d..46999fb9266 100644
--- a/src/test/regress/sql/collate.icu.utf8.sql
+++ b/src/test/regress/sql/collate.icu.utf8.sql
@@ -2,6 +2,14 @@
* This test is for ICU collations.
*/
+/* skip test if not UTF8 server encoding or no ICU collations installed */
+SELECT getdatabaseencoding() <> 'UTF8' OR
+ (SELECT count(*) FROM pg_collation WHERE collprovider = 'i') = 0
+ AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+
SET client_encoding TO UTF8;
CREATE SCHEMA collate_tests;
diff --git a/src/test/regress/sql/collate.linux.utf8.sql b/src/test/regress/sql/collate.linux.utf8.sql
index c009fd2372d..eac2f900142 100644
--- a/src/test/regress/sql/collate.linux.utf8.sql
+++ b/src/test/regress/sql/collate.linux.utf8.sql
@@ -4,6 +4,14 @@
* because other encodings don't support all the characters used.
*/
+SELECT getdatabaseencoding() <> 'UTF8' OR
+ (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
+ version() !~ 'linux-gnu'
+ AS skip_test \gset
+\if :skip_test
+\quit
+\endif
+
SET client_encoding TO UTF8;
CREATE SCHEMA collate_tests;