Bugzilla – Attachment 69929 Details for
Bug 17770
t/db_dependent/Sitemapper.t fails when date changes during test run
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17770: Counter patch - sleep till past midnight.
Bug-17770-Counter-patch---sleep-till-past-midnight.patch (text/plain), 2.08 KB, created by
Mark Tompsett
on 2017-12-19 19:56:25 UTC
(
hide
)
Description:
Bug 17770: Counter patch - sleep till past midnight.
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2017-12-19 19:56:25 UTC
Size:
2.08 KB
patch
obsolete
>From 060d5c095e650f35ea104fb4ae434ac598b81bca Mon Sep 17 00:00:00 2001 >From: Mark Tompsett <mtompset@hotmail.com> >Date: Tue, 19 Dec 2017 13:19:57 -0500 >Subject: [PATCH] Bug 17770: Counter patch - sleep till past midnight. > >As per Jonathan's comment #14, added a wait_till_midnight >function to t::lib::Dates. > >Running this test at 23:59 will trigger a sleep until after midnight >accumulated in 60 second intervals. >--- > t/db_dependent/Sitemapper.t | 8 ++++---- > t/lib/Dates.pm | 27 +++++++++++++++++++++++++++ > 2 files changed, 31 insertions(+), 4 deletions(-) > >diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t >index 4276470..379538d 100755 >--- a/t/db_dependent/Sitemapper.t >+++ b/t/db_dependent/Sitemapper.t >@@ -24,12 +24,12 @@ use DateTime; > use Test::MockModule; > use Test::More tests => 16; > use Koha::Schema; >+use t::lib::Dates; > > >-BEGIN { >- use_ok('Koha::Sitemapper'); >- use_ok('Koha::Sitemapper::Writer'); >-} >+t::lib::Dates::wait_till_midnight(1); >+use_ok('Koha::Sitemapper'); >+use_ok('Koha::Sitemapper::Writer'); > > sub slurp { > my $file = shift; >diff --git a/t/lib/Dates.pm b/t/lib/Dates.pm >index 66299d9..6938a7d 100644 >--- a/t/lib/Dates.pm >+++ b/t/lib/Dates.pm >@@ -28,4 +28,31 @@ sub compare { > return $diff > 0 ? 1 : -1; > } > >+=head2 wait_till_midnight >+ >+ $test_duration = 1; >+ t::lib::Dates::wait_till_midnight($test_duration); >+ >+Some tests that cross midnight wrongly fail. This waits >+until after midnight to ensure that the failure is not time related. >+ >+I<test_duration> - The number of minutes the test takes to run >+ rounded up. Most run quickly, so a default >+ of 1 is sufficient when the parameter is >+ not passed. >+ >+=cut >+ >+sub wait_till_midnight { >+ my ($test_duration) = @_; >+ $test_duration = $test_duration // 1; >+ my $current_time = DateTime->now(); >+ if ($current_time->hour == 23 && $current_time->minute >= (60-$test_duration)) { >+ while ($current_time->hour == 23) { >+ sleep(60); >+ $current_time = DateTime->now(); >+ } >+ } >+} >+ > 1; >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17770
:
68994
|
68995
|
68996
|
69741
|
69742
|
69743
|
69929
|
69930
|
69931
|
70005
|
70006
|
70007