stash.t 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. #! /usr/bin/env perl
  2. BEGIN {
  3. #if ($ENV{PERL_CORE}){
  4. # chdir('t') if -d 't';
  5. # if ($^O eq 'MacOS') {
  6. # @INC = qw(: ::lib ::macos:lib);
  7. # } else {
  8. # @INC = '.';
  9. # push @INC, '../lib';
  10. # }
  11. #} else {
  12. # unshift @INC, 't';
  13. #}
  14. use Config;
  15. if (($Config{'extensions'} !~ /\bB\b/) ){
  16. print "1..0 # Skip -- Perl configured without B module\n";
  17. exit 0;
  18. }
  19. if ($] < 5.007 and $^O eq 'os2'){
  20. print "1..0 # Skip -- stash tests disabled for OS2 5.6\n";
  21. exit 0;
  22. }
  23. #if ($^O eq 'MSWin32' and $Config{cc} =~ /^cl/i) {
  24. # print "1..0 # Skip -- stash tests skipped on MSVC for now\n";
  25. # exit 0;
  26. #}
  27. }
  28. use Test::More tests => 4;
  29. use strict;
  30. use Config;
  31. my $got;
  32. my $Is_VMS = $^O eq 'VMS';
  33. my $Is_MacOS = $^O eq 'MacOS';
  34. my $path = join " ", map { qq["-I$_"] } @INC;
  35. $path = '"-I../lib" "-Iperl_root:[lib]"' if $Is_VMS; # gets too long otherwise
  36. my $redir = $Is_MacOS ? "" : "2>&1";
  37. my $cover = $ENV{HARNESS_PERL_SWITCHES} || "";
  38. my $X = $^X =~ m/\s/ ? qq{"$^X"} : $^X;
  39. chomp($got = `$X $path "-MB::Stash" $cover "-Mwarnings" -e1`);
  40. $got =~ s/Using \w+blib\n// if $] < 5.008001;
  41. $got =~ s/-u//g;
  42. diag "got = $got";
  43. my @got = map { s/^\S+ //; $_ }
  44. sort { $a cmp $b }
  45. map { lc($_) . " " . $_ }
  46. split /,/, $got;
  47. diag "(after sorting)";
  48. diag "got = @got";
  49. ok (@got > 3, "not empty");
  50. ok ($got =~ /main,/, "contains main");
  51. ok ($got =~ /,warnings/, "contains warnings");
  52. @got = grep { ! /^(PerlIO|open)(?:::\w+)?$/ } @got;
  53. diag "(after perlio censorings)";
  54. diag "got = @got";
  55. @got = grep { ! /^Win32$/ } @got if $^O eq 'MSWin32';
  56. @got = grep { ! /^NetWare$/ } @got if $^O eq 'NetWare';
  57. @got = grep { ! /^(Cwd|File|File::Copy|OS2)$/ } @got if $^O eq 'os2';
  58. @got = grep { ! /^(Win32|Win32CORE|Cwd|Cygwin)$/} @got if $^O eq 'cygwin';
  59. @got = grep { ! /^(Devel::Cover)$/ } @got if $cover =~ /-MDevel::Cover/;
  60. # XXX freebsd prepends BSDPAN.pm ?
  61. @got = grep { ! /^(Exporter::Heavy|strict)$/} @got
  62. if $^O eq 'freebsd';
  63. @got = grep { ! /^(threads)$/} @got; # < 5.8.9
  64. if ($Is_VMS) {
  65. @got = grep { ! /^File(?:::Copy)?$/ } @got;
  66. @got = grep { ! /^VMS(?:::Filespec)?$/ } @got;
  67. @got = grep { ! /^vmsish$/ } @got;
  68. # Socket is optional/compiler version dependent
  69. @got = grep { ! /^Socket$/ } @got;
  70. }
  71. diag "(after platform censorings)";
  72. diag "got = @got";
  73. $got = "@got";
  74. my $expected = "attributes Carp Carp::Heavy DB Exporter Exporter::Heavy main Regexp strict warnings";
  75. if ($] < 5.008009) {
  76. $expected = "attributes Carp DB Exporter Exporter::Heavy main overload Regexp strict warnings";
  77. }
  78. if ($] < 5.008001) {
  79. $expected = "attributes Carp Carp::Heavy DB Exporter Exporter::Heavy main strict warnings";
  80. }
  81. if ($] >= 5.010) {
  82. $expected = "attributes Carp Carp::Heavy DB Exporter Exporter::Heavy main mro re Regexp strict Tie Tie::Hash warnings";
  83. }
  84. if ($] >= 5.011002) {
  85. $expected = "Carp DB Exporter Exporter::Heavy main mro re Regexp strict Tie Tie::Hash warnings";
  86. #Carp DB Exporter main mro re Regexp Tie Tie::Hash Tie::Hash::NamedCapture utf8 version warnings";
  87. }
  88. if ($] >= 5.011001 and $] < 5.011004) {
  89. $expected .= " XS::APItest::KeywordRPN";
  90. }
  91. if ($] >= 5.013004) {
  92. $expected = "Carp DB Exporter Exporter::Heavy main mro re Regexp strict Tie Tie::Hash warnings";
  93. }
  94. if ($] >= 5.013006) {
  95. $expected = "Carp DB Exporter Exporter::Heavy main mro re Regexp strict warnings";
  96. }
  97. $expected =~ s/(Exporter::Heavy|strict) //g if $^O eq 'freebsd';
  98. {
  99. no strict 'vars';
  100. if ($^O eq 'os2') {
  101. eval q(use vars '$OS2::is_aout';);
  102. }
  103. }
  104. TODO: {
  105. # todo: freebsd
  106. # local $TODO = "exact stashes may vary" if $^O !~ /^(MSWin32|cygwin|linux|darwin)$/;
  107. local $TODO = "exact stashes may vary";
  108. if ((($Config{static_ext} eq ' ')
  109. || ($Config{static_ext} eq '')
  110. || ($^O eq 'cygwin' and $Config{static_ext} =~ /^(Cwd )?Win32CORE$/))
  111. && !($^O eq 'os2' and $OS2::is_aout)
  112. ) {
  113. diag "got [$got]" if $got ne $expected;
  114. diag "expected [$expected]" if $got ne $expected;
  115. ok($got eq $expected);
  116. } else {
  117. ok(1, "skip: one or more static extensions");
  118. }
  119. }