From 102792e4254c301110f09ad123608bbd90a93486 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 1 Jun 2014 09:45:46 -0400 Subject: [PATCH] Unit Tests - Removed useless setup/teardown tests, improving the signal to noise ratio. --- test/add.t | 9 +-------- test/alias.t | 9 +-------- test/annotate.t | 16 ++++------------ test/append.t | 9 +-------- test/backslash.t | 9 +-------- test/bash_completion.t | 41 +---------------------------------------- test/basic.t | 5 +---- 7 files changed, 10 insertions(+), 88 deletions(-) diff --git a/test/add.t b/test/add.t index f03923a90..1ba1087fe 100755 --- a/test/add.t +++ b/test/add.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 9; +use Test::More tests => 7; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'add.rc') print $fh "data.location=.\n", "confirmation=off\n"; close $fh; - ok (-r 'add.rc', 'Created add.rc'); } # Test the add command. @@ -60,11 +59,5 @@ like ($output, qr/Description\s+This a TEST\n/, 'add Description'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data add.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'add.rc', 'Cleanup'); - exit 0; diff --git a/test/alias.t b/test/alias.t index e9988cdbb..5229ed8c0 100755 --- a/test/alias.t +++ b/test/alias.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, '>', 'alias.rc') "alias.foo=_projects\n", "alias.bar=foo\n"; close $fh; - ok (-r 'alias.rc', 'Created alias.rc'); } # Add a task with certain project, then access that task via aliases. @@ -57,11 +56,5 @@ like ($output, qr/ALIAS/, 'task bar -> foo -> _projects -> ALIAS'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data alias.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'alias.rc', 'Cleanup'); - exit 0; diff --git a/test/annotate.t b/test/annotate.t index c4cac8d0e..771334ee0 100755 --- a/test/annotate.t +++ b/test/annotate.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 25; +use Test::More tests => 23; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -46,7 +46,6 @@ if (open my $fh, '>', 'annotate.rc') "color=off\n", "dateformat=m/d/Y\n"; close $fh; - ok (-r 'annotate.rc', 'Created annotate.rc'); } # Add four tasks, annotate one three times, one twice, one just once and one none. @@ -63,7 +62,7 @@ qx{../src/task rc:annotate.rc 3 annotate baz1 2>&1}; my $output = qx{../src/task rc:annotate.rc rrr 2>&1}; -# ID Description +# ID Description # -- ------------------------------- # 1 one # 3/24/2009 foo1 @@ -75,7 +74,7 @@ my $output = qx{../src/task rc:annotate.rc rrr 2>&1}; # 3 three # 3/24/2009 baz1 # 4 four -# +# # 4 tasks like ($output, qr/1 one/, 'task 1'); # 2 @@ -99,7 +98,7 @@ if (open my $fh, '>', 'annotate2.rc') "report.rrr.description=rrr\n", "report.rrr.columns=id,description\n", "report.rrr.sort=id+\n", - "dateformat.annotation=yMD HNS\n"; + "dateformat.annotation=yMD HNS\n"; close $fh; ok (-r 'annotate2.rc', 'Created annotate2.rc'); } @@ -119,12 +118,5 @@ like ($output, qr/4 tasks/, 'count'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data annotate.rc annotate2.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'annotate.rc' && - ! -r 'annotate2.rc', 'Cleanup'); - exit 0; diff --git a/test/append.t b/test/append.t index e0dae1853..01b62a97a 100755 --- a/test/append.t +++ b/test/append.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, '>', 'append.rc') print $fh "data.location=.\n", "confirmation=off\n"; close $fh; - ok (-r 'append.rc', 'Created append.rc'); } # Add a task, then append more description. @@ -56,11 +55,5 @@ unlike ($output, qr/^Appended 1 task.$/, 'blank append failed'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data append.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'append.rc', 'Cleanup'); - exit 0; diff --git a/test/backslash.t b/test/backslash.t index 6115b5201..b8bed2902 100755 --- a/test/backslash.t +++ b/test/backslash.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'}; @@ -38,7 +38,6 @@ if (open my $fh, '>', 'backslash.rc') { print $fh "data.location=.\n"; close $fh; - ok (-r 'backslash.rc', 'Created backslash.rc'); } # Add a description with a backslash. @@ -48,12 +47,6 @@ like ($output, qr/\\/, 'Backslash preserved, no parsing issues'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data backslash.rc); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'backslash.rc', 'Cleanup'); - exit 0; ################################################################################ diff --git a/test/bash_completion.t b/test/bash_completion.t index b18aa2e11..9ccbab0a9 100755 --- a/test/bash_completion.t +++ b/test/bash_completion.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'}; @@ -41,7 +41,6 @@ if (open my $fh, '>', 'bug.rc') print $fh "abbreviation.minimum=5\n"; close $fh; - ok (-r 'bug.rc', 'Created bug.rc'); } my $source_dir = $0; @@ -108,37 +107,6 @@ $output = qx{bash ./task.sh task proj : to 2>&1}; ok ($? == 0, 'Exit status check'); unlike ($output, qr/todd/, '\'proj:\' does not expand if abbreviation.minimum is 5'); -# The following tests were removed because we no longer expand task IDs after -# depends. This expansion was stopped because it was using the _ids command -# which runs _ids and can lead to confusing behavior for the user. See: -# https://groups.google.com/forum/#!topic/taskwarrior-dev/KwHnb9MOOqA - -## "priority:" should be expanded correctly and dependent on abbreviation.minimum -#$output = qx{bash ./task.sh task priorABC : 2>&1}; -#ok ($? == 0, 'Exit status check'); -#unlike ($output, qr/H/, '\'priorABC:\' does not expand'); -# -#$output = qx{bash ./task.sh task prior : 2>&1}; -#ok ($? == 0, 'Exit status check'); -#like ($output, qr/H/, '\'prior:\' does expand'); -# -#$output = qx{bash ./task.sh task prio : 2>&1}; -#ok ($? == 0, 'Exit status check'); -#unlike ($output, qr/H/, '\'prio:\' does not expand if abbreviation.minimum is 5'); -# -## "depends:" should be expanded correctly and dependent on abbreviation.minimum -#$output = qx{bash ./task.sh task depenABC : 2>&1}; -#ok ($? == 0, 'Exit status check'); -#unlike ($output, qr/1/, '\'depenABC:\' does not expand'); -# -#$output = qx{bash ./task.sh task depen : 2>&1}; -#ok ($? == 0, 'Exit status check'); -#like ($output, qr/1/, '\'depen:\' does expand'); -# -#$output = qx{bash ./task.sh task depe : 2>&1}; -#ok ($? == 0, 'Exit status check'); -#unlike ($output, qr/1/, '\'depe:\' does not expand if abbreviation.minimum is 5'); - # there should be no gc coming from bash completion qx{../src/task rc:bug.rc add this task should be number 2 and stay number 2 2>&1}; ok ($? == 0, 'Exit status check'); @@ -152,11 +120,4 @@ like ($output, qr/shouldreplacetext/, 'no gc was run'); # Cleanup. unlink qw(pending.data completed.data undo.data backlog.data bug.rc task.sh); -ok (! -r 'pending.data' && - ! -r 'completed.data' && - ! -r 'undo.data' && - ! -r 'backlog.data' && - ! -r 'bug.rc' && - ! -r 'task.sh', 'Cleanup'); - exit 0; diff --git a/test/basic.t b/test/basic.t index 534696ba2..8df78f03b 100755 --- a/test/basic.t +++ b/test/basic.t @@ -27,7 +27,7 @@ use strict; use warnings; -use Test::More tests => 7; +use Test::More tests => 5; # Ensure environment has no influence. delete $ENV{'TASKDATA'}; @@ -39,7 +39,6 @@ if (open my $fh, '>', 'basic.rc') print $fh "data.location=.\n", "default.command=\n"; close $fh; - ok (-r 'basic.rc', 'Created basic.rc'); } # Get the version number from configure.ac @@ -61,8 +60,6 @@ like ($output, qr/[a-f0-9]{7}/, '_version - task version number'); # Cleanup. unlink 'basic.rc'; -ok (!-r 'basic.rc', 'Removed basic.rc'); - exit 0; ################################################################################