diff --git a/test/bug.956.t b/test/bug.956.t index be0d47731..f47e33b22 100755 --- a/test/bug.956.t +++ b/test/bug.956.t @@ -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;