Code Cleanup

- Remove duplicate modify call to TDB2.
- Check if quitting in bulk change only if permission fails.
- Correct test logic (the unit for each operation is the second, not the day).
- Consistency in test for feature.1013.t
- Correctly color deleted tasks.

test
This commit is contained in:
Louis-Claude Canon 2012-07-03 17:33:21 +02:00 committed by Paul Beckingham
parent 39456a3243
commit 160260ff48
13 changed files with 34 additions and 35 deletions

View file

@ -117,10 +117,10 @@ int CmdAnnotate::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_ANNO_NO << "\n"; std::cout << STRING_CMD_ANNO_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
// Now list the project changes. // Now list the project changes.

View file

@ -117,10 +117,10 @@ int CmdAppend::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_APPEND_NO << "\n"; std::cout << STRING_CMD_APPEND_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
// Now list the project changes. // Now list the project changes.

View file

@ -141,10 +141,10 @@ int CmdDelete::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_DELETE_NO << "\n"; std::cout << STRING_CMD_DELETE_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
else else
{ {

View file

@ -130,10 +130,10 @@ int CmdDenotate::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_DENO_NO << "\n"; std::cout << STRING_CMD_DENO_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
else else
{ {

View file

@ -99,7 +99,6 @@ int CmdDone::execute (std::string& output)
++count; ++count;
feedback_affected (STRING_CMD_DONE_TASK, *task); feedback_affected (STRING_CMD_DONE_TASK, *task);
feedback_unblocked (*task); feedback_unblocked (*task);
context.tdb2.modify (*task);
if (!nagged) if (!nagged)
nagged = nag (*task); nagged = nag (*task);
dependencyChainOnComplete (*task); dependencyChainOnComplete (*task);
@ -109,10 +108,10 @@ int CmdDone::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_DONE_NO << "\n"; std::cout << STRING_CMD_DONE_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
else else
{ {

View file

@ -123,10 +123,10 @@ int CmdDuplicate::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_DUPLICATE_NO << "\n"; std::cout << STRING_CMD_DUPLICATE_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
// Now list the project changes. // Now list the project changes.

View file

@ -160,10 +160,10 @@ int CmdModify::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_MODIFY_NO << "\n"; std::cout << STRING_CMD_MODIFY_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
} }

View file

@ -117,10 +117,10 @@ int CmdPrepend::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_PREPEND_NO << "\n"; std::cout << STRING_CMD_PREPEND_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
// Now list the project changes. // Now list the project changes.

View file

@ -102,10 +102,10 @@ int CmdStart::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_START_NO << "\n"; std::cout << STRING_CMD_START_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
else else
{ {

View file

@ -98,10 +98,10 @@ int CmdStop::execute (std::string& output)
else else
{ {
std::cout << STRING_CMD_STOP_NO << "\n"; std::cout << STRING_CMD_STOP_NO << "\n";
rc = 1; rc = 1;
if (_permission_quit)
break;
} }
if (_permission_quit)
break;
} }
else else
{ {

View file

@ -273,7 +273,7 @@ static void colorizeCompleted (Task& task, const Color& base, Color& c)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
static void colorizeDeleted (Task& task, const Color& base, Color& c) static void colorizeDeleted (Task& task, const Color& base, Color& c)
{ {
if (task.getStatus () == Task::completed) if (task.getStatus () == Task::deleted)
c.blend (base); c.blend (base);
} }

View file

@ -41,7 +41,7 @@ int main (int argc, char** argv)
{ {
Date now; Date now;
Date yesterday; Date yesterday;
yesterday -= 1; yesterday -= 86400;
t.ok (yesterday <= now, "yesterday <= now"); t.ok (yesterday <= now, "yesterday <= now");
t.ok (yesterday < now, "yesterday < now"); t.ok (yesterday < now, "yesterday < now");
@ -140,7 +140,7 @@ int main (int argc, char** argv)
t.is (happyNewYear.day (), 1, "1/1/2008 == 1"); t.is (happyNewYear.day (), 1, "1/1/2008 == 1");
t.is (happyNewYear.year (), 2008, "1/1/2008 == 2008"); t.is (happyNewYear.year (), 2008, "1/1/2008 == 2008");
t.is (now - yesterday, 1, "today - yesterday == 1"); t.is (now - yesterday, 86400, "today - yesterday == 1");
t.is (happyNewYear.toString (), "1/1/2008", "toString 1/1/2008"); t.is (happyNewYear.toString (), "1/1/2008", "toString 1/1/2008");

View file

@ -61,7 +61,7 @@ like ($stderr, qr/^Configuration override rc.debug:on$/ms, 'Footnotes are sent t
# Check that debugs are sent to standard error # Check that debugs are sent to standard error
$stdout = qx{../src/task rc:outerr.rc rc.debug:on list 2> /dev/null}; $stdout = qx{../src/task rc:outerr.rc rc.debug:on list 2> /dev/null};
unlike ($stdout, qr/^Perf task /ms, 'Debugs are not sent to stdout'); unlike ($stdout, qr/^Timer Config::load \(outerr.rc\) /ms, 'Debugs are not sent to stdout');
$stderr = qx{../src/task rc:outerr.rc rc.debug:on list 2>&1 >/dev/null}; $stderr = qx{../src/task rc:outerr.rc rc.debug:on list 2>&1 >/dev/null};
like ($stderr, qr/^Timer Config::load \(outerr.rc\) /ms, 'Debugs are sent to stderr'); like ($stderr, qr/^Timer Config::load \(outerr.rc\) /ms, 'Debugs are sent to stderr');