Item1589: UnitTests: UseLocale breaks Fn_SEARCH

pencil
Priority: Normal
Current State: Closed
Released In: 1.0.6
Target Release: patch
Applies To: Engine
Component: UnitTestContrib
Branches:
Reported By: OlivierRaginel
Waiting For:
Last Change By: KennethLavrsen
If you have UseLocale set to some language, it might swap the order of Ok+Topic and Ok-Topic in the search, and therefore breaks the unit tests (mostly Fn_SEARCH.pm)

Crawford tried to fix this by disabling locales for this test, but the problem is that this fixes it only for this particular test, when run by its own.

If you run any other test that instantiates a Foswiki::Search object, such as Fn_GROUPS (used by UserMappingContrib), then the Foswiki::Search object will have its locales set, and therefore the Fn_SEARCH will fail.

I see 2 ways to fix this:
  1. Unset the locales directly inside UnitTestContrib/test/unit/FoswikiTestCase.pm, this way all modules will be loaded without it. Drawback is that we will never be able to unit-test things when people use UseLocale
  2. Fixes the unit tests to sort the data instead of hard-coding the order. This is pretty complex as locale is a pragma, therefore happens during compilation.

I've already written fix #1, but as I prefer #2, I won't commit it smile

-- OlivierRaginel - 08 May 2009

I am fixing your fix.

I get Failed to use Fn_SEARCH: Bareword "POSIX::LC_COLLATE" not allowed while "strict subs" in use at /var/www/Release01x00/core/test/unit/Fn_SEARCH.pm line 25.

Seems some '' missing

-- KennethLavrsen - 09 May 2009

Now I understand why there was a & in the original code.

So the proper fix is to add this & instead of the '': &POSIX::LC_COLLATE

Sorry, will merge that fix in my trunk merge that I'm doint atm.

-- OlivierRaginel - 09 May 2009

Damned, I forgot to close that bug which was fixed 2 months ago frown, sad smile

-- OlivierRaginel - 02 Jul 2009
Topic revision: r9 - 03 Jul 2009, KennethLavrsen
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy