5 my $debug = shift @ARGV;
7 use Test::More tests => 73;
8 use Data::Dump qw/dump/;
13 # XML::Rules doesn't like it!
14 #use Devel::LeakTrace::Fast;
17 use_ok('CWMP::Parser');
20 my @models = ( qw/SpeedTouch-706 SpeedTouch-780/ );
22 ok( $#models + 1, 'got models' );
24 ok(my $abs_path = abs_path($0), "abs_path");
25 $abs_path =~ s!/[^/]*$!/!; #!fix-vim
33 ok( my $xml = read_file( $path ), "read_file( $path )" );
37 ok( my $trigger = $path2method->{$path}, "path2method($path)" );
39 ok( my $state = CWMP::Parser->parse( $xml ), 'parse' );
41 my $dump_path = $path;
42 $dump_path =~ s/\.xml/\.pl/;
44 write_file( $dump_path, dump( $state ) ) unless ( -e $dump_path );
46 diag "$path ? $dump_path" if $debug;
48 ok( my $hash = read_file( $dump_path ), "read_file( $dump_path )" );
49 ok ( $hash = eval "$hash", 'eval' );
51 is_deeply( $state, $hash, 'same' );
54 foreach my $model ( @models ) {
56 my $dir = "$abs_path/$model/";
57 opendir(DIR, $dir) || die "can't opendir $dir: $!";
61 $method =~ s/\.xml$//;
62 $path2method->{$path} = $method;
64 } grep { /\.xml$/ && -f "$dir/$_" } readdir(DIR);
67 diag "$model has ", $#xmls + 1, " xml tests";
71 foreach my $xml_path ( @xmls ) {
72 ok ( $xml_path, 'xml path' );
73 file_is_deeply( $xml_path );
77 diag "triggers_count = ",dump( $triggers_count ) if $debug;