From 87e95786669c2cd529d98c9e776d17771bb8637a Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sat, 7 Mar 2015 13:29:59 -0500 Subject: [PATCH] Unit Tests - Combined all the separate color rule tests into one script, and converted it to Python. --- test/color.active.t | 57 ----------- test/color.blocked.t | 58 ----------- test/color.disable.t | 62 ------------ test/color.due.t | 57 ----------- test/color.err.t | 62 ------------ test/color.keyword.t | 66 ------------ test/color.overdue.t | 57 ----------- test/color.pri.t | 64 ------------ test/color.project.t | 58 ----------- test/color.recurring.t | 57 ----------- test/color.rules.t | 222 +++++++++++++++++++++++++++++++++++++++++ test/color.tag.t | 62 ------------ test/color.tagged.t | 60 ----------- test/color.uda.t | 63 ------------ 14 files changed, 222 insertions(+), 783 deletions(-) delete mode 100755 test/color.active.t delete mode 100755 test/color.blocked.t delete mode 100755 test/color.disable.t delete mode 100755 test/color.due.t delete mode 100755 test/color.err.t delete mode 100755 test/color.keyword.t delete mode 100755 test/color.overdue.t delete mode 100755 test/color.pri.t delete mode 100755 test/color.project.t delete mode 100755 test/color.recurring.t create mode 100755 test/color.rules.t delete mode 100755 test/color.tag.t delete mode 100755 test/color.tagged.t delete mode 100755 test/color.uda.t diff --git a/test/color.active.t b/test/color.active.t deleted file mode 100755 index 5dcdf0511..000000000 --- a/test/color.active.t +++ /dev/null @@ -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; - diff --git a/test/color.blocked.t b/test/color.blocked.t deleted file mode 100755 index 6d32c845d..000000000 --- a/test/color.blocked.t +++ /dev/null @@ -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; - diff --git a/test/color.disable.t b/test/color.disable.t deleted file mode 100755 index ca6d3dd4c..000000000 --- a/test/color.disable.t +++ /dev/null @@ -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; - diff --git a/test/color.due.t b/test/color.due.t deleted file mode 100755 index e22259a7a..000000000 --- a/test/color.due.t +++ /dev/null @@ -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; - diff --git a/test/color.err.t b/test/color.err.t deleted file mode 100755 index 22f14b7dc..000000000 --- a/test/color.err.t +++ /dev/null @@ -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; - diff --git a/test/color.keyword.t b/test/color.keyword.t deleted file mode 100755 index 17c15511b..000000000 --- a/test/color.keyword.t +++ /dev/null @@ -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; - diff --git a/test/color.overdue.t b/test/color.overdue.t deleted file mode 100755 index a88233f14..000000000 --- a/test/color.overdue.t +++ /dev/null @@ -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; - diff --git a/test/color.pri.t b/test/color.pri.t deleted file mode 100755 index a6071f303..000000000 --- a/test/color.pri.t +++ /dev/null @@ -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; - diff --git a/test/color.project.t b/test/color.project.t deleted file mode 100755 index 3f80d6873..000000000 --- a/test/color.project.t +++ /dev/null @@ -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; - diff --git a/test/color.recurring.t b/test/color.recurring.t deleted file mode 100755 index 9a4cda1b4..000000000 --- a/test/color.recurring.t +++ /dev/null @@ -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; - diff --git a/test/color.rules.t b/test/color.rules.t new file mode 100755 index 000000000..8e9f121fa --- /dev/null +++ b/test/color.rules.t @@ -0,0 +1,222 @@ +#!/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.pri.H', 'red') + cls.t.config('color.pri.M', 'blue') + cls.t.config('color.pri.L', 'green') + cls.t.config('color.keyword.keyword', 'red') + 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 diff --git a/test/color.tag.t b/test/color.tag.t deleted file mode 100755 index 8fe8b919f..000000000 --- a/test/color.tag.t +++ /dev/null @@ -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; - diff --git a/test/color.tagged.t b/test/color.tagged.t deleted file mode 100755 index a96827af0..000000000 --- a/test/color.tagged.t +++ /dev/null @@ -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; - diff --git a/test/color.uda.t b/test/color.uda.t deleted file mode 100755 index cad6f1194..000000000 --- a/test/color.uda.t +++ /dev/null @@ -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; -