From 6354bc09abbdf8d5c79d9c536117c59f3935369d Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 5 Apr 2014 11:25:20 -0400 Subject: [PATCH] Bug TW-1295 - TW-1295 test/time.t fails on the last day of the month (thanks to Jakub Wilk). --- ChangeLog | 2 ++ test/count.t | 47 ++++++++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f8e16982..40406dbed 100644 --- a/ChangeLog +++ b/ChangeLog @@ -37,6 +37,8 @@ Bugs - TW-1282 incorrect URLs in man task-sync (thanks to Jeremiah Marks). - TW-1288 Added missing locking for task modifications (thanks to Kosta H, Ralph Bean, Adam Coddington). +- TW-1295 test/time.t fails on the last day of the month (thanks to Jakub + Wilk). - TW-1296 make test/run_all exit with non-zero code if a test fail (thanks to Jakub Wilk). - #1511 sync init crashes if client certification file is empty or invalid diff --git a/test/count.t b/test/count.t index 920a44e7d..85d3c1729 100755 --- a/test/count.t +++ b/test/count.t @@ -27,6 +27,7 @@ use strict; use warnings; +use POSIX qw(mktime); use Test::More tests => 7; # Ensure environment has no influence. @@ -49,30 +50,38 @@ qx{../src/task rc:count.rc add three 2>&1}; qx{../src/task rc:count.rc 2 delete 2>&1}; qx{../src/task rc:count.rc add four wait:eom 2>&1}; -# TODO This fails when today == eom. For example, on 2013-04-30 at 8:00:00, the -# value for 'eom' is 2013-04-30 0:00:00, which is already past due, which -# means a second child task is generated. This would be fixed by 'eom' -# expanding to 2013-04-30 24:00:00, as per ISO-8601. -qx{../src/task rc:count.rc add five due:eom recur:monthly 2>&1}; +TODO: { + my @today = localtime; + my @tomorrow = @today; + $tomorrow[3] += 1; + @tomorrow = localtime(mktime(@tomorrow)); + local $TODO = 'can fail when today == eom' if $today[4] != $tomorrow[4]; -diag ("Problem: the next test fails at EOM"); -my $output = qx{../src/task rc:count.rc count 2>&1}; -like ($output, qr/^5\n/ms, 'count'); + # TODO This fails when today == eom. For example, on 2013-04-30 at 8:00:00, the + # value for 'eom' is 2013-04-30 0:00:00, which is already past due, which + # means a second child task is generated. This would be fixed by 'eom' + # expanding to 2013-04-30 24:00:00, as per ISO-8601. + qx{../src/task rc:count.rc add five due:eom recur:monthly 2>&1}; -$output = qx{../src/task rc:count.rc count status:deleted rc.debug:1 2>&1}; -like ($output, qr/^1\n/ms, 'count status:deleted'); + diag ("Problem: the next test fails at EOM"); + my $output = qx{../src/task rc:count.rc count 2>&1}; + like ($output, qr/^5\n/ms, 'count'); -diag ("Problem: the next test fails at EOM"); -$output = qx{../src/task rc:count.rc count e 2>&1}; -like ($output, qr/^3\n/ms, 'count e'); + $output = qx{../src/task rc:count.rc count status:deleted rc.debug:1 2>&1}; + like ($output, qr/^1\n/ms, 'count status:deleted'); -diag ("Problem: the next test fails at EOM"); -$output = qx{../src/task rc:count.rc count description.startswith:f 2>&1}; -like ($output, qr/^2\n/ms, 'count description.startswith:f'); + diag ("Problem: the next test fails at EOM"); + $output = qx{../src/task rc:count.rc count e 2>&1}; + like ($output, qr/^3\n/ms, 'count e'); -diag ("Problem: the next test fails at EOM"); -$output = qx{../src/task rc:count.rc count due.any: 2>&1}; -like ($output, qr/^1\n/ms, 'count due.any:'); + diag ("Problem: the next test fails at EOM"); + $output = qx{../src/task rc:count.rc count description.startswith:f 2>&1}; + like ($output, qr/^2\n/ms, 'count description.startswith:f'); + + diag ("Problem: the next test fails at EOM"); + $output = qx{../src/task rc:count.rc count due.any: 2>&1}; + like ($output, qr/^1\n/ms, 'count due.any:'); +} # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data count.rc);