47ab80459267be66d59cdd254855fa5eeee1060a
2 use lib
(split(/:/, $ENV{GITPERLLIB
}));
11 use lib
$ENV{GITWEBLIBDIR
} || "$ENV{GIT_BUILD_DIR}/gitweb/lib";
13 # ....................................................................
15 use_ok
('GitwebCache::Capture::Simple');
16 diag
("Using lib '$INC[0]'");
17 diag
("Testing '$INC{'GitwebCache/Capture/Simple.pm'}'");
19 # Test setting up capture
21 my $capture = new_ok
('GitwebCache::Capture::Simple' => [], 'The $capture');
25 sub capture_block
(&) {
26 return $capture->capture(shift);
29 diag
('Should not print anything except test results and diagnostic');
30 my $test_data = 'Capture this';
31 my $captured = capture_block
{
34 is
($captured, $test_data, 'capture simple data');
36 binmode STDOUT
, ':utf8';
40 utf8
::decode
($test_data);
41 $captured = capture_block
{
42 binmode STDOUT
, ':utf8';
46 utf8
::decode
($captured);
47 is
($captured, $test_data, 'capture utf8 data');
49 $test_data = '|\x{fe}\x{ff}|\x{9F}|\000|'; # invalid utf-8
50 $captured = capture_block
{
51 binmode STDOUT
, ':raw';
55 is
($captured, $test_data, 'capture raw data');
57 # Test nested capturing
60 local $TODO = "not required for capturing gitweb output";
63 my $outer_capture = GitwebCache
::Capture
::Simple
->new();
64 $captured = $outer_capture->capture(sub {
66 my $captured = $capture->capture(sub {
72 is
($captured, "pre|inner|post", 'nested capture');
76 skip
"Capture::Tiny not available", 1
77 unless eval { require Capture
::Tiny
; };
79 $captured = Capture
::Tiny
::capture
(sub {
80 my $inner = $capture->capture(sub {
84 is
($captured, '', "doesn't print while capturing");