/[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 507 by dpavlin, Tue Nov 25 00:26:15 2008 UTC revision 682 by dpavlin, Tue Dec 2 17:36:51 2008 UTC
# Line 8  with 'Frey::Storage'; Line 8  with 'Frey::Storage';
8  use TAP::Harness;  use TAP::Harness;
9  use TAP::Formatter::HTML;  use TAP::Formatter::HTML;
10  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
11    use File::Slurp;
12    
13  use Frey::SVK;  use Frey::SVK;
14  use Frey::PPI;  use Frey::PPI;
# Line 18  has tests => ( Line 19  has tests => (
19          required => 1,          required => 1,
20          lazy => 1, # FIXME ask users which tests to run          lazy => 1, # FIXME ask users which tests to run
21          default => sub {          default => sub {
 #               [ 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',          documentation => 'run tests which are result of modifications or whole full tests',
# Line 30  has test => ( Line 30  has test => (
30          documentation => 'run only this single test',          documentation => 'run only this single test',
31  );  );
32    
33  has depends => (  has test_because => (
34            documentation => 'returns classes responsable for each test run',
35          is => 'rw',          is => 'rw',
36  #       isa => 'HashRef[Hashref[Int]',  #       isa => 'HashRef[Hashref[Int]',
37          required => 1,          required => 1,
# Line 62  has depends => ( Line 63  has depends => (
63  sub as_markup {  sub as_markup {
64          my ($self) = @_;          my ($self) = @_;
65    
66    =for later
67    
68            my $path = 'var/test/';
69            my $running_pid = "$path/running.pid";
70    
71            my $pid = read_file $running_pid if -e $running_pid;
72            if ( $pid ) {
73                    if ( kill 0, $pid ) {
74                            warn "ABORTING: $self allready running as pid $pid";
75                            return 'abort';
76                    } else {
77                            warn "got $pid from $running_pid but no process alive, ignoring...";
78                    }
79            }
80    
81            write_file( $running_pid, $$ );
82            warn "# started $self with pid $$ -> $running_pid";
83    
84    =cut
85    
86          my $f = TAP::Formatter::HTML->new({          my $f = TAP::Formatter::HTML->new({
87  #               silent => 1,  #               silent => 1,
88    
# Line 77  sub as_markup { Line 98  sub as_markup {
98    
99          @tests = ( $self->test ) if $self->test;          @tests = ( $self->test ) if $self->test;
100    
101          if ( my $depends = $self->depends ) {          if ( my $depends = $self->test_because ) {
102                  @tests = grep {                  @tests = grep {
103                            $_ ne '' &&
104                          ! m{$0} # break recursion                                ! m{$0} # break recursion      
105                  } sort keys %{ $depends } unless @tests;                  } sort keys %{ $depends } unless @tests;
106          }          }
107    
108          $self->add_status( { test => { depends => $self->depends } } );          $self->add_status( { test => { depends => $self->test_because } } );
109    
110          if ( ! @tests ) {          if ( ! @tests ) {
111                  warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->depends );                  warn "can't find any tests ", dump( $self->tests ), " within depends ", dump( $self->test_because );
112                  warn "running all tests instead";  #               warn "running all tests instead";
113                  @tests = glob('t/*.t');  #               @tests = glob('t/*.t');
114                    @tests = ( qw{t/00-load.t t/pod.t} ); # XXX default tests
115          }          }
116    
117            $self->title( join(' ', @tests ) );
118    
119          warn "testing ",dump( @tests );          warn "testing ",dump( @tests );
120          $h->runtests( @tests );          $h->runtests( @tests );
121    
# Line 101  sub as_markup { Line 126  sub as_markup {
126          warn "got ",length($html), " bytes";          warn "got ",length($html), " bytes";
127    
128          while ( $html =~ s{(<style.+?/style>)}{}gs ) {          while ( $html =~ s{(<style.+?/style>)}{}gs ) {
129                  $self->add_head( $1 );                  my $style = $1;
130                    $style =~ s[((?:body|html)\s+{[^}]+})][/\* $1 \*/]sg; # remove some styles
131                    $self->add_head( $style );
132          }          }
133    
134          $self->add_head(qq|          $self->add_head(qq|
# Line 111  sub as_markup { Line 138  sub as_markup {
138                  td.results:hover ul.test-out { display: block; }                  td.results:hover ul.test-out { display: block; }
139                  </style>                  </style>
140          |);          |);
141            $html =~ s{<div id="menu">.+?</div>}{}sg; # remove menu which doesn't work without JavaScript
142    
143          $html =~ s{^.*<body>}{}s;          $html =~ s{^.*<body>}{}s;
144          $html =~ s{</body>.*$}{}s;          $html =~ s{</body>.*$}{}s;
145    
146          $html =~ s{(<a class="file") href="#"(.+?)>t/(.+?)</a>}{<a target="editor" href="/editor+t/$3.t+1" name="t/$3.t" $2>$3</a>}sg;          $html =~ s{(<a class="file") href="#"(.+?)>t/(.+?)</a>}{<a target="editor" href="/editor+t/$3.t+1" name="t/$3.t" $2>$3</a>}sg;
147    
148          return          $html = $self->html_links( $html );
149                  $self->editor_links( $html )  
150                  . qq|Test dependencies:<ul><li>|          if ( my $depends = $self->test_because ) {
151                    $html .= qq|Test dependencies:|
152                    . qq|<ul><li>|
153                  . join("</li>\n<li>",                  . join("</li>\n<li>",
154                          map {                          map {
155                                  qq|<a href="#$_"><tt>$_</tt></a> &larr; |                                  qq|<a href="?test=$_"><tt>$_</tt></a> &larr; |
156                                  .                                  .
157                                  join(' ',                                  join(' ',
158                                          map {                                          map {
# Line 132  sub as_markup { Line 162  sub as_markup {
162                                                          qq|<a target="introspect" href="/$_" title="introspect">$_</a>|                                                          qq|<a target="introspect" href="/$_" title="introspect">$_</a>|
163  #                                                       qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>|  #                                                       qq|<a target="editor" href="/editor+$_+1" title="edit">$_</a>|
164                                                  }                                                  }
165                                          } keys %{ $self->depends->{$_} }                                          } keys %{ $depends->{$_} }
166                                  )                                  )
167                          } @tests )                          } @tests )
168                  . qq|</li></ul>|                  . qq|</li></ul>|
169                  ;                  ;
170                    } else {
171                    warn "# test_because empty";
172            }
173    
174            $self->add_icon( $1 ) if $html =~ m{class="(passed|failed)"};
175    
176    =for later
177    
178            unlink $running_pid or die "can't remove $running_pid: $!";
179    
180    =cut
181    
182            return $html;
183  }  }
184    
185  1;  1;

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

  ViewVC Help
Powered by ViewVC 1.1.26