Merge branch '2.4.2' into lexer2

This commit is contained in:
Paul Beckingham 2015-03-07 17:36:10 -05:00
commit 29dff399bd
41 changed files with 1095 additions and 1472 deletions

View file

@ -22,6 +22,8 @@
forks (thanks to Jens Erat). forks (thanks to Jens Erat).
- Re-enabled hook script feedback when exiting with 0 exit status. - Re-enabled hook script feedback when exiting with 0 exit status.
- The 'info' command now shows virtual tags. - The 'info' command now shows virtual tags.
- Fixed major on-modify hooks regression where hooks could no longer modify
the tasks handed to them.
------ current release --------------------------- ------ current release ---------------------------

View file

@ -433,7 +433,7 @@ std::string Config::_defaults =
"report.next.labels=ID,Active,Age,Deps,P,Project,Tag,Recur,S,Due,Until,Description,Urg\n" "report.next.labels=ID,Active,Age,Deps,P,Project,Tag,Recur,S,Due,Until,Description,Urg\n"
"report.next.columns=id,start.age,entry.age,depends,priority,project,tags,recur,scheduled.countdown,due.remaining,until.remaining,description,urgency\n" "report.next.columns=id,start.age,entry.age,depends,priority,project,tags,recur,scheduled.countdown,due.remaining,until.remaining,description,urgency\n"
"report.next.filter=status:pending limit:page\n" "report.next.filter=status:pending limit:page\n"
"report.next.sort=start-,urgency-\n" "report.next.sort=urgency-\n"
"\n" "\n"
"report.ready.description=Most urgent actionable tasks\n" "report.ready.description=Most urgent actionable tasks\n"
"report.ready.labels=ID,Active,Age,D,P,Project,Tags,R,S,Due,Until,Description,Urg\n" "report.ready.labels=ID,Active,Age,D,P,Project,Tags,R,S,Due,Until,Description,Urg\n"

View file

@ -358,6 +358,8 @@ void Hooks::onModify (const Task& before, Task& after)
throw 0; // This is how hooks silently terminate processing. throw 0; // This is how hooks silently terminate processing.
} }
} }
after = Task (input[1]);
} }
context.timer_hooks.stop (); context.timer_hooks.stop ();

1
test/.gitignore vendored
View file

@ -53,7 +53,6 @@ variant_partial.t
variant_subtract.t variant_subtract.t
variant_xor.t variant_xor.t
view.t view.t
width.t
json_test json_test

View file

@ -8,8 +8,8 @@ include_directories (${CMAKE_SOURCE_DIR}
set (test_SRCS autocomplete.t color.t config.t date.t directory.t dom.t set (test_SRCS autocomplete.t color.t config.t date.t directory.t dom.t
file.t i18n.t json.t list.t msg.t nibbler.t path.t rx.t t.t t2.t file.t i18n.t json.t list.t msg.t nibbler.t path.t rx.t t.t t2.t
t3.t tdb2.t text.t utf8.t util.t view.t width.t json_test t3.t tdb2.t text.t utf8.t util.t view.t json_test lexer.t
iso8601d.t iso8601p.t duration.t lexer.t variant_add.t iso8601d.t iso8601p.t duration.t variant_add.t
variant_and.t variant_cast.t variant_divide.t variant_equal.t variant_and.t variant_cast.t variant_divide.t variant_equal.t
variant_exp.t variant_gt.t variant_gte.t variant_inequal.t variant_exp.t variant_gt.t variant_gte.t variant_inequal.t
variant_lt.t variant_lte.t variant_match.t variant_math.t variant_lt.t variant_lte.t variant_match.t variant_math.t

View file

@ -5,8 +5,8 @@ import tempfile
import shutil import shutil
import atexit import atexit
import unittest import unittest
from .utils import (run_cmd_wait, run_cmd_wait_nofail, which, binary_location, from .utils import (run_cmd_wait, run_cmd_wait_nofail, which,
) task_binary_location)
from .exceptions import CommandError from .exceptions import CommandError
from .hooks import Hooks from .hooks import Hooks
@ -22,7 +22,7 @@ class Task(object):
A taskw client should not be used after being destroyed. A taskw client should not be used after being destroyed.
""" """
DEFAULT_TASK = binary_location("task") DEFAULT_TASK = task_binary_location()
def __init__(self, taskd=None, taskw=DEFAULT_TASK): def __init__(self, taskd=None, taskw=DEFAULT_TASK):
"""Initialize a Task warrior (client) that can interact with a taskd """Initialize a Task warrior (client) that can interact with a taskd

View file

@ -8,7 +8,8 @@ import atexit
from time import sleep from time import sleep
from subprocess import Popen from subprocess import Popen
from .utils import (find_unused_port, release_port, port_used, run_cmd_wait, from .utils import (find_unused_port, release_port, port_used, run_cmd_wait,
which, parse_datafile, DEFAULT_CERT_PATH, binary_location) which, parse_datafile, DEFAULT_CERT_PATH,
taskd_binary_location)
from .exceptions import CommandError from .exceptions import CommandError
try: try:
@ -30,7 +31,7 @@ class Taskd(object):
A server can be stopped and started multiple times, but should not be A server can be stopped and started multiple times, but should not be
started or stopped after being destroyed. started or stopped after being destroyed.
""" """
DEFAULT_TASKD = binary_location("taskd") DEFAULT_TASKD = taskd_binary_location()
def __init__(self, taskd=DEFAULT_TASKD, certpath=None, def __init__(self, taskd=DEFAULT_TASKD, certpath=None,
address="localhost"): address="localhost"):

View file

@ -41,13 +41,28 @@ DEFAULT_HOOK_PATH = os.path.abspath(
TASKW_SKIP = os.environ.get("TASKW_SKIP", False) TASKW_SKIP = os.environ.get("TASKW_SKIP", False)
TASKD_SKIP = os.environ.get("TASKD_SKIP", False) TASKD_SKIP = os.environ.get("TASKD_SKIP", False)
# Environment flags to control use of PATH or in-tree binaries # Environment flags to control use of PATH or in-tree binaries
USE_PATH = os.environ.get("USE_PATH", False) TASK_USE_PATH = os.environ.get("TASK_USE_PATH", False)
TASKD_USE_PATH = os.environ.get("TASKD_USE_PATH", False)
UUID_regex = ("[0-9A-Fa-f]{8}-" + ("[0-9A-Fa-f]{4}-" * 3) + "[0-9A-Fa-f]{12}") UUID_regex = ("[0-9A-Fa-f]{8}-" + ("[0-9A-Fa-f]{4}-" * 3) + "[0-9A-Fa-f]{12}")
def binary_location(cmd): def task_binary_location(cmd="task"):
"""If USE_PATH is set rely on PATH to look for task/taskd binaries. """If TASK_USE_PATH is set rely on PATH to look for task binaries.
Otherwise ../src/ is used by default.
"""
return binary_location(cmd, TASK_USE_PATH)
def taskd_binary_location(cmd="taskd"):
"""If TASKD_USE_PATH is set rely on PATH to look for taskd binaries.
Otherwise ../src/ is used by default.
"""
return binary_location(cmd, TASKD_USE_PATH)
def binary_location(cmd, USE_PATH=False):
"""If USE_PATH is True rely on PATH to look for taskd binaries.
Otherwise ../src/ is used by default. Otherwise ../src/ is used by default.
""" """
if USE_PATH: if USE_PATH:

View file

@ -1,76 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 9;
# Ensure environment has no influence.
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, '>', $rc)
{
print $fh "data.location=.\n",
"default.project=home\n";
close $fh;
}
# Bug 1023: rc.default.project gets applied during modify, and should not.
qx{../src/task rc:$rc add foo project:garden 2>&1};
qx{../src/task rc:$rc add bar 2>&1};
qx{../src/task rc:$rc add baz rc.default.project= 2>&1};
my $output = qx{../src/task rc:$rc 1 info 2>&1};
like ($output, qr/Project\s*garden/, "$ut: default project not applied when otherwise specified.");
$output = qx{../src/task rc:$rc 2 info 2>&1};
like ($output, qr/Project\s*home/, "$ut: default project applied when blank.");
$output = qx{../src/task rc:$rc 3 info 2>&1};
like ($output, qr/^Description\s+baz$/m, "$ut: task baz shown.");
unlike ($output, qr/Project\s*home/, "$ut: no project applied when default project is blank.");
$output = qx{../src/task rc:$rc 3 modify +tag 2>&1};
like ($output, qr/^Modified 1 task.$/m, "$ut: task modified.");
unlike ($output, qr/Project\s*home/, "$ut: default project not applied on modification.");
qx{../src/task rc:$rc 1 modify project: 2>&1};
$output = qx{../src/task rc:$rc 1 info 2>&1};
like ($output, qr/^Description\s+foo$/m, "$ut: task foo shown.");
unlike ($output, qr/Project\s*garden/, "$ut: default project not re-applied on attribute removal.");
unlike ($output, qr/Project\s*home/, "$ut: default project not re-applied on attribute removal.");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;

View file

@ -1,65 +1,75 @@
#! /usr/bin/env perl #!/usr/bin/env python2.7
################################################################################ # -*- coding: utf-8 -*-
## ###############################################################################
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. #
## # Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
## Permission is hereby granted, free of charge, to any person obtaining a copy #
## of this software and associated documentation files (the "Software"), to deal # Permission is hereby granted, free of charge, to any person obtaining a copy
## in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights
## copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## furnished to do so, subject to the following conditions: # copies of the Software, and to permit persons to whom the Software is
## # furnished to do so, subject to the following conditions:
## The above copyright notice and this permission notice shall be included #
## in all copies or substantial portions of the Software. # The above copyright notice and this permission notice shall be included
## # in all copies or substantial portions of the Software.
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS #
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## SOFTWARE. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## # SOFTWARE.
## http://www.opensource.org/licenses/mit-license.php #
## # http://www.opensource.org/licenses/mit-license.php
################################################################################ #
###############################################################################
use strict; import sys
use warnings; import os
use Test::More tests => 3; import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Ensure environment has no influence. from basetest import Task, TestCase
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. class TestBug1031(TestCase):
if (open my $fh, '>', $rc) def setUp(self):
{ """Executed before each test in the class"""
print $fh "data.location=.\n", # Used to initialize objects that should be re-initialized or
"alias.from=to\n"; # re-created for each individual test
close $fh; self.t = Task()
}
# Bug 1031: -- does not bypass aliasing self.t.config("alias.from", "to")
qx{../src/task rc:$rc add from 2>&1};
qx{../src/task rc:$rc add from -- to 2>&1};
qx{../src/task rc:$rc add to -- from 2>&1};
my $output = qx{../src/task rc:$rc 1 info 2>&1}; def test_alias_to(self):
like ($output, qr/Description\s+to$/ms, "$ut: 'from' --> 'to'"); """alias working as expected: 'from' -> 'to'"""
self.t(("add", "from"))
code, out, err = self.t(("1", "info"))
$output = qx{../src/task rc:$rc 2 info 2>&1}; expected = "Description\s+to"
like ($output, qr/Description\s+to to$/ms, "$ut: 'from -- to' --> 'to to'"); self.assertRegexpMatches(out, expected)
$output = qx{../src/task rc:$rc 3 info 2>&1}; def test_alias_to_to(self):
like ($output, qr/Description\s+to from$/ms, "$ut: 'to -- from' --> 'to from'"); """alias working as expected: 'from -- to' -> 'to to'"""
self.t(("add", "from", "--", "to"))
code, out, err = self.t(("1", "info"))
# Cleanup. expected = "Description\s+to to"
unlink qw(pending.data completed.data undo.data backlog.data), $rc; self.assertRegexpMatches(out, expected)
exit 0;
def test_alias_to_from(self):
"""alias working as expected: 'to -- from' -> 'to from'"""
self.t(("add", "to", "--", "from"))
code, out, err = self.t(("1", "info"))
expected = "Description\s+to from"
self.assertRegexpMatches(out, expected)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -1,63 +1,67 @@
#! /usr/bin/env perl #!/usr/bin/env python2.7
################################################################################ # -*- coding: utf-8 -*-
## ###############################################################################
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. #
## # Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
## Permission is hereby granted, free of charge, to any person obtaining a copy #
## of this software and associated documentation files (the "Software"), to deal # Permission is hereby granted, free of charge, to any person obtaining a copy
## in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights
## copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## furnished to do so, subject to the following conditions: # copies of the Software, and to permit persons to whom the Software is
## # furnished to do so, subject to the following conditions:
## The above copyright notice and this permission notice shall be included #
## in all copies or substantial portions of the Software. # The above copyright notice and this permission notice shall be included
## # in all copies or substantial portions of the Software.
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS #
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## SOFTWARE. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## # SOFTWARE.
## http://www.opensource.org/licenses/mit-license.php #
## # http://www.opensource.org/licenses/mit-license.php
################################################################################ #
###############################################################################
use strict; import sys
use warnings; import os
use Test::More tests => 2; import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Ensure environment has no influence. from basetest import Task, TestCase
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. class TestBug1036(TestCase):
if (open my $fh, '>', $rc) "'until' attribute should be modifiable in non-recurring tasks"
{
print $fh "data.location=.\n",
"dateformat=m/d/Y\n";
close $fh;
}
# Bug #1036: prevents 'until' attributes to be modified for non-recurring def setUp(self):
# tasks. self.t = Task()
# Check that until attribute may be modified self.t.config("dateformat", "m/d/Y")
qx{../src/task rc:$rc add test 2>&1};
my $output = qx{../src/task rc:$rc 1 mod until:1/1/2020 2>&1};
like ($output, qr/^Modifying task 1 'test'.$/ms, "$ut: 'until' attribute added");
qx{../src/task rc:$rc add test until:1/1/2020 2>&1}; def test_until_may_modify(self):
$output = qx{../src/task rc:$rc 1 mod /test/Test/ 2>&1}; """check that until attribute may be modified"""
like ($output, qr/^Modifying task 1 'Test'.$/ms, "$ut: Task with 'until' attribute modified"); self.t(("add", "test"))
code, out, err = self.t(("1", "mod", "until:1/1/2020"))
# Cleanup. expected = "Modifying task 1 'test'."
unlink qw(pending.data completed.data undo.data backlog.data), $rc; self.assertIn(expected, out)
exit 0;
def test_may_modify_on_until(self):
"""check that task with until attribute set may be modified"""
self.t(("add", "test", "until:1/1/2020"))
code, out, err = self.t(("1", "mod", "/test/Hello/"))
expected = "Modifying task 1 'Hello'."
self.assertIn(expected, out)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -1,63 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 5;
# Ensure environment has no influence.
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, '>', $rc)
{
print $fh "data.location=.\n";
print $fh "alias.samplealias=long\n";
close $fh;
}
# Bug - aliases should be listed by '_aliases' and not by '_commands' or '_zshcommands'
my $output = qx{../src/task rc:$rc _aliases 2>&1};
like ($output, qr/samplealias/, "$ut: aliases are listed in _aliases");
$output = qx{../src/task rc:$rc _commands 2>&1};
like ($output, qr/^information$/m, "$ut: info is listed in _commands");
unlike ($output, qr/samplealias/, "$ut: aliases are not listed in _commands");
$output = qx{../src/task rc:$rc _zshcommands 2>&1};
like ($output, qr/^information:/m, "$ut: info is listed in _zshcommands");
unlike ($output, qr/samplealias/, "$ut: aliases are not listed in _zshcommands");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;

View file

@ -1,62 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 1;
# Ensure environment has no influence.
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, '>', $rc)
{
print $fh "data.location=.\n",
"confirmation=off\n";
close $fh;
}
# Bug #1044: 'task projects' considers newly deleted tasks and provides an
# incorrect summary
# Check that until attribute may be modified
qx{../src/task rc:$rc add project:A 1 2>&1};
qx{../src/task rc:$rc add project:B 2 2>&1};
qx{../src/task rc:$rc add project:B 3 2>&1};
qx{../src/task rc:$rc 3 delete 2>&1};
my $output = qx{../src/task rc:$rc project:B projects 2>&1};
like ($output, qr/^1 project \(1 task\)$/ms, "$ut: Summary filtered new deleted task 3 and project A");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;

View file

@ -1,57 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.active=red\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc add red 2>&1};
qx{../src/task rc:color.rc 2 start 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.active');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,58 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# 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;
}
# Test the add command.
qx{../src/task rc:color.rc add red 2>&1};
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc 1 modify depends:2 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.blocked');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,62 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 3;
# Ensure environment has no influence.
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, '>', $rc)
{
print $fh "data.location=.\n",
"color.pri.H=red\n",
"color.label=\n",
"color.label.sort=\n",
"fontunderline=no\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:$rc add priority:H red 2>&1};
my $output = qx{../src/task rc:$rc list 2>&1};
like ($output, qr/red/, "$ut: color.disable - found red");
unlike ($output, qr/\033\[31m/, "$ut: color.disable - no color red");
unlike ($output, qr/\033\[0m/, "$ut: color.disable - no color reset");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;

View file

@ -1,57 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.due=red\n",
"_forcecolor=1\n",
"dateformat=m/d/Y\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add due:someday nothing 2>&1};
qx{../src/task rc:color.rc add due:tomorrow red 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) \d{1,2}\/\d{1,2}\/\d{4} (?!>\033\[0m) .* nothing /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m/x, 'color.due');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,62 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 4;
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', $rc)
{
print $fh "data.location=.\n",
"color.header=blue\n",
"color.footnote=red\n",
"color.error=yellow\n",
"color.debug=green\n",
"_forcecolor=1\n";
close $fh;
}
# Test the errors colors
my $output = qx{../src/task rc:$rc rc.debug:on add foo priority:X 2>&1 >/dev/null};
like ($output, qr/^\033\[33mThe 'priority' attribute does not allow a value of 'X'\./ms, "$ut: color.error");
like ($output, qr/^\033\[32mTimer Config::load \(.*?$rc\)/ms, "$ut: color.debug");
like ($output, qr/^\033\[34mUsing alternate \.taskrc file/ms, "$ut: color.header");
like ($output, qr/^\033\[31mConfiguration override rc\.debug:on/ms, "$ut: color.footnote");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;

View file

@ -1,66 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 4;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"search.case.sensitive=yes\n",
"color=on\n",
"color.alternate=\n",
"color.keyword.red=red\n",
"color.keyword.green=green\n",
"color.keyword.yellow=yellow\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc add red 2>&1};
qx{../src/task rc:color.rc add green 2>&1};
qx{../src/task rc:color.rc add -- annotation 2>&1};
qx{../src/task rc:color.rc 4 annotate yellow 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.keyword.red');
like ($output, qr/ \033\[32m .* green .* \033\[0m /x, 'color.keyword.green');
like ($output, qr/ \033\[33m .* annotation .* \033\[0m /x, 'color.keyword.yellow (annotation)');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,57 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.overdue=red\n",
"_forcecolor=1\n",
"dateformat=m/d/Y\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add due:tomorrow nothing 2>&1};
qx{../src/task rc:color.rc add due:yesterday red 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) \d{1,2}\/\d{1,2}\/\d{4} (?!>\033\[0m) .* nothing /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m/x, 'color.overdue');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,64 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 4;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.pri.H=red\n",
"color.pri.M=green\n",
"color.pri.L=blue\n",
"color.pri.none=yellow\n",
"color.alternate=\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add priority:H red 2>&1};
qx{../src/task rc:color.rc add priority:M green 2>&1};
qx{../src/task rc:color.rc add priority:L blue 2>&1};
qx{../src/task rc:color.rc add yellow 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.pri.H');
like ($output, qr/ \033\[32m .* green .* \033\[0m /x, 'color.pri.M');
like ($output, qr/ \033\[34m .* blue .* \033\[0m /x, 'color.pri.L');
like ($output, qr/ \033\[33m .* yellow .* \033\[0m /x, 'color.pri.none');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,58 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.project.x=red\n",
"color.project.none=green\n",
"color.alternate=\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc add project:x red 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ \033\[32m .* nothing .* \033\[0m /x, 'color.project.none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.project.red');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,57 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.recurring=red\n",
"color.due=\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc add due:tomorrow recur:1w red 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.recurring');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

226
test/color.rules.t Executable file
View file

@ -0,0 +1,226 @@
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import os
import unittest
from datetime import datetime
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from basetest import Task, TestCase
class TestColorRules(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
# Controlling peripheral color.
cls.t.config('_forcecolor', 'on')
cls.t.config('fontunderline', 'off') # label underlining complicates the tests.
cls.t.config('color.alternate', '') # alternating color complicateѕ the tests.
cls.t.config('default.command', 'list')
cls.t.config('uda.xxx.type', 'numeric')
cls.t.config('uda.xxx.label', 'XXX')
# Color rules.
cls.t.config('color.active', 'red')
cls.t.config('color.blocked', 'red')
cls.t.config('color.blocking', 'blue')
cls.t.config('color.due', 'red')
cls.t.config('color.overdue', 'blue')
cls.t.config('color.error', 'blue')
cls.t.config('color.header', 'blue')
cls.t.config('color.footnote', 'red')
cls.t.config('color.debug', 'green')
cls.t.config('color.project.x', 'red')
cls.t.config('color.project.none', '')
cls.t.config('color.pri.H', 'red')
cls.t.config('color.pri.M', 'blue')
cls.t.config('color.pri.L', 'green')
cls.t.config('color.pri.none', '')
cls.t.config('color.keyword.keyword', 'red')
cls.t.config('color.tagged', '')
cls.t.config('color.tag.none', '')
cls.t.config('color.tag.x', 'red')
cls.t.config('color.recurring', 'red')
cls.t.config('color.uda.xxx', 'red')
cls.t.config('color.uda.xxx.4', 'blue')
cls.t(('add', 'control task')) # 1
cls.t(('add', 'active task')) # 2
cls.t(('2', 'start'))
cls.t(('add', 'blocked task')) # 3
cls.t(('add', 'blocking task')) # 4
cls.t(('3', 'modify', 'depends:4'))
cls.t(('add', 'tomorrow', 'due:tomorrow')) # 5
cls.t(('add', 'yesterday', 'due:yesterday')) # 6
cls.t(('add', 'someday', 'due:yesterday')) # 7
cls.t(('add', 'project_x', 'project:x')) # 8
cls.t(('add', 'pri_h', 'priority:H')) # 9
cls.t(('add', 'pri_m', 'priority:M')) # 10
cls.t(('add', 'pri_l', 'priority:L')) # 11
cls.t(('add', 'keyword')) # 12
cls.t(('add', 'tag_x', '+x')) # 13
cls.t(('add', 'uda_xxx_1', 'xxx:1')) # 14
cls.t(('add', 'uda_xxx_4', 'xxx:4')) # 15
cls.t(('add', 'recurring', 'due:tomorrow', 'recur:1week')) # 16 # Keep this last
def test_control(self):
"""No color on control task."""
code, out, err = self.t(('1', 'info'))
self.assertNotIn('\x1b[', out)
def test_disable_in_pipe(self):
"""No color in pipe unless forced."""
code, out, err = self.t(('2', 'info', 'rc._forcecolor:off'))
self.assertNotIn('\x1b[', out)
def test_active(self):
"""Active color rule."""
code, out, err = self.t(('/active/', 'info'))
self.assertIn('\x1b[31m', out)
def test_blocked(self):
"""Blocked color rule."""
code, out, err = self.t(('/blocked/', 'info'))
self.assertIn('\x1b[31m', out)
def test_blocking(self):
"""Blocking color rule."""
code, out, err = self.t(('/blocking/', 'info'))
self.assertIn('\x1b[34m', out)
def test_due_yesterday(self):
"""Overdue color rule."""
code, out, err = self.t(('/yesterday/', 'info'))
self.assertIn('\x1b[34m', out)
def test_due_tomorrow(self):
"""Due tomorrow color rule."""
code, out, err = self.t(('/tomorrow/', 'info'))
self.assertIn('\x1b[31m', out)
def test_due_someday(self):
"""Due someday color rule."""
code, out, err = self.t(('/someday/', 'info'))
self.assertIn('\x1b[', out)
def test_color_error(self):
"""Error color."""
code, out, err = self.t.runError(('add', 'error', 'priority:X'))
self.assertIn('\x1b[34m', err)
def test_color_header(self):
"""Header color."""
code, out, err = self.t(('rc.verbose=header', '/control/'))
self.assertIn('\x1b[34m', err)
def test_color_footnote(self):
"""Footnote color."""
code, out, err = self.t(('rc.verbose=footnote', '/control/'))
self.assertIn('\x1b[31mConfiguration override', err)
def test_color_debug(self):
"""Debug color."""
code, out, err = self.t(('rc.debug=1', '/control/'))
self.assertIn('\x1b[32mTimer', err)
def test_project_x(self):
"""Project x color rule."""
code, out, err = self.t(('/project_x/', 'info'))
self.assertIn('\x1b[31m', out)
def test_project_none(self):
"""Project none color rule."""
code, out, err = self.t(('/control/', 'rc.color.project.none=red', 'info'))
self.assertIn('\x1b[31m', out)
def test_priority_h(self):
"""Priority H color rule."""
code, out, err = self.t(('/pri_h/', 'info'))
self.assertIn('\x1b[31m', out)
def test_priority_m(self):
"""Priority M color rule."""
code, out, err = self.t(('/pri_m/', 'info'))
self.assertIn('\x1b[34m', out)
def test_priority_l(self):
"""Priority L color rule."""
code, out, err = self.t(('/pri_l/', 'info'))
self.assertIn('\x1b[32m', out)
def test_priority_none(self):
"""Priority none color rule."""
code, out, err = self.t(('/control/', 'rc.color.pri.none=red', 'info'))
self.assertIn('\x1b[31m', out)
def test_keyword(self):
"""Keyword color rule."""
code, out, err = self.t(('/keyword/', 'info'))
self.assertIn('\x1b[31m', out)
def test_tag_x(self):
"""Tag x color rule."""
code, out, err = self.t(('/tag_x/', 'info'))
self.assertIn('\x1b[31m', out)
def test_tag_none(self):
"""Tag none color rule."""
code, out, err = self.t(('/control/', 'rc.color.tag.none=red', 'info'))
self.assertIn('\x1b[31m', out)
def test_tagged(self):
"""Tagged color rule."""
code, out, err = self.t(('/tag_x/', 'rc.color.tag.x=', 'rc.color.tagged=blue', 'info'))
self.assertIn('\x1b[34m', out)
def test_recurring(self):
"""Recurring color rule."""
code, out, err = self.t(('/recurring/', 'info'))
self.assertIn('\x1b[31m', out)
def test_uda(self):
"""UDA color rule."""
code, out, err = self.t(('/uda_xxx_1/', 'info'))
self.assertIn('\x1b[31m', out)
def test_uda_value(self):
"""UDA Value color rule."""
code, out, err = self.t(('/uda_xxx_4/', 'rc.color.uda.xxx=', 'info'))
self.assertIn('\x1b[34m', out)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -36,11 +36,7 @@ Context context;
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (1036); UnitTest t (40 + 256 + 256 + 6*6*6 + 6*6*6 + 1 + 24 + 24 + 3);
// Ensure environment has no influence.
unsetenv ("TASKDATA");
unsetenv ("TASKRC");
// Names matched to values. // Names matched to values.
t.is ((int) Color (""), (int) Color (Color::nocolor), "'' == Color::nocolor"); t.is ((int) Color (""), (int) Color (Color::nocolor), "'' == Color::nocolor");

View file

@ -1,62 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 3;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.tagged=\n",
"color.alternate=\n",
"color.tag.none=yellow\n",
"color.tag.red=red\n",
"color.tag.green=green\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc add +red red 2>&1};
qx{../src/task rc:color.rc add +green green 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ \033\[33m .* nothing .* \033\[0m /x, 'color.tag.none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.tag.red');
like ($output, qr/ \033\[32m .* green .* \033\[0m /x, 'color.tag.green');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,60 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 3;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
unlink 'pending.data';
ok (!-r 'pending.data', 'Removed pending.data');
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.tagged=red\n",
"color.alternate=\n",
"_forcecolor=1\n";
close $fh;
}
# Test the add command.
qx{../src/task rc:color.rc add nothing 2>&1};
qx{../src/task rc:color.rc add +tag red 2>&1};
my $output = qx{../src/task rc:color.rc list 2>&1};
like ($output, qr/ (?!<\033\[\d\dm) .* nothing .* (?!>\033\[0m) /x, 'none');
like ($output, qr/ \033\[31m .* red .* \033\[0m /x, 'color.tagged');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

View file

@ -1,63 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 3;
# Ensure environment has no influence.
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
# Create the rc file.
if (open my $fh, '>', 'color.rc')
{
print $fh "data.location=.\n",
"color.uda.x=red\n",
"uda.x.type=numeric\n",
"uda.x.label=X\n",
"uda.y.type=numeric\n",
"uda.y.label=Y\n",
"color.uda.y.4=blue\n",
"color.alternate=\n",
"_forcecolor=1\n";
close $fh;
}
qx{../src/task rc:color.rc add one 2>&1};
qx{../src/task rc:color.rc add two x:3 y:2 2>&1};
qx{../src/task rc:color.rc add three y:4 2>&1};
my $output = qx{../src/task rc:color.rc list 2>/dev/null};
unlike ($output, qr/ \033\[32m .* one .* \033\[0m /x, 'No color.uda');
like ($output, qr/ \033\[31m .* two .* \033\[0m /x, 'Found color.uda');
like ($output, qr/ \033\[34m .* three .* \033\[0m /x, 'Found color.uda.x');
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data color.rc);
exit 0;

71
test/completion.t Executable file
View file

@ -0,0 +1,71 @@
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import os
import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from basetest import Task, TestCase
class TestAliasesCompletion(TestCase):
"""Aliases should be listed by '_aliases' not '_commands' or '_zshcommands'
reported as bug 1043
"""
def setUp(self):
self.t = Task()
self.t.config("alias.samplealias", "long")
def test__aliases(self):
"""samplealias in _aliases"""
code, out, err = self.t(("_aliases",))
self.assertIn("samplealias", out)
def test__commands(self):
"""samplealias not in _commands"""
code, out, err = self.t(("_commands",))
self.assertIn("information", out)
self.assertNotIn("samplealias", out)
def test__zshcommands(self):
"""samplealias not in _zshcommands"""
code, out, err = self.t(("_zshcommands",))
self.assertIn("information", out)
self.assertNotIn("samplealias", out)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -4,7 +4,7 @@ printf "C++: %5d\n" $(ls *.t.cpp | wc -l)
printf "Python: %5d\n" $(head -n1 *.t | grep -a '\bpython' | wc -l) printf "Python: %5d\n" $(head -n1 *.t | grep -a '\bpython' | wc -l)
printf "Perl: %5d\n" $(head -n1 *.t | grep -a '\bperl\b' | wc -l) printf "Perl: %5d\n" $(head -n1 *.t | grep -a '\bperl\b' | wc -l)
if [ "$1" = "-v" ]; then if [ "$1" = "-v" ]; then
echo -n "Perl left: "; echo $(grep -l '^#\! \?/usr/bin/env perl\b' *.t) echo "Perl left: " $(grep -l '^#\! \?/usr/bin/env perl\b' *.t)
fi fi
echo echo
printf "Feature %5d\n" $(ls feature.*.t | wc -l) printf "Feature %5d\n" $(ls feature.*.t | wc -l)

278
test/feature.default.project.t Executable file
View file

@ -0,0 +1,278 @@
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import os
import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from basetest import Task, TestCase, Taskd, ServerTestCase
class TestDefaultProject(TestCase):
"""Bug 1023: rc.default.project gets applied during modify, and should not
"""
def setUp(self):
self.t = Task()
def set_default_project(self):
self.default_project = "HOMEPROJ"
self.t.config("default.project", self.default_project)
def test_with_project(self):
"""default.project not applied when specified nor on attribute removal
"""
self.set_default_project()
self.t(("add", "foobar", "project:garden"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
expected = "Project\s+garden"
self.assertRegexpMatches(out, expected)
self.t(("1", "modify", "project:"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotRegexpMatches(out, expected)
notexpected = "Project\s+" + self.default_project
self.assertNotRegexpMatches(out, notexpected)
def test_without_project(self):
"""default.project applied when no project is specified"""
self.set_default_project()
self.t(("add", "foobar"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
expected = "Project\s+" + self.default_project
self.assertRegexpMatches(out, expected)
def test_default_project_inline_override(self):
"""no project applied when default.project is overridden"""
self.set_default_project()
self.t(("add", "foobar", "rc.default.project="))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotIn("Project", out)
def test_without_default_project(self):
"""no project applied when default.project is blank"""
self.t(("add", "foobar"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotIn("Project", out)
def test_modify_default_project(self):
"""default.project is not applied when modifying a task"""
self.t(("add", "foobar"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotIn("Project", out)
self.set_default_project()
self.t(("1", "modify", "+tag"))
code, out, err = self.t("1", "info")
self.assertNotIn("Project", out)
def test_annotate_default_project(self):
"""default.project is not applied when annotating a task"""
self.t(("add", "foobar"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotIn("Project", out)
self.set_default_project()
self.t(("1", "annotate", "Hello"))
code, out, err = self.t("1", "info")
expected = "Description\s+foobar\n[0-9-: ]+ Hello"
self.assertRegexpMatches(out, expected)
self.assertNotIn("Project", out)
def test_time_default_project(self):
"""default.project is not applied when start/stop'ing a task"""
# Allow keeping track of time spent on task
self.t.config("journal.time", "yes")
self.t(("add", "foobar"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotIn("Project", out)
self.set_default_project()
self.t(("1", "start"))
self.t(("1", "stop"))
code, out, err = self.t("1", "info")
self.assertIn("foobar", out)
self.assertNotIn("Project", out)
def test_recurring_parent_default_project(self):
"""default.project is applied on recurring parent tasks"""
self.set_default_project()
DESC = "foobar"
self.t(("add", "recur:daily", "due:today", DESC))
self.t() # Ensure creation of recurring children
code, out, err = self.t(("1", "info"))
self.assertIn(DESC, out)
self.assertRegexpMatches(out, "Status\s+Recurring") # is a parent task
self.assertIn(self.default_project, out)
self.t.faketime("+1d")
self.t() # Ensure creation of recurring children
# Try to figure out the ID of last created task
code, out, err = self.t(("count",))
# Will fail if some other message is printed as part of "count"
id = out.split()[-1]
try:
id = int(id)
except ValueError:
raise ValueError("Unexpected output when running 'task count', "
"expected int, got '{0}'".format(id))
else:
# parent task is not considered when counting
id = str(id + 1)
code, out, err = self.t(id, "info")
self.assertIn(DESC, out)
self.assertIn("Parent task", out) # is a child task
self.assertIn(self.default_project, out)
def test_recurring_default_project(self):
"""no project is applied on recurring tasks"""
# NOTE - reported on TW-1279
DESC = "foobar"
self.t(("add", "recur:daily", "due:today", DESC))
code, out, err = self.t()
self.assertIn(DESC, out)
self.assertNotIn("Project", out)
self.set_default_project()
self.t.faketime("+1d")
code, out, err = self.t()
self.assertIn(DESC, out)
self.assertNotIn("Project", out)
def test_recurring_with_project_and_default_project(self):
"""default.project is not applied to children if parent has a project
"""
# NOTE - reported on TW-1279
self.set_default_project()
DESC = "foobar"
self.t(("add", "recur:daily", "due:today", "project:HELLO", DESC))
code, out, err = self.t()
self.assertIn(DESC, out)
self.assertIn("HELLO", out)
self.t.faketime("+1d")
code, out, err = self.t()
self.assertIn("foobar", out)
self.assertIn("HELLO", out)
self.assertNotIn(self.default_project, out)
class ServerTestDefaultProject(ServerTestCase):
@classmethod
def setUpClass(cls):
cls.taskd = Taskd()
# This takes a while...
cls.taskd.start()
def setUp(self):
self.t1 = Task(taskd=self.taskd)
self.t2 = Task(taskd=self.taskd)
self.t3 = Task(taskd=self.taskd)
def test_default_project_sync(self):
"""default.project is not applied to projectless tasks during sync"""
# NOTE - reported on TW-1287
desc = "Testing task"
self.t1(("add", desc))
self.t1(("sync",))
code, out, err = self.t1()
self.assertIn(desc, out)
# Testing scenario - default.project is applied on task arrival
proj2 = "Client2"
self.t2.config("default.project", proj2)
self.t2(("sync",))
code, out, err = self.t2()
self.assertIn(desc, out)
self.assertNotIn(proj2, out)
self.t2(("sync",))
# Testing scenario - default.project is applied on task delivery
proj3 = "Client3"
self.t3.config("default.project", proj3)
self.t3(("sync",))
code, out, err = self.t3()
self.assertIn(desc, out)
self.assertNotIn(proj2, out)
self.assertNotIn(proj3, out)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -1,57 +0,0 @@
#! /usr/bin/env perl
################################################################################
##
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################
use strict;
use warnings;
use Test::More tests => 2;
# Ensure environment has no influence.
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, '>', $rc)
{
print $fh "data.location=.\n",
"confirmation=no\n";
close $fh;
}
qx{../src/task rc:$rc add foo 2>&1};
my $exit_good = system ("../src/task rc:$rc ls /foo/ >/dev/null 2>&1") >> 8;
is ($exit_good, 0, "$ut: task returns 0 on success");
my $exit_bad = system ("../src/task rc:$rc ls /bar/ >/dev/null 2>&1") >> 8;
isnt ($exit_bad, 0, "$ut: task returns non-zero on failure");
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;

View file

@ -1,130 +1,144 @@
#! /usr/bin/env perl #!/usr/bin/env python2.7
################################################################################ # -*- coding: utf-8 -*-
## ###############################################################################
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. #
## # Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
## Permission is hereby granted, free of charge, to any person obtaining a copy #
## of this software and associated documentation files (the "Software"), to deal # Permission is hereby granted, free of charge, to any person obtaining a copy
## in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights
## copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## furnished to do so, subject to the following conditions: # copies of the Software, and to permit persons to whom the Software is
## # furnished to do so, subject to the following conditions:
## The above copyright notice and this permission notice shall be included #
## in all copies or substantial portions of the Software. # The above copyright notice and this permission notice shall be included
## # in all copies or substantial portions of the Software.
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS #
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## SOFTWARE. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## # SOFTWARE.
## http://www.opensource.org/licenses/mit-license.php #
## # http://www.opensource.org/licenses/mit-license.php
################################################################################ #
###############################################################################
use strict; import sys
use warnings; import os
use Test::More tests => 56; import unittest
from datetime import datetime
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Ensure environment has no influence. from basetest import Task, TestCase
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. class TestFilterPrefix(TestCase):
if (open my $fh, '>', $rc) @classmethod
{ def setUpClass(cls):
print $fh "data.location=.\n"; """Executed once before any test in the class"""
close $fh; cls.t = Task()
} cls.t.config("verbose", "nothing")
# Test the filters. cls.t(('add', 'project:foo.uno', 'priority:H', '+tag', 'one foo' ))
qx{../src/task rc:$rc add project:foo.uno priority:H +tag one foo 2>&1}; cls.t(('add', 'project:foo.dos', 'priority:H', 'two' ))
qx{../src/task rc:$rc add project:foo.dos priority:H two 2>&1}; cls.t(('add', 'project:foo.tres', 'three' ))
qx{../src/task rc:$rc add project:foo.tres three 2>&1}; cls.t(('add', 'project:bar.uno', 'priority:H', 'four' ))
qx{../src/task rc:$rc add project:bar.uno priority:H four 2>&1}; cls.t(('add', 'project:bar.dos', '+tag', 'five' ))
qx{../src/task rc:$rc add project:bar.dos +tag five 2>&1}; cls.t(('add', 'project:bar.tres', 'six foo' ))
qx{../src/task rc:$rc add project:bar.tres six foo 2>&1}; cls.t(('add', 'project:bazuno', 'seven bar foo'))
qx{../src/task rc:$rc add project:bazuno seven bar foo 2>&1}; cls.t(('add', 'project:bazdos', 'eight bar foo'))
qx{../src/task rc:$rc add project:bazdos eight bar foo 2>&1};
my $output = qx{../src/task rc:$rc list 2>&1}; def test_list_all(self):
like ($output, qr/one/, 'a1'); """No filter shows all tasks."""
like ($output, qr/two/, 'a2'); code, out, err = self.t(('list',))
like ($output, qr/three/, 'a3'); self.assertIn('one', out)
like ($output, qr/four/, 'a4'); self.assertIn('two', out)
like ($output, qr/five/, 'a5'); self.assertIn('three', out)
like ($output, qr/six/, 'a6'); self.assertIn('four', out)
like ($output, qr/seven/, 'a7'); self.assertIn('five', out)
like ($output, qr/eight/, 'a8'); self.assertIn('six', out)
self.assertIn('seven', out)
self.assertIn('eight', out)
$output = qx{../src/task rc:$rc list project:foo 2>&1}; def test_list_project_foo(self):
like ($output, qr/one/, 'b1'); """Filter on project name."""
like ($output, qr/two/, 'b2'); code, out, err = self.t(('list', 'project:foo'))
like ($output, qr/three/, 'b3'); self.assertIn('one', out)
unlike ($output, qr/four/, 'b4'); self.assertIn('two', out)
unlike ($output, qr/five/, 'b5'); self.assertIn('three', out)
unlike ($output, qr/six/, 'b6'); self.assertNotIn('four', out)
unlike ($output, qr/seven/, 'b7'); self.assertNotIn('five', out)
unlike ($output, qr/eight/, 'b8'); self.assertNotIn('six', out)
self.assertNotIn('seven', out)
self.assertNotIn('eight', out)
$output = qx{../src/task rc:$rc list project.not:foo 2>&1}; def test_list_project_not_foo(self):
unlike ($output, qr/one/, 'c1'); """Filter on not project name."""
unlike ($output, qr/two/, 'c2'); code, out, err = self.t(('list', 'project.not:foo'))
unlike ($output, qr/three/, 'c3'); self.assertNotIn('one', out)
like ($output, qr/four/, 'c4'); self.assertNotIn('two', out)
like ($output, qr/five/, 'c5'); self.assertNotIn('three', out)
like ($output, qr/six/, 'c6'); self.assertIn('four', out)
like ($output, qr/seven/, 'c7'); self.assertIn('five', out)
like ($output, qr/eight/, 'c8'); self.assertIn('six', out)
self.assertIn('seven', out)
self.assertIn('eight', out)
$output = qx{../src/task rc:$rc list project.startswith:bar 2>&1}; def test_list_project_startwsith_bar(self):
unlike ($output, qr/one/, 'd1'); """Filter on project name start."""
unlike ($output, qr/two/, 'd2'); code, out, err = self.t(('list', 'project.startswith:bar'))
unlike ($output, qr/three/, 'd3'); self.assertNotIn('one', out)
like ($output, qr/four/, 'd4'); self.assertNotIn('two', out)
like ($output, qr/five/, 'd5'); self.assertNotIn('three', out)
like ($output, qr/six/, 'd6'); self.assertIn('four', out)
unlike ($output, qr/seven/, 'd7'); self.assertIn('five', out)
unlike ($output, qr/eight/, 'd8'); self.assertIn('six', out)
self.assertNotIn('seven', out)
self.assertNotIn('eight', out)
$output = qx{../src/task rc:$rc list project:ba 2>&1}; def test_list_project_ba(self):
unlike ($output, qr/one/, 'f1'); """Filter on project partial match."""
unlike ($output, qr/two/, 'f2'); code, out, err = self.t(('list', 'project:ba'))
unlike ($output, qr/three/, 'f3'); self.assertNotIn('one', out)
like ($output, qr/four/, 'f4'); self.assertNotIn('two', out)
like ($output, qr/five/, 'f5'); self.assertNotIn('three', out)
like ($output, qr/six/, 'f6'); self.assertIn('four', out)
like ($output, qr/seven/, 'f7'); self.assertIn('five', out)
like ($output, qr/eight/, 'f8'); self.assertIn('six', out)
self.assertIn('seven', out)
self.assertIn('eight', out)
$output = qx{../src/task rc:$rc list project.not:ba 2>&1}; def test_list_project_not_ba(self):
like ($output, qr/one/, 'g1'); """Filter on project partial non-match."""
like ($output, qr/two/, 'g2'); code, out, err = self.t(('list', 'project.not:ba'))
like ($output, qr/three/, 'g3'); self.assertIn('one', out)
unlike ($output, qr/four/, 'g4'); self.assertIn('two', out)
unlike ($output, qr/five/, 'g5'); self.assertIn('three', out)
unlike ($output, qr/six/, 'g6'); self.assertNotIn('four', out)
unlike ($output, qr/seven/, 'g7'); self.assertNotIn('five', out)
unlike ($output, qr/eight/, 'g8'); self.assertNotIn('six', out)
self.assertNotIn('seven', out)
self.assertNotIn('eight', out)
$output = qx{../src/task rc:$rc list description.has:foo 2>&1}; def test_list_descrtiption_has_foo(self):
like ($output, qr/one/, 'i1'); """Filter on description pattern."""
unlike ($output, qr/two/, 'i2'); code, out, err = self.t(('list', 'description.has:foo'))
unlike ($output, qr/three/, 'i3'); self.assertIn('one', out)
unlike ($output, qr/four/, 'i4'); self.assertNotIn('two', out)
unlike ($output, qr/five/, 'i5'); self.assertNotIn('three', out)
like ($output, qr/six/, 'i6'); self.assertNotIn('four', out)
like ($output, qr/seven/, 'i7'); self.assertNotIn('five', out)
like ($output, qr/eight/, 'i8'); self.assertIn('six', out)
self.assertIn('seven', out)
self.assertIn('eight', out)
# Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
exit 0;
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -56,6 +56,9 @@ class TestHooksOnAdd(TestCase):
logs = hook.get_logs() logs = hook.get_logs()
self.assertEqual(logs["output"]["msgs"][0], "FEEDBACK") self.assertEqual(logs["output"]["msgs"][0], "FEEDBACK")
code, out, err = self.t(("1", "info"))
self.assertIn("Description foo", out)
def test_onadd_builtin_reject(self): def test_onadd_builtin_reject(self):
"""on-add-reject - a well-behaved, failing, on-add hook.""" """on-add-reject - a well-behaved, failing, on-add hook."""
hookname = 'on-add-reject' hookname = 'on-add-reject'

View file

@ -57,6 +57,10 @@ class TestHooksOnModify(TestCase):
logs = hook.get_logs() logs = hook.get_logs()
self.assertEqual(logs["output"]["msgs"][0], "FEEDBACK") self.assertEqual(logs["output"]["msgs"][0], "FEEDBACK")
code, out, err = self.t(("1", "info"))
self.assertIn("Description foo", out)
self.assertIn("Tags tag", out)
def test_onmodify_builtin_reject(self): def test_onmodify_builtin_reject(self):
"""on-modify-reject - a well-behaved, failing, on-modify hook.""" """on-modify-reject - a well-behaved, failing, on-modify hook."""
hookname = 'on-modify-reject' hookname = 'on-modify-reject'

View file

@ -25,8 +25,6 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <cmake.h> #include <cmake.h>
#include <iostream>
#include <stdlib.h>
#include <Context.h> #include <Context.h>
#include <Msg.h> #include <Msg.h>
#include <test.h> #include <test.h>
@ -38,10 +36,6 @@ int main (int argc, char** argv)
{ {
UnitTest t (12); UnitTest t (12);
// Ensure environment has no influence.
unsetenv ("TASKDATA");
unsetenv ("TASKRC");
Msg m; Msg m;
t.is (m.serialize (), std::string ("client: ") + PACKAGE_STRING + "\n\n\n", "Msg::serialize '' --> '\\n\\n'"); t.is (m.serialize (), std::string ("client: ") + PACKAGE_STRING + "\n\n\n", "Msg::serialize '' --> '\\n\\n'");
@ -55,16 +49,17 @@ int main (int argc, char** argv)
t.is (m.serialize (), std::string ("client: ") + PACKAGE_STRING + "\nfoo: bar\nname: value\n\npayload\n", "Msg::serialize 2 vars + payload"); t.is (m.serialize (), std::string ("client: ") + PACKAGE_STRING + "\nfoo: bar\nname: value\n\npayload\n", "Msg::serialize 2 vars + payload");
Msg m2; Msg m2;
t.ok (m2.parse ("foo: bar\nname: value\n\npayload\n"), "Msg::parse ok"); t.ok (m2.parse ("foo: bar\nname: value\n\npayload\n"), "Msg::parse ok");
t.is (m2.get ("foo"), "bar", "Msg::get"); t.is (m2.get ("foo"), "bar", "Msg::get");
t.is (m2.get ("name"), "value", "Msg::get"); t.is (m2.get ("name"), "value", "Msg::get");
t.is (m2.getPayload (), "payload\n", "Msg::getPayload"); t.is (m2.getPayload (), "payload\n", "Msg::getPayload");
Msg m3; Msg m3;
t.ok (m3.parse ("foo:bar\nname: value\n\npayload\n"), "Msg::parse ok"); t.ok (m3.parse ("foo:bar\nname: value\n\npayload\n"), "Msg::parse ok");
t.is (m3.get ("foo"), "bar", "Msg::get"); t.is (m3.get ("foo"), "bar", "Msg::get");
t.is (m3.get ("name"), "value", "Msg::get"); t.is (m3.get ("name"), "value", "Msg::get");
t.is (m3.getPayload (), "payload\n", "Msg::getPayload"); t.is (m3.getPayload (), "payload\n", "Msg::getPayload");
return 0; return 0;
} }

View file

@ -1,111 +1,143 @@
#! /usr/bin/env perl #!/usr/bin/env python2.7
################################################################################ # -*- coding: utf-8 -*-
## ###############################################################################
## Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez. #
## # Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
## Permission is hereby granted, free of charge, to any person obtaining a copy #
## of this software and associated documentation files (the "Software"), to deal # Permission is hereby granted, free of charge, to any person obtaining a copy
## in the Software without restriction, including without limitation the rights # of this software and associated documentation files (the "Software"), to deal
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # in the Software without restriction, including without limitation the rights
## copies of the Software, and to permit persons to whom the Software is # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## furnished to do so, subject to the following conditions: # copies of the Software, and to permit persons to whom the Software is
## # furnished to do so, subject to the following conditions:
## The above copyright notice and this permission notice shall be included #
## in all copies or substantial portions of the Software. # The above copyright notice and this permission notice shall be included
## # in all copies or substantial portions of the Software.
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS #
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## SOFTWARE. # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## # SOFTWARE.
## http://www.opensource.org/licenses/mit-license.php #
## # http://www.opensource.org/licenses/mit-license.php
################################################################################ #
###############################################################################
use strict; import sys
use warnings; import os
use Test::More tests => 16; import unittest
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
# Ensure environment has no influence. from basetest import Task, TestCase
delete $ENV{'TASKDATA'};
delete $ENV{'TASKRC'};
use File::Basename;
my $ut = basename ($0);
my $rc = $ut . '.rc';
# Create the rc file. class TestProjects(TestCase):
if (open my $fh, '>', $rc) def setUp(self):
{ self.t = Task()
print $fh "data.location=.\n",
"confirmation=off\n";
close $fh;
}
# Test the project status numbers. self.STATUS = ("The project '{0}' has changed\. "
my $output = qx{../src/task rc:$rc add one pro:foo 2>&1 >/dev/null}; "Project '{0}' is {1} complete \({2} remaining\)\.")
like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(1 task remaining\)\./, "$ut: add one");
$output = qx{../src/task rc:$rc add two pro:'foo' 2>&1 >/dev/null}; def test_project_summary_count(self):
like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(2 of 2 tasks remaining\)\./, "$ut: add two"); """'task projects' shouldn't consider deleted tasks in summary.
Reported in bug 1044
"""
self.t(("add", "project:A", "1"))
self.t(("add", "project:B", "2"))
self.t(("add", "project:B", "3"))
self.t(("3", "delete"))
code, out, err = self.t(("project:B", "projects"))
$output = qx{../src/task rc:$rc add three pro:'foo' 2>&1 >/dev/null}; expected = "1 project \(1 task\)"
like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(3 of 3 tasks remaining\)\./, "$ut: add three"); self.assertRegexpMatches(out, expected)
$output = qx{../src/task rc:$rc add four pro:'foo' 2>&1 >/dev/null}; def test_project_progress(self):
like ($output, qr/The project 'foo' has changed\. Project 'foo' is 0% complete \(4 of 4 tasks remaining\)\./, "$ut: add four"); """project status/progress is shown and is up-to-date"""
$output = qx{../src/task rc:$rc 1 done 2>&1 >/dev/null}; code, out, err = self.t(("add", "one", "pro:foo"))
like ($output, qr/Project 'foo' is 25% complete \(3 of 4 tasks remaining\)\./, "$ut: done one"); self.assertRegexpMatches(err, self.STATUS.format("foo", "0%",
"1 task"))
$output = qx{../src/task rc:$rc 2 delete 2>&1 >/dev/null}; code, out, err = self.t(("add", "two", "pro:foo"))
like ($output, qr/The project 'foo' has changed\. Project 'foo' is 33% complete \(2 of 3 tasks remaining\)\./, "$ut: delete two"); self.assertRegexpMatches(err, self.STATUS.format("foo", "0%",
"2 of 2 tasks"))
$output = qx{../src/task rc:$rc 3 modify pro:bar 2>&1 >/dev/null}; code, out, err = self.t(("add", "three", "pro:foo"))
like ($output, qr/The project 'foo' has changed\. Project 'foo' is 50% complete \(1 of 2 tasks remaining\)\./, "$ut: change project"); self.assertRegexpMatches(err, self.STATUS.format("foo", "0%",
like ($output, qr/The project 'bar' has changed\. Project 'bar' is 0% complete \(1 task remaining\)\./, "$ut: change project"); "3 of 3 tasks"))
# Test projects with spaces in them. code, out, err = self.t(("add", "four", "pro:foo"))
$output = qx{../src/task rc:$rc 3 modify pro:"foo bar" 2>&1 >/dev/null}; self.assertRegexpMatches(err, self.STATUS.format("foo", "0%",
like ($output, qr/The project 'foo bar' has changed\./, "$ut: project with spaces"); "4 of 4 tasks"))
# Bug 1056: Project indentation. code, out, err = self.t(("1", "done"))
# see also the tests of helper functions for CmdProjects in util.t.cpp self.assertRegexpMatches(err, self.STATUS.format("foo", "25%",
qx{../src/task rc:$rc add testing project:existingParent 2>&1 >/dev/null}; "3 of 4 tasks"))
qx{../src/task rc:$rc add testing project:existingParent.child 2>&1 >/dev/null};
qx{../src/task rc:$rc add testing project:abstractParent.kid 2>&1 >/dev/null};
qx{../src/task rc:$rc add testing project:.myProject 2>&1 >/dev/null};
qx{../src/task rc:$rc add testing project:myProject. 2>&1 >/dev/null};
qx{../src/task rc:$rc add testing project:.myProject. 2>&1 >/dev/null};
$output = qx{../src/task rc:$rc projects 2>&1}; code, out, err = self.t(("2", "delete"))
my @lines = split ('\n',$output); self.assertRegexpMatches(err, self.STATUS.format("foo", "33%",
"2 of 3 tasks"))
my ($project_name_column) = $lines[4] =~ /^(\s*\S+)/; code, out, err = self.t(("3", "modify", "pro:bar"))
like ($project_name_column, qr/^\.myProject$/, "$ut: '.myProject' not indented"); self.assertRegexpMatches(err, self.STATUS.format("foo", "50%",
"1 of 2 tasks"))
self.assertRegexpMatches(err, self.STATUS.format("bar", "0%",
"1 task"))
($project_name_column) = $lines[5] =~ /^(\s*\S+)/; def test_project_spaces(self):
like ($project_name_column, qr/^\.myProject\.$/, "$ut: '.myProject.' not indented"); """projects with spaces are handled correctly"""
($project_name_column) = $lines[6] =~ /^(\s*\S+)/; self.t(("add", "hello", "pro:bob"))
like ($project_name_column, qr/^abstractParent$/, "$ut: abstract parent not indented"); code, out, err = self.t(("1", "mod", 'pro:"foo bar"'))
self.assertRegexpMatches(err, self.STATUS.format("foo bar", "0%",
"1 task"))
($project_name_column) = $lines[7] =~ /^(\s*\S+)/; def test_project_indentation(self):
like ($project_name_column, qr/^ kid$/, "$ut: child indented and without parent name"); """check project/subproject indentation
($project_name_column) = $lines[8] =~ /^(\s*\S+)/; Reported in bug 1056
like ($project_name_column, qr/^existingParent$/, "$ut: existing parent not indented");
($project_name_column) = $lines[9] =~ /^(\s*\S+)/; See also the tests of helper functions for CmdProjects in util.t.cpp
like ($project_name_column, qr/^ child$/, "$ut: child of existing parent indented and without parent name"); """
self.t(("add", "testing", "project:existingParent"))
self.t(("add", "testing", "project:existingParent.child"))
self.t(("add", "testing", "project:abstractParent.kid"))
self.t(("add", "testing", "project:.myProject"))
self.t(("add", "testing", "project:myProject"))
self.t(("add", "testing", "project:.myProject."))
($project_name_column) = $lines[12] =~ /^(\s*\S+)/; code, out, err = self.t(("projects",))
like ($project_name_column, qr/^myProject\.$/, "$ut: 'myProject.' not indented");
# Cleanup. order = (
unlink qw(pending.data completed.data undo.data backlog.data), $rc; ".myProject ",
exit 0; ".myProject. ",
"abstractParent ",
" kid ",
"existingParent ",
" child ",
"myProject ",
)
lines = out.splitlines(True) # True = keep newlines
# position where project names start on the lines list
position = 3
for i, proj in enumerate(order):
pos = position + i
self.assertTrue(
lines[pos].startswith(proj),
msg=("Project '{0}' is not in line #{1} or has an unexpected "
"indentation.{2}".format(proj, pos, out))
)
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -1,5 +1,8 @@
#! /bin/sh #! /bin/sh
# Look for taskd in $PATH instead of task/src/
export TASKD_USE_PATH=1
rc=0 rc=0
if [ x"$1" = x"--verbose" ]; if [ x"$1" = x"--verbose" ];
then then

60
test/shell.t Executable file
View file

@ -0,0 +1,60 @@
#!/usr/bin/env python2.7
# -*- coding: utf-8 -*-
###############################################################################
#
# Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
#
# http://www.opensource.org/licenses/mit-license.php
#
###############################################################################
import sys
import os
import unittest
from datetime import datetime
# Ensure python finds the local simpletap module
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
from basetest import Task, TestCase
class TestFilterPrefix(TestCase):
@classmethod
def setUpClass(cls):
"""Executed once before any test in the class"""
cls.t = Task()
cls.t.config("verbose", "nothing")
cls.t(('add', 'foo'))
def test_success(self):
"""Test successful search returns zero."""
code, out, err = self.t(('list', '/foo/'))
def test_failure(self):
"""Test failed search returns non-zero."""
code, out, err = self.t.runError(('list', '/bar/'))
if __name__ == "__main__":
from simpletap import TAPTestRunner
unittest.main(testRunner=TAPTestRunner())
# vim: ai sts=4 et sw=4

View file

@ -25,45 +25,39 @@
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
#include <cmake.h> #include <cmake.h>
#include <iostream>
#include <stdlib.h>
#include <utf8.h> #include <utf8.h>
#include <test.h> #include <test.h>
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv) int main (int argc, char** argv)
{ {
UnitTest t (17); UnitTest t (33);
// Ensure environment has no influence. std::string ascii_text = "This is a test";
unsetenv ("TASKDATA"); std::string utf8_text = "más sábado miércoles";
unsetenv ("TASKRC"); std::string utf8_wide_text = "改变各种颜色";
std::string ascii_text = "This is a test";
std::string utf8_text = "más sábado miércoles";
std::string utf8_wide_text = "改变各种颜色";
std::string ascii_text_color = "This is a test"; std::string ascii_text_color = "This is a test";
std::string utf8_text_color = "más sábado miércoles"; std::string utf8_text_color = "más sábado miércoles";
std::string utf8_wide_text_color = "变各种颜色"; std::string utf8_wide_text_color = "变各种颜色";
// unsigned int utf8_codepoint (const std::string&); // unsigned int utf8_codepoint (const std::string&);
t.is ((int) utf8_codepoint ("\\u0020"), 32, "\\u0020 --> ' '"); t.is ((int) utf8_codepoint ("\\u0020"), 32, "\\u0020 --> ' '");
t.is ((int) utf8_codepoint ("U+0020"), 32, "U+0020 --> ' '"); t.is ((int) utf8_codepoint ("U+0020"), 32, "U+0020 --> ' '");
// TODO unsigned int utf8_next_char (const std::string&, std::string::size_type&); // TODO unsigned int utf8_next_char (const std::string&, std::string::size_type&);
// TODO std::string utf8_character (unsigned int); // TODO std::string utf8_character (unsigned int);
// TODO int utf8_sequence (unsigned int); // TODO int utf8_sequence (unsigned int);
// unsigned int utf8_length (const std::string&); // unsigned int utf8_length (const std::string&);
t.is ((int) utf8_length (ascii_text), 14, "ASCII utf8_length"); t.is ((int) utf8_length (ascii_text), 14, "ASCII utf8_length");
t.is ((int) utf8_length (utf8_text), 20, "UTF8 utf8_length"); t.is ((int) utf8_length (utf8_text), 20, "UTF8 utf8_length");
t.is ((int) utf8_length (utf8_wide_text), 6, "UTF8 wide utf8_length"); t.is ((int) utf8_length (utf8_wide_text), 6, "UTF8 wide utf8_length");
// unsigned int utf8_width (const std::string&); // unsigned int utf8_width (const std::string&);
t.is ((int) utf8_width (ascii_text), 14, "ASCII utf8_width"); t.is ((int) utf8_width (ascii_text), 14, "ASCII utf8_width");
t.is ((int) utf8_width (utf8_text), 20, "UTF8 utf8_width"); t.is ((int) utf8_width (utf8_text), 20, "UTF8 utf8_width");
t.is ((int) utf8_width (utf8_wide_text), 12, "UTF8 wide utf8_width"); t.is ((int) utf8_width (utf8_wide_text), 12, "UTF8 wide utf8_width");
// unsigned int utf8_text_length (const std::string&); // unsigned int utf8_text_length (const std::string&);
t.is ((int) utf8_text_length (ascii_text_color), 14, "ASCII utf8_text_length"); t.is ((int) utf8_text_length (ascii_text_color), 14, "ASCII utf8_text_length");
@ -71,14 +65,32 @@ int main (int argc, char** argv)
t.is ((int) utf8_text_length (utf8_wide_text_color), 6, "UTF8 wide utf8_text_length"); t.is ((int) utf8_text_length (utf8_wide_text_color), 6, "UTF8 wide utf8_text_length");
// unsigned int utf8_text_width (const std::string&); // unsigned int utf8_text_width (const std::string&);
t.is ((int) utf8_text_width (ascii_text_color), 14, "ASCII utf8_text_width"); t.is ((int) utf8_text_width (ascii_text_color), 14, "ASCII utf8_text_width");
t.is ((int) utf8_text_width (utf8_text_color), 20, "UTF8 utf8_text_width"); t.is ((int) utf8_text_width (utf8_text_color), 20, "UTF8 utf8_text_width");
t.is ((int) utf8_text_width (utf8_wide_text_color), 12, "UTF8 wide utf8_text_width"); t.is ((int) utf8_text_width (utf8_wide_text_color), 12, "UTF8 wide utf8_text_width");
// const std::string utf8_substr (const std::string&, unsigned int, unsigned int length = 0); // const std::string utf8_substr (const std::string&, unsigned int, unsigned int length = 0);
t.is (utf8_substr (ascii_text, 0, 2), "Th", "ASCII utf8_substr"); t.is (utf8_substr (ascii_text, 0, 2), "Th", "ASCII utf8_substr");
t.is (utf8_substr (utf8_text, 0, 2), "", "UTF8 utf8_substr"); t.is (utf8_substr (utf8_text, 0, 2), "", "UTF8 utf8_substr");
t.is (utf8_substr (utf8_wide_text, 0, 2), "改变", "UTF8 wide utf8_substr"); t.is (utf8_substr (utf8_wide_text, 0, 2), "改变", "UTF8 wide utf8_substr");
// int mk_wcwidth (wchar_t);
t.is (mk_wcwidth ('a'), 1, "mk_wcwidth U+0061 --> 1");
t.is (mk_wcwidth (0x5149), 2, "mk_wcwidth U+5149 --> 2");
t.is (mk_wcwidth (0x9a8c), 2, "mk_wcwidth U+9a8c --> 2");
t.is (mk_wcwidth (0x4e70), 2, "mk_wcwidth U+4e70 --> 2");
t.is (mk_wcwidth (0x94b1), 2, "mk_wcwidth U+94b1 --> 2");
t.is (mk_wcwidth (0x5305), 2, "mk_wcwidth U+5305 --> 2");
t.is (mk_wcwidth (0x91cd), 2, "mk_wcwidth U+91cd --> 2");
t.is (mk_wcwidth (0x65b0), 2, "mk_wcwidth U+65b0 --> 2");
t.is (mk_wcwidth (0x8bbe), 2, "mk_wcwidth U+8bbe --> 2");
t.is (mk_wcwidth (0x8ba1), 2, "mk_wcwidth U+8ba1 --> 2");
t.is (mk_wcwidth (0x5411), 2, "mk_wcwidth U+5411 --> 2");
t.is (mk_wcwidth (0x4e0a), 2, "mk_wcwidth U+4e0a --> 2");
t.is (mk_wcwidth (0x4e0b), 2, "mk_wcwidth U+4e0b --> 2");
t.is (mk_wcwidth (0x7bad), 2, "mk_wcwidth U+7bad --> 2");
t.is (mk_wcwidth (0x5934), 2, "mk_wcwidth U+5934 --> 2");
t.is (mk_wcwidth (0xff0c), 2, "mk_wcwidth U+ff0c --> 2"); // comma
return 0; return 0;
} }

View file

@ -1,63 +0,0 @@
////////////////////////////////////////////////////////////////////////////////
//
// Copyright 2006 - 2015, Paul Beckingham, Federico Hernandez.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included
// in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// http://www.opensource.org/licenses/mit-license.php
//
////////////////////////////////////////////////////////////////////////////////
#include <cmake.h>
#include <iostream>
#include <stdlib.h>
#include <text.h>
#include <test.h>
////////////////////////////////////////////////////////////////////////////////
int main (int argc, char** argv)
{
UnitTest t (16);
// Ensure environment has no influence.
unsetenv ("TASKDATA");
unsetenv ("TASKRC");
t.is (mk_wcwidth ('a'), 1, "U+0061 --> 1");
t.is (mk_wcwidth (0x5149), 2, "U+5149 --> 2");
t.is (mk_wcwidth (0x9a8c), 2, "U+9a8c --> 2");
t.is (mk_wcwidth (0x4e70), 2, "U+4e70 --> 2");
t.is (mk_wcwidth (0x94b1), 2, "U+94b1 --> 2");
t.is (mk_wcwidth (0x5305), 2, "U+5305 --> 2");
t.is (mk_wcwidth (0x91cd), 2, "U+91cd --> 2");
t.is (mk_wcwidth (0x65b0), 2, "U+65b0 --> 2");
t.is (mk_wcwidth (0x8bbe), 2, "U+8bbe --> 2");
t.is (mk_wcwidth (0x8ba1), 2, "U+8ba1 --> 2");
t.is (mk_wcwidth (0x5411), 2, "U+5411 --> 2");
t.is (mk_wcwidth (0x4e0a), 2, "U+4e0a --> 2");
t.is (mk_wcwidth (0x4e0b), 2, "U+4e0b --> 2");
t.is (mk_wcwidth (0x7bad), 2, "U+7bad --> 2");
t.is (mk_wcwidth (0x5934), 2, "U+5934 --> 2");
t.is (mk_wcwidth (0xff0c), 2, "U+ff0c --> 2"); // comma
return 0;
}
////////////////////////////////////////////////////////////////////////////////