Fix tests

Display differences between expected and actual strings more readily by using Test::Differences
This commit is contained in:
Duncan Ferguson 2012-11-26 21:42:06 +00:00
parent 521b1fd37c
commit 5e51e41790
3 changed files with 16 additions and 15 deletions

View file

@ -34,6 +34,7 @@ my $build = Module::Build->new(
'File::Which' => 0,
'File::Temp' => 0,
'Test::DistManifest' => 0,
'Test::Differences' => 0,
},
add_to_cleanup => ['App-ClusterSSH-*'],
create_makefile_pl => 'traditional',

View file

@ -10,3 +10,4 @@
^WIP_TASKS$
^Makefile$
^Makefile.old$
pm_to_blib

View file

@ -8,6 +8,7 @@ use Test::More;
use Test::Trap;
use File::Which qw(which);
use File::Temp qw(tempdir);
use Test::Differences;
use Readonly;
@ -72,8 +73,8 @@ Readonly::Hash my %default_config => {
history_height => 10,
command => q{},
title => q{15CONFIG.T},
comms => q{ssh},
title => q{15CONFIG.T},
comms => q{ssh},
max_host_menu_items => 30,
max_addhost_menu_cluster_items => 6,
@ -241,11 +242,11 @@ is( $trap->stdout, q{}, 'Expecting no STDOUT' );
is( $trap->stderr, q{}, 'Expecting no STDERR' );
is_deeply( $config, \%expected, 'amended config is correct' );
is( $path, which('ls'), 'Found correct path to "ls"' );
is( $path, $newpath, 'No change made from find_binary');
is( $path, $newpath, 'No change made from find_binary' );
# give false path to force another search
trap {
$newpath = $config->find_binary('/does/not/exist/'.$path);
$newpath = $config->find_binary( '/does/not/exist/' . $path );
};
is( $trap->leaveby, 'return', 'returned ok' );
isa_ok( $config, "App::ClusterSSH::Config" );
@ -254,7 +255,7 @@ is( $trap->stdout, q{}, 'Expecting no STDOUT' );
is( $trap->stderr, q{}, 'Expecting no STDERR' );
is_deeply( $config, \%expected, 'amended config is correct' );
is( $path, which('ls'), 'Found correct path to "ls"' );
is( $path, $newpath, 'No change made from find_binary');
is( $path, $newpath, 'No change made from find_binary' );
note('Checks on loading configs');
note('empty dir');
@ -456,12 +457,12 @@ is( $trap->stderr,
);
note('Checking dump');
$config = App::ClusterSSH::Config->new();
$config = App::ClusterSSH::Config->new(
send_menu_xml_file => $ENV{HOME} . '/.csshrc_send_menu' );
trap {
$config->dump();
};
my $expected = <<'EOF';
# Configuration dump produced by "cssh -u"
my $expected = qq{# Configuration dump produced by "cssh -u"
auto_close=5
auto_quit=yes
console_position=
@ -486,7 +487,7 @@ screen_reserve_bottom=60
screen_reserve_left=0
screen_reserve_right=0
screen_reserve_top=0
send_menu_xml_file=/home/dferguson/.csshrc_send_menu
send_menu_xml_file=} . $ENV{HOME} . qq{/.csshrc_send_menu
show_history=0
ssh_args=
telnet_args=
@ -509,13 +510,11 @@ use_all_a_records=0
use_hotkeys=yes
window_tiling=yes
window_tiling_direction=right
EOF
$expected =~ s#/home/dferguson#$ENV{HOME}#; # he don't live here no more
};
isa_ok( $config, "App::ClusterSSH::Config" );
is( $trap->die, undef, 'die message correct' );
is( $trap->stdout, $expected, 'Expecting no STDOUT' );
is( $trap->stderr, q{}, 'Expecting no STDERR' );
is( $trap->die, undef, 'die message correct' );
eq_or_diff( $trap->stdout, $expected, 'Expecting no STDOUT' );
is( $trap->stderr, q{}, 'Expecting no STDERR' );
done_testing();