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.
This commit is contained in:
Peter Eisentraut 2009-02-11 14:03:42 +00:00
parent 715ea2bf18
commit 20a43b16b4
2 changed files with 50 additions and 17 deletions

View File

@ -1,4 +1,4 @@
<!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.60 2008/09/05 12:11:18 petere Exp $ --> <!-- $PostgreSQL: pgsql/doc/src/sgml/regress.sgml,v 1.61 2009/02/11 14:03:41 petere Exp $ -->
<chapter id="regress"> <chapter id="regress">
<title id="regress-title">Regression Tests</title> <title id="regress-title">Regression Tests</title>
@ -204,13 +204,43 @@ gmake installcheck
<title>Locale differences</title> <title>Locale differences</title>
<para> <para>
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 initialized with a collation-order locale other than C, then
there might be differences due to sort order and follow-up there might be differences due to sort order and follow-up
failures. The regression test suite is set up to handle this failures. The regression test suite is set up to handle this
problem by providing alternative result files that together are problem by providing alternative result files that together are
known to handle a large number of locales. known to handle a large number of locales.
</para> </para>
<para>
To run the tests in a different locale when using the
temporary-installation method, pass the appropriate
locale-related environment variables on
the <command>make</command> command line, for example:
<programlisting>
gmake check LC_ALL=de_DE.utf8
</programlisting>
or analogously to use no locale:
<programlisting>
gmake check LC_ALL=C
</programlisting>
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 <command>initdb</command>.
</para>
<para>
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.
</para>
</sect2> </sect2>
<sect2> <sect2>

View File

@ -11,7 +11,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.59 2009/01/28 15:32:21 mha Exp $ * $PostgreSQL: pgsql/src/test/regress/pg_regress.c,v 1.60 2009/02/11 14:03:42 petere Exp $
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
@ -686,22 +686,25 @@ initialize_environment(void)
{ {
char *tmp; char *tmp;
/* if (nolocale)
* Clear out any non-C locale settings {
*/ /*
unsetenv("LC_COLLATE"); * Clear out any non-C locale settings
unsetenv("LC_CTYPE"); */
unsetenv("LC_MONETARY"); unsetenv("LC_COLLATE");
unsetenv("LC_MESSAGES"); unsetenv("LC_CTYPE");
unsetenv("LC_NUMERIC"); unsetenv("LC_MONETARY");
unsetenv("LC_TIME"); unsetenv("LC_MESSAGES");
unsetenv("LC_ALL"); unsetenv("LC_NUMERIC");
unsetenv("LANG"); unsetenv("LC_TIME");
unsetenv("LANGUAGE"); unsetenv("LC_ALL");
/* On Windows the default locale cannot be English, so force it */ unsetenv("LANG");
unsetenv("LANGUAGE");
/* On Windows the default locale cannot be English, so force it */
#if defined(WIN32) || defined(__CYGWIN__) #if defined(WIN32) || defined(__CYGWIN__)
putenv("LANG=en"); putenv("LANG=en");
#endif #endif
}
/* /*
* Set multibyte as requested * Set multibyte as requested