From dc6d02e285c371997351b7e31f5fe4d0d93138a5 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Wed, 11 Feb 2009 14:03:42 +0000 Subject: [PATCH] Only unset the locale environment when --no-locale is used (the way it was presumably designed, but didn't act). This allows running the temp install tests in a non-C locale, thus exercising users' real environments better. Document how to change locales for test runs. --- doc/src/sgml/regress.sgml | 32 +++++++++++++++++++++++++++++++- src/test/regress/pg_regress.c | 31 +++++++++++++++++-------------- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/doc/src/sgml/regress.sgml b/doc/src/sgml/regress.sgml index d1b7139ddf..3ca4cfa8e2 100644 --- a/doc/src/sgml/regress.sgml +++ b/doc/src/sgml/regress.sgml @@ -204,13 +204,43 @@ gmake installcheck Locale differences - If you run the tests against an already-installed server that was + If you run the tests against a server that was initialized with a collation-order locale other than C, then there might be differences due to sort order and follow-up failures. The regression test suite is set up to handle this problem by providing alternative result files that together are known to handle a large number of locales. + + + To run the tests in a different locale when using the + temporary-installation method, pass the appropriate + locale-related environment variables on + the make command line, for example: + +gmake check LC_ALL=de_DE.utf8 + + or analogously to use no locale: + +gmake check LC_ALL=C + + When running the tests against an existing installation, the + locale setup is determined by the existing installation. To + change it, initialize the database cluster with a different + locale by passing the appropriate options + to initdb. + + + + In general, it is nevertheless advisable to try to run the + regression tests in the locale setup that is wanted for + production use, as this will exercise the locale- and + encoding-related code portions that will actually be used in + production. Depending on the operating system environment, you + might get failures, but then you will at least know what + locale-specific behaviors to expect when running real + applications. + diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index c31a2b7380..944596509b 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -686,22 +686,25 @@ initialize_environment(void) { char *tmp; - /* - * Clear out any non-C locale settings - */ - unsetenv("LC_COLLATE"); - unsetenv("LC_CTYPE"); - unsetenv("LC_MONETARY"); - unsetenv("LC_MESSAGES"); - unsetenv("LC_NUMERIC"); - unsetenv("LC_TIME"); - unsetenv("LC_ALL"); - unsetenv("LANG"); - unsetenv("LANGUAGE"); - /* On Windows the default locale cannot be English, so force it */ + if (nolocale) + { + /* + * Clear out any non-C locale settings + */ + unsetenv("LC_COLLATE"); + unsetenv("LC_CTYPE"); + unsetenv("LC_MONETARY"); + unsetenv("LC_MESSAGES"); + unsetenv("LC_NUMERIC"); + unsetenv("LC_TIME"); + unsetenv("LC_ALL"); + unsetenv("LANG"); + unsetenv("LANGUAGE"); + /* On Windows the default locale cannot be English, so force it */ #if defined(WIN32) || defined(__CYGWIN__) - putenv("LANG=en"); + putenv("LANG=en"); #endif + } /* * Set multibyte as requested -- 2.39.5