mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-07-07 20:06:36 +02:00
Unit Tests - post-start, pre-exit
- Implemented unit tests for the post-start and pre-exit hooks.
This commit is contained in:
parent
1cd6d4c7e7
commit
21d5607af2
2 changed files with 134 additions and 0 deletions
67
src/tests/hook.post-start.t
Executable file
67
src/tests/hook.post-start.t
Executable file
|
@ -0,0 +1,67 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
################################################################################
|
||||||
|
## task - a command line task list manager.
|
||||||
|
##
|
||||||
|
## Copyright 2006 - 2010, Paul Beckingham.
|
||||||
|
## 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, '>', 'hook.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n",
|
||||||
|
"hook.post-start=" . $ENV{'PWD'} . "/hook:test\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'hook.rc', 'Created hook.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open my $fh, '>', 'hook')
|
||||||
|
{
|
||||||
|
print $fh "function test () print ('marker') return 0, nil end\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'hook', 'Created hook');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test the hook.
|
||||||
|
my $output = qx{../task rc:hook.rc _version};
|
||||||
|
like ($output, qr/^marker.+\n\d\.\d+\.\d+\n$/ms, 'Found marker before output');
|
||||||
|
|
||||||
|
# Cleanup.
|
||||||
|
unlink 'pending.data';
|
||||||
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
||||||
|
unlink 'undo.data';
|
||||||
|
ok (!-r 'undo.data', 'Removed undo.data');
|
||||||
|
|
||||||
|
unlink 'hook';
|
||||||
|
ok (!-r 'hook', 'Removed hook');
|
||||||
|
|
||||||
|
unlink 'hook.rc';
|
||||||
|
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
67
src/tests/hook.pre-exit.t
Executable file
67
src/tests/hook.pre-exit.t
Executable file
|
@ -0,0 +1,67 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
################################################################################
|
||||||
|
## task - a command line task list manager.
|
||||||
|
##
|
||||||
|
## Copyright 2006 - 2010, Paul Beckingham.
|
||||||
|
## 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, '>', 'hook.rc')
|
||||||
|
{
|
||||||
|
print $fh "data.location=.\n",
|
||||||
|
"hook.pre-exit=" . $ENV{'PWD'} . "/hook:test\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'hook.rc', 'Created hook.rc');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (open my $fh, '>', 'hook')
|
||||||
|
{
|
||||||
|
print $fh "function test () print ('marker') return 0, nil end\n";
|
||||||
|
close $fh;
|
||||||
|
ok (-r 'hook', 'Created hook');
|
||||||
|
}
|
||||||
|
|
||||||
|
# Test the hook.
|
||||||
|
my $output = qx{../task rc:hook.rc _version};
|
||||||
|
like ($output, qr/\n\d\.\d+\.\d+\nmarker\n$/ms, 'Found marker after output');
|
||||||
|
|
||||||
|
# Cleanup.
|
||||||
|
unlink 'pending.data';
|
||||||
|
ok (!-r 'pending.data', 'Removed pending.data');
|
||||||
|
|
||||||
|
unlink 'undo.data';
|
||||||
|
ok (!-r 'undo.data', 'Removed undo.data');
|
||||||
|
|
||||||
|
unlink 'hook';
|
||||||
|
ok (!-r 'hook', 'Removed hook');
|
||||||
|
|
||||||
|
unlink 'hook.rc';
|
||||||
|
ok (!-r 'hook.rc', 'Removed hook.rc');
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue