mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-29 07:57:20 +02:00
Unit Tests
- Added unit tests for the color.blocked rule. - Added unit tests for dependencies (placeholder). - Added unit tests for the format-depends hook.
This commit is contained in:
parent
64344d0328
commit
45bb3dd583
3 changed files with 203 additions and 0 deletions
64
src/tests/color.blocked.t
Executable file
64
src/tests/color.blocked.t
Executable file
|
@ -0,0 +1,64 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
################################################################################
|
||||||
|
## task - a command line task list manager.
|
||||||
|
##
|
||||||
|
## Copyright 2006 - 2010, Paul Beckingham.
|
||||||
|
## All rights reserved.
|
||||||
|
##
|
||||||
|
## This program is free software; you can redistribute it and/or modify it under
|
||||||
|
## the terms of the GNU General Public License as published by the Free Software
|
||||||
|
## Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
## version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
## details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along with
|
||||||
|
## this program; if not, write to the
|
||||||
|
##
|
||||||
|
## Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor,
|
||||||
|
## Boston, MA
|
||||||
|
## 02110-1301
|
||||||
|
## USA
|
||||||
|
##
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More tests => 6;
|
||||||
|
|
||||||
|
# Create the rc file.
|
||||||
|
if (open my $fh, '>', 'color.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n",
|
||||||
|
"color.blocked=red\n",
|
||||||
|
"color.alternate=\n",
|
||||||
|
"_forcecolor=1\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'color.rc', 'Created color.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test the add command.
|
||||||
|
qx{../task rc:color.rc add red};
|
||||||
|
qx{../task rc:color.rc add nothing};
|
||||||
|
qx{../task rc:color.rc 1 depends:2};
|
||||||
|
my $output = qx{../task rc:color.rc list};
|
||||||
|
|
||||||
|
like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
|
||||||
|
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.blocked');
|
||||||
|
|
||||||
|
# Cleanup.
|
||||||
|
unlink 'pending.data';
|
||||||
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
||||||
|
unlink 'undo.data';
|
||||||
|
ok (!-r 'undo.data', 'Removed undo.data');
|
||||||
|
|
||||||
|
unlink 'color.rc';
|
||||||
|
ok (!-r 'color.rc', 'Removed color.rc');
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
57
src/tests/dependencies.t
Executable file
57
src/tests/dependencies.t
Executable file
|
@ -0,0 +1,57 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
################################################################################
|
||||||
|
## task - a command line task list manager.
|
||||||
|
##
|
||||||
|
## Copyright 2006 - 2010, Paul Beckingham.
|
||||||
|
## All rights reserved.
|
||||||
|
##
|
||||||
|
## This program is free software; you can redistribute it and/or modify it under
|
||||||
|
## the terms of the GNU General Public License as published by the Free Software
|
||||||
|
## Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
## version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
## details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along with
|
||||||
|
## this program; if not, write to the
|
||||||
|
##
|
||||||
|
## Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor,
|
||||||
|
## Boston, MA
|
||||||
|
## 02110-1301
|
||||||
|
## USA
|
||||||
|
##
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More tests => 10;
|
||||||
|
|
||||||
|
# Create the rc file.
|
||||||
|
if (open my $fh, '>', 'dep.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'dep.rc', 'Created dep.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
# TODO t 1 dep:2; t info 1 => blocked by 2
|
||||||
|
# TODO t info 2 => blocking 1
|
||||||
|
# TODO t 1 dep:2,3,4; t 1 dep:-2,-4,5; t info 1 => blocked by 3,5
|
||||||
|
# TODO t 1 dep:2; t 2 dep:1 => error
|
||||||
|
|
||||||
|
# Cleanup.
|
||||||
|
unlink 'pending.data';
|
||||||
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
||||||
|
unlink 'undo.data';
|
||||||
|
ok (!-r 'undo.data', 'Removed undo.data');
|
||||||
|
|
||||||
|
unlink 'dep.rc';
|
||||||
|
ok (!-r 'dep.rc', 'Removed dep.rc');
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
82
src/tests/hook.format-depends.t
Executable file
82
src/tests/hook.format-depends.t
Executable file
|
@ -0,0 +1,82 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
################################################################################
|
||||||
|
## task - a command line task list manager.
|
||||||
|
##
|
||||||
|
## Copyright 2006 - 2010, Paul Beckingham.
|
||||||
|
## All rights reserved.
|
||||||
|
##
|
||||||
|
## This program is free software; you can redistribute it and/or modify it under
|
||||||
|
## the terms of the GNU General Public License as published by the Free Software
|
||||||
|
## Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
## version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
## details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along with
|
||||||
|
## this program; if not, write to the
|
||||||
|
##
|
||||||
|
## Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor,
|
||||||
|
## Boston, MA
|
||||||
|
## 02110-1301
|
||||||
|
## USA
|
||||||
|
##
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More tests => 7;
|
||||||
|
|
||||||
|
# Create the rc file.
|
||||||
|
if (open my $fh, '>', 'hook.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n",
|
||||||
|
"hooks=on\n",
|
||||||
|
"hook.format-depends=" . $ENV{'PWD'} . "/hook:depends\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'hook.rc', 'Created hook.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Create the hook functions.
|
||||||
|
if (open my $fh, '>', 'hook')
|
||||||
|
{
|
||||||
|
print $fh "function depends (name, value)\n",
|
||||||
|
" value = '<' .. value .. '>'\n",
|
||||||
|
" return value, 0, nil\n",
|
||||||
|
"end\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'hook', 'Created hook');
|
||||||
|
}
|
||||||
|
|
||||||
|
my $output = qx{../task rc:hook.rc version};
|
||||||
|
if ($output =~ /PUC-Rio/)
|
||||||
|
{
|
||||||
|
qx{../task rc:hook.rc add one};
|
||||||
|
qx{../task rc:hook.rc add two depends:1};
|
||||||
|
$output = qx{../task rc:hook.rc long};
|
||||||
|
|
||||||
|
like ($output, qr/<1>/, 'format-depends hook 1 -> <1>');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pass ('format-depends hook 1 -> <1> - skip: no Lua support');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Cleanup.
|
||||||
|
unlink 'pending.data';
|
||||||
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
||||||
|
unlink 'undo.data';
|
||||||
|
ok (!-r 'undo.data', 'Removed undo.data');
|
||||||
|
|
||||||
|
unlink 'hook';
|
||||||
|
ok (!-r 'hook', 'Removed hook');
|
||||||
|
|
||||||
|
unlink 'hook.rc';
|
||||||
|
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue