From 307ea1c8570e2adaef1b4eb1c4619bce783f9b62 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Jun 2014 10:02:53 -0400 Subject: [PATCH] Unit Tests - Removed useless setup/teardown tests, improving the signal to noise ratio. --- test/rc.override.t | 6 ++---- test/rc.t | 6 +----- test/roundtrip.t | 11 +---------- test/sequence.t | 9 +-------- test/shadow.t | 10 +--------- test/shell.t | 9 +-------- test/sorting.t | 9 +-------- test/special.t | 9 +-------- test/start.t | 11 +---------- 9 files changed, 10 insertions(+), 70 deletions(-) diff --git a/test/rc.override.t b/test/rc.override.t index b8e59cc59..9145301f7 100755 --- a/test/rc.override.t +++ b/test/rc.override.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'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'rc.rc') print $fh "data.location=.\n", "foo=bar\n"; close $fh; - ok (-r 'rc.rc', 'Created rc.rc'); } my $output = qx{../src/task rc:rc.rc show 2>&1}; @@ -48,8 +47,7 @@ like ($output, qr/^.*foo.+bar.*$/m, 'unmodified'); $output = qx{../src/task rc:rc.rc rc.foo:baz show 2>&1}; like ($output, qr/^.*foo.*baz.*$/m, 'overridden'); +# Cleanup. unlink 'rc.rc'; -ok (!-r 'rc.rc', 'Removed rc.rc'); - exit 0; diff --git a/test/rc.t b/test/rc.t index 5c735cdc1..8a17c6460 100755 --- a/test/rc.t +++ b/test/rc.t @@ -28,7 +28,7 @@ use strict; use warnings; use File::Path; -use Test::More tests => 15; +use Test::More tests => 13; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -87,10 +87,6 @@ $output = qx{../src/task rc:foo.rc show 2>&1}; like ($output, qr/^must_be_unique\s+one two three/ms, 'config allows multi-word unquoted values'); rmtree 'foo', 0, 0; -ok (!-r 'foo', 'Removed foo'); - unlink 'foo.rc'; -ok (!-r 'foo.rc', 'Removed foo.rc'); - exit 0; diff --git a/test/roundtrip.t b/test/roundtrip.t index 59461c548..a0d38a541 100755 --- a/test/roundtrip.t +++ b/test/roundtrip.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'}; @@ -42,7 +42,6 @@ if (open my $fh, '>', 'roundtrip.rc') "defaultwidth=100\n", "dateformat=m/d/Y\n"; close $fh; - ok (-r 'roundtrip.rc', 'Created roundtrip.rc'); } # Add two tasks. @@ -76,13 +75,5 @@ like ($output, qr/^$/, 'JSON files roundtrip1.json and roundtrip2.json identical # Cleanup. unlink qw(roundtrip1.json roundtrip2.json pending.data completed.data undo.data backlog.data roundtrip.rc); -ok (! -r 'roundtrip1.json' && - ! -r 'roundtrip2.json' && - ! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'roundtrip.rc', 'Cleanup'); - exit 0; diff --git a/test/sequence.t b/test/sequence.t index 76956abad..173c54106 100755 --- a/test/sequence.t +++ b/test/sequence.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 26; +use Test::More tests => 24; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -40,7 +40,6 @@ if (open my $fh, '>', 'seq.rc') "confirmation=off\n", "dateformat.annotation=m/d/Y\n"; close $fh; - ok (-r 'seq.rc', 'Created seq.rc'); } # Test sequences in done/undo @@ -123,11 +122,5 @@ like ($output, qr/\d+\/\d+\/\d+ note/, 'sequence 2 annotate'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data seq.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'seq.rc', 'Cleanup'); - exit 0; diff --git a/test/shadow.t b/test/shadow.t index 6e5dd8cd3..e58d29e02 100755 --- a/test/shadow.t +++ b/test/shadow.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 18; +use Test::More tests => 16; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -42,7 +42,6 @@ if (open my $fh, '>', 'shadow.rc') "shadow.command=rc:shadow.rc stats\n", "shadow.notify=on\n"; close $fh; - ok (-r 'shadow.rc', 'Created shadow.rc'); } my $output = qx{../src/task rc:shadow.rc add one 2>&1 >/dev/null}; @@ -74,13 +73,6 @@ like ($file, qr/Projects\s+0\n/, 'Projects 0'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data shadow.txt shadow.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'shadow.txt' && - ! -r 'shadow.rc', 'Cleanup'); - exit 0; ################################################################################ diff --git a/test/shell.t b/test/shell.t index f6efd23a4..21eb92771 100755 --- a/test/shell.t +++ b/test/shell.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'}; @@ -41,7 +41,6 @@ if (open my $fh, '>', 'shell.rc') "defaultwidth=0\n", "default.command=ls\n"; close $fh; - ok (-r 'shell.rc', 'Created shell.rc'); } # Test the prompt. @@ -58,11 +57,5 @@ ok (!-r 'shell.rc', 'Removed shell.rc'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data shell.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'shell.rc', 'Cleanup'); - exit 0; diff --git a/test/sorting.t b/test/sorting.t index d1e2ee879..fd648ad9f 100755 --- a/test/sorting.t +++ b/test/sorting.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 100; +use Test::More tests => 98; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -38,7 +38,6 @@ if (open my $fh, '>', 'sorting.rc') { print $fh "data.location=.\n"; close $fh; - ok (-r 'sorting.rc', 'Created sorting.rc'); } # Test assorted sort orders. @@ -181,11 +180,5 @@ for my $sort (sort keys %tests) # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data sorting.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'sorting.rc', 'Cleanup'); - exit 0; diff --git a/test/special.t b/test/special.t index f6d67d793..7ba9c2cf8 100755 --- a/test/special.t +++ b/test/special.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'}; @@ -45,7 +45,6 @@ if (open my $fh, '>', 'special.rc') "nag=NAG\n", "_forcecolor=1\n"; close $fh; - ok (-r 'special.rc', 'Created special.rc'); } # Prove that +nocolor suppresses all color for a task. @@ -63,11 +62,5 @@ unlike ($output, qr/NAG/, '+nonag suppressed nagging for task 2'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data special.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'special.rc', 'Cleanup'); - exit 0; diff --git a/test/start.t b/test/start.t index 4421ae9f1..78dff060f 100755 --- a/test/start.t +++ b/test/start.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 17; +use Test::More tests => 15; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -38,7 +38,6 @@ if (open my $fh, '>', 'start.rc') { print $fh "data.location=.\n"; close $fh; - ok (-r 'start.rc', 'Created start.rc'); } # Test the add/start/stop commands. @@ -106,13 +105,5 @@ like ($output, qr/Nu.+stannar.+vi/ms, 'one stopped and annotated with custom des # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data start.rc start2.rc start3.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'start.rc' && - ! -r 'start2.rc' && - ! -r 'start3.rc', 'Cleanup'); - exit 0;