Skip to content

Commit

Permalink
Add tests for Parrot::BuildUtil::get_bc_version().
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.parrot.org/parrot/trunk@37155 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information
jkeenan committed Mar 7, 2009
1 parent db5848c commit 7b0550e
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion t/configure/023-version.t
Expand Up @@ -6,7 +6,7 @@
use strict;
use warnings;

use Test::More tests => 7;
use Test::More tests => 14;
use Carp;
use Cwd;
use File::Copy;
Expand Down Expand Up @@ -36,8 +36,42 @@ my $cwd = cwd();
ok( chdir $cwd, "Able to change back to directory after testing" );
}

{
my $tdir = tempdir( CLEANUP => 1 );
ok( chdir $tdir, "Changed to temporary directory for testing" );
my $rv = set_bc_version(q{3.07});
my ($bc_major, $bc_minor) = Parrot::BuildUtil::get_bc_version();
is( $bc_major, 3, "Got expected bytecode major version" );
is( $bc_minor, 7, "Got expected bytecode minor version" );

ok( chdir $cwd, "Able to change back to directory after testing" );
}

{
my $tdir = tempdir( CLEANUP => 1 );
ok( chdir $tdir, "Changed to temporary directory for testing" );
my $rv = set_bc_version(q{3.tomboy});
eval {
my ($bc_major, $bc_minor) = Parrot::BuildUtil::get_bc_version();
};
like( $@, qr/No bytecode version found/,
"Got expected error message on failure to find bytecode version" );

ok( chdir $cwd, "Able to change back to directory after testing" );
}

pass("Completed all tests in $0");

sub set_bc_version {
my $version_str = shift;
my $compat_file = 'PBC_COMPAT';
my ( $bc_major, $bc_minor );
open my $OUT, '>', $compat_file or die "Can't write $compat_file";
print $OUT "$version_str\n";
close $OUT;
return 1;
}

################### DOCUMENTATION ###################

=head1 NAME
Expand Down

0 comments on commit 7b0550e

Please sign in to comment.