From 338e4dfbc7329f2a7411bead37b953a6c68a1eb9 Mon Sep 17 00:00:00 2001 From: Federico Hernandez Date: Tue, 22 Dec 2009 00:18:26 +0100 Subject: [PATCH] basic.t - check version number against configure.ac - added test for _version command --- src/tests/basic.t | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/src/tests/basic.t b/src/tests/basic.t index 6114911fc..0f1fde77b 100755 --- a/src/tests/basic.t +++ b/src/tests/basic.t @@ -28,7 +28,7 @@ use strict; use warnings; -use Test::More tests => 6; +use Test::More tests => 7; # Create the rc file. if (open my $fh, '>', 'basic.rc') @@ -38,19 +38,44 @@ if (open my $fh, '>', '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. 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'); # Test the version command. $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/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. unlink 'basic.rc'; ok (!-r 'basic.rc', 'Removed basic.rc'); 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 $_; + } + } + } + ''; +}