[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Bad handling of locales in test-suite

From: Mark H Weaver
Subject: Bad handling of locales in test-suite
Date: Thu, 06 Feb 2014 02:21:00 -0500

Hello all,

While investigating a test failure in "foreign.test" that happens when
running "./check-guile" but not when running "make check" or
"./check-guile foreign.test", I've discovered that our handling of
locales in the Guile test suite is a mess.

It turns out that this particular test passes or fails depending on the
locale, and that several *.test files set the locale without restoring
it, so the locale setting changes from one *.test file to the next.

The handling of locales in our test suite is quite inconsistent:

* In some files that set the locale, there's broken code that tries to
  restore the locale to its previous value, but fails to do so.  The
  author apparently believed that (setlocale LC_ALL x) returns the
  previous locale, when it fact it returns the new locale:


* In several other places, the locale is set without even trying to
  restore it:


* Some files check to see if 'setlocale' is defined before calling it,
  while other files call 'setlocale' unconditionally.

* foreign.test: "%default-port-conversion-strategy is substitute"
  fails on modern glibc if the locale is "en_US.UTF-8", because "ĥ" is
  transliterated to "h", but works as expected if the locale is set to
  "C", where "ĥ" becomes "?".

It's easy enough to fix these problems: the "test-suite/guile-test"
script, which loads the requested *.test files (or all of them), could
be modified to save and restore the locale, or it could simply set the
locale to a known value before each test file.

However, there's a question of policy to decide.  Here are some options:

* (setlocale LC_ALL "C") before loading each file.  The argument for
  this would be consistency, so that the test suite runs the same way
  regardless of the user's locale.

* (setlocale LC_ALL "") before loading each file.  The argument for this
  would be diversity, to make sure that Guile works as expected for any

* Save the locale before loading each file, and restore after.

And then there's the question of what to do about all the places where
the locale is set in the individual *.test files.  Should they be left
mostly as-is, or should we clean up and remove all the 'setlocale' calls
that would be rendered redundant with whatever policy is chosen above?

I'm leaning toward (setlocale LC_ALL "C") before loading each file, and
stripping out all (setlocale LC_ALL "C") calls in the individual test
files, as well as the broken attempts to restore the previous locale

What do you think?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]