While testing test scripts I noticed that their output is defferent
when running directly or under Harness.

I have scripts like this: (called a.t)

use strict;
use warnings;

use Test::More tests => 2;

is(2, 2);
is(2, 3);

and I'd like to test if their output is what I expect.
(These are examples for my training)



A simple script to test the above is this: (called t.t)

use strict;
use warnings;

use Test::More tests => 1;
system "$^X a.t > out 2>&1";

open my $in, '<out' or die;
my @lines = <$in>;
my @expected = <DATA>;

is_deeply(\...@lines, \...@expected);


__DATA__
1..2
ok 1
not ok 2
#   Failed test at a.t line 7.
#          got: '2'
#     expected: '3'
# Looks like you failed 1 test of 2.



If I run "perl t.t" I get OK

If I run   perl -MTest::Harness -e'runtests("t.t")'
it fails with

#   Failed test at t.t line 11.
#     Structures begin differing at:
#          $got->[3] = '
#     '
#     $expected->[3] = '#   Failed test at a.t line 7.
#     '

that is, under Harness there is an extra empty row
between the not ok line and the explanation line:
#   Failed test at a.t line 7.

Is this intentional?
If not should this be fixed?

Gabor

Reply via email to