/[Frey]/trunk/lib/Frey/Test/Runner.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/lib/Frey/Test/Runner.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 503 by dpavlin, Mon Nov 24 21:50:05 2008 UTC revision 507 by dpavlin, Tue Nov 25 00:26:15 2008 UTC
# Line 21  has tests => ( Line 21  has tests => (
21  #               [ glob('t/*.t') ] # all tests  #               [ glob('t/*.t') ] # all tests
22                  [ Frey::SVK->modified ]                  [ Frey::SVK->modified ]
23          },          },
24            documentation => 'run tests which are result of modifications or whole full tests',
25    );
26    
27    has test => (
28            is => 'rw',
29            isa => 'Str',
30            documentation => 'run only this single test',
31    );
32    
33    has depends => (
34            is => 'rw',
35    #       isa => 'HashRef[Hashref[Int]',
36            required => 1,
37            lazy => 1,
38            default => sub {
39                    my $self = shift;
40                    my $depends;
41    
42                    # collect real tests
43                    map {
44                            $depends->{$_}->{'test modified'}++ if m{\.t$};
45                    } @{ $self->tests };
46    
47                    # and tests which depend on modified classes supplied
48                    map {
49                            if ( m{(.+)\.pm$} ) {
50                                    my $class = $1;
51                                    $class =~ s{^lib/}{};
52                                    $class =~ s{/}{::}g;
53                                    warn "extract tests from $_ class $class";
54                                    $depends->{$_}->{$class}++ foreach Frey::PPI->new( class => $class )->has_tests;
55                            }
56                    } @{ $self->tests };
57    
58                    return $depends;
59            },
60  );  );
61    
62  sub as_markup {  sub as_markup {
# Line 37  sub as_markup { Line 73  sub as_markup {
73                  formatter => $f,                  formatter => $f,
74          });          });
75    
76          my $tests;          my @tests;
77    
78          map {          @tests = ( $self->test ) if $self->test;
79                  $tests->{$_}->{'test modified'}++ if m{\.t$};  
80          } @{ $self->tests };          if ( my $depends = $self->depends ) {
81                    @tests = grep {
82          map {                          ! m{$0} # break recursion      
83                  if ( m{(.+)\.pm$} ) {                  } sort keys %{ $depends } unless @tests;
84                          my $class = $1;          }
85                          $class =~ s{^lib/}{};  
86                          $class =~ s{/}{::}g;          $self->add_status( { test => { depends => $self->depends } } );
87                          warn "extract tests from $_ class $class";  
88                          $tests->{$_}->{$class}++ foreach Frey::PPI->new( class => $class )->has_tests;          if ( ! @tests ) {
89                  }                  warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->depends );
90          } @{ $self->tests };                  warn "running all tests instead";
91                    @tests = glob('t/*.t');
92          my @tests = grep {          }
                 ! m{$0} # break recursion        
         } sort keys %$tests;  
         die "no tests for files ", dump( $self->tests ),dump( $tests ) unless @tests;  
93    
94          warn "testing ",dump( @tests );          warn "testing ",dump( @tests );
95          $h->runtests( @tests );          $h->runtests( @tests );
96    
97          $self->store( 'var/test/' . time() . '.yaml', $h );          $self->store( 'var/test/' . time() . '.yaml', $h );
98    
         push @{ $self->status }, { test => $tests };  
   
99          my $html = ${ $f->html };          my $html = ${ $f->html };
100  #       warn $html;  #       warn $html;
101          warn "got ",length($html), " bytes";          warn "got ",length($html), " bytes";
# Line 88  sub as_markup { Line 119  sub as_markup {
119    
120          return          return
121                  $self->editor_links( $html )                  $self->editor_links( $html )
122                  . qq|<ul><li>|                  . qq|Test dependencies:<ul><li>|
123                  . join("</li>\n<li>",                  . join("</li>\n<li>",
124                          map {                          map {
125                                  qq|<a href="#$_"><tt>$_</tt></a> &larr; |                                  qq|<a href="#$_"><tt>$_</tt></a> &larr; |
# Line 101  sub as_markup { Line 132  sub as_markup {
132                                                          qq|<a target="introspect" href="/$_" title="introspect">$_</a>|                                                          qq|<a target="introspect" href="/$_" title="introspect">$_</a>|
133  #                                                       qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>|  #                                                       qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>|
134                                                  }                                                  }
135                                          } keys %{ $tests->{$_} }                                          } keys %{ $self->depends->{$_} }
136                                  )                                  )
137                          } @tests )                          } @tests )
138                  . qq|</li></ul>|                  . qq|</li></ul>|

Legend:
Removed from v.503  
changed lines
  Added in v.507

  ViewVC Help
Powered by ViewVC 1.1.26