File: 05-runcommand-nomoose.t

package info (click to toggle)
libdist-zilla-util-test-kentnl-perl 1.005014-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 340 kB
  • sloc: perl: 595; makefile: 2
file content (63 lines) | stat: -rw-r--r-- 1,698 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
use strict;
use warnings;

use Test::More;

my @paths;
my %inc_report;

BEGIN {
  unshift @INC, sub {
    my ( $self, $file ) = @_;
    return unless $file =~ /\AMoose.pm\z/;
    my @path;
    my $i = 0;
    my (@call) = caller($i);
    while ( $call[0] ) {

      #next if $call[0] =~ /\AMoose(\z|::)/;
      my $nick = $call[1];
      for my $dir_no ( 0 .. $#INC ) {
        next if ref $INC[$dir_no];
        my $dir = $INC[$dir_no];
        my $sub = sprintf '@INC[%d]', $dir_no;
        if ( $nick =~ s/\A\Q$dir\E/$sub/ ) {
          $inc_report{$dir_no} = $INC[$dir_no];
          last;
        }
      }
      push @path, sprintf "%-30s line %4s *( %s %s )", $nick, $call[2], $call[0], $call[3];
    }
    continue {
      $i++;
      (@call) = caller($i);
    }
    push @paths, join qq{\n\t}, @path;
    return;
  };
}
use Test::DZil qw( simple_ini );
use Dist::Zilla::Util::Test::KENTNL qw( dztest );
use Dist::Zilla::App::Command::authordeps;

# FILENAME: 02-basic-dztest.t
# ABSTRACT: Make sure dztest works

my $test     = dztest;
my $was_good = 0;
$test->add_file( 'dist.ini', simple_ini( ['GatherDir'] ) );
{
  local $TODO = "This wont always pass on systems because things :(";
  my $result = $test->run_command( ['version'] );
  ok( ref $result, 'version executed' );
  is( $result->error,     undef, 'no errors' );
  is( $result->exit_code, 0,     'exit = 0' );
  note( $result->stdout );
  $was_good = is( ( scalar @paths ), 0, "No Moose paths accidentally loaded" );
}
unless ($was_good) {
  diag "Moose is loaded by accident to simply to test `dzil version`. Causes:", join qq[\n], @paths;
  diag map { "INC[$_] => " . $inc_report{$_} } sort keys %inc_report;
}
done_testing;