mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-08-02 14:38:34 +02:00
Enhancement - annotations
- Added support for "annotate" command to annotate existing tasks. - Bumped file format to version 3, due to the annotations. - Added unit tests to verify that annotations work. - Changed 'description' column everywhere to include annotations. - Added 'description_only' column to exclude the annotations. - Fixed bug in Table.cpp that calculated the width of multi-line columns by using the cell length, instead of the length of the longest individual line. - Updated documentation with new feature. - Updated documentation with new column. - Enhanced t.t unit tests to cover format 43
This commit is contained in:
parent
ca795ea281
commit
3979c3283e
16 changed files with 446 additions and 54 deletions
74
src/tests/annotate.t
Executable file
74
src/tests/annotate.t
Executable file
|
@ -0,0 +1,74 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## task - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2009, Paul Beckingham.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 8;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'annotate.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"report.r.description=r\n",
|
||||
"report.r.columns=id,description\n",
|
||||
"report.r.sort=id+\n";
|
||||
close $fh;
|
||||
ok (-r 'annotate.rc', 'Created annotate.rc');
|
||||
}
|
||||
|
||||
# Add two tasks, annotate one twice.
|
||||
qx{../task rc:annotate.rc add one};
|
||||
qx{../task rc:annotate.rc add two};
|
||||
qx{../task rc:annotate.rc annotate 1 foo};
|
||||
sleep 2;
|
||||
qx{../task rc:annotate.rc annotate 1 bar};
|
||||
my $output = qx{../task rc:annotate.rc r};
|
||||
|
||||
# ID Description
|
||||
# -- -------------------------------
|
||||
# 1 one
|
||||
# 3/24/2009 foo
|
||||
# 3/24/2009 bar
|
||||
# 2 two
|
||||
#
|
||||
# 2 tasks
|
||||
like ($output, qr/1 one/, 'task 1');
|
||||
like ($output, qr/2 two/, 'task 2');
|
||||
like ($output, qr/one.+\d{1,2}\/\d{1,2}\/\d{4} foo/ms, 'first annotation');
|
||||
like ($output, qr/foo.+\d{1,2}\/\d{1,2}\/\d{4} bar/ms, 'second annotation');
|
||||
like ($output, qr/2 tasks/, 'count');
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'annotate.rc';
|
||||
ok (!-r 'annotate.rc', 'Removed annotate.rc');
|
||||
|
||||
exit 0;
|
||||
|
|
@ -31,11 +31,11 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
UnitTest test (5);
|
||||
UnitTest test (8);
|
||||
|
||||
T t;
|
||||
std::string s = t.compose ();
|
||||
test.is ((int)s.length (), 46, "T::T (); T::compose ()");
|
||||
test.is ((int)s.length (), 49, "T::T (); T::compose ()");
|
||||
test.diag (s);
|
||||
|
||||
t.setStatus (T::completed);
|
||||
|
@ -54,11 +54,26 @@ int main (int argc, char** argv)
|
|||
test.diag (s);
|
||||
|
||||
// Round trip test.
|
||||
std::string sample = "00000000-0000-0000-0000-000000000000 - [] [] Sample";
|
||||
std::string sample = "00000000-0000-0000-0000-000000000000 - [] [] [] Sample";
|
||||
T t2;
|
||||
t2.parse (sample);
|
||||
sample += "\n";
|
||||
test.is (t2.compose (), sample, "T::parse -> T::compose round trip");
|
||||
|
||||
// b10b3236-70d8-47bb-840a-b4c430758fb6 - [foo] [bar:baz] [1237865996:'woof'] sample\n
|
||||
// ....:....|....:....|....:....|....:....|....:....|....:....|....:....|....:....|....:....|
|
||||
// ^ ^ ^
|
||||
// 0 36 66
|
||||
t.setStatus (T::pending);
|
||||
t.addTag ("foo");
|
||||
t.setAttribute ("bar", "baz");
|
||||
t.addAnnotation ("woof");
|
||||
t.setDescription ("sample");
|
||||
std::string format = t.compose ();
|
||||
test.is (format.substr (36, 20), " - [foo] [bar:baz] [", "compose tag, attribute");
|
||||
test.is (format.substr (66, 16), ":'woof'] sample\n", "compose annotation");
|
||||
test.is (t.getAnnotationCount (), 1, "annotation count");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue