File: 73_autoflush.t

package info (click to toggle)
libcpan-reporter-perl 1.2020-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,752 kB
  • sloc: perl: 5,440; makefile: 2
file content (57 lines) | stat: -rw-r--r-- 1,340 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use strict;
BEGIN{ if (not $] < 5.006) { require warnings; warnings->import } }

select(STDERR); $|=1;
select(STDOUT); $|=1;

use Test::More;
use Capture::Tiny qw/capture/;
use File::Spec::Functions qw/catdir catfile rel2abs/;
use lib 't/lib';
use Frontend;
use MockHomeDir;
use Probe::Perl ();

# protect CPAN::Reporter from itself
local %ENV = %ENV;
delete $ENV{PERL5OPT};

my @cases = (
  [ 'Makefile.PL'     , 1 ],
  [ 'NotMakefile.PL'  , 0 ],
  [ 'Build.PL'     , 1 ],
  [ 'NotBuild.PL'  , 0 ],
);

plan tests => 1 + @cases;

#--------------------------------------------------------------------------#
# fixtures
#--------------------------------------------------------------------------#

my $perl = Probe::Perl->find_perl_interpreter();
$perl = qq{"$perl"};

my ($stdout, $stderr, $output, $exit, $line);

#--------------------------------------------------------------------------#
# tests
#--------------------------------------------------------------------------#


require_ok( "CPAN::Reporter" );

for my $c ( @cases ) {
  my ($name, $expect) = @$c;
  my $bin = catfile( qw/t bin /, $name );

  eval {
    ($stdout, $stderr) = capture {
      ($output, $exit) = CPAN::Reporter::record_command( "$perl $bin" );
    };
  };

  chomp( $line = $output->[0] );
  is( $line, $expect, "$name had \$| = $expect" ) or diag $stdout;
}