Bug 9486

Summary: t/Letters.t loads modules in wrong order
Product: Koha Reporter: Jared Camins-Esakov <jcamins>
Component: Test SuiteAssignee: Jared Camins-Esakov <jcamins>
Status: CLOSED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: blocker    
Priority: P5 - low CC: chris, katrin.fischer
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Trivial patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Attachments: Bug 9486: t/Letters.t loads modules in wrong order
Bug 9486: t/Letters.t loads modules in wrong order
[SIGNED-OFF] Bug 9486: t/Letters.t loads modules in wrong order

Description Jared Camins-Esakov 2013-01-24 18:49:47 UTC
Because the unit test t/Letters.t loads C4::Letters before C4::Context, and C4::Letters is not even vaguely thread-safe, the test tends to fail. Usually. Moving the dbh mocking to before the use_ok('C4::Letters') test fixes the problem.
Comment 1 Jared Camins-Esakov 2013-01-24 18:59:04 UTC Comment hidden (obsolete)
Comment 2 Chris Cormack 2013-01-24 19:09:58 UTC
Before
1..2
DBD::mysql::db do failed: Unknown or incorrect time zone: 'Pacific/Auckland' at C4/Context.pm line 825, <DATA> line 429.
ok 1 - use C4::Letters;
not ok 2 - HASH ref of ISBN is book
#   Failed test 'HASH ref of ISBN is book'
#   at t/Letters.t line 36.
#          got: undef
#     expected: 'book'
# Looks like you failed 1 test of 2

After
1..2
Name "DBI::errstr" used only once: possible typo at t/Letters.t line 16.
ok 1 - use C4::Letters;
ok 2 - HASH ref of ISBN is boo
Comment 3 Chris Cormack 2013-01-24 19:10:58 UTC Comment hidden (obsolete)
Comment 4 Katrin Fischer 2013-01-24 19:39:09 UTC
Created attachment 14839 [details] [review]
[SIGNED-OFF] Bug 9486: t/Letters.t loads modules in wrong order

Because the unit test t/Letters.t loads C4::Letters before C4::Context,
and C4::Letters is not even vaguely thread-safe, the test tends to fail.
Usually. Moving the dbh mocking to before the use_ok('C4::Letters') test
fixes the problem.

To test:
1) Before applying patch, run `prove t/Letters.t` a few times. Note that
   it fails most of the time, if not all the time.
2) Apply patch.
3) Repeat step (1), noting that now it passes every time.

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
Signed-off-by: Katrin Fischer <Katrin.Fischer.83@web.de>
Works as advertised.
Comment 5 Jared Camins-Esakov 2013-01-24 19:44:19 UTC
This patch has been pushed to master.
Comment 6 Chris Cormack 2013-02-01 08:47:54 UTC
Pushed to 3.10.x will be in 3.10.3