mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests
- Eliminated obsolete benchmark.t. - Removed the 'quick' mode logic to skip benchmarks in run_all. - Restored bug.480.t tests that hung earlier.
This commit is contained in:
parent
7aa4efef8d
commit
1b55a48757
4 changed files with 8 additions and 132 deletions
112
test/benchmark.t
112
test/benchmark.t
|
@ -1,112 +0,0 @@
|
|||
#! /usr/bin/perl
|
||||
################################################################################
|
||||
## taskwarrior - a command line task list manager.
|
||||
##
|
||||
## Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||
## All rights reserved.
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify it under
|
||||
## the terms of the GNU General Public License as published by the Free Software
|
||||
## Foundation; either version 2 of the License, or (at your option) any later
|
||||
## version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||
## details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License along with
|
||||
## this program; if not, write to the
|
||||
##
|
||||
## Free Software Foundation, Inc.,
|
||||
## 51 Franklin Street, Fifth Floor,
|
||||
## Boston, MA
|
||||
## 02110-1301
|
||||
## USA
|
||||
##
|
||||
################################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 7;
|
||||
|
||||
# Create the rc file.
|
||||
if (open my $fh, '>', 'bench.rc')
|
||||
{
|
||||
print $fh "data.location=.\n",
|
||||
"_forcecolor=1\n";
|
||||
close $fh;
|
||||
ok (-r 'bench.rc', 'Created bench.rc');
|
||||
}
|
||||
|
||||
# Do lots of things. Time it all.
|
||||
|
||||
my @tags = qw(t_one t_two t_three t_four t_five t_six t_seven t_eight);
|
||||
my @projects = qw(p_one p_two p_three p_foud p_five p_six p_seven p_eight);
|
||||
my @priorities = qw(H M L);
|
||||
my $description = 'This is a medium-sized description with no special characters';
|
||||
|
||||
# Start the clock.
|
||||
my $start = time ();
|
||||
my $cursor = $start;
|
||||
diag ("start=$start");
|
||||
|
||||
# Make a mess.
|
||||
for my $i (1 .. 1000)
|
||||
{
|
||||
my $project = $projects[rand % 8];
|
||||
my $priority = $priorities[rand % 3];
|
||||
my $tag = $tags[rand % 8];
|
||||
|
||||
qx{../src/task rc:bench.rc add project:$project priority:$priority +$tag $i $description};
|
||||
}
|
||||
diag ("1000 tasks added in " . (time () - $cursor) . " seconds");
|
||||
$cursor = time ();
|
||||
|
||||
qx{../src/task rc:bench.rc $_ modify /with/WITH/} for 1 .. 200;
|
||||
qx{../src/task rc:bench.rc $_ done} for 201 .. 400;
|
||||
qx{../src/task rc:bench.rc $_ start} for 401 .. 600;
|
||||
diag ("600 tasks altered in " . (time () - $cursor) . " seconds");
|
||||
$cursor = time ();
|
||||
|
||||
# Report it all. Note that all Timer information is displayed.
|
||||
|
||||
for (1 .. 100)
|
||||
{
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc ls});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc list});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc list priority:H});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc list +tag});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc list project_A});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc long});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc completed});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc history});
|
||||
diag (grep {/^Timer /} qx{../src/task rc:bench.rc ghistory});
|
||||
}
|
||||
|
||||
# Stop the clock.
|
||||
my $stop = time ();
|
||||
diag ("stop=$stop");
|
||||
diag ("total=" . ($stop - $start));
|
||||
|
||||
# Cleanup.
|
||||
unlink 'pending.data';
|
||||
ok (!-r 'pending.data', 'Removed pending.data');
|
||||
|
||||
unlink 'completed.data';
|
||||
ok (!-r 'completed.data', 'Removed completed.data');
|
||||
|
||||
unlink 'undo.data';
|
||||
ok (!-r 'undo.data', 'Removed undo.data');
|
||||
|
||||
unlink 'backlog.data';
|
||||
ok (!-r 'backlog.data', 'Removed backlog.data');
|
||||
|
||||
unlink 'synch.key';
|
||||
ok (!-r 'synch.key', 'Removed synch.key');
|
||||
|
||||
unlink 'bench.rc';
|
||||
ok (!-r 'bench.rc', 'Removed bench.rc');
|
||||
|
||||
exit 0;
|
||||
|
|
@ -82,9 +82,9 @@ unlike ($output, qr/two/, 'Triple: no t2');
|
|||
unlike ($output, qr/three/, 'Triple: no t3');
|
||||
|
||||
# Once again, with @ characters.
|
||||
#qx{../src/task rc:bug.rc 1 modify +\@1};
|
||||
#qx{../src/task rc:bug.rc 2 modify +\@2};
|
||||
#qx{../src/task rc:bug.rc 3 modify +\@3};
|
||||
qx{../src/task rc:bug.rc 1 modify +\@1};
|
||||
qx{../src/task rc:bug.rc 2 modify +\@2};
|
||||
qx{../src/task rc:bug.rc 3 modify +\@3};
|
||||
|
||||
$output = qx{../src/task rc:bug.rc list -\@1};
|
||||
unlike ($output, qr/one/, 'Single: no @1');
|
||||
|
@ -102,9 +102,9 @@ unlike ($output, qr/two/, 'Triple: no @2');
|
|||
unlike ($output, qr/three/, 'Triple: no @3');
|
||||
|
||||
# Once again, with @ characters and punctuation.
|
||||
#qx{../src/task rc:bug.rc 1 modify +\@foo.1};
|
||||
#qx{../src/task rc:bug.rc 2 modify +\@foo.2};
|
||||
#qx{../src/task rc:bug.rc 3 modify +\@foo.3};
|
||||
qx{../src/task rc:bug.rc 1 modify +\@foo.1};
|
||||
qx{../src/task rc:bug.rc 2 modify +\@foo.2};
|
||||
qx{../src/task rc:bug.rc 3 modify +\@foo.3};
|
||||
|
||||
$output = qx{../src/task rc:bug.rc list -\@foo.1};
|
||||
unlike ($output, qr/one/, 'Single: no @foo.1');
|
||||
|
|
10
test/run_all
10
test/run_all
|
@ -2,14 +2,6 @@
|
|||
|
||||
date > all.log
|
||||
|
||||
MODE=quick
|
||||
if [ "x$1" == 'xslow' ]; then
|
||||
echo 'Including benchmarks'
|
||||
MODE=slow
|
||||
else
|
||||
echo 'Skipping benchmarks'
|
||||
fi
|
||||
|
||||
VRAMSTEG=/usr/local/bin/vramsteg
|
||||
BAR=0
|
||||
if [ -x $VRAMSTEG ]; then
|
||||
|
@ -28,9 +20,7 @@ do
|
|||
COUNT=$[COUNT + 1]
|
||||
fi
|
||||
|
||||
if [[ $MODE == 'slow' || $i != 'benchmark.t' ]]; then
|
||||
./$i >> all.log 2>&1
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $BAR == 1 ]; then
|
||||
|
|
|
@ -44,8 +44,8 @@ qx{../src/task rc:sorting.rc add priority:H project:A due:yesterday one};
|
|||
qx{../src/task rc:sorting.rc add priority:M project:B due:today two};
|
||||
qx{../src/task rc:sorting.rc add priority:L project:C due:tomorrow three};
|
||||
qx{../src/task rc:sorting.rc add priority:H project:C due:today four};
|
||||
|
||||
qx{../src/task rc:sorting.rc 2 start};
|
||||
#diag (qx{../src/task rc:sorting.rc list});
|
||||
|
||||
my %tests =
|
||||
(
|
||||
|
@ -170,8 +170,6 @@ my %tests =
|
|||
for my $sort (sort keys %tests)
|
||||
{
|
||||
my $output = qx{../src/task rc:sorting.rc rc.report.list.sort:${sort} list};
|
||||
# like ($output, qr/$tests{$sort}/ms, "sort:${sort}");
|
||||
|
||||
for my $expectation (@{$tests{$sort}})
|
||||
{
|
||||
like ($output, qr/$expectation/ms, "sort:${sort}");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue