Skip to content

Commit

Permalink
subtest_remote() now tests all remote sources for all categories
Browse files Browse the repository at this point in the history
  • Loading branch information
book committed May 4, 2012
1 parent e5a867d commit dbde66e
Showing 1 changed file with 31 additions and 21 deletions.
52 changes: 31 additions & 21 deletions lib/Test/MetaSyntactic.pm
Expand Up @@ -330,29 +330,39 @@ sub subtest_remote {
: !$has_network ? 'Remote list test needs network'
: '';

my $tb = __PACKAGE__->builder;
$tb->plan( tests => 1 );
my $tb = __PACKAGE__->builder;
my @metas = _theme_sublists($theme);
$tb->plan( tests => scalar @metas );

SKIP: {
$tb->skip($why) and last SKIP if $why;

no warnings 'utf8';
my $current = [ sort $class->name(0) ];
my $remote = [ sort $class->remote_list() ];

$tb->skip("Fetching remote items for $theme probably failed")
and last SKIP
if !@$remote;

# compare both lists
my %seen;
$seen{$_}++ for @$remote;
$seen{$_}-- for @$current;
$tb->ok( !grep( $_, values %seen ),
"Local and remote lists are identical for $theme" )
or $tb->diag("Differences between local and remote list:");
$tb->diag( $seen{$_} > 0 ? "+ $_" : "- $_" )
for grep $seen{$_}, sort keys %seen;
if ($why) {
$tb->skip($why) for 1 .. @metas;
last SKIP;
}


for my $test (@metas) {
my ( $ams, $theme ) = @$test;

no warnings 'utf8';
my $current = [ sort $ams->name(0) ];
my $remote = [ sort $ams->remote_list() ];

if ( !@$remote ) {
$tb->skip("Fetching remote items for $theme probably failed");
next;
}

# compare both lists
my %seen;
$seen{$_}++ for @$remote;
$seen{$_}-- for @$current;
$tb->ok( !grep( $_, values %seen ),
"Local and remote lists are identical for $theme" )
or $tb->diag("Differences between local and remote list:");
$tb->diag( $seen{$_} > 0 ? "+ $_" : "- $_" )
for grep $seen{$_}, sort keys %seen;
}
}
}

Expand Down

0 comments on commit dbde66e

Please sign in to comment.