From b4510e9f48ad9ebf5b5fc2cb33795d1239655d90 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 15 Jun 2014 08:33:52 -0400 Subject: [PATCH] Unit Tests - Corrected unit test that relied on old behavior, namely 'due.before:1d', which is like specifying '1403007839 < 86400'. Taskwarrior always assumed that whenever a duration was specified, such as '1d', it really meant 'now + 1d'. With full algebraic expression support, this can no longer be the case and now we need 'due.before:now+1d'. --- test/bug.851.t | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/test/bug.851.t b/test/bug.851.t index 89b2b09d8..6a9a40d1b 100755 --- a/test/bug.851.t +++ b/test/bug.851.t @@ -33,29 +33,33 @@ use Test::More tests => 6; delete $ENV{'TASKDATA'}; delete $ENV{'TASKRC'}; +use File::Basename; +my $ut = basename ($0); +my $rc = $ut . '.rc'; + # Create the rc file. -if (open my $fh, '>', 'bug.rc') +if (open my $fh, '>', $rc) { print $fh "data.location=.\n"; close $fh; } # Bug 851: Filtering by due dates with ordinal and d/wks/etc. doesn't work -qx{../src/task rc:bug.rc add yesterday due:-2days 2>&1}; -qx{../src/task rc:bug.rc add tomorrow due:2days 2>&1}; -my $output = qx{../src/task rc:bug.rc ls 2>&1}; -like ($output, qr/yesterday/, "yesterday - task added"); -like ($output, qr/tomorrow/, "tomorrow - task added"); +qx{../src/task rc:$rc add yesterday due:-2days 2>&1}; +qx{../src/task rc:$rc add tomorrow due:2days 2>&1}; +my $output = qx{../src/task rc:$rc ls 2>&1}; +like ($output, qr/yesterday/, "$ut: yesterday - task added"); +like ($output, qr/tomorrow/, "$ut: tomorrow - task added"); -$output = qx{../src/task rc:bug.rc list due.before:1d 2>&1}; -like ($output, qr/yesterday/, "yesterday - found before:1d"); -unlike ($output, qr/tomorrow/, "tomorrow - not found before:1d"); +$output = qx{../src/task rc:$rc list due.before:now+1d 2>&1}; +like ($output, qr/yesterday/, "$ut: yesterday - found before:1d"); +unlike ($output, qr/tomorrow/, "$ut: tomorrow - not found before:1d"); -$output = qx{../src/task rc:bug.rc list due.after:1d 2>&1}; -unlike ($output, qr/yesterday/, "yesterday - not found after:1d"); -like ($output, qr/tomorrow/, "tomorrow - found after:1d"); +$output = qx{../src/task rc:$rc list due.after:now+1d 2>&1}; +unlike ($output, qr/yesterday/, "$ut: yesterday - not found after:1d"); +like ($output, qr/tomorrow/, "$ut: tomorrow - found after:1d"); # Cleanup. -unlink qw(pending.data completed.data undo.data backlog.data bug.rc); +unlink qw(pending.data completed.data undo.data backlog.data), $rc; exit 0;