From e3e21b72a935d8db70dbf15cebb046eaa7abe50a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Jun 2014 10:28:24 -0400 Subject: [PATCH] Unit Tests - Removed useless setup/teardown tests, improving the signal to noise ratio. --- test/bug.annotate.t | 9 +-------- test/bug.annual.t | 9 +-------- test/bug.before.t | 10 +--------- test/bug.bulk.t | 9 +-------- test/bug.c001.t | 9 +-------- test/bug.cal.t | 10 +--------- test/bug.concat.t | 9 +-------- test/bug.hang.t | 10 +--------- test/bug.hasnt.t | 13 +++---------- test/bug.period.t | 9 +-------- test/bug.range.t | 9 +-------- test/bug.recur.t | 9 +-------- test/bug.sort.t | 9 +-------- test/bug.start.extra.t | 9 +-------- test/bug.uuid.t | 9 +-------- 15 files changed, 17 insertions(+), 125 deletions(-) diff --git a/test/bug.annotate.t b/test/bug.annotate.t index 6d1c6b5dc..51d135fed 100755 --- a/test/bug.annotate.t +++ b/test/bug.annotate.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 3; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -38,7 +38,6 @@ if (open my $fh, '>', 'bug.rc') { print $fh "data.location=.\n"; close $fh; - ok (-r 'bug.rc', 'Created bug.rc'); } # Attempt a blank annotation. @@ -55,11 +54,5 @@ unlike ($output, qr/Command prevented from running/, 'Filter-less write command # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data bug.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'bug.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.annual.t b/test/bug.annual.t index 2b0632bf7..5efc3e45c 100755 --- a/test/bug.annual.t +++ b/test/bug.annual.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 11; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -43,7 +43,6 @@ if (open my $fh, '>', 'annual.rc') "report.annual.filter=status:pending\n", "report.annual.sort=due+\n"; close $fh; - ok (-r 'annual.rc', 'Created annual.rc'); } # If a task is added with a due date ten years ago, with an annual recurrence, @@ -81,11 +80,5 @@ like ($output, qr/No duplicates found/, 'No duplicate UUIDs detected'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data annual.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'annual.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.before.t b/test/bug.before.t index 03b31f373..9b29e4c6d 100755 --- a/test/bug.before.t +++ b/test/bug.before.t @@ -28,7 +28,7 @@ use strict; use warnings; use Time::Local; -use Test::More tests => 17; +use Test::More tests => 14; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -42,7 +42,6 @@ if (open my $fh, '>', 'before.rc') "dateformat=m/d/Y\n", "dateformat.info=m/d/Y\n"; close $fh; - ok (-r 'before.rc', 'Created before.rc'); } # Create some example data directly. @@ -56,7 +55,6 @@ if (open my $fh, '>', 'pending.data') EOF close $fh; - ok (-r 'pending.data', 'Created pending.data'); } # Verify data is readable and just as expected. @@ -87,11 +85,5 @@ unlike ($output, qr/bar/, 'no bar after 5/1/2009'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data before.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'before.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.bulk.t b/test/bug.bulk.t index df86ddc84..07333867a 100755 --- a/test/bug.bulk.t +++ b/test/bug.bulk.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 10; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -40,7 +40,6 @@ if (open my $fh, '>', 'bulk.rc') "confirmation=yes\n", "bulk=3\n"; close $fh; - ok (-r 'bulk.rc', 'Created bulk.rc'); } # Add some tasks with project, prioriy and due date, some with only due date. @@ -74,11 +73,5 @@ like ($output, qr/Priority\s+M/, 'priority applied to 6'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data bulk.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'bulk.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.c001.t b/test/bug.c001.t index 8f60b59c4..322e5553f 100755 --- a/test/bug.c001.t +++ b/test/bug.c001.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 1; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc') print $fh "data.location=.\n", "confirmation=no\n"; close $fh; - ok (-r 'bug.rc', 'Created bug.rc'); } # Unreported Bug c01: Entering two recurring tasks back to back fails to increment @@ -56,11 +55,5 @@ like ($output, qr/Created task 2\./ms, 'Recurring task assigned correct ID.'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data bug.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'bug.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.cal.t b/test/bug.cal.t index b6c56892c..018024e56 100755 --- a/test/bug.cal.t +++ b/test/bug.cal.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 29; +use Test::More tests => 27; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -37,9 +37,7 @@ delete $ENV{'TASKRC'}; if (open my $fh, '>', 'cal.rc') { print $fh "data.location=."; - close $fh; - ok (-r 'cal.rc', 'Created cal.rc'); } # Bug: The 'cal' command can fail when provided with challenging arguments. @@ -108,10 +106,4 @@ unlike ($output, qr/(?:Assertion failed|Could note recognize|not a valid)/, 'cal # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data cal.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'cal.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.concat.t b/test/bug.concat.t index 93f492b1b..fd66923a5 100755 --- a/test/bug.concat.t +++ b/test/bug.concat.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 3; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'bug.rc') print $fh "data.location=.\n", "confirmation=no\n"; close $fh; - ok (-r 'bug.rc', 'Created bug.rc'); } # When a task is modified like this: @@ -72,11 +71,5 @@ like ($output, qr/Description\s+aaa bbb:ccc ddd\n/, 'properly concatenated'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data bug.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'bug.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.hang.t b/test/bug.hang.t index 4adb15b8a..a7551633b 100755 --- a/test/bug.hang.t +++ b/test/bug.hang.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 1; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -40,7 +40,6 @@ if (open my $fh, '>', 'hang.rc') "shadow.file=shadow.txt\n", "shadow.command=list\n"; close $fh; - ok (-r 'hang.rc', 'Created hang.rc'); } =pod @@ -74,12 +73,5 @@ if ($@ eq "alarm\n") # Cleanup. unlink qw(shadow.txt pending.data completed.data undo.data backlog.data hang.rc); -ok (! -r 'shadow.txt' && - ! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'hang.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.hasnt.t b/test/bug.hasnt.t index 93c4fdbf6..246d930ab 100755 --- a/test/bug.hasnt.t +++ b/test/bug.hasnt.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 16; +use Test::More tests => 14; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'hasnt.rc') print $fh "data.location=.\n", "confirmation=no\n"; close $fh; - ok (-r 'hasnt.rc', 'Created hasnt.rc'); } # 1 @@ -71,7 +70,7 @@ qx{../src/task rc:hasnt.rc add one 2>&1}; qx{../src/task rc:hasnt.rc 7 annotate two 2>&1}; qx{../src/task rc:hasnt.rc 7 annotate three 2>&1}; -my $output = qx{../src/task rc:hasnt.rc ls description.has:foo 2>&1}; +my $output = qx{../src/task rc:hasnt.rc long description.has:foo 2>&1}; like ($output, qr/\n 1/, '1 has foo -> yes'); like ($output, qr/\n 2/, '2 has foo -> yes'); like ($output, qr/\n 3/, '3 has foo -> yes'); @@ -80,7 +79,7 @@ like ($output, qr/\n 5/, '5 has foo -> yes'); like ($output, qr/\n 6/, '6 has foo -> yes'); unlike ($output, qr/\n 7/, '7 has foo -> no'); -$output = qx{../src/task rc:hasnt.rc ls description.hasnt:foo 2>&1}; +$output = qx{../src/task rc:hasnt.rc long description.hasnt:foo 2>&1}; unlike ($output, qr/\n 1/, '1 hasnt foo -> no'); unlike ($output, qr/\n 2/, '2 hasnt foo -> no'); # 10 unlike ($output, qr/\n 3/, '3 hasnt foo -> no'); @@ -91,11 +90,5 @@ like ($output, qr/\n 7/, '7 hasnt foo -> yes'); # 15 # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data hasnt.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'hasnt.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.period.t b/test/bug.period.t index 632732583..aff1c0328 100755 --- a/test/bug.period.t +++ b/test/bug.period.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 41; +use Test::More tests => 39; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -38,7 +38,6 @@ if (open my $fh, '>', 'period.rc') { print $fh "data.location=.\n"; close $fh; - ok (-r 'period.rc', 'Created period.rc'); } =pod @@ -161,11 +160,5 @@ like ($output, qr/No duplicates found/, 'No duplicate UUIDs detected'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data period.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'period.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.range.t b/test/bug.range.t index c65c72e85..66c6c5d0b 100755 --- a/test/bug.range.t +++ b/test/bug.range.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 3; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -40,7 +40,6 @@ if (open my $fh, '>', 'range.rc') "confirmation=no\n", "dateformat=m/d/Y\n"; close $fh; - ok (-r 'range.rc', 'Created range.rc'); } # Add three tasks, and attempt to list the middle one within a range. @@ -54,11 +53,5 @@ unlike ($output, qr/three/, 'Missing after range'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data range.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'range.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.recur.t b/test/bug.recur.t index 9ed108302..f111be08e 100755 --- a/test/bug.recur.t +++ b/test/bug.recur.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 3; +use Test::More tests => 1; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'recur.rc') print $fh "data.location=.\n", "confirmation=no\n"; close $fh; - ok (-r 'recur.rc', 'Created recur.rc'); } # Add a recurring task with no due date, look for expected error. @@ -49,11 +48,5 @@ unlike ($output, qr/Description\s+foo/, 'task not created - missing due date'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data recur.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'recur.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.sort.t b/test/bug.sort.t index 88f50a6d8..3be919e5f 100755 --- a/test/bug.sort.t +++ b/test/bug.sort.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 4; +use Test::More tests => 2; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -38,7 +38,6 @@ if (open my $fh, '>', 'bug_sort.rc') { print $fh "data.location=.\n"; close $fh; - ok (-r 'bug_sort.rc', 'Created bug_sort.rc'); } my $setup = "../src/task rc:bug_sort.rc add one 2>&1;" @@ -55,11 +54,5 @@ like ($output, qr/three.*one.*two/msi, 'list did not hang after pri:H on 1'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data bug_sort.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'bug_sort.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.start.extra.t b/test/bug.start.extra.t index afc70cfd1..8cc695868 100755 --- a/test/bug.start.extra.t +++ b/test/bug.start.extra.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 4; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'extra.rc') print $fh "data.location=.\n", "confirmation=no\n"; close $fh; - ok (-r 'extra.rc', 'Created extra.rc'); } qx{../src/task rc:extra.rc add foo 2>&1}; @@ -53,11 +52,5 @@ like ($output, qr/bar/, 'Correct annotation'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data extra.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'extra.rc', 'Cleanup'); - exit 0; diff --git a/test/bug.uuid.t b/test/bug.uuid.t index ee882b76f..628b66f9b 100755 --- a/test/bug.uuid.t +++ b/test/bug.uuid.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 3; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'uuid.rc') print $fh "data.location=.\n", "confirmation=no\n"; close $fh; - ok (-r 'uuid.rc', 'Created uuid.rc'); } # Add a task, dup it, add a recurring task, list. Then make sure they all have @@ -89,11 +88,5 @@ like ($output, qr/No duplicates found/, 'No duplicate UUIDs detected'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data uuid.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'uuid.rc', 'Cleanup'); - exit 0;