/[cwmp]/google/trunk/t/10-request.t
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 /google/trunk/t/10-request.t

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

revision 112 by dpavlin, Fri Oct 26 11:42:39 2007 UTC revision 200 by dpavlin, Wed Nov 14 19:23:32 2007 UTC
# Line 4  use warnings; Line 4  use warnings;
4    
5  my $debug = shift @ARGV;  my $debug = shift @ARGV;
6    
7  use Test::More tests => 53;  use Test::More tests => 73;
8  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
9  use Cwd qw/abs_path/;  use Cwd qw/abs_path/;
10  use File::Slurp;  use File::Slurp;
# Line 21  ok( $#models + 1, 'got models' ); Line 21  ok( $#models + 1, 'got models' );
21  ok(my $abs_path = abs_path($0), "abs_path");  ok(my $abs_path = abs_path($0), "abs_path");
22  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim
23    
24    my $path2method;
25    my $triggers_count;
26    
27  sub file_is_deeply {  sub file_is_deeply {
28          my ( $path ) = @_;          my ( $path ) = @_;
29    
# Line 28  sub file_is_deeply { Line 31  sub file_is_deeply {
31    
32          diag $xml if $debug;          diag $xml if $debug;
33    
34            ok( my $trigger = $path2method->{$path}, "path2method($path)" );
35    
36            CWMP::Request->add_trigger( name => $trigger, callback => sub {
37                    my ( $self, $state ) = @_;
38                    $triggers_count->{$trigger}++;
39                    ok( $state, "called trigger $trigger" );
40            });
41    
42          ok( my $state = CWMP::Request->parse( $xml ), 'parse' );          ok( my $state = CWMP::Request->parse( $xml ), 'parse' );
43    
44          my $dump_path = $path;          my $dump_path = $path;
# Line 47  foreach my $model ( @models ) { Line 58  foreach my $model ( @models ) {
58    
59          my $dir = "$abs_path/$model/";          my $dir = "$abs_path/$model/";
60          opendir(DIR, $dir) || die "can't opendir $dir: $!";          opendir(DIR, $dir) || die "can't opendir $dir: $!";
61          my @xmls = map { "$dir/$_" } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);          my @xmls = map {
62                    my $path = "$dir/$_";
63                    my $method = $_;
64                    $method =~ s/\.xml$//;
65                    $path2method->{$path} = $method;
66                    $path;
67            } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);
68          closedir DIR;          closedir DIR;
69    
70          diag "$model has ", $#xmls + 1, " xml tests";          diag "$model has ", $#xmls + 1, " xml tests";
# Line 60  foreach my $model ( @models ) { Line 77  foreach my $model ( @models ) {
77          }          }
78  }  }
79    
80    diag "triggers_count = ",dump( $triggers_count ) if $debug;
81    

Legend:
Removed from v.112  
changed lines
  Added in v.200

  ViewVC Help
Powered by ViewVC 1.1.26