Annotation Collisions

- Annotation timestamps are now incremented until unique.  This prevents
  rapid, successive annotations colliding.  The kind that occur during
  unit tests and when using UI wrapper programs.
- Removed 'sleep' commands in unit tests that were added to circumvent
  this.  This speeds up the test suite somewhat.
This commit is contained in:
Paul Beckingham 2011-08-13 21:53:10 -04:00
parent cb366e0270
commit be0522d567
6 changed files with 12 additions and 30 deletions

View file

@ -762,12 +762,21 @@ void Task::setAnnotations (const std::map <std::string, std::string>& annotation
// The timestamp is part of the name: // The timestamp is part of the name:
// annotation_1234567890:"..." // annotation_1234567890:"..."
// //
// Note that the time is incremented (one second) in order to find a unique
// timestamp.
void Task::addAnnotation (const std::string& description) void Task::addAnnotation (const std::string& description)
{ {
std::stringstream s; time_t now = time (NULL);
s << "annotation_" << time (NULL); std::string key;
(*this)[s.str ()] = description; do
{
key = "annotation_" + format ((int) now);
++now;
}
while (has (key));
(*this)[key] = description;
recalc_urgency = true; recalc_urgency = true;
} }

View file

@ -51,16 +51,10 @@ qx{../src/task rc:annotate.rc add two};
qx{../src/task rc:annotate.rc add three}; qx{../src/task rc:annotate.rc add three};
qx{../src/task rc:annotate.rc add four}; qx{../src/task rc:annotate.rc add four};
qx{../src/task rc:annotate.rc 1 annotate foo1}; qx{../src/task rc:annotate.rc 1 annotate foo1};
diag ("5 second delay");
sleep 1;
qx{../src/task rc:annotate.rc 1 annotate foo2}; qx{../src/task rc:annotate.rc 1 annotate foo2};
sleep 1;
qx{../src/task rc:annotate.rc 1 annotate foo3}; qx{../src/task rc:annotate.rc 1 annotate foo3};
sleep 1;
qx{../src/task rc:annotate.rc 2 annotate bar1}; qx{../src/task rc:annotate.rc 2 annotate bar1};
sleep 1;
qx{../src/task rc:annotate.rc 2 annotate bar2}; qx{../src/task rc:annotate.rc 2 annotate bar2};
sleep 1;
qx{../src/task rc:annotate.rc 3 annotate baz1}; qx{../src/task rc:annotate.rc 3 annotate baz1};
my $output = qx{../src/task rc:annotate.rc rrr}; my $output = qx{../src/task rc:annotate.rc rrr};

View file

@ -42,12 +42,9 @@ if (open my $fh, '>', 'bug.rc')
# Bug 703: /from/t/g fails to make all changes to annotations # Bug 703: /from/t/g fails to make all changes to annotations
# Setup: Add a few tasks # Setup: Add a few tasks
diag ("2 second delay");
qx{../src/task rc:bug.rc add This is a test}; qx{../src/task rc:bug.rc add This is a test};
qx{../src/task rc:bug.rc 1 annotate Annotation one}; qx{../src/task rc:bug.rc 1 annotate Annotation one};
sleep 1;
qx{../src/task rc:bug.rc 1 annotate Annotation two}; qx{../src/task rc:bug.rc 1 annotate Annotation two};
sleep 1;
qx{../src/task rc:bug.rc 1 annotate Annotation three}; qx{../src/task rc:bug.rc 1 annotate Annotation three};
my $output = qx{../src/task rc:bug.rc list}; my $output = qx{../src/task rc:bug.rc list};

View file

@ -49,8 +49,6 @@ qx{../src/task rc:hasnt.rc 2 annotate bar};
# 3 # 3
qx{../src/task rc:hasnt.rc add foo}; qx{../src/task rc:hasnt.rc add foo};
qx{../src/task rc:hasnt.rc 3 annotate bar}; qx{../src/task rc:hasnt.rc 3 annotate bar};
diag ("3 second delay");
sleep 1;
qx{../src/task rc:hasnt.rc 3 annotate baz}; qx{../src/task rc:hasnt.rc 3 annotate baz};
# 4 # 4
@ -63,13 +61,11 @@ qx{../src/task rc:hasnt.rc 5 annotate foo};
# 6 # 6
qx{../src/task rc:hasnt.rc add bar}; qx{../src/task rc:hasnt.rc add bar};
qx{../src/task rc:hasnt.rc 6 annotate foo}; qx{../src/task rc:hasnt.rc 6 annotate foo};
sleep 1;
qx{../src/task rc:hasnt.rc 6 annotate baz}; qx{../src/task rc:hasnt.rc 6 annotate baz};
#7 #7
qx{../src/task rc:hasnt.rc add one}; qx{../src/task rc:hasnt.rc add one};
qx{../src/task rc:hasnt.rc 7 annotate two}; qx{../src/task rc:hasnt.rc 7 annotate two};
sleep 1;
qx{../src/task rc:hasnt.rc 7 annotate three}; qx{../src/task rc:hasnt.rc 7 annotate three};
my $output = qx{../src/task rc:hasnt.rc ls description.has:foo}; my $output = qx{../src/task rc:hasnt.rc ls description.has:foo};

View file

@ -47,18 +47,11 @@ if (open my $fh, '>', 'denotate.rc')
# Add four tasks, annotate one three times, one twice, one just once and one none. # Add four tasks, annotate one three times, one twice, one just once and one none.
qx{../src/task rc:denotate.rc add one}; qx{../src/task rc:denotate.rc add one};
qx{../src/task rc:denotate.rc 1 annotate Ernie}; qx{../src/task rc:denotate.rc 1 annotate Ernie};
diag ("6 second delay");
sleep 1;
qx{../src/task rc:denotate.rc 1 annotate Bert}; qx{../src/task rc:denotate.rc 1 annotate Bert};
sleep 1;
qx{../src/task rc:denotate.rc 1 annotate Bibo}; qx{../src/task rc:denotate.rc 1 annotate Bibo};
sleep 1;
qx{../src/task rc:denotate.rc 1 annotate Kermit the frog}; qx{../src/task rc:denotate.rc 1 annotate Kermit the frog};
sleep 1;
qx{../src/task rc:denotate.rc 1 annotate Kermit the frog}; qx{../src/task rc:denotate.rc 1 annotate Kermit the frog};
sleep 1;
qx{../src/task rc:denotate.rc 1 annotate Kermit}; qx{../src/task rc:denotate.rc 1 annotate Kermit};
sleep 1;
qx{../src/task rc:denotate.rc 1 annotate Kermit and Miss Piggy}; qx{../src/task rc:denotate.rc 1 annotate Kermit and Miss Piggy};
my $output = qx{../src/task rc:denotate.rc rrr}; my $output = qx{../src/task rc:denotate.rc rrr};

View file

@ -120,22 +120,15 @@ qx{../src/task rc:urgency.rc add 6a}; # task 12
qx{../src/task rc:urgency.rc 12 annotate A}; qx{../src/task rc:urgency.rc 12 annotate A};
qx{../src/task rc:urgency.rc add 6b}; # task 13 qx{../src/task rc:urgency.rc add 6b}; # task 13
qx{../src/task rc:urgency.rc 13 annotate A}; qx{../src/task rc:urgency.rc 13 annotate A};
diag ("6 second delay");
sleep 1;
qx{../src/task rc:urgency.rc 13 annotate B}; qx{../src/task rc:urgency.rc 13 annotate B};
qx{../src/task rc:urgency.rc add 6c}; # task 14 qx{../src/task rc:urgency.rc add 6c}; # task 14
qx{../src/task rc:urgency.rc 14 annotate A}; qx{../src/task rc:urgency.rc 14 annotate A};
sleep 1;
qx{../src/task rc:urgency.rc 14 annotate B}; qx{../src/task rc:urgency.rc 14 annotate B};
sleep 1;
qx{../src/task rc:urgency.rc 14 annotate C}; qx{../src/task rc:urgency.rc 14 annotate C};
qx{../src/task rc:urgency.rc add 6d}; # task 15 qx{../src/task rc:urgency.rc add 6d}; # task 15
qx{../src/task rc:urgency.rc 15 annotate A}; qx{../src/task rc:urgency.rc 15 annotate A};
sleep 1;
qx{../src/task rc:urgency.rc 15 annotate B}; qx{../src/task rc:urgency.rc 15 annotate B};
sleep 1;
qx{../src/task rc:urgency.rc 15 annotate C}; qx{../src/task rc:urgency.rc 15 annotate C};
sleep 1;
qx{../src/task rc:urgency.rc 15 annotate D}; qx{../src/task rc:urgency.rc 15 annotate D};
# annotations: 8 (1 annotation) + 10 (pending) # annotations: 8 (1 annotation) + 10 (pending)