basic.t
- check version number against configure.ac - added test for _version command
This commit is contained in:
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
use warnings;
|
use warnings;
|
||||||
use Test::More tests => 6;
|
use Test::More tests => 7;
|
||||||
|
|
||||||
# Create the rc file.
|
# Create the rc file.
|
||||||
if (open my $fh, '>', 'basic.rc')
|
if (open my $fh, '>', 'basic.rc')
|
||||||
@@ -38,19 +38,44 @@ if (open my $fh, '>', 'basic.rc')
|
|||||||
ok (-r 'basic.rc', 'Created basic.rc');
|
ok (-r 'basic.rc', 'Created basic.rc');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Get the version number from configure.ac
|
||||||
|
my $version = slurp ('../../configure.ac');
|
||||||
|
|
||||||
# Test the usage command.
|
# Test the usage command.
|
||||||
my $output = qx{../task rc:basic.rc};
|
my $output = qx{../task rc:basic.rc};
|
||||||
like ($output, qr/You must specify a command, or a task ID to modify/m, 'missing command and ID');
|
like ($output, qr/You must specify a command, or a task ID to modify/m, 'missing command and ID');
|
||||||
|
|
||||||
# Test the version command.
|
# Test the version command.
|
||||||
$output = qx{../task rc:basic.rc version};
|
$output = qx{../task rc:basic.rc version};
|
||||||
like ($output, qr/task \d+\.\d+\.\d+/, 'version - task version number');
|
like ($output, qr/task $version/, 'version - task version number');
|
||||||
like ($output, qr/GNU General Public License/, 'version - license');
|
like ($output, qr/GNU General Public License/, 'version - license');
|
||||||
like ($output, qr/http:\/\/taskwarrior\.org/, 'version - url');
|
like ($output, qr/http:\/\/taskwarrior\.org/, 'version - url');
|
||||||
|
|
||||||
|
# Test the _version command.
|
||||||
|
$output = qx{../task rc:basic.rc _version};
|
||||||
|
like ($output, qr/$version/, '_version - task version number');
|
||||||
|
|
||||||
# Cleanup.
|
# Cleanup.
|
||||||
unlink 'basic.rc';
|
unlink 'basic.rc';
|
||||||
ok (!-r 'basic.rc', 'Removed basic.rc');
|
ok (!-r 'basic.rc', 'Removed basic.rc');
|
||||||
|
|
||||||
exit 0;
|
exit 0;
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
sub slurp
|
||||||
|
{
|
||||||
|
my ($file) = @_;
|
||||||
|
if (open my $fh, '<', $file)
|
||||||
|
{
|
||||||
|
while (<$fh>) {
|
||||||
|
if (/AC_INIT/) {
|
||||||
|
chomp;
|
||||||
|
s/^AC_INIT\(task, //;
|
||||||
|
s/, support.*$//;
|
||||||
|
close $fh;
|
||||||
|
return $_;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user