Unit Tests
- Explicitly set colors so that tests are not dependent on current defaults.
This commit is contained in:
@@ -33,24 +33,30 @@ use Test::More tests => 3;
|
|||||||
delete $ENV{'TASKDATA'};
|
delete $ENV{'TASKDATA'};
|
||||||
delete $ENV{'TASKRC'};
|
delete $ENV{'TASKRC'};
|
||||||
|
|
||||||
|
use File::Basename;
|
||||||
|
my $ut = basename ($0);
|
||||||
|
my $rc = $ut . '.rc';
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'color.rc')
|
if (open my $fh, '>', $rc)
|
||||||
{
|
{
|
||||||
print $fh "data.location=.\n",
|
print $fh "data.location=.\n",
|
||||||
"color.pri.H=red\n",
|
"color.pri.H=red\n",
|
||||||
|
"color.label=\n",
|
||||||
|
"color.label.sort=\n",
|
||||||
"fontunderline=no\n";
|
"fontunderline=no\n";
|
||||||
close $fh;
|
close $fh;
|
||||||
}
|
}
|
||||||
|
|
||||||
# Test the add command.
|
# Test the add command.
|
||||||
qx{../src/task rc:color.rc add priority:H red 2>&1};
|
qx{../src/task rc:$rc add priority:H red 2>&1};
|
||||||
my $output = qx{../src/task rc:color.rc list 2>&1};
|
my $output = qx{../src/task rc:$rc list 2>&1};
|
||||||
|
|
||||||
like ($output, qr/red/, 'color.disable - found red');
|
like ($output, qr/red/, "$ut: color.disable - found red");
|
||||||
unlike ($output, qr/\033\[31m/, 'color.disable - no color red');
|
unlike ($output, qr/\033\[31m/, "$ut: color.disable - no color red");
|
||||||
unlike ($output, qr/\033\[0m/, 'color.disable - no color reset');
|
unlike ($output, qr/\033\[0m/, "$ut: color.disable - no color reset");
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
|
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user