/[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

google/t/10-request.t revision 63 by dpavlin, Wed Jun 20 21:38:09 2007 UTC google/trunk/t/10-request.t revision 227 by dpavlin, Sun Nov 25 18:51:26 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 => 28;  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;
11  use blib;  use blib;
12    
13    #use Devel::LeakTrace::Fast;
14    
15  BEGIN {  BEGIN {
16          use_ok('CWMP::Request');          use_ok('CWMP::Request');
17  }  }
18    
19  my @models = ( qw/SpeedTouch-706/ );  my @models = ( qw/SpeedTouch-706 SpeedTouch-780/ );
20    
21  ok( $#models + 1, 'got models' );  ok( $#models + 1, 'got models' );
22    
23  ok(my $abs_path = abs_path($0), "abs_path");  ok(my $abs_path = abs_path($0), "abs_path");
24  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim  $abs_path =~ s!/[^/]*$!/!;      #!fix-vim
25    
26    my $path2method;
27    my $triggers_count;
28    
29  sub file_is_deeply {  sub file_is_deeply {
30          my ( $path ) = @_;          my ( $path ) = @_;
31    
# Line 28  sub file_is_deeply { Line 33  sub file_is_deeply {
33    
34          diag $xml if $debug;          diag $xml if $debug;
35    
36            ok( my $trigger = $path2method->{$path}, "path2method($path)" );
37    
38            CWMP::Request->add_trigger( name => $trigger, callback => sub {
39                    my ( $self, $state ) = @_;
40                    $triggers_count->{$trigger}++;
41                    ok( $state, "called trigger $trigger" );
42            });
43    
44          ok( my $state = CWMP::Request->parse( $xml ), 'parse' );          ok( my $state = CWMP::Request->parse( $xml ), 'parse' );
45    
46          my $dump_path = $path;          my $dump_path = $path;
# Line 47  foreach my $model ( @models ) { Line 60  foreach my $model ( @models ) {
60    
61          my $dir = "$abs_path/$model/";          my $dir = "$abs_path/$model/";
62          opendir(DIR, $dir) || die "can't opendir $dir: $!";          opendir(DIR, $dir) || die "can't opendir $dir: $!";
63          my @xmls = map { "$dir/$_" } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);          my @xmls = map {
64                    my $path = "$dir/$_";
65                    my $method = $_;
66                    $method =~ s/\.xml$//;
67                    $path2method->{$path} = $method;
68                    $path;
69            } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);
70          closedir DIR;          closedir DIR;
71    
72          diag "got ", $#xmls + 1, " xml tests";          diag "$model has ", $#xmls + 1, " xml tests";
73    
74          ok( $#xmls, "xmls" );          ok( $#xmls, "xmls" );
75    
# Line 60  foreach my $model ( @models ) { Line 79  foreach my $model ( @models ) {
79          }          }
80  }  }
81    
82    diag "triggers_count = ",dump( $triggers_count ) if $debug;
83    

Legend:
Removed from v.63  
changed lines
  Added in v.227

  ViewVC Help
Powered by ViewVC 1.1.26