Unit Tests

- Removed useless setup/teardown tests, improving the signal to noise ratio.
This commit is contained in:
Paul Beckingham 2014-06-01 09:45:46 -04:00
parent c0f4baa8d9
commit 102792e425
7 changed files with 10 additions and 88 deletions

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 9; use Test::More tests => 7;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'add.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=off\n"; "confirmation=off\n";
close $fh; close $fh;
ok (-r 'add.rc', 'Created add.rc');
} }
# Test the add command. # Test the add command.
@ -60,11 +59,5 @@ like ($output, qr/Description\s+This a TEST\n/, 'add Description');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data add.rc); 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; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 5; use Test::More tests => 3;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -40,7 +40,6 @@ if (open my $fh, '>', 'alias.rc')
"alias.foo=_projects\n", "alias.foo=_projects\n",
"alias.bar=foo\n"; "alias.bar=foo\n";
close $fh; close $fh;
ok (-r 'alias.rc', 'Created alias.rc');
} }
# Add a task with certain project, then access that task via aliases. # 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. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data alias.rc); 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; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 25; use Test::More tests => 23;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -46,7 +46,6 @@ if (open my $fh, '>', 'annotate.rc')
"color=off\n", "color=off\n",
"dateformat=m/d/Y\n"; "dateformat=m/d/Y\n";
close $fh; close $fh;
ok (-r 'annotate.rc', 'Created annotate.rc');
} }
# Add four tasks, annotate one three times, one twice, one just once and one none. # Add four tasks, annotate one three times, one twice, one just once and one none.
@ -119,12 +118,5 @@ like ($output, qr/4 tasks/, 'count');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data annotate.rc annotate2.rc); 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; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 6; use Test::More tests => 4;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'append.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"confirmation=off\n"; "confirmation=off\n";
close $fh; close $fh;
ok (-r 'append.rc', 'Created append.rc');
} }
# Add a task, then append more description. # Add a task, then append more description.
@ -56,11 +55,5 @@ unlike ($output, qr/^Appended 1 task.$/, 'blank append failed');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data append.rc); 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; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 3; use Test::More tests => 1;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -38,7 +38,6 @@ if (open my $fh, '>', 'backslash.rc')
{ {
print $fh "data.location=.\n"; print $fh "data.location=.\n";
close $fh; close $fh;
ok (-r 'backslash.rc', 'Created backslash.rc');
} }
# Add a description with a backslash. # Add a description with a backslash.
@ -48,12 +47,6 @@ like ($output, qr/\\/, 'Backslash preserved, no parsing issues');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data backslash.rc); 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; exit 0;
################################################################################ ################################################################################

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 18; use Test::More tests => 16;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -41,7 +41,6 @@ if (open my $fh, '>', 'bug.rc')
print $fh "abbreviation.minimum=5\n"; print $fh "abbreviation.minimum=5\n";
close $fh; close $fh;
ok (-r 'bug.rc', 'Created bug.rc');
} }
my $source_dir = $0; my $source_dir = $0;
@ -108,37 +107,6 @@ $output = qx{bash ./task.sh task proj : to 2>&1};
ok ($? == 0, 'Exit status check'); ok ($? == 0, 'Exit status check');
unlike ($output, qr/todd/, '\'proj:\' does not expand if abbreviation.minimum is 5'); 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 # 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}; qx{../src/task rc:bug.rc add this task should be number 2 and stay number 2 2>&1};
ok ($? == 0, 'Exit status check'); ok ($? == 0, 'Exit status check');
@ -152,11 +120,4 @@ like ($output, qr/shouldreplacetext/, 'no gc was run');
# Cleanup. # Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc task.sh); 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; exit 0;

View file

@ -27,7 +27,7 @@
use strict; use strict;
use warnings; use warnings;
use Test::More tests => 7; use Test::More tests => 5;
# Ensure environment has no influence. # Ensure environment has no influence.
delete $ENV{'TASKDATA'}; delete $ENV{'TASKDATA'};
@ -39,7 +39,6 @@ if (open my $fh, '>', 'basic.rc')
print $fh "data.location=.\n", print $fh "data.location=.\n",
"default.command=\n"; "default.command=\n";
close $fh; close $fh;
ok (-r 'basic.rc', 'Created basic.rc');
} }
# Get the version number from configure.ac # Get the version number from configure.ac
@ -61,8 +60,6 @@ like ($output, qr/[a-f0-9]{7}/, '_version - task version number');
# Cleanup. # Cleanup.
unlink 'basic.rc'; unlink 'basic.rc';
ok (!-r 'basic.rc', 'Removed basic.rc');
exit 0; exit 0;
################################################################################ ################################################################################