mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Dependencies
- Improved a few of the unit tests. - Minor progress on the support functions.
This commit is contained in:
parent
d9ec233d23
commit
612c613764
3 changed files with 34 additions and 17 deletions
|
@ -6,8 +6,8 @@
|
||||||
'1 month', '4d' for 'due', 'wait' and 'until' dates. Essentially
|
'1 month', '4d' for 'due', 'wait' and 'until' dates. Essentially
|
||||||
durations are now allowed where dates are expected, and are treated
|
durations are now allowed where dates are expected, and are treated
|
||||||
as relative to the current date/time.
|
as relative to the current date/time.
|
||||||
+ Added feature #189, that records the start and stop times
|
+ Added feature #189, that records the start and stop times as an
|
||||||
as an annotation for a task.
|
annotation for a task.
|
||||||
+ Added features #244, #272, #274 and #275, which support import and
|
+ 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.
|
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
|
+ Added feature #391, now the 'task color legend' command will show
|
||||||
|
|
|
@ -64,18 +64,33 @@ bool dependencyIsBlocking (Task& task)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Follow each of the given task's dependencies to the end of the chain, and if
|
// 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.
|
// 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 <std::string> 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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 32;
|
use Test::More tests => 35;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'dep.rc')
|
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
|
# 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};
|
$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
|
# t info 2 => blocking 1
|
||||||
$output = qx{../task rc:dep.rc info 2};
|
$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');
|
like ($output, qr/This task is blocking\s+1 One\nUUID/, 'dependencies - trivial blocking');
|
||||||
|
|
||||||
# t 1 dep:2 (again)
|
# 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');
|
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};
|
$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};
|
$output = qx{../task rc:dep.rc depreport};
|
||||||
like ($output, qr/\s1\s+One\s+/, 'dependencies - depends report column reflects completed dependencies');
|
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');
|
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{printf "Y\nY\n" | ../task rc:dep.rc del 2};
|
||||||
qx{echo y | ../task rc:dep.rc del 2};
|
|
||||||
$output = qx{../task rc:dep.rc depreport};
|
$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');
|
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');
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue