⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 01_archive-extract.t

📁 source of perl for linux application,
💻 T
📖 第 1 页 / 共 2 页
字号:
BEGIN {     if( $ENV{PERL_CORE} ) {        chdir '../lib/Archive/Extract' if -d '../lib/Archive/Extract';        unshift @INC, '../../..', '../../../..';    }}    BEGIN { chdir 't' if -d 't' };BEGIN { mkdir 'out' unless -d 'out' };### left behind, at least on Win32. See core patch #31904END   { rmtree('out') };        use strict;use lib qw[../lib];use constant IS_WIN32   => $^O eq 'MSWin32' ? 1 : 0;use constant IS_CYGWIN  => $^O eq 'cygwin'  ? 1 : 0;use constant IS_VMS     => $^O eq 'VMS'     ? 1 : 0;use Cwd                         qw[cwd];use Test::More                  qw[no_plan];use File::Spec;use File::Spec::Unix;use File::Path;use Data::Dumper;use File::Basename              qw[basename];use Module::Load::Conditional   qw[check_install];### uninitialized value in File::Spec warnings come from A::Zip:# t/01_Archive-Extract....ok 135/0Use of uninitialized value in concatenation (.) or string at /opt/lib/perl5/5.8.3/File/Spec/Unix.pm line 313.#         File::Spec::Unix::catpath('File::Spec','','','undef') called at /opt/lib/perl5/site_perl/5.8.3/Archive/Zip.pm line 473#         Archive::Zip::_asLocalName('') called at /opt/lib/perl5/site_perl/5.8.3/Archive/Zip.pm line 652#         Archive::Zip::Archive::extractMember('Archive::Zip::Archive=HASH(0x9679c8)','Archive::Zip::ZipFileMember=HASH(0x9678fc)') called at ../lib/Archive/Extract.pm line 753#         Archive::Extract::_unzip_az('Archive::Extract=HASH(0x966eac)') called at ../lib/Archive/Extract.pm line 674#         Archive::Extract::_unzip('Archive::Extract=HASH(0x966eac)') called at ../lib/Archive/Extract.pm line 275#         Archive::Extract::extract('Archive::Extract=HASH(0x966eac)','to','/Users/kane/sources/p4/other/archive-extract/t/out') called at t/01_Archive-Extract.t line 180#BEGIN { $SIG{__WARN__} = sub { require Carp; Carp::cluck(@_) } };if ((IS_WIN32 or IS_CYGWIN) && ! $ENV{PERL_CORE}) {    diag( "Older versions of Archive::Zip may cause File::Spec warnings" );    diag( "See bug #19713 in rt.cpan.org. It is safe to ignore them" );}my $Debug   = $ARGV[0] ? 1 : 0;my $Me      = basename( $0 );my $Class   = 'Archive::Extract';my $Self    = File::Spec->rel2abs(                     IS_WIN32 ? &Win32::GetShortPathName( cwd() ) : cwd()                 );my $SrcDir  = File::Spec->catdir( $Self,'src' );my $OutDir  = File::Spec->catdir( $Self,'out' );use_ok($Class);### set verbose if debug is on ###### stupid stupid silly stupid warnings silly! ###$Archive::Extract::VERBOSE  = $Archive::Extract::VERBOSE = $Debug;$Archive::Extract::WARN     = $Archive::Extract::WARN    = $Debug ? 1 : 0;my $tmpl = {    ### plain files    'x.bz2' => {    programs    => [qw[bunzip2]],                    modules     => [qw[IO::Uncompress::Bunzip2]],                    method      => 'is_bz2',                    outfile     => 'a',                },    'x.tgz' => {    programs    => [qw[gzip tar]],                    modules     => [qw[Archive::Tar IO::Zlib]],                    method      => 'is_tgz',                    outfile     => 'a',                },    'x.tar.gz' => { programs    => [qw[gzip tar]],                    modules     => [qw[Archive::Tar IO::Zlib]],                    method      => 'is_tgz',                    outfile     => 'a',                },    'x.tar' => {    programs    => [qw[tar]],                    modules     => [qw[Archive::Tar]],                    method      => 'is_tar',                    outfile     => 'a',                },    'x.gz'  => {    programs    => [qw[gzip]],                    modules     => [qw[Compress::Zlib]],                    method      => 'is_gz',                    outfile     => 'a',                },    'x.Z'   => {    programs    => [qw[uncompress]],                    modules     => [qw[Compress::Zlib]],                    method      => 'is_Z',                    outfile     => 'a',                },    'x.zip' => {    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'a',                },    'x.jar' => {    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'a',                },                    'x.par' => {    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'a',                },                    ### with a directory    'y.tbz'     => {    programs    => [qw[bunzip2 tar]],                        modules     => [qw[Archive::Tar                                            IO::Uncompress::Bunzip2]],                        method      => 'is_tbz',                        outfile     => 'z',                        outdir      => 'y',                    },    'y.tar.bz2' => {    programs    => [qw[bunzip2 tar]],                        modules     => [qw[Archive::Tar                                            IO::Uncompress::Bunzip2]],                        method      => 'is_tbz',                        outfile     => 'z',                        outdir      => 'y'                    },        'y.tgz'     => {    programs    => [qw[gzip tar]],                        modules     => [qw[Archive::Tar IO::Zlib]],                        method      => 'is_tgz',                        outfile     => 'z',                        outdir      => 'y'                    },    'y.tar.gz' => {     programs    => [qw[gzip tar]],                        modules     => [qw[Archive::Tar IO::Zlib]],                        method      => 'is_tgz',                        outfile     => 'z',                        outdir      => 'y'                    },    'y.tar' => {    programs    => [qw[tar]],                    modules     => [qw[Archive::Tar]],                    method      => 'is_tar',                    outfile     => 'z',                    outdir      => 'y'                },    'y.zip' => {    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'z',                    outdir      => 'y'                },    'y.par' => {    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'z',                    outdir      => 'y'                },    'y.jar' => {    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'z',                    outdir      => 'y'                },    ### with non-same top dir    'double_dir.zip' => {                    programs    => [qw[unzip]],                    modules     => [qw[Archive::Zip]],                    method      => 'is_zip',                    outfile     => 'w',                    outdir      => 'x'                },};### XXX special case: on older solaris boxes (8),### bunzip2 is version 0.9.x. Older versions (pre 1),### only extract files that end in .bz2, and nothing### else. So remove that test case if we have an older### bunzip2 :({   if( $Class->have_old_bunzip2 ) {        delete $tmpl->{'y.tbz'};        diag "Old bunzip2 detected, skipping .tbz test";    }}    ### show us the tools IPC::Cmd will use to run binary programsif( $Debug ) {    diag( "IPC::Run enabled: $IPC::Cmd::USE_IPC_RUN " );    diag( "IPC::Run available: " . IPC::Cmd->can_use_ipc_run );    diag( "IPC::Run vesion: $IPC::Run::VERSION" );    diag( "IPC::Open3 enabled: $IPC::Cmd::USE_IPC_OPEN3 " );    diag( "IPC::Open3 available: " . IPC::Cmd->can_use_ipc_open3 );    diag( "IPC::Open3 vesion: $IPC::Open3::VERSION" );}### test all type specifications to new()### this tests bug #24578: Wrong check for `type' argument{   my $meth = 'types';    can_ok( $Class, $meth );    my @types = $Class->$meth;    ok( scalar(@types),         "   Got a list of types" );        for my $type ( @types ) {        my $obj = $Class->new( archive => $Me, type => $type );        ok( $obj,               "   Object created based on '$type'" );        ok( !$obj->error,       "       No error logged" );    }}    ### XXX whitebox test

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -