mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Bug Fixes, Unit Tests
- Fixed bug where "foo:bar" was not recognized as an attribute, and generated an error rather than demoting is to part of the description. - Fixed bug where en-passant deltas were applied only to the first task in a sequence. - Fixed various unit test.
This commit is contained in:
parent
1511c1fcfd
commit
9c2e70b73a
9 changed files with 53 additions and 39 deletions
|
@ -239,7 +239,8 @@ bool Att::validNameValue (
|
||||||
autoComplete (name, candidates, matches);
|
autoComplete (name, candidates, matches);
|
||||||
|
|
||||||
if (matches.size () == 0)
|
if (matches.size () == 0)
|
||||||
throw std::string ("Unrecognized attribute '") + name + "'";
|
// throw std::string ("Unrecognized attribute '") + name + "'";
|
||||||
|
return false;
|
||||||
|
|
||||||
else if (matches.size () != 1)
|
else if (matches.size () != 1)
|
||||||
{
|
{
|
||||||
|
|
|
@ -428,12 +428,26 @@ void Context::parse (
|
||||||
std::string name = attribute.name ();
|
std::string name = attribute.name ();
|
||||||
std::string mod = attribute.mod ();
|
std::string mod = attribute.mod ();
|
||||||
std::string value = attribute.value ();
|
std::string value = attribute.value ();
|
||||||
attribute.validNameValue (name, mod, value);
|
if (attribute.validNameValue (name, mod, value))
|
||||||
attribute.name (name);
|
{
|
||||||
attribute.mod (mod);
|
attribute.name (name);
|
||||||
attribute.value (value);
|
attribute.mod (mod);
|
||||||
|
attribute.value (value);
|
||||||
|
|
||||||
parseTask[attribute.name ()] = attribute;
|
parseTask[attribute.name ()] = attribute;
|
||||||
|
}
|
||||||
|
|
||||||
|
// *arg has the appearance of an attribute (foo:bar), but isn't
|
||||||
|
// recognized, so downgrade it to part of the description.
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (foundSequence)
|
||||||
|
foundSomethingAfterSequence = true;
|
||||||
|
|
||||||
|
if (descCandidate.length ())
|
||||||
|
descCandidate += " ";
|
||||||
|
descCandidate += *arg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Substitution of description and/or annotation text.
|
// Substitution of description and/or annotation text.
|
||||||
|
|
|
@ -661,11 +661,7 @@ std::string handleDone ()
|
||||||
{
|
{
|
||||||
// Apply deltas.
|
// Apply deltas.
|
||||||
deltaDescription (*task);
|
deltaDescription (*task);
|
||||||
context.task.remove ("description");
|
|
||||||
|
|
||||||
deltaTags (*task);
|
deltaTags (*task);
|
||||||
context.task.remove ("tags");
|
|
||||||
|
|
||||||
deltaAttributes (*task);
|
deltaAttributes (*task);
|
||||||
deltaSubstitutions (*task);
|
deltaSubstitutions (*task);
|
||||||
|
|
||||||
|
@ -799,11 +795,7 @@ std::string handleModify ()
|
||||||
|
|
||||||
// Apply other deltas.
|
// Apply other deltas.
|
||||||
changes += deltaDescription (*other);
|
changes += deltaDescription (*other);
|
||||||
context.task.remove ("description");
|
|
||||||
|
|
||||||
changes += deltaTags (*other);
|
changes += deltaTags (*other);
|
||||||
context.task.remove ("tags");
|
|
||||||
|
|
||||||
changes += deltaAttributes (*other);
|
changes += deltaAttributes (*other);
|
||||||
changes += deltaSubstitutions (*other);
|
changes += deltaSubstitutions (*other);
|
||||||
|
|
||||||
|
@ -853,11 +845,7 @@ std::string handleAppend ()
|
||||||
|
|
||||||
// Apply other deltas.
|
// Apply other deltas.
|
||||||
changes += deltaAppend (*other);
|
changes += deltaAppend (*other);
|
||||||
context.task.remove ("description");
|
|
||||||
|
|
||||||
changes += deltaTags (*other);
|
changes += deltaTags (*other);
|
||||||
context.task.remove ("tags");
|
|
||||||
|
|
||||||
changes += deltaAttributes (*other);
|
changes += deltaAttributes (*other);
|
||||||
|
|
||||||
if (changes)
|
if (changes)
|
||||||
|
@ -924,11 +912,7 @@ std::string handleDuplicate ()
|
||||||
|
|
||||||
// Apply deltas.
|
// Apply deltas.
|
||||||
deltaDescription (dup);
|
deltaDescription (dup);
|
||||||
context.task.remove ("description");
|
|
||||||
|
|
||||||
deltaTags (dup);
|
deltaTags (dup);
|
||||||
context.task.remove ("tags");
|
|
||||||
|
|
||||||
deltaAttributes (dup);
|
deltaAttributes (dup);
|
||||||
deltaSubstitutions (dup);
|
deltaSubstitutions (dup);
|
||||||
|
|
||||||
|
@ -1137,7 +1121,9 @@ int deltaAttributes (Task& task)
|
||||||
|
|
||||||
foreach (att, context.task)
|
foreach (att, context.task)
|
||||||
{
|
{
|
||||||
if (att->first != "uuid")
|
if (att->first != "uuid" &&
|
||||||
|
att->first != "description" &&
|
||||||
|
att->first != "tags")
|
||||||
{
|
{
|
||||||
if (att->second.value () == "")
|
if (att->second.value () == "")
|
||||||
task.remove (att->first);
|
task.remove (att->first);
|
||||||
|
|
|
@ -210,7 +210,7 @@ int main (int argc, char** argv)
|
||||||
n = Nibbler ("name:");
|
n = Nibbler ("name:");
|
||||||
good = true;
|
good = true;
|
||||||
try {a7.parse (n);} catch (...) {good = false;}
|
try {a7.parse (n);} catch (...) {good = false;}
|
||||||
t.notok (good, "Att::parse (name:)");
|
t.ok (good, "Att::parse (name:)");
|
||||||
|
|
||||||
n = Nibbler ("name:\"value");
|
n = Nibbler ("name:\"value");
|
||||||
good = true;
|
good = true;
|
||||||
|
|
|
@ -41,13 +41,13 @@ if (open my $fh, '>', 'basic.rc')
|
||||||
# Test the usage command.
|
# Test the usage command.
|
||||||
my $output = qx{../task rc:basic.rc};
|
my $output = qx{../task rc:basic.rc};
|
||||||
like ($output, qr/Usage: task/, 'usage');
|
like ($output, qr/Usage: task/, 'usage');
|
||||||
like ($output, qr/http:\/\/www\.beckingham\.net\/task\.html/, 'usage - url');
|
like ($output, qr/http:\/\/taskwarrior\.org/, 'usage - url');
|
||||||
|
|
||||||
# Test the version command.
|
# Test the version command.
|
||||||
$output = qx{../task rc:basic.rc version};
|
$output = qx{../task rc:basic.rc version};
|
||||||
like ($output, qr/task \d+\.\d+\.\d+/, 'version - task version number');
|
like ($output, qr/task \d+\.\d+\.\d+/, 'version - task version number');
|
||||||
like ($output, qr/ABSOLUTELY NO WARRANTY/, 'version - warranty');
|
like ($output, qr/ABSOLUTELY NO WARRANTY/, 'version - warranty');
|
||||||
like ($output, qr/http:\/\/www\.beckingham\.net\/task\.html/, 'version - url');
|
like ($output, qr/http:\/\/taskwarrior\.org/, 'version - url');
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
unlink 'basic.rc';
|
unlink 'basic.rc';
|
||||||
|
|
|
@ -38,3 +38,16 @@
|
||||||
ok 3 - Removed completed.data
|
ok 3 - Removed completed.data
|
||||||
ok 4 - Removed bench.rc
|
ok 4 - Removed bench.rc
|
||||||
|
|
||||||
|
6/18/2009
|
||||||
|
1.8.0:
|
||||||
|
1..4
|
||||||
|
ok 1 - Created bench.rc
|
||||||
|
# start=1245372501
|
||||||
|
# 1000 tasks added in 4 seconds
|
||||||
|
# 600 tasks altered in 45 seconds
|
||||||
|
# stop=1245372747
|
||||||
|
# total=246
|
||||||
|
ok 2 - Removed pending.data
|
||||||
|
ok 3 - Removed completed.data
|
||||||
|
ok 4 - Removed bench.rc
|
||||||
|
|
||||||
|
|
|
@ -57,14 +57,14 @@ if (open my $fh, '>', 'annual.rc')
|
||||||
|
|
||||||
qx{../task rc:annual.rc add foo due:1/1/2000 recur:annual until:1/1/2009};
|
qx{../task rc:annual.rc add foo due:1/1/2000 recur:annual until:1/1/2009};
|
||||||
my $output = qx{../task rc:annual.rc list};
|
my $output = qx{../task rc:annual.rc list};
|
||||||
like ($output, qr/2\s+1\/1\/2000\s+- foo/, 'synthetic 1 no creep');
|
like ($output, qr/2\s+1\/1\/2000\s+- foo/, 'synthetic 1 no creep');
|
||||||
like ($output, qr/3\s+1\/1\/2001\s+- foo/, 'synthetic 2 no creep');
|
like ($output, qr/3\s+1\/1\/2001\s+- foo/, 'synthetic 2 no creep');
|
||||||
like ($output, qr/4\s+1\/1\/2002\s+- foo/, 'synthetic 3 no creep');
|
like ($output, qr/4\s+1\/1\/2002\s+- foo/, 'synthetic 3 no creep');
|
||||||
like ($output, qr/5\s+1\/1\/2003\s+- foo/, 'synthetic 4 no creep');
|
like ($output, qr/5\s+1\/1\/2003\s+- foo/, 'synthetic 4 no creep');
|
||||||
like ($output, qr/6\s+1\/1\/2004\s+- foo/, 'synthetic 5 no creep');
|
like ($output, qr/6\s+1\/1\/2004\s+- foo/, 'synthetic 5 no creep');
|
||||||
like ($output, qr/7\s+1\/1\/2005\s+- foo/, 'synthetic 6 no creep');
|
like ($output, qr/7\s+1\/1\/2005\s+- foo/, 'synthetic 6 no creep');
|
||||||
like ($output, qr/8\s+1\/1\/2006\s+- foo/, 'synthetic 7 no creep');
|
like ($output, qr/8\s+1\/1\/2006\s+- foo/, 'synthetic 7 no creep');
|
||||||
like ($output, qr/9\s+1\/1\/2007\s+- foo/, 'synthetic 8 no creep');
|
like ($output, qr/9\s+1\/1\/2007\s+- foo/, 'synthetic 8 no creep');
|
||||||
like ($output, qr/10\s+1\/1\/2008\s+- foo/, 'synthetic 9 no creep');
|
like ($output, qr/10\s+1\/1\/2008\s+- foo/, 'synthetic 9 no creep');
|
||||||
like ($output, qr/11\s+1\/1\/2009\s+- foo/, 'synthetic 10 no creep');
|
like ($output, qr/11\s+1\/1\/2009\s+- foo/, 'synthetic 10 no creep');
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ use Test::More tests => 16;
|
||||||
if (open my $fh, '>', 'default.rc')
|
if (open my $fh, '>', 'default.rc')
|
||||||
{
|
{
|
||||||
print $fh "data.location=.\n",
|
print $fh "data.location=.\n",
|
||||||
"default.command=list\n",
|
"default.command=rc:default.rc list\n",
|
||||||
"default.project=PROJECT\n",
|
"default.project=PROJECT\n",
|
||||||
"default.priority=M\n";
|
"default.priority=M\n";
|
||||||
close $fh;
|
close $fh;
|
||||||
|
|
|
@ -46,21 +46,21 @@ like ($output, qr/Status\s+Pending\n/, 'Pending');
|
||||||
|
|
||||||
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc info 1};
|
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc info 1};
|
||||||
like ($output, qr/Status\s+Deleted\n/, 'Deleted');
|
like ($output, qr/Status\s+Deleted\n/, 'Deleted');
|
||||||
ok (! -r 'completed.data', 'completed.data not created');
|
ok (-r 'completed.data', 'completed.data created');
|
||||||
|
|
||||||
$output = qx{../task rc:undelete.rc undelete 1; ../task rc:undelete.rc info 1};
|
$output = qx{../task rc:undelete.rc undelete 1; ../task rc:undelete.rc info 1};
|
||||||
like ($output, qr/Status\s+Pending\n/, 'Pending');
|
like ($output, qr/Status\s+Pending\n/, 'Pending');
|
||||||
ok (! -r 'completed.data', 'completed.data not created');
|
ok (-r 'completed.data', 'completed.data created');
|
||||||
|
|
||||||
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc list};
|
$output = qx{../task rc:undelete.rc delete 1; ../task rc:undelete.rc list};
|
||||||
like ($output, qr/^No matches/, 'No matches');
|
like ($output, qr/No matches./, 'No matches');
|
||||||
ok (-r 'completed.data', 'completed.data created');
|
ok (-r 'completed.data', 'completed.data created');
|
||||||
|
|
||||||
$output = qx{../task rc:undelete.rc undelete 1};
|
$output = qx{../task rc:undelete.rc undelete 1};
|
||||||
like ($output, qr/Task 1 not found/, 'Task 1 not found');
|
like ($output, qr/Task 1 not found/, 'Task 1 not found');
|
||||||
|
|
||||||
$output = qx{../task rc:undelete.rc info 1};
|
$output = qx{../task rc:undelete.rc info 1};
|
||||||
like ($output, qr/No matches./, 'no matches');
|
like ($output, qr/Task 1 not found/, 'No matches');
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
ok (-r 'pending.data', 'Need to remove pending.data');
|
ok (-r 'pending.data', 'Need to remove pending.data');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue