Skip to content

Commit 2de9e09

Browse files
committed
use subtests in run()
1 parent ba13919 commit 2de9e09

File tree

1 file changed

+36
-41
lines changed

1 file changed

+36
-41
lines changed

t/run.t

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,58 +12,53 @@ require 'setup_common.pl';
1212

1313
my $class = 'Module::Release';
1414
subtest setup => sub {
15-
use_ok( $class );
16-
can_ok( $class, 'new' );
15+
use_ok $class;
16+
can_ok $class, 'new';
1717
};
1818

1919
my @subs = qw( run run_error _run_error_set _run_error_reset );
2020

21-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
22-
# Create test object
23-
my $release = $class->new;
24-
isa_ok( $release, $class );
25-
can_ok( $release, @subs );
21+
my $release;
22+
subtest 'make objects' => sub {
23+
$release = $class->new;
24+
isa_ok $release, $class;
25+
can_ok $release, @subs;
26+
};
2627

27-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
28-
# Try setting some things
29-
ok( ! defined $release->run_error, "run_error not set yet" );
28+
subtest 'settings' => sub {
29+
ok ! defined $release->run_error, "run_error not set yet";
3030

31-
ok( $release->_run_error_set, "Set run_error" );
32-
ok( $release->run_error, "run_error is set" );
31+
ok $release->_run_error_set, "Set run_error";
32+
ok $release->run_error, "run_error is set";
3333

34-
ok( ! $release->_run_error_reset, "run_error is reset" );
35-
ok( ! $release->run_error, "run_error is not set" );
34+
ok ! $release->_run_error_reset, "run_error is reset";
35+
ok ! $release->run_error, "run_error is not set";
36+
};
3637

37-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
38-
# Don't pass run a command
39-
{
40-
my $rc = eval { $release->run };
41-
my $at = $@;
42-
ok( defined $at, "run with no arguments dies" );
43-
like( $at, qr/Didn't get a command!/, "Error message with no arguments" );
44-
}
38+
subtest 'no args to run' => sub {
39+
my $rc = eval { $release->run };
40+
my $at = $@;
41+
ok defined $at, "run with no arguments dies";
42+
like $at, qr/Didn't get a command!/, "Error message with no arguments";
43+
};
4544

46-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
47-
# Pass run undef
48-
{
49-
my $rc = eval { $release->run( undef ) };
50-
my $at = $@;
51-
ok( defined $at, "run with undef argument dies" );
52-
like( $at, qr/Didn't get a command!/, "Error message with undef argument" );
53-
}
45+
subtest 'undef arg' => sub {
46+
my $rc = eval { $release->run( undef ) };
47+
my $at = $@;
48+
ok defined $at, "run with undef argument dies";
49+
like $at, qr/Didn't get a command!/, "Error message with undef argument";
50+
};
5451

55-
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
56-
# Pass it a bad command
57-
{
58-
local $ENV{PATH} = '';
59-
my $command = "foo";
60-
ok( ! -x $command, "$command is not executable (good)" );
52+
subtest 'bad command' => sub {
53+
local $ENV{PATH} = '';
54+
my $command = "foo";
55+
ok ! -x $command, "$command is not executable (good)";
6156

62-
my $message = eval { $release->run( qq|$command| ) };
63-
my $at = $@;
64-
ok( defined $at, "Bad command dies" );
65-
like( $at, qr/Could not open command/, "Error message with bad command" );
66-
}
57+
my $message = eval { $release->run( qq|$command| ) };
58+
my $at = $@;
59+
ok defined $at, "Bad command dies";
60+
like $at, qr/Could not open command/, "Error message with bad command";
61+
};
6762

6863
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
6964
# Pass it a cammand that exits with 255 (which should be bad)

0 commit comments

Comments
 (0)