mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests
- Upgraded to use the new template.
This commit is contained in:
parent
9f934925c5
commit
743d4dd155
1 changed files with 25 additions and 21 deletions
|
@ -33,8 +33,12 @@ use Test::More tests => 12;
|
|||
delete $ENV{'TASKDATA'};
|
||||
delete $ENV{'TASKRC'};
|
||||
|
||||
use File::Basename;
|
||||
my $ut = basename ($0);
|
||||
my $rc = $ut . '.rc';
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bug.rc')
|
||||
if (open my $fh, '>', $rc)
|
||||
{
|
||||
print $fh "data.location=.\n";
|
||||
close $fh;
|
||||
|
@ -43,34 +47,34 @@ if (open my $fh, '>', 'bug.rc')
|
|||
# Bug 956 - 'task ids' prints the header, which prevents using the command in
|
||||
# external script (it applies also for 'uuids' and helper subcommands).
|
||||
|
||||
qx{../src/task rc:bug.rc add test 2>&1};
|
||||
qx{../src/task rc:$rc add test 2>&1};
|
||||
|
||||
# Solution 1: rc.verbose=nothing
|
||||
my $output = qx{TASKRC=bug.rc ../src/task rc:bug.rc rc.verbose=nothing ids 2>&1};
|
||||
like ($output, qr/^1$/m, 'ID 1 shown');
|
||||
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "ids" (rc.verbose=nothing)');
|
||||
my $output = qx{TASKRC=$rc ../src/task rc:$rc rc.verbose=nothing ids 2>&1};
|
||||
like ($output, qr/^1$/m, "$ut: ID 1 shown");
|
||||
unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'ids' (rc.verbose=nothing)");
|
||||
|
||||
$output = qx{TASKRC=bug.rc ../src/task rc.verbose=nothing uuids 2>&1};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown');
|
||||
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "uuids" (rc.verbose=nothing)');
|
||||
$output = qx{TASKRC=$rc ../src/task rc.verbose=nothing uuids 2>&1};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
|
||||
unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'uuids' (rc.verbose=nothing)");
|
||||
|
||||
$output = qx{TASKRC=bug.rc ../src/task rc.verbose=nothing uuids 2>&1};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown');
|
||||
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "uuids" (rc.verbose=nothing)');
|
||||
$output = qx{TASKRC=$rc ../src/task rc.verbose=nothing uuids 2>&1};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
|
||||
unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'uuids' (rc.verbose=nothing)");
|
||||
|
||||
# Solution 2: task ... 2>/dev/null
|
||||
$output = qx{TASKRC=bug.rc ../src/task rc:bug.rc ids 2>/dev/null};
|
||||
like ($output, qr/^1$/m, 'ID 1 shown');
|
||||
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "ids" (2>/dev/null)');
|
||||
$output = qx{TASKRC=$rc ../src/task rc:$rc ids 2>/dev/null};
|
||||
like ($output, qr/^1$/m, "$ut: ID 1 shown");
|
||||
unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with 'ids' (2>/dev/null)");
|
||||
|
||||
$output = qx{TASKRC=bug.rc ../src/task _ids 2>/dev/null};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown');
|
||||
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "_ids" (2>/dev/null)');
|
||||
$output = qx{TASKRC=$rc ../src/task _ids 2>/dev/null};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
|
||||
unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with '_ids' (2>/dev/null)");
|
||||
|
||||
$output = qx{TASKRC=bug.rc ../src/task _ids 2>/dev/null};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, 'UUID shown');
|
||||
unlike ($output, qr/TASKRC/ms, 'The header does not appear with "_ids" (2>/dev/null)');
|
||||
$output = qx{TASKRC=$rc ../src/task _ids 2>/dev/null};
|
||||
like ($output, qr/^[0-9a-f-]*$/m, "$ut: UUID shown");
|
||||
unlike ($output, qr/TASKRC/ms, "$ut: The header does not appear with '_ids' (2>/dev/null)");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue