Bug 13933 - t/DateUtils.t causes the build to break (from bug 13601)
Summary: t/DateUtils.t causes the build to break (from bug 13601)
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Test Suite (show other bugs)
Version: master
Hardware: All All
: P5 - low blocker (vote)
Assignee: Jonathan Druart
QA Contact: Galen Charlton
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-03-31 01:16 UTC by Robin Sheat
Modified: 2015-12-03 22:11 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Bot Control: ---
When did the bot last check this:
Who signed the patch off:
Text to go in the release notes:


Attachments
Bug 13933: Fix t/DateUtils.t without DB (1.79 KB, patch)
2015-03-31 08:00 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 13933: Fix t/DateUtils.t without DB (1.85 KB, patch)
2015-03-31 08:08 UTC, Nicolas Legrand
Details | Diff | Splinter Review
[PASSED QA] Bug 13933: Fix t/DateUtils.t without DB (1.92 KB, patch)
2015-04-01 15:40 UTC, Kyle M Hall
Details | Diff | Splinter Review
Reproduce Bug 13933 (1.67 KB, text/plain)
2015-04-02 13:17 UTC, Nicolas Legrand
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Robin Sheat 2015-03-31 01:16:26 UTC
DBI connect('dbname=koha;host=localhost;port=3306','kohaadmin',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/share/perl5/DBIx/Connector.pm line 32
Can't call method "do" on unblessed reference at /tmp/buildd/koha-3.19~git+20150331135711.7fa67b2f/blib/PERL_MODULE_DIR/C4/Context.pm line 817.
# Looks like you planned 55 tests but ran 4.
# Looks like your test exited with 255 just after 4.
t/DateUtils.t ....................... 

This is caused by:

commit dd9f456ab7c2f0e66173a6feb7df2a38604c82cd
Author: Jonathan Druart <jonathan.druart@biblibre.com>
Date:   Tue Jan 20 15:28:19 2015 +0100

    Bug 13601: Add tests to highlight the problems with DateTime::Format::DateParse
Comment 1 Jonathan Druart 2015-03-31 08:00:20 UTC Comment hidden (obsolete)
Comment 2 Nicolas Legrand 2015-03-31 08:08:04 UTC Comment hidden (obsolete)
Comment 3 Kyle M Hall 2015-04-01 15:40:17 UTC
Created attachment 37422 [details] [review]
[PASSED QA] Bug 13933: Fix t/DateUtils.t without DB

If the mysql server is not running, the DateUtils.t tests failed.
This is caused by

commit dd9f456ab7c2f0e66173a6feb7df2a38604c82cd
    Bug 13601: Add tests to highlight the problems with
    DateTime::Format::DateParse

The pref dateformat and TimeFormat were retrieved before the mock.
Before bug 13601, the complete preference method was mocked, that's why
the error did not appear.

Test plan:
  sudo service mysql stop
  prove t/DateUtils.t
should be happy

Signed-off-by: Nicolas Legrand <nicolas.legrand@bulac.fr>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 4 Tomás Cohen Arazi 2015-04-01 16:13:46 UTC
Patch pushed to master.

Thanks Jonathan!
Comment 5 Robin Sheat 2015-04-01 22:04:21 UTC
Cheers, I had a quick look but I couldn't actually see _why_ it was happening.
Comment 6 Nicolas Legrand 2015-04-02 13:17:11 UTC Comment hidden (obsolete)
Comment 7 Nicolas Legrand 2015-04-02 13:20:40 UTC
argh sorry wrong bug, is there a way to remove my attachment and comments?
Comment 8 Nicolas Legrand 2015-04-02 13:25:12 UTC
Comment on attachment 37436 [details]
Reproduce Bug 13933

Make it obsolete, sorry for the noise :(
Comment 9 Jonathan Druart 2015-04-07 07:48:27 UTC
(In reply to Robin Sheat from comment #5)
> Cheers, I had a quick look but I couldn't actually see _why_ it was
> happening.

It's what I tried to explain in the commit description. Before 13601, the C4::Context->preference method was mocked: for all calls, "us" was returned.
The patches for 13601 replaced this global mock with a call to t::lib::Mocks::mock_preference, which mocks only the dateformat pref.
But somewhere (dt_from_string if I remember correctly) the value for TimeFormat is retrieved. Since it's not mocked, the value in the DB is picked.
You know the rest of the story :)