Skip to content

Commit

Permalink
Skip tests when .git not present (tarball).
Browse files Browse the repository at this point in the history
  • Loading branch information
jkeenan committed Nov 18, 2010
1 parent 649a9d5 commit 5ac740e
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 98 deletions.
109 changes: 56 additions & 53 deletions t/steps/auto/git_describe-01.t
Expand Up @@ -37,61 +37,64 @@ my $pkg = q{auto::git_describe};
$conf->add_steps($pkg);
$conf->options->set( %{$args} );
my $step = test_step_constructor_and_description($conf);
{
no warnings 'once';
local $Parrot::Git::Describe::current = undef;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), q{done},
"Got expected result for undefined \$Parrot::Git::Describe::current"
);
ok(! defined $conf->data->get( 'git_describe' ),
"'git_describe' undefined as expected" );
$conf->data->set( git_describe => undef ); # prepare for next test
}

$conf->replenish($serialized);

{
no warnings 'once';
local $Parrot::Git::Describe::current = 'invalid git describe string';
my $ret;
eval { $ret = $step->runstep($conf); };
like($@, qr/Invalid git describe string \(Git::Describe\)/,
"Got expected 'die' message for invalid git describe string" );
ok( ! defined $ret, "runstep() returned undefined as expected" );
}

$conf->replenish($serialized);

{
no warnings 'once';
my $cur = 'REL_2004_09_07-678-ga83bdab';
local $Parrot::Git::Describe::current = $cur;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), $cur,
"Got expected result for valid \$Parrot::Git::Describe::current"
);
$conf->data->set( git_describe => undef ); # prepare for next test
}

$conf->replenish($serialized);

{
no warnings 'once';
my $cur = 'RELEASE_2_10_0';
local $Parrot::Git::Describe::current = $cur;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), $cur,
"Got expected result for valid \$Parrot::Git::Describe::current"
);
$conf->data->set( git_describe => undef ); # prepare for next test
SKIP: {
skip "No .git directory when working from tarball", 9 unless (-e '.git');
{
no warnings 'once';
local $Parrot::Git::Describe::current = undef;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), q{done},
"Got expected result for undefined \$Parrot::Git::Describe::current"
);
ok(! defined $conf->data->get( 'git_describe' ),
"'git_describe' undefined as expected" );
$conf->data->set( git_describe => undef ); # prepare for next test
}

$conf->replenish($serialized);

{
no warnings 'once';
local $Parrot::Git::Describe::current = 'invalid git describe string';
my $ret;
eval { $ret = $step->runstep($conf); };
like($@, qr/Invalid git describe string \(Git::Describe\)/,
"Got expected 'die' message for invalid git describe string" );
ok( ! defined $ret, "runstep() returned undefined as expected" );
}

$conf->replenish($serialized);

{
no warnings 'once';
my $cur = 'REL_2004_09_07-678-ga83bdab';
local $Parrot::Git::Describe::current = $cur;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), $cur,
"Got expected result for valid \$Parrot::Git::Describe::current"
);
$conf->data->set( git_describe => undef ); # prepare for next test
}

$conf->replenish($serialized);

{
no warnings 'once';
my $cur = 'RELEASE_2_10_0';
local $Parrot::Git::Describe::current = $cur;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), $cur,
"Got expected result for valid \$Parrot::Git::Describe::current"
);
$conf->data->set( git_describe => undef ); # prepare for next test
}

$conf->replenish($serialized);
}

$conf->replenish($serialized);

my $cwd = cwd();
{
my $tdir = tempdir( CLEANUP => 1 );
Expand Down
93 changes: 48 additions & 45 deletions t/steps/auto/sha1-01.t
Expand Up @@ -37,53 +37,56 @@ my $pkg = q{auto::sha1};
$conf->add_steps($pkg);
$conf->options->set( %{$args} );
my $step = test_step_constructor_and_description($conf);
{
no warnings 'once';
local $Parrot::SHA1::current = undef;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), q{done},
"Got expected result for undefined \$Parrot::SHA1::current"
);
ok(! defined $conf->data->get( 'sha1' ),
"'sha1' undefined as expected" );
$conf->data->set( sha1 => undef ); # prepare for next test
}

$conf->replenish($serialized);

{
no warnings 'once';
local $Parrot::SHA1::current = 'invalid SHA1 string';
my $ret;
eval { $ret = $step->runstep($conf); };
like($@, qr/Invalid Parrot sha1 \(SHA1\)/,
"Got expected result for invalid SHA1 string" );
ok( ! defined $ret, "runstep() returned undefined as expected" );
}

$conf->replenish($serialized);

{
no warnings 'once';
my $cur = 'abcdefABCDEF0123456789012345678901234567';
my $abbrev_cur = substr($cur,0,7);
local $Parrot::SHA1::current = $cur;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), $abbrev_cur,
"Got expected result for valid \$Parrot::SHA1::current"
);
is($conf->data->get('sha1'), $cur,
"Got expected value for sha1" );
is($conf->data->get('abbrev_sha1'), $abbrev_cur,
"Got expected value for abbrev_sha1" );
$conf->data->set( sha1 => undef ); # prepare for next test
$conf->data->set( abbrev_sha1 => undef ); # prepare for next test
SKIP: {
skip "No .git directory when working from tarball", 9 unless (-e '.git');
{
no warnings 'once';
local $Parrot::SHA1::current = undef;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), q{done},
"Got expected result for undefined \$Parrot::SHA1::current"
);
ok(! defined $conf->data->get( 'sha1' ),
"'sha1' undefined as expected" );
$conf->data->set( sha1 => undef ); # prepare for next test
}

$conf->replenish($serialized);

{
no warnings 'once';
local $Parrot::SHA1::current = 'invalid SHA1 string';
my $ret;
eval { $ret = $step->runstep($conf); };
like($@, qr/Invalid Parrot sha1 \(SHA1\)/,
"Got expected result for invalid SHA1 string" );
ok( ! defined $ret, "runstep() returned undefined as expected" );
}

$conf->replenish($serialized);

{
no warnings 'once';
my $cur = 'abcdefABCDEF0123456789012345678901234567';
my $abbrev_cur = substr($cur,0,7);
local $Parrot::SHA1::current = $cur;
my $ret = $step->runstep($conf);
ok( $ret, "runstep() returned true value" );
is($step->result(), $abbrev_cur,
"Got expected result for valid \$Parrot::SHA1::current"
);
is($conf->data->get('sha1'), $cur,
"Got expected value for sha1" );
is($conf->data->get('abbrev_sha1'), $abbrev_cur,
"Got expected value for abbrev_sha1" );
$conf->data->set( sha1 => undef ); # prepare for next test
$conf->data->set( abbrev_sha1 => undef ); # prepare for next test
}

$conf->replenish($serialized);
}

$conf->replenish($serialized);

my $cwd = cwd();
{
my $tdir = tempdir( CLEANUP => 1 );
Expand Down

0 comments on commit 5ac740e

Please sign in to comment.