Merge branch '2.4.3' into lexer2
This commit is contained in:
86
test/basic.t
86
test/basic.t
@@ -1,86 +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",
|
||||
"default.command=\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Get the version number from configure.ac
|
||||
my $version = slurp ('../CMakeLists.txt');
|
||||
|
||||
# Test the usage command.
|
||||
my $output = qx{../src/task rc:$rc 2>&1 >/dev/null};
|
||||
like ($output, qr/You must specify a command or a task to modify./m, "$ut: missing command and ID");
|
||||
|
||||
# Test the version command.
|
||||
$output = qx{../src/task rc:$rc version 2>&1};
|
||||
like ($output, qr/task $version/, "$ut: version - task version number");
|
||||
like ($output, qr/MIT\slicense/, "$ut: version - license");
|
||||
like ($output, qr/http:\/\/taskwarrior\.org/, "$ut: version - url");
|
||||
|
||||
# Test the _version command.
|
||||
$output = qx{../src/task rc:$rc _version 2>&1};
|
||||
like ($output, qr/[a-f0-9]{7}/, "$ut: _version - task version number");
|
||||
|
||||
# Cleanup.
|
||||
unlink $rc;
|
||||
exit 0;
|
||||
|
||||
################################################################################
|
||||
sub slurp
|
||||
{
|
||||
my ($file) = @_;
|
||||
if (open my $fh, '<', $file)
|
||||
{
|
||||
while (<$fh>) {
|
||||
if (/PROJECT_VERSION/) {
|
||||
chomp;
|
||||
s/^set \(PROJECT_VERSION "//;
|
||||
s/"\).*$//;
|
||||
close $fh;
|
||||
return $_;
|
||||
}
|
||||
}
|
||||
}
|
||||
'';
|
||||
}
|
||||
@@ -1,72 +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 => 7;
|
||||
|
||||
# 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",
|
||||
"color=off\n",
|
||||
"verbose=nothing\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Bug 1056: Project indentation in CmdSummary.
|
||||
qx{../src/task rc:$rc add testing project:existingParent 2>&1 >/dev/null};
|
||||
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};
|
||||
|
||||
my $output = qx{../src/task rc:$rc summary 2>&1};
|
||||
my @lines = split ('\n',$output);
|
||||
|
||||
like ($lines[0], qr/^\.myProject\s/, "$ut: '.myProject' not indented");
|
||||
like ($lines[1], qr/^\.myProject\.\s/, "$ut: '.myProject.' not indented");
|
||||
like ($lines[2], qr/^abstractParent\s*$/, "$ut: 'abstractParent' not indented, no data");
|
||||
like ($lines[3], qr/^\s\skid\s+\d/, "$ut: ' kid' indented, without parent, with data");
|
||||
like ($lines[4], qr/^existingParent\s+\d/, "$ut: 'existingParent' not indented, with data");
|
||||
like ($lines[5], qr/^\s\schild\s+\d/, "$ut: ' child' indented, without parent, with data");
|
||||
like ($lines[6], qr/^myProject\.\s+\d/, "$ut: 'myProject.' not indented, with data");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
|
||||
130
test/bug.1063.t
130
test/bug.1063.t
@@ -1,72 +1,74 @@
|
||||
#! /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
|
||||
##
|
||||
################################################################################
|
||||
#!/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
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 6;
|
||||
import sys
|
||||
import os
|
||||
import re
|
||||
import unittest
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Ensure environment has no influence.
|
||||
delete $ENV{'TASKDATA'};
|
||||
delete $ENV{'TASKRC'};
|
||||
from basetest import Task, TestCase
|
||||
|
||||
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",
|
||||
"uda.foo.type=numeric\n",
|
||||
"uda.foo.label=Foo\n",
|
||||
"report.bar.columns=foo,description\n",
|
||||
"report.bar.description=Bar\n",
|
||||
"report.bar.labels=Foo,Desc\n",
|
||||
"report.bar.sort=foo-\n";
|
||||
close $fh;
|
||||
}
|
||||
class TestBug1063(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
# Bug 1063 - Numeric UDA fields are not sortable.
|
||||
qx{../src/task rc:$rc add four foo:4 2>&1};
|
||||
ok ($? == 0, "$ut: add four");
|
||||
qx{../src/task rc:$rc add one foo:1 2>&1};
|
||||
ok ($? == 0, "$ut: add one");
|
||||
qx{../src/task rc:$rc add three foo:3 2>&1};
|
||||
ok ($? == 0, "$ut: add three");
|
||||
qx{../src/task rc:$rc add two foo:2 2>&1};
|
||||
ok ($? == 0, "$ut: add two");
|
||||
self.t.config("uda.foo.type", "numeric")
|
||||
self.t.config("uda.foo.label", "Foo")
|
||||
self.t.config("report.bar.columns", "foo,description")
|
||||
self.t.config("report.bar.description", "Bar")
|
||||
self.t.config("report.bar.labels", "Foo,Desc")
|
||||
self.t.config("report.bar.sort", "foo-")
|
||||
|
||||
my $output = qx{../src/task rc:$rc bar 2>&1};
|
||||
like ($output, qr/4.+3.+2.+1/ms, "$ut: Default descending sort correct");
|
||||
def test_sortable_uda(self):
|
||||
"""numeric UDA fields are sortable
|
||||
|
||||
$output = qx{../src/task rc:$rc bar rc.report.bar.sort=foo+ 2>&1};
|
||||
like ($output, qr/1.+2.+3.+4/ms, "$ut: Default ascending sort correct");
|
||||
Reported as bug 1063
|
||||
"""
|
||||
|
||||
## Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
self.t(("add", "four", "foo:4"))
|
||||
self.t(("add", "one", "foo:1"))
|
||||
self.t(("add", "three", "foo:3"))
|
||||
self.t(("add", "two", "foo:2"))
|
||||
|
||||
code, out, err = self.t(("bar",))
|
||||
expected = re.compile("4.+3.+2.+1", re.DOTALL) # dot matches \n too
|
||||
self.assertRegexpMatches(out, expected)
|
||||
|
||||
code, out, err = self.t(("bar", "rc.report.bar.sort=foo+"))
|
||||
expected = re.compile("1.+2.+3.+4", re.DOTALL) # dot matches \n too
|
||||
self.assertRegexpMatches(out, expected)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
||||
|
||||
@@ -1,78 +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 => 12;
|
||||
|
||||
# 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.xyzzyx=status:waiting\n";
|
||||
print $fh "imnotrecognized=kai\n";
|
||||
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Bug 1065 - CmdShow should not display the differ message if no non-default in matched elements.
|
||||
my $output = qx{../src/task rc:$rc show alias 2>&1};
|
||||
ok ($? == 0, "$ut: Exit status check");
|
||||
like ($output, qr/Some of your .taskrc variables differ from the default values./, "$ut: Message is shown when non-default matches in pattern");
|
||||
|
||||
$output = qx{../src/task rc:$rc show 2>&1};
|
||||
ok ($? == 0, "$ut: Exit status check");
|
||||
like ($output, qr/Some of your .taskrc variables differ from the default values./, "$ut: Message is shown when non-default matches in all");
|
||||
|
||||
$output = qx{../src/task rc:$rc show report.overdue 2>&1};
|
||||
ok ($? == 0, "$ut: Exit status check");
|
||||
unlike ($output, qr/Some of your .taskrc variables differ/, "$ut: Message is not shown when no non-default matches in pattern");
|
||||
|
||||
# Bug 1065 - CmdShow should not display the unrecognized message if no non-default in matched elements.
|
||||
$output = qx{../src/task rc:$rc show notrecog 2>&1};
|
||||
ok ($? == 0, "$ut: Exit status check");
|
||||
like ($output, qr/Your .taskrc file contains these unrecognized variables:/, "$ut: Message is shown when unrecognized matches in pattern");
|
||||
|
||||
$output = qx{../src/task rc:$rc show 2>&1};
|
||||
ok ($? == 0, "$ut: Exit status check");
|
||||
like ($output, qr/Your .taskrc file contains these unrecognized variables:/, "$ut: Message is shown when unrecognized matches in all");
|
||||
|
||||
$output = qx{../src/task rc:$rc show report.overdue 2>&1};
|
||||
ok ($? == 0, "$ut: Exit status check");
|
||||
unlike ($output, qr/unrecognized variables/, "$ut: Message is not shown when no non-default matches in pattern");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
@@ -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 => 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=off\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Bug 1110: reports print "Completed" but "Completed" != "completed"
|
||||
qx{../src/task rc:$rc add ToBeCompleted 2>&1};
|
||||
qx{../src/task rc:$rc 1 done 2>&1};
|
||||
|
||||
my $output = qx{../src/task all status:Completed rc:$rc 2>&1};
|
||||
like ($output, qr/ToBeCompleted/, "$ut: status:Completed returns Completed tasks");
|
||||
|
||||
$output = qx{../src/task all status:completed rc:$rc 2>&1};
|
||||
like ($output, qr/ToBeCompleted/, "$ut: status:completed returns completed tasks");
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data), $rc;
|
||||
exit 0;
|
||||
95
test/custom.config.t
Executable file
95
test/custom.config.t
Executable file
@@ -0,0 +1,95 @@
|
||||
#!/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 TestCustomConfig(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
self.t.config("alias.xyzzyx", "status:waiting")
|
||||
self.t.config("imnotrecognized", "kai")
|
||||
|
||||
self.DIFFER_MSG = ("Some of your .taskrc variables differ from the "
|
||||
"default values.")
|
||||
self.NOT_RECOG_MSG = ("Your .taskrc file contains these unrecognized "
|
||||
"variables:")
|
||||
|
||||
def test_show_alias(self):
|
||||
"""task show <filter> - warns when non-default values are matched
|
||||
|
||||
Reported in bug 1065
|
||||
"""
|
||||
code, out, err = self.t(("show", "alias"))
|
||||
|
||||
self.assertIn(self.DIFFER_MSG, out)
|
||||
self.assertNotIn(self.NOT_RECOG_MSG, out)
|
||||
|
||||
def test_show(self):
|
||||
"""task show - warns when non-default values are matched
|
||||
|
||||
Reported in bug 1065
|
||||
"""
|
||||
code, out, err = self.t(("show",))
|
||||
|
||||
self.assertIn(self.DIFFER_MSG, out)
|
||||
self.assertIn(self.NOT_RECOG_MSG, out)
|
||||
|
||||
def test_show_report_overdue(self):
|
||||
"""task show <filter> - no warn when no non-default values are matched
|
||||
|
||||
Reported in bug 1065
|
||||
"""
|
||||
code, out, err = self.t(("show", "report.overdue"))
|
||||
|
||||
self.assertNotIn(self.DIFFER_MSG, out)
|
||||
self.assertNotIn(self.NOT_RECOG_MSG, out)
|
||||
|
||||
def test_show_notrecog(self):
|
||||
"""task show <filter> - warns when unrecognized values are matched
|
||||
|
||||
Reported in bug 1065
|
||||
"""
|
||||
code, out, err = self.t(("show", "notrecog"))
|
||||
|
||||
self.assertNotIn(self.DIFFER_MSG, out)
|
||||
self.assertIn(self.NOT_RECOG_MSG, out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
||||
@@ -88,7 +88,7 @@ class TestFilterPrefix(TestCase):
|
||||
self.assertIn('seven', out)
|
||||
self.assertIn('eight', out)
|
||||
|
||||
def test_list_project_startwsith_bar(self):
|
||||
def test_list_project_startswith_bar(self):
|
||||
"""Filter on project name start."""
|
||||
code, out, err = self.t(('list', 'project.startswith:bar'))
|
||||
self.assertNotIn('one', out)
|
||||
@@ -124,7 +124,7 @@ class TestFilterPrefix(TestCase):
|
||||
self.assertNotIn('seven', out)
|
||||
self.assertNotIn('eight', out)
|
||||
|
||||
def test_list_descrtiption_has_foo(self):
|
||||
def test_list_description_has_foo(self):
|
||||
"""Filter on description pattern."""
|
||||
code, out, err = self.t(('list', 'description.has:foo'))
|
||||
self.assertIn('one', out)
|
||||
|
||||
594
test/filter.t
594
test/filter.t
@@ -1,281 +1,375 @@
|
||||
#! /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
|
||||
##
|
||||
################################################################################
|
||||
#!/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
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 161;
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# Ensure environment has no influence.
|
||||
delete $ENV{'TASKDATA'};
|
||||
delete $ENV{'TASKRC'};
|
||||
from basetest import Task, TestCase
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'filter.rc')
|
||||
{
|
||||
print $fh "data.location=.\n";
|
||||
close $fh;
|
||||
}
|
||||
|
||||
# Test the filters.
|
||||
qx{../src/task rc:filter.rc add project:A priority:H +tag one foo 2>&1};
|
||||
qx{../src/task rc:filter.rc add project:A priority:H two 2>&1};
|
||||
qx{../src/task rc:filter.rc add project:A three 2>&1};
|
||||
qx{../src/task rc:filter.rc add priority:H four 2>&1};
|
||||
qx{../src/task rc:filter.rc add +tag five 2>&1};
|
||||
qx{../src/task rc:filter.rc add six foo 2>&1};
|
||||
qx{../src/task rc:filter.rc add priority:L seven bar foo 2>&1};
|
||||
class TestFilter(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
my $output = qx{../src/task rc:filter.rc list 2>&1};
|
||||
like ($output, qr/one/, 'a1');
|
||||
like ($output, qr/two/, 'a2');
|
||||
like ($output, qr/three/, 'a3');
|
||||
like ($output, qr/four/, 'a4');
|
||||
like ($output, qr/five/, 'a5');
|
||||
like ($output, qr/six/, 'a6');
|
||||
like ($output, qr/seven/, 'a7');
|
||||
self.t(("add", "project:A", "prio:H", "+tag", "one", "foo"))
|
||||
self.t(("add", "project:A", "prio:H", "two"))
|
||||
self.t(("add", "project:A", "three"))
|
||||
self.t(("add", "prio:H", "four"))
|
||||
self.t(("add", "+tag", "five"))
|
||||
self.t(("add", "six", "foo"))
|
||||
self.t(("add", "prio:L", "seven", "bar", "foo"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A 2>&1};
|
||||
like ($output, qr/one/, 'b1');
|
||||
like ($output, qr/two/, 'b2');
|
||||
like ($output, qr/three/, 'b3');
|
||||
unlike ($output, qr/four/, 'b4');
|
||||
unlike ($output, qr/five/, 'b5');
|
||||
unlike ($output, qr/six/, 'b6');
|
||||
unlike ($output, qr/seven/, 'b7');
|
||||
def test_list(self):
|
||||
"""filter - list"""
|
||||
code, out, err = self.t(("list",))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list priority:H 2>&1};
|
||||
like ($output, qr/one/, 'c1');
|
||||
like ($output, qr/two/, 'c2');
|
||||
unlike ($output, qr/three/, 'c3');
|
||||
like ($output, qr/four/, 'c4');
|
||||
unlike ($output, qr/five/, 'c5');
|
||||
unlike ($output, qr/six/, 'c6');
|
||||
unlike ($output, qr/seven/, 'c7');
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertIn("four", out)
|
||||
self.assertIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list priority: 2>&1};
|
||||
unlike ($output, qr/one/, 'd1');
|
||||
unlike ($output, qr/two/, 'd2');
|
||||
like ($output, qr/three/, 'd3');
|
||||
unlike ($output, qr/four/, 'd4');
|
||||
like ($output, qr/five/, 'd5');
|
||||
like ($output, qr/six/, 'd6');
|
||||
unlike ($output, qr/seven/, 'd7');
|
||||
def test_list_projectA(self):
|
||||
"""filter - list project:A"""
|
||||
code, out, err = self.t(("list", "project:A"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list /foo/ 2>&1};
|
||||
like ($output, qr/one/, 'e1');
|
||||
unlike ($output, qr/two/, 'e2');
|
||||
unlike ($output, qr/three/, 'e3');
|
||||
unlike ($output, qr/four/, 'e4');
|
||||
unlike ($output, qr/five/, 'e5');
|
||||
like ($output, qr/six/, 'e6');
|
||||
like ($output, qr/seven/, 'e7');
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list /foo/ /bar/ 2>&1};
|
||||
unlike ($output, qr/one/, 'f1');
|
||||
unlike ($output, qr/two/, 'f2');
|
||||
unlike ($output, qr/three/, 'f3');
|
||||
unlike ($output, qr/four/, 'f4');
|
||||
unlike ($output, qr/five/, 'f5');
|
||||
unlike ($output, qr/six/, 'f6');
|
||||
like ($output, qr/seven/, 'f7');
|
||||
def test_list_priorityH(self):
|
||||
"""filter - list priority:H"""
|
||||
code, out, err = self.t(("list", "priority:H"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list +tag 2>&1};
|
||||
like ($output, qr/one/, 'g1');
|
||||
unlike ($output, qr/two/, 'g2');
|
||||
unlike ($output, qr/three/, 'g3');
|
||||
unlike ($output, qr/four/, 'g4');
|
||||
like ($output, qr/five/, 'g5');
|
||||
unlike ($output, qr/six/, 'g6');
|
||||
unlike ($output, qr/seven/, 'g7');
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list -tag 2>&1};
|
||||
unlike ($output, qr/one/, 'h1');
|
||||
like ($output, qr/two/, 'h2');
|
||||
like ($output, qr/three/, 'h3');
|
||||
like ($output, qr/four/, 'h4');
|
||||
unlike ($output, qr/five/, 'h5');
|
||||
like ($output, qr/six/, 'h6');
|
||||
like ($output, qr/seven/, 'h7');
|
||||
def test_list_priority(self):
|
||||
"""filter - list priority:"""
|
||||
code, out, err = self.t(("list", "priority:"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list -missing 2>&1};
|
||||
like ($output, qr/one/, 'i1');
|
||||
like ($output, qr/two/, 'i2');
|
||||
like ($output, qr/three/, 'i3');
|
||||
like ($output, qr/four/, 'i4');
|
||||
like ($output, qr/five/, 'i5');
|
||||
like ($output, qr/six/, 'i6');
|
||||
like ($output, qr/seven/, 'i7');
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list +tag -tag 2>&1};
|
||||
unlike ($output, qr/one/, 'j1');
|
||||
unlike ($output, qr/two/, 'j2');
|
||||
unlike ($output, qr/three/, 'j3');
|
||||
unlike ($output, qr/four/, 'j4');
|
||||
unlike ($output, qr/five/, 'j5');
|
||||
unlike ($output, qr/six/, 'j6');
|
||||
unlike ($output, qr/seven/, 'j7');
|
||||
def test_list_substring(self):
|
||||
"""filter - list /foo/"""
|
||||
code, out, err = self.t(("list", "/foo/"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A priority:H 2>&1};
|
||||
like ($output, qr/one/, 'k1');
|
||||
like ($output, qr/two/, 'k2');
|
||||
unlike ($output, qr/three/, 'k3');
|
||||
unlike ($output, qr/four/, 'k4');
|
||||
unlike ($output, qr/five/, 'k5');
|
||||
unlike ($output, qr/six/, 'k6');
|
||||
unlike ($output, qr/seven/, 'k7');
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A priority: 2>&1};
|
||||
unlike ($output, qr/one/, 'l1');
|
||||
unlike ($output, qr/two/, 'l2');
|
||||
like ($output, qr/three/, 'l3');
|
||||
unlike ($output, qr/four/, 'l4');
|
||||
unlike ($output, qr/five/, 'l5');
|
||||
unlike ($output, qr/six/, 'l6');
|
||||
unlike ($output, qr/seven/, 'l7');
|
||||
def test_list_double_substring(self):
|
||||
"""filter - list /foo/ /bar/"""
|
||||
code, out, err = self.t(("list", "/foo/", "/bar/"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A /foo/ 2>&1};
|
||||
like ($output, qr/one/, 'm1');
|
||||
unlike ($output, qr/two/, 'm2');
|
||||
unlike ($output, qr/three/, 'm3');
|
||||
unlike ($output, qr/four/, 'm4');
|
||||
unlike ($output, qr/five/, 'm5');
|
||||
unlike ($output, qr/six/, 'm6');
|
||||
unlike ($output, qr/seven/, 'm7');
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A +tag 2>&1};
|
||||
like ($output, qr/one/, 'n1');
|
||||
unlike ($output, qr/two/, 'n2');
|
||||
unlike ($output, qr/three/, 'n3');
|
||||
unlike ($output, qr/four/, 'n4');
|
||||
unlike ($output, qr/five/, 'n5');
|
||||
unlike ($output, qr/six/, 'n6');
|
||||
unlike ($output, qr/seven/, 'n7');
|
||||
def test_list_include_tag(self):
|
||||
"""filter - list +tag"""
|
||||
code, out, err = self.t(("list", "+tag"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A priority:H /foo/ 2>&1};
|
||||
like ($output, qr/one/, 'o1');
|
||||
unlike ($output, qr/two/, 'o2');
|
||||
unlike ($output, qr/three/, 'o3');
|
||||
unlike ($output, qr/four/, 'o4');
|
||||
unlike ($output, qr/five/, 'o5');
|
||||
unlike ($output, qr/six/, 'o6');
|
||||
unlike ($output, qr/seven/, 'o7');
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A priority:H +tag 2>&1};
|
||||
like ($output, qr/one/, 'p1');
|
||||
unlike ($output, qr/two/, 'p2');
|
||||
unlike ($output, qr/three/, 'p3');
|
||||
unlike ($output, qr/four/, 'p4');
|
||||
unlike ($output, qr/five/, 'p5');
|
||||
unlike ($output, qr/six/, 'p6');
|
||||
unlike ($output, qr/seven/, 'p7');
|
||||
def test_list_exclude_tag(self):
|
||||
"""filter - list -tag"""
|
||||
code, out, err = self.t(("list", "-tag"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A priority:H /foo/ +tag 2>&1};
|
||||
like ($output, qr/one/, 'q1');
|
||||
unlike ($output, qr/two/, 'q2');
|
||||
unlike ($output, qr/three/, 'q3');
|
||||
unlike ($output, qr/four/, 'q4');
|
||||
unlike ($output, qr/five/, 'q5');
|
||||
unlike ($output, qr/six/, 'q6');
|
||||
unlike ($output, qr/seven/, 'q7');
|
||||
self.assertNotIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc list project:A priority:H /foo/ +tag /baz/ 2>&1};
|
||||
unlike ($output, qr/one/, 'r1');
|
||||
unlike ($output, qr/two/, 'r2');
|
||||
unlike ($output, qr/three/, 'r3');
|
||||
unlike ($output, qr/four/, 'r4');
|
||||
unlike ($output, qr/five/, 'r5');
|
||||
unlike ($output, qr/six/, 'r6');
|
||||
unlike ($output, qr/seven/, 'r7');
|
||||
def test_list_non_existing_tag(self):
|
||||
"""filter - list -missing"""
|
||||
code, out, err = self.t(("list", "-missing"))
|
||||
|
||||
# Regex filters.
|
||||
#$output = qx{../src/task rc:filter.rc list rc.regex:on project:/[A-Z]/ 2>&1};
|
||||
#like ($output, qr/one/, 's1');
|
||||
#like ($output, qr/two/, 's2');
|
||||
#like ($output, qr/three/, 's3');
|
||||
#unlike ($output, qr/four/, 's4');
|
||||
#unlike ($output, qr/five/, 's5');
|
||||
#unlike ($output, qr/six/, 's6');
|
||||
#unlike ($output, qr/seven/, 's7');
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertIn("four", out)
|
||||
self.assertIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
#$output = qx{../src/task rc:filter.rc list rc.regex:on project:. 2>&1};
|
||||
#like ($output, qr/one/, 't1');
|
||||
#like ($output, qr/two/, 't2');
|
||||
#like ($output, qr/three/, 't3');
|
||||
#unlike ($output, qr/four/, 't4');
|
||||
#unlike ($output, qr/five/, 't5');
|
||||
#unlike ($output, qr/six/, 't6');
|
||||
#unlike ($output, qr/seven/, 't7');
|
||||
def test_list_mutually_exclusive_tag(self):
|
||||
"""filter - list +tag -tag"""
|
||||
code, out, err = self.t.runError(("list", "+tag", "-tag"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc rc.regex:on list /fo\{2\}/ 2>&1};
|
||||
like ($output, qr/one/, 'u1');
|
||||
unlike ($output, qr/two/, 'u2');
|
||||
unlike ($output, qr/three/, 'u3');
|
||||
unlike ($output, qr/four/, 'u4');
|
||||
unlike ($output, qr/five/, 'u5');
|
||||
like ($output, qr/six/, 'u6');
|
||||
like ($output, qr/seven/, 'u7');
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc rc.regex:on list /f../ /b../ 2>&1};
|
||||
unlike ($output, qr/one/, 'v1');
|
||||
unlike ($output, qr/two/, 'v2');
|
||||
unlike ($output, qr/three/, 'v3');
|
||||
unlike ($output, qr/four/, 'v4');
|
||||
unlike ($output, qr/five/, 'v5');
|
||||
unlike ($output, qr/six/, 'v6');
|
||||
like ($output, qr/seven/, 'v7');
|
||||
def test_list_projectA_priorityH(self):
|
||||
"""filter - list project:A priority:H"""
|
||||
code, out, err = self.t(("list", "project:A", "priority:H"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc rc.regex:on list /\\^s/ 2>&1};
|
||||
unlike ($output, qr/one/, 'w1');
|
||||
unlike ($output, qr/two/, 'w2');
|
||||
unlike ($output, qr/three/, 'w3');
|
||||
unlike ($output, qr/four/, 'w4');
|
||||
unlike ($output, qr/five/, 'w5');
|
||||
like ($output, qr/six/, 'w6');
|
||||
like ($output, qr/seven/, 'w7');
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
$output = qx{../src/task rc:filter.rc rc.regex:on list /\\^.i/ 2>&1};
|
||||
unlike ($output, qr/one/, 'x1');
|
||||
unlike ($output, qr/two/, 'x2');
|
||||
unlike ($output, qr/three/, 'x3');
|
||||
unlike ($output, qr/four/, 'x4');
|
||||
like ($output, qr/five/, 'x5');
|
||||
like ($output, qr/six/, 'x6');
|
||||
unlike ($output, qr/seven/, 'x7');
|
||||
def test_list_projectA_priority(self):
|
||||
"""filter - list project:A priority:"""
|
||||
code, out, err = self.t(("list", "project:A", "priority:"))
|
||||
|
||||
$output = qx{../src/task rc:filter.rc rc.regex:on list "/two|five/" 2>&1};
|
||||
unlike ($output, qr/one/, 'y1');
|
||||
like ($output, qr/two/, 'y2');
|
||||
unlike ($output, qr/three/, 'y3');
|
||||
unlike ($output, qr/four/, 'y4');
|
||||
like ($output, qr/five/, 'y5');
|
||||
unlike ($output, qr/six/, 'y6');
|
||||
unlike ($output, qr/seven/, 'y7');
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
# Cleanup.
|
||||
unlink qw(pending.data completed.data undo.data backlog.data filter.rc);
|
||||
exit 0;
|
||||
def test_list_projectA_substring(self):
|
||||
"""filter - list project:A /foo/"""
|
||||
code, out, err = self.t(("list", "project:A", "/foo/"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_list_projectA_tag(self):
|
||||
"""filter - list project:A +tag"""
|
||||
code, out, err = self.t(("list", "project:A", "+tag"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_list_projectA_priorityH_substring(self):
|
||||
"""filter - list project:A priority:H /foo/"""
|
||||
code, out, err = self.t(("list", "project:A", "priority:H", "/foo/"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_list_projectA_priorityH_tag(self):
|
||||
"""filter - list project:A priority:H +tag"""
|
||||
code, out, err = self.t(("list", "project:A", "priority:H", "+tag"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_list_projectA_priorityH_substring_tag(self):
|
||||
"""filter - list project:A priority:H /foo/ +tag"""
|
||||
code, out, err = self.t(("list", "project:A", "priority:H", "/foo/",
|
||||
"+tag"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_list_projectA_priorityH_substring_tag_substring(self):
|
||||
"""filter - list project:A priority:H /foo/ +tag /baz/"""
|
||||
code, out, err = self.t.runError(("list", "project:A", "priority:H",
|
||||
"/foo/", "+tag", "/baz/"))
|
||||
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_regex_list_project(self):
|
||||
"""filter - rc.regex:on list project:/[A-Z]/"""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "project:/[A-Z]/"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
@unittest.expectedFailure
|
||||
def test_regex_list_project_any(self):
|
||||
"""filter - rc.regex:on list project:."""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "project:."))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_regex_list_substring(self):
|
||||
"""filter - rc.regex:on list /fo{2}/"""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "/fo{2}/"))
|
||||
|
||||
self.assertIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
def test_regex_list_double_substring_wildcard(self):
|
||||
"""filter - rc.regex:on list /f../ /b../"""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "/f../", "/b../"))
|
||||
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
def test_regex_list_substring_startswith(self):
|
||||
"""filter - rc.regex:on list /^s/"""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "/^s/"))
|
||||
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertNotIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertIn("seven", out)
|
||||
|
||||
def test_regex_list_substring_wildcard_startswith(self):
|
||||
"""filter - rc.regex:on list /^.i/"""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "/^.i/"))
|
||||
|
||||
self.assertNotIn("one", out)
|
||||
self.assertNotIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertIn("five", out)
|
||||
self.assertIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
def test_regex_list_substring_or(self):
|
||||
"""filter - rc.regex:on list /two|five/"""
|
||||
code, out, err = self.t(("rc.regex:on", "list", "/two|five/"))
|
||||
|
||||
self.assertNotIn("one", out)
|
||||
self.assertIn("two", out)
|
||||
self.assertNotIn("three", out)
|
||||
self.assertNotIn("four", out)
|
||||
self.assertIn("five", out)
|
||||
self.assertNotIn("six", out)
|
||||
self.assertNotIn("seven", out)
|
||||
|
||||
|
||||
class TestBug1110(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
def test_status_is_case_insensitive(self):
|
||||
"""filter - status:Completed / status:completed - behave the same"""
|
||||
self.t(("add", "ToBeCompleted"))
|
||||
self.t(("1", "done"))
|
||||
|
||||
code, out, err = self.t(("all", "status:Completed"))
|
||||
self.assertIn("ToBeCompleted", out)
|
||||
|
||||
code, out, err = self.t(("all", "status:completed"))
|
||||
self.assertIn("ToBeCompleted", out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4
|
||||
|
||||
@@ -96,13 +96,7 @@ class TestProjects(TestCase):
|
||||
self.assertRegexpMatches(err, self.STATUS.format("foo bar", "0%",
|
||||
"1 task"))
|
||||
|
||||
def test_project_indentation(self):
|
||||
"""check project/subproject indentation
|
||||
|
||||
Reported in bug 1056
|
||||
|
||||
See also the tests of helper functions for CmdProjects in util.t.cpp
|
||||
"""
|
||||
def add_tasks(self):
|
||||
self.t(("add", "testing", "project:existingParent"))
|
||||
self.t(("add", "testing", "project:existingParent.child"))
|
||||
self.t(("add", "testing", "project:abstractParent.kid"))
|
||||
@@ -110,8 +104,7 @@ class TestProjects(TestCase):
|
||||
self.t(("add", "testing", "project:myProject"))
|
||||
self.t(("add", "testing", "project:.myProject."))
|
||||
|
||||
code, out, err = self.t(("projects",))
|
||||
|
||||
def validate_indentation(self, out):
|
||||
order = (
|
||||
".myProject ",
|
||||
".myProject. ",
|
||||
@@ -135,6 +128,30 @@ class TestProjects(TestCase):
|
||||
"indentation.{2}".format(proj, pos, out))
|
||||
)
|
||||
|
||||
def test_project_indentation(self):
|
||||
"""check project/subproject indentation in 'task projects'
|
||||
|
||||
Reported in bug 1056
|
||||
|
||||
See also the tests of helper functions for CmdProjects in util.t.cpp
|
||||
"""
|
||||
self.add_tasks()
|
||||
|
||||
code, out, err = self.t(("projects",))
|
||||
|
||||
self.validate_indentation(out)
|
||||
|
||||
def test_project_indentation_in_summary(self):
|
||||
"""check project/subproject indentation in 'task summary'
|
||||
|
||||
Reported in bug 1056
|
||||
"""
|
||||
self.add_tasks()
|
||||
|
||||
code, out, err = self.t(("summary",))
|
||||
|
||||
self.validate_indentation(out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
|
||||
@@ -33,6 +33,23 @@ import warnings
|
||||
import traceback
|
||||
|
||||
|
||||
def color(text, c):
|
||||
"""
|
||||
Add color on the keyword that identifies the state of the test
|
||||
"""
|
||||
if sys.stdout.isatty():
|
||||
clear = "\033[0m"
|
||||
|
||||
colors = {
|
||||
"red": "\033[1m\033[91m",
|
||||
"yellow": "\033[1m\033[93m",
|
||||
"green": "\033[1m\033[92m",
|
||||
}
|
||||
return colors[c] + text + clear
|
||||
else:
|
||||
return text
|
||||
|
||||
|
||||
class TAPTestResult(unittest.result.TestResult):
|
||||
def __init__(self, stream, descriptions, verbosity):
|
||||
super(TAPTestResult, self).__init__(stream, descriptions, verbosity)
|
||||
@@ -126,13 +143,20 @@ class TAPTestResult(unittest.result.TestResult):
|
||||
|
||||
if status:
|
||||
if status == "SKIP":
|
||||
self.stream.writeln("skip {0} - {1}".format(
|
||||
self.testsRun, desc))
|
||||
self.stream.writeln("{0} {1} - {2}".format(
|
||||
color("skip", "yellow"), self.testsRun, desc)
|
||||
)
|
||||
elif status == "EXPECTED_FAILURE":
|
||||
self.stream.writeln("{0} {1} - {2}".format(
|
||||
color("ok", "green"), self.testsRun, desc)
|
||||
)
|
||||
else:
|
||||
self.stream.writeln("not ok {0} - {1}".format(
|
||||
self.testsRun, desc))
|
||||
self.stream.writeln("{0} {1} - {2}".format(
|
||||
color("not ok", "red"), self.testsRun, desc)
|
||||
)
|
||||
self.stream.writeln("# {0}: {1} {2}:".format(
|
||||
status, exception_name, trace_msg))
|
||||
status, exception_name, trace_msg)
|
||||
)
|
||||
|
||||
# Magic 3 is just for pretty indentation
|
||||
padding = " " * (len(status) + 3)
|
||||
@@ -142,7 +166,9 @@ class TAPTestResult(unittest.result.TestResult):
|
||||
line = line.replace("\\n", "\n# ")
|
||||
self.stream.writeln("#{0}{1}".format(padding, line))
|
||||
else:
|
||||
self.stream.writeln("ok {0} - {1}".format(self.testsRun, desc))
|
||||
self.stream.writeln("{0} {1} - {2}".format(
|
||||
color("ok", "green"), self.testsRun, desc)
|
||||
)
|
||||
|
||||
# Flush all buffers to stdout
|
||||
self._mergeStdout()
|
||||
@@ -163,6 +189,10 @@ class TAPTestResult(unittest.result.TestResult):
|
||||
super(TAPTestResult, self).addSkip(test, reason)
|
||||
self.report(test, "SKIP", reason)
|
||||
|
||||
def addExpectedFailure(self, test, err):
|
||||
super(TAPTestResult, self).addExpectedFailure(test, err)
|
||||
self.report(test, "EXPECTED_FAILURE", err)
|
||||
|
||||
|
||||
class TAPTestRunner(unittest.runner.TextTestRunner):
|
||||
"""A test runner that displays results using the Test Anything Protocol
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
import re
|
||||
from datetime import datetime
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
@@ -41,28 +42,76 @@ class TestVersion(TestCase):
|
||||
def setUp(self):
|
||||
self.t = Task()
|
||||
|
||||
def test_version(self):
|
||||
"""Copyright is current"""
|
||||
args = ("version",)
|
||||
self.t.config("default.command", "")
|
||||
|
||||
code, out, err = self.t(args)
|
||||
def test_usage_command(self):
|
||||
"""no_command = usage - reports failure"""
|
||||
code, out, err = self.t.runError()
|
||||
|
||||
self.assertIn("You must specify a command or a task to modify", err)
|
||||
|
||||
def test_copyright_up_to_date(self):
|
||||
"""Copyright is current"""
|
||||
code, out, err = self.t(("version",))
|
||||
|
||||
expected = "Copyright \(C\) \d{4} - %d" % (datetime.now().year,)
|
||||
self.assertRegexpMatches(out.decode("utf8"), expected)
|
||||
self.assertRegexpMatches(out, expected)
|
||||
|
||||
def slurp(self, file="../CMakeLists.txt"):
|
||||
number = "\.".join(["[0-9]+"] * 3)
|
||||
ver = re.compile("^set \(PROJECT_VERSION \"({0})\"\)$".format(number))
|
||||
with open(file) as fh:
|
||||
for line in fh:
|
||||
if "PROJECT_VERSION" in line:
|
||||
match = ver.match(line)
|
||||
if match:
|
||||
return match.group(1)
|
||||
raise ValueError("Couldn't find matching version in {0}".format(file))
|
||||
|
||||
def test_version(self):
|
||||
"""version command outputs expected version and license"""
|
||||
code, out, err = self.t(("version",))
|
||||
|
||||
expected = "task {0}".format(self.slurp())
|
||||
self.assertIn(expected, out)
|
||||
self.assertIn("MIT license", out)
|
||||
self.assertIn("http://taskwarrior.org", out)
|
||||
|
||||
def slurp_git(self):
|
||||
git_cmd = ("git", "rev-parse", "--short", "--verify", "HEAD")
|
||||
_, hash, _ = run_cmd_wait(git_cmd)
|
||||
return hash.rstrip("\n")
|
||||
|
||||
def test_under_version(self):
|
||||
"""_version outputs expected version and syntax"""
|
||||
code, out, err = self.t(("_version",))
|
||||
|
||||
# version = "x.x.x (git-hash)" or simply "x.x.x"
|
||||
# corresponding to "compiled from git" or "compiled from tarball"
|
||||
version = out.split()
|
||||
|
||||
if 2 >= len(version) > 0:
|
||||
git = version[1]
|
||||
git_expected = "({0})".format(self.slurp_git())
|
||||
self.assertEqual(git_expected, git)
|
||||
else:
|
||||
raise ValueError("Unexpected output from _version '{0}'".format(
|
||||
out))
|
||||
|
||||
ver = version[0]
|
||||
ver_expected = self.slurp()
|
||||
self.assertEqual(ver_expected, ver)
|
||||
|
||||
def test_task_git_version(self):
|
||||
"""Task binary matches the current git commit"""
|
||||
|
||||
git_cmd = ("git", "rev-parse", "--short", "--verify", "HEAD")
|
||||
_, hash, _ = run_cmd_wait(git_cmd)
|
||||
|
||||
expected = "Commit: {0}".format(hash)
|
||||
expected = "Commit: {0}".format(self.slurp_git())
|
||||
|
||||
args = ("diag",)
|
||||
|
||||
code, out, err = self.t(args)
|
||||
self.assertIn(expected, out)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
Reference in New Issue
Block a user