CPAN

 view release on metacpan or  search on metacpan

t/30shell.t  view on Meta::CPAN

               "mreq",
               "splitchunk",
               "test_name",
               "run_shell_cmd_lit",
              ) {
        no strict "refs";
        *$x = \&{"local_utils\::$x"};
    }
}

{
    local *FH;
    open *FH, (">"._f"t/dot-cpan-$$/build/Something-From-Builddir-0.00.yml") or die;
    my @stat = stat $^X;
    my $dll = eval {OS2::DLLname()};
    my $mtime_dll = 0;
    if (defined $dll) {
        $mtime_dll = (-f $dll ? (stat(_))[9] : '-1');
    }
    print FH <<EOF;
---
distribution: !!perl/hash:CPAN::Distribution
  ID: A/AN/ANDK/Something-From-Builddir-0.00.tar.gz
  RO:
    CPAN_COMMENT: ~
    CPAN_USERID: ANDK
  archived: tar
  make: !!perl/hash:CPAN::Distrostatus
    COMMANDID: 78
    FAILED: ''
    TEXT: YES
  make_test: !!perl/hash:CPAN::Distrostatus
    COMMANDID: 78
    FAILED: ''
    TEXT: YES
  unwrapped: !!perl/hash:CPAN::Distrostatus
    COMMANDID: 78
    FAILED: ''
    TEXT: YES
  writemakefile: !!perl/hash:CPAN::Distrostatus
    COMMANDID: 78
    FAILED: ''
    TEXT: YES
perl:
  \$^X: "$^X"
  mtime_dll: "$mtime_dll"
  sitearchexp: "$Config::Config{sitearchexp}"
  mtime_\$^X: $stat[9]
time: 1
EOF
}
    close FH; #attempt to fix RT#43779
cp _f"t/CPAN/authors/id/A/AN/ANDK/CHECKSUMS.2nd",
    _f"t/dot-cpan-$$/sources/authors/id/A/AN/ANDK/CHECKSUMS"
    or die "Could not cp t/CPAN/authors/id/A/AN/ANDK/CHECKSUMS.2nd ".
    "over t/dot-cpan-$$/sources/authors/id/A/AN/ANDK/CHECKSUMS: $!";
cp _f"t/CPAN/CpanTestDummies-1.55.pm",
    _f"t/dot-cpan-$$/Bundle/CpanTestDummies.pm" or die
    "Could not cp t/CPAN/CpanTestDummies-1.55.pm over ".
    "t/dot-cpan-$$/Bundle/CpanTestDummies.pm: $!";
cp _f"distroprefs/ANDK.CPAN-Test-Dummy-Perl5-Make-Expect.yml",
    _f"t/dot-cpan-$$/prefs/ANDK.CPAN-Test-Dummy-Perl5-Make-Expect.yml" or die
    "Could not cp distroprefs/ANDK.CPAN-Test-Dummy-Perl5-Make-Expect.yml to ".
    "t/dot-cpan-$$/prefs/ANDK.CPAN-Test-Dummy-Perl5-Make-Expect.yml: $!";

my $cwd = Cwd::cwd;

open FH, (">" . _f"t/dot-cpan-$$/prefs/TestDistroPrefsFile.yml") or die "Could not open: $!";
print FH <<EOF;
---
comment: "Having more than one yaml variable per file is OK?"
match:
  distribution: "matches never^"
---
match:
  module: "CPAN::Test::Dummy::Perl5::Build::Fails"
patches:
  - "$cwd/t/CPAN/TestPatch.txt"
EOF
close FH; #attempt to fix RT#43779

my @prgs;
{
    local $/;
    my $data = <DATA>;
    close DATA;
    $data =~ s/^=head.*//ms;
    @prgs = split /########.*/, $data;
}
my @modules = qw(
                 Archive::Zip
                 Data::Dumper
                 Digest::SHA
                 Expect
                 Module::Build
                 Term::ANSIColor
                 Term::ReadKey
                 Term::ReadLine
                 Text::Glob
                 YAML
                );
my @programs = qw(
                  patch
                 );

use Test::More;
plan tests => (
               scalar @prgs
               + 2                     # 2 histsize tests
               + 1                     # 1 RUN_EXPECT feedback
               + 1                     # run_..._cmd feedback
               + 1                     # spawn/open
               + 1                     # 1 count keys for 'o conf init variable'
               + 2                     # t/dot-cpan-$$/.../ANDK dir exists and is empty
               # + scalar @modules
              );

{
    my $m;
    for $m (@modules) {
        $HAVE->{$m}++ if mreq $m;
    }
}
{
    my $p;
    my(@path) = split /$Config::Config{path_sep}/, $ENV{PATH};
    require CPAN::FirstTime;
    for $p (@programs) {
        $HAVE->{$p}++ if CPAN::FirstTime::find_exe($p,\@path);
    }
}
$HAVE->{"Term::ReadLine::Perl||Term::ReadLine::Gnu"}
    =
    $HAVE->{"Term::ReadLine::Perl"}
    || $HAVE->{"Term::ReadLine::Gnu"};
# My impression is that wehn Devel::Cover is running we cannot test
# Expect. Across several perl versions the same test was hanging. Go
# figure.
if ($INC{"Devel/Cover.pm"}) {
    delete $HAVE->{Expect};
}
read_myconfig;
is($CPAN::Config->{histsize},100,"histsize is 100 before testing");

{
    require CPAN::HandleConfig;
    my @ociv_tests = map { /P:o conf init (\w+)/ && $1 } @prgs;
    my %ociv;
    @ociv{@ociv_tests} = ();
    my $keys = %CPAN::HandleConfig::keys; # to keep warnings silent
    # kwnt => "key words not tested"
    my @kwnt = sort grep { not exists $ociv{$_} }
        grep { ! m/
                   ^(?:
                   urllist
                   |.*_hash
                   |.*_list
                   |applypatch
                   |build_dir_reuse
                   |build_requires_install_policy
                   |colorize_output
                   |colorize_print
                   |colorize_warn
                   |commands_quote
                   |inhibit_startup_message
                   |password
                   |patch
                   |prefs_dir
                   |proxy_(?:user|pass)
                   |randomize_urllist
                   |use_sqlite
                   |username
                   |yaml_module
                  )$/x }
            keys %CPAN::HandleConfig::keys;
    my $test_tuning = 0; # from time to time we set it to 1 to find
                         # untested config variables
    if ($test_tuning) {
        ok(@kwnt==0,"key words not tested[@kwnt]");
        die if @kwnt;
    } else {
        ok(1,"Another dummy test");
    }
}

my $prompt = "cpan>";
my $prompt_re = "cpan[^>]*>"; # note: replicated in DATA!
my $default_timeout = $ENV{CPAN_EXPECT_TIMEOUT} || 240;

$|=1;
if ($ENV{CPAN_RUN_SHELL_TEST_WITHOUT_EXPECT}) {
    $RUN_EXPECT = 0;
} elsif ($Config::Config{archname} =~ /solaris/) {
    # expect on some solaris is broken enough to fail this test but
    # good enough to survive everyday work with the CPAN shell.
    $RUN_EXPECT = 0;
} else {
    $RUN_EXPECT = 1;
}
ok(1,"RUN_EXPECT[$RUN_EXPECT]\$^X[$^X]");
my $expo;
my @run_shell_cmd_lit = run_shell_cmd_lit($cwd,0);
ok(scalar @run_shell_cmd_lit,"@run_shell_cmd_lit");
if ($RUN_EXPECT) {
    $expo = Expect->new;
    $ENV{LANG} = "C";
    my $spawned = $expo->spawn(@run_shell_cmd_lit);
    ok($spawned, "could at least spawn a process and \$! is[$!]");
    $expo->log_stdout(0);
    $expo->notransfer(1);
} else {
    delete $HAVE->{Expect};
    my $system = join(" ", map { "\"$_\"" } @run_shell_cmd_lit)." > test-$$.out";
    # warn "# DEBUG: system[$system]";
    my $opened = open SYSTEM, "| $system";
    ok($opened, "Could at least open a process pipe and $! is [$!]");
}

my $skip_the_rest;
my @PAIRS;
TUPL: for my $i (0..$#prgs){
    my $chunk = $prgs[$i];
    my %h = splitchunk $chunk;
    my($status,$prog,$expected,$notexpected,
       $req,$test_timeout,$comment) = @h{qw(S P E e R T C N)};
    if ($skip_the_rest) {
        ok(1,"skipping");
        next TUPL;

t/30shell.t  view on Meta::CPAN

#P:b
#E:(?s:Bundle::CpanTestDummies.*?items found)
########
#P:b
#E:(?s:Bundle::Snapshot\S+\s+\(N/A\))
########
#P:o debug all
#E:CPAN[\s\S]+?CacheMgr[\s\S]+?FirstTime
########
#P:b Bundle::CpanTestDummies
#E:\sCONTAINS.+?CPAN::Test::Dummy::Perl5::Make.+?CPAN::Test::Dummy::Perl5::Make::Zip
#R:Archive::Zip
########
#P:o debug 0
#E:turned off
########
#P:install ANDK/NotInChecksums-0.000.tar.gz
#E:(?s:awry.*?yes)
#R:Digest::SHA
########
#P:n
#R:Digest::SHA
########
#P:d ANDK/CPAN-Test-Dummy-Perl5-Make-1.05.tar.gz
#E:CONTAINSMODS\s+CPAN::Test::Dummy::Perl5::Make
########
#P:d ANDK/CPAN-Test-Dummy-Perl5-Make-1.05.tar.gz
#E:CPAN_USERID.*?ANDK.*?Andreas
########
#P:ls ANDK
#E:\d+\s+\d\d\d\d-\d\d-\d\d\sANDK/CPAN-Test-Dummy[\d\D]*?\d+\s+\d\d\d\d-\d\d-\d\d\sANDK/Devel-Symdump
########
#P:ls ANDK/CPAN*
#E:Text::Glob\s+loaded\s+ok[\d\D]*?CPAN-Test-Dummy
#R:Text::Glob
########
#P:force ls ANDK/CPAN*
#E:CPAN-Test-Dummy
#R:Text::Glob
########
#P:o debug all
#E:CPAN[\s\S]+?CacheMgr[\s\S]+?FirstTime
########
#P:test CPAN::Test::Dummy::Perl5::Make
#E:test\s+--\s+OK
########
#P:test CPAN::Test::Dummy::Perl5::Build
#E:\s\sANDK/CPAN-Test-Dummy-Perl5-Build-1.03.tar.gz[\s\S]*?test\s+--\s+OK
#R:Module::Build Archive::Zip
########
#P:o debug 0
#E:turned off
########
#P:test CPAN::Test::Dummy::Perl5::Make::Zip
#E:Has already been tested successfully
#R:Archive::Zip Module::Build
########
#P:failed
#E:Nothing
########
#P:o conf prefs_dir ""
#N:to hide the YAML file
########
#P:o conf prefs_dir
#E:prefs_dir
########
#P:test CPAN::Test::Dummy::Perl5::Build::Fails
#E:test\s+--\s+NOT OK
#R:Module::Build
#C:If this test fails, it's probably due to Test::Harness being < 2.62
########
#P:dump CPAN::Test::Dummy::Perl5::Make
#E:\}.+?CPAN::Module.+?;
#R:Data::Dumper
########
#P:install CPAN::Test::Dummy::Perl5::Make::Failearly
#E:Failed during this command[\d\D]+?writemakefile NO
########
#P:test CPAN::Test::Dummy::Perl5::NotExists
#E:Warning:
########
#P:clean NOTEXISTS/Notxists-0.000.tar.gz
#E:nothing done
########
#P:failed
#E:Test-Dummy-Perl5-Build-Fails.*?make_test NO
#R:Module::Build
########
#P:failed
#E:Test-Dummy-Perl5-Make-Failearly.*?writemakefile NO
########
#P:o conf commandnumber_in_prompt 1
########
#P:o conf build_cache 0.1
#E:build_cache
########
#P:reload index
#E:staleness
########
#P:m /l/
#E:(?s:Perl5.*?Fcntl.*?items)
########
#P:i /l/
#E:(?s:Dummies.*?Dummy.*?Perl5.*?Fcntl.*?items)
########
#P:h
#E:(?s:make.*?test.*?install.*?force.*?notest.*?reload)
########
#P:o conf
#E:commit[\d\D]*?build_cache[\d\D]*?cpan_home[\d\D]*?inhibit_startup_message[\d\D]*?urllist[\d\D]*?wget
########
#P:o conf prefer_installer EUMM
#E:EUMM\]
########
#P:dump CPAN::Test::Dummy::Perl5::BuildOrMake
#E:\}.+?CPAN::Module
########
#P:dump ANDK/CPAN-Test-Dummy-Perl5-BuildOrMake-1.02.tar.gz
#E:\}.+?CPAN::Distribution
########
#P:make CPAN::Test::Dummy::Perl5::BuildOrMake
#E:(?s:Running make.*?Writing Makefile.*?make["']?\s+-- OK)
#C:first try
########
#P:o conf prefer_installer MB



( run in 0.767 second using v1.01-cache-2.11-cpan-0bb4e1dffa6 )