File: bug.987.x

package info (click to toggle)
task 2.3.0%2Bdfsg-3
  • links: PTS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,728 kB
  • ctags: 4,813
  • sloc: cpp: 34,267; perl: 18,509; python: 298; sh: 257; makefile: 73; ruby: 32
file content (122 lines) | stat: -rwxr-xr-x 4,767 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#! /usr/bin/env perl
################################################################################
## taskwarrior - a command line task list manager.
##
## Copyright 2006-2014, Paul Beckingham, Federico Hernandez.
##
## Permission is hereby granted, free of charge, to any person obtaining a copy
## of this software and associated documentation files (the "Software"), to deal
## in the Software without restriction, including without limitation the rights
## to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
## copies of the Software, and to permit persons to whom the Software is
## furnished to do so, subject to the following conditions:
##
## The above copyright notice and this permission notice shall be included
## in all copies or substantial portions of the Software.
##
## THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
## OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
## FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
## THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
## LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
## OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
## SOFTWARE.
##
## http://www.opensource.org/licenses/mit-license.php
##
################################################################################

use strict;
use warnings;
use Test::More tests => 9;

# Create the rc file.
if (open my $fh, '>', 'bug.rc')
{
  print $fh "data.location=.\n",
            "confirmation=off\n";
  close $fh;
  ok (-r 'bug.rc', 'Created bug.rc');
}

# Bug 987 - 'Total active time' is still increasing when a task is done

# Test all cases for which the active duration must be close to zero and
# constant:
# - start (a), stop (o), done (d) and none (n)
#   (none disallows the name of each task to be the prefix of any other)
qx{../src/task rc:bug.rc add test_aodn};
qx{../src/task rc:bug.rc test_aodn start};
qx{faketime -f '+1s' ../src/task rc:bug.rc test_aodn stop};
qx{faketime -f '+2s' ../src/task rc:bug.rc test_aodn done};
check_constant_close_zero("test_aodn");

# - start and done
qx{../src/task rc:bug.rc add test_adn};
qx{../src/task rc:bug.rc test_adn start};
qx{faketime -f '+1s' ../src/task rc:bug.rc test_adn done};
check_constant_close_zero("test_adn");

# - start, done and stop
qx{../src/task rc:bug.rc add test_adon};
qx{../src/task rc:bug.rc test_adon start};
qx{faketime -f '+1s' ../src/task rc:bug.rc test_adon done};
qx{faketime -f '+2s' ../src/task rc:bug.rc test_adon stop};
check_constant_close_zero("test_adon");

# - done, start and stop (XXX whether this should be allowed is questionable)
qx{../src/task rc:bug.rc add test_daon};
qx{../src/task rc:bug.rc test_daon done};
qx{faketime -f '+1s' ../src/task rc:bug.rc test_daon start};
qx{faketime -f '+2s' ../src/task rc:bug.rc test_daon stop};
check_constant_close_zero("test_daon");

# Test all cases for which the active duration must not be shown:
# - done
qx{../src/task rc:bug.rc add test_dn};
qx{../src/task rc:bug.rc test_dn done};
check_no_summary("test_dn");

# Test all case for which the active duration must be close to zero and
# increasing:
# - start
qx{../src/task rc:bug.rc add test_sn};
qx{../src/task rc:bug.rc test_sn start};
check_running_close_zero("test_sn");

# - done and start (XXX whether this should be allowed is questionable)
qx{../src/task rc:bug.rc add test_dsn};
qx{../src/task rc:bug.rc test_dsn start};
check_running_close_zero("test_dsn");

### Cleanup.
unlink qw(pending.data completed.data undo.data backlog.data bug.rc);
ok (! -r 'pending.data'   &&
    ! -r 'completed.data' &&
    ! -r 'undo.data'      &&
    ! -r 'backlog.data'   &&
    ! -r 'bug.rc', 'Cleanup');

exit 0;

################################################################################
# Check that the active time is not above one minute after waiting for one minute
sub check_constant_close_zero {
  my ($task) = @_;
  my $output = qx{faketime -f '+60s' ../src/task rc:bug.rc $task info};
  like ($output, qr/Total active time 0:00:/ms, 'Total active duration is not increasing and is close to zeo');
}

# Check that there is no active time summary
sub check_no_summary {
  my ($task) = @_;
  my $output = qx{faketime -f '+10s' ../src/task rc:bug.rc $task info};
  unlike ($output, qr/Total active time/ms, 'No total active duration summary');
}

# Check that the active time is above one minute after waiting for one minute
sub check_running_close_zero {
  my ($task) = @_;
  my $output = qx{faketime -f '+60s' ../src/task rc:bug.rc $task info};
  like ($output, qr/Total active time 0:01:/ms, 'Total active duration is increasing and is close to zero');
}