Skip to content

Commit

Permalink
Outdent subtest intro comment
Browse files Browse the repository at this point in the history
This commit puts the subtest intro comment at the parent indent level.

Before:

    ok 1 - regular test
        # Subtest: my first subtest
        ok 1 - first test
        ok 2 - second test
        ok 3 - third test
        1..3
    ok 2 - my first subtest

After:

    ok 1 - regular test
    # Subtest: my first subtest
        ok 1 - first test
        ok 2 - second test
        ok 3 - third test
        1..3
    ok 2 - my first subtest

I think this is much easier to read because it brackets the subtest
information at the same indentation level.  The subtest details are
clearly between the opening comment and the matching "ok".
  • Loading branch information
xdg committed Apr 28, 2014
1 parent c347c8d commit 4829c9f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
5 changes: 3 additions & 2 deletions lib/Test/Builder.pm
Original file line number Diff line number Diff line change
Expand Up @@ -247,14 +247,15 @@ sub subtest {
# $Level first to limit the scope of the reset to the subtest.
local $Test::Builder::Level = $Test::Builder::Level + 1;

# Add subtest name for clarification of starting point
$self->note("Subtest: $name");

# Store the guts of $self as $parent and turn $child into $self.
$child = $self->child($name);
_copy($self, $parent);
_copy($child, $self);

my $run_the_subtests = sub {
# Add subtest name for clarification of starting point
$self->note("Subtest: $name");
$subtests->();
$self->done_testing unless $self->_plan_handled;
1;
Expand Down
4 changes: 2 additions & 2 deletions t/subtest/bail_out.t
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ subtest 'bar' => sub {
$Test->is_eq( $output, <<'OUT' );
1..4
ok 1
# Subtest: bar
# Subtest: bar
1..3
ok 1
# Subtest: sub_bar
# Subtest: sub_bar
1..3
ok 1
ok 2
Expand Down
10 changes: 5 additions & 5 deletions t/subtest/line_numbers.t
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ $ENV{HARNESS_ACTIVE} = 0;
our %line;

{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..3");
test_out(" ok 1");
test_out(" not ok 2");
Expand All @@ -47,7 +47,7 @@ our %line;
test_test("un-named inner tests");
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..3");
test_out(" ok 1 - first is good");
test_out(" not ok 2 - second is bad");
Expand Down Expand Up @@ -78,7 +78,7 @@ sub run_the_subtest {
}; BEGIN{ $line{outerfail3} = __LINE__ }
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..3");
test_out(" ok 1 - first is good");
test_out(" not ok 2 - second is bad");
Expand All @@ -95,7 +95,7 @@ sub run_the_subtest {
test_test("subtest() called from a sub");
}
{
test_out( " # Subtest: namehere");
test_out( "# Subtest: namehere");
test_out( " 1..0");
test_err( " # No tests run!");
test_out( 'not ok 1 - No tests run for subtest "namehere"');
Expand All @@ -109,7 +109,7 @@ sub run_the_subtest {
test_test("lineno in 'No tests run' diagnostic");
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..1");
test_out(" not ok 1 - foo is bar");
test_err(" # Failed test 'foo is bar'");
Expand Down
12 changes: 6 additions & 6 deletions t/subtest/predicate.t
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ sub foobar_ok ($;$) {
};
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..2");
test_out(" ok 1 - foo");
test_out(" not ok 2 - bar");
Expand All @@ -65,7 +65,7 @@ sub foobar_ok_2 ($;$) {
foobar_ok($value, $name);
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..2");
test_out(" ok 1 - foo");
test_out(" not ok 2 - bar");
Expand Down Expand Up @@ -95,7 +95,7 @@ sub barfoo_ok ($;$) {
});
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..2");
test_out(" ok 1 - foo");
test_out(" not ok 2 - bar");
Expand All @@ -120,7 +120,7 @@ sub barfoo_ok_2 ($;$) {
barfoo_ok($value, $name);
}
{
test_out(" # Subtest: namehere");
test_out("# Subtest: namehere");
test_out(" 1..2");
test_out(" ok 1 - foo");
test_out(" not ok 2 - bar");
Expand All @@ -138,10 +138,10 @@ sub barfoo_ok_2 ($;$) {

# A subtest-based predicate called from within a subtest
{
test_out(" # Subtest: outergroup");
test_out("# Subtest: outergroup");
test_out(" 1..2");
test_out(" ok 1 - this passes");
test_out(" # Subtest: namehere");
test_out(" # Subtest: namehere");
test_out(" 1..2");
test_out(" ok 1 - foo");
test_out(" not ok 2 - bar");
Expand Down
2 changes: 1 addition & 1 deletion t/subtest/todo.t
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ sub test_subtest_in_todo {
my ($set_via, $todo_reason, $level) = @$combo;

test_out(
" # Subtest: xxx",
"# Subtest: xxx",
@outlines,
"not ok 1 - $xxx # TODO $todo_reason",
"# Failed (TODO) test '$xxx'",
Expand Down

0 comments on commit 4829c9f

Please sign in to comment.