From 612c613764f8313079f2b670782f91708a2f8462 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Tue, 17 Aug 2010 21:36:58 -0400 Subject: [PATCH] Dependencies - Improved a few of the unit tests. - Minor progress on the support functions. --- ChangeLog | 4 ++-- src/dependency.cpp | 35 +++++++++++++++++++++++++---------- src/tests/dependencies.t | 12 +++++++----- 3 files changed, 34 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index ee59d543a..5b617ede2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -6,8 +6,8 @@ '1 month', '4d' for 'due', 'wait' and 'until' dates. Essentially durations are now allowed where dates are expected, and are treated as relative to the current date/time. - + Added feature #189, that records the start and stop times - as an annotation for a task. + + Added feature #189, that records the start and stop times as an + annotation for a task. + Added features #244, #272, #274 and #275, which support import and export of YAML 1.1. YAML is now the default export format for task. + Added feature #391, now the 'task color legend' command will show diff --git a/src/dependency.cpp b/src/dependency.cpp index 532a01b33..19d01b82f 100644 --- a/src/dependency.cpp +++ b/src/dependency.cpp @@ -64,18 +64,33 @@ bool dependencyIsBlocking (Task& task) //////////////////////////////////////////////////////////////////////////////// // Follow each of the given task's dependencies to the end of the chain, and if // any duplicates show up, or the chain length exceeds N, stop. -bool dependencyCheckCircular (Task& task) + +/* + Linear: + 1->2 + + 1->2->3->4 + `->5->6 + `->7 + + Circular: + 1->1 + + 1->2->1 + + 1->2->3 + `->1 + + Algorithm: + 1. Generate a subset of all task that have dependencies + 2. Find the heads of all the chains + 3. For each unique chain head + 3.1 Walk the chain recording IDs + 3.2 Duplicate ID => circular +*/ +bool dependencyIsCircular (Task& task) { - int maximum = 100; - std::vector all; - // Must include self if checking for circular. - all.push_back (task.get ("uuid")); - - // TODO foreach dependency - // TODO is uuid in all? - // TODO y: circular! - // TODO n: add uuid to all. return false; } diff --git a/src/tests/dependencies.t b/src/tests/dependencies.t index 535fdf953..97d25c841 100755 --- a/src/tests/dependencies.t +++ b/src/tests/dependencies.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 32; +use Test::More tests => 35; # Create the rc file. if (open my $fh, '>', 'dep.rc') @@ -59,10 +59,12 @@ like ($output, qr/Task 99 not found\./, 'dependencies - add dependency to nonexi # t 1 dep:2; t info 1 => blocked by 2 $output = qx{../task rc:dep.rc 1 dep:2; ../task rc:dep.rc info 1}; -like ($output, qr/This task blocked by\s+2 Two\nThis task is blocking/, 'dependencies - trivial blocked'); +like ($output, qr/This task blocked by\s+2 Two\nUUID/, 'dependencies - trivial blocked'); +unlike ($output, qr/This task is blocking\n/, 'dependencies - trivial blocked'); # t info 2 => blocking 1 $output = qx{../task rc:dep.rc info 2}; +unlike ($output, qr/This task blocked by/, 'dependencies - trivial blocking'); like ($output, qr/This task is blocking\s+1 One\nUUID/, 'dependencies - trivial blocking'); # t 1 dep:2 (again) @@ -109,7 +111,8 @@ $output = qx{../task rc:dep.rc 1 dep:2,3,4; ../task rc:dep.rc 1 dep:-2,-4,5; ../ like ($output, qr/This task blocked by\s+3 Three\n\s+5 Five\nThis task is blocking/, 'dependencies - multiple dependencies modified'); $output = qx{../task rc:dep.rc do 3,5; ../task rc:dep.rc info 1}; -like ($output, qr/This task blocked by\nThis task is blocking/, 'dependencies - task info reflects completed dependencies'); +unlike ($output, qr/This task blocked by/, 'dependencies - task info reflects completed dependencies'); +unlike ($output, qr/This task is blocking/, 'dependencies - task info reflects completed dependencies'); $output = qx{../task rc:dep.rc depreport}; like ($output, qr/\s1\s+One\s+/, 'dependencies - depends report column reflects completed dependencies'); @@ -171,8 +174,7 @@ $output = qx{../task rc:dep.rc depreport}; like ($output, qr/\s1\s+One\s*\n\s2\s+1\s+Three\s*\n\s3\s+2\s+Four\s*\n\s4\s+3\s+Five/, 'dependencies - fixed chain after completing a blocked task'); -# TODO TODO TODO - Need to echo Y Y (once for delete confirmation, again for repair prompt) -qx{echo y | ../task rc:dep.rc del 2}; +qx{printf "Y\nY\n" | ../task rc:dep.rc del 2}; $output = qx{../task rc:dep.rc depreport}; like ($output, qr/\s1\s+One\s*\n\s2\s+1\s+Four\s*\n\s3\s+2\s+Five/, 'dependencies - fixed chain after deleting a blocked task');