From 3717d3046c836f9c65dc1b7293134f56aea9e84c Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Thu, 6 May 2010 00:43:16 +0200 Subject: Use prove for tests. Might be a bit ugly right now... hm. --- test/feh.t | 83 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ test/test.pl | 83 ------------------------------------------------------------ 2 files changed, 83 insertions(+), 83 deletions(-) create mode 100644 test/feh.t delete mode 100644 test/test.pl (limited to 'test') diff --git a/test/feh.t b/test/feh.t new file mode 100644 index 0000000..2db0db0 --- /dev/null +++ b/test/feh.t @@ -0,0 +1,83 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use 5.010; +use Test::Command tests => 48; + +my $feh = 'src/feh'; +my $images = 'test/ok.* test/fail.*'; + +my ($feh_name, $feh_version) = @ENV{'PACKAGE', 'VERSION'}; + +my $re_warning = + qr{${feh_name} WARNING: test/fail\.... \- No Imlib2 loader for that file format\n}; +my $re_loadable = qr{test/ok\....}; +my $re_unloadable = qr{test/fail\....}; +my $re_list_action = qr{test/ok\.... 16x16 \(${feh_name}\)}; + +my $cmd = Test::Command->new(cmd => $feh); + +# Insufficient Arguments -> Usage should return failure +$cmd->exit_is_num(1, 'missing arguments return 1'); +$cmd->stdout_is_eq('', 'missing arguments print usage (!stdout)'); +$cmd->stderr_is_eq(<<"EOF", 'missing arguments print usage (stderr)'); +${feh_name} - No loadable images specified. +Use ${feh_name} --help for detailed usage information +EOF + +$cmd = Test::Command->new(cmd => "$feh --version"); + +$cmd->exit_is_num(0); +$cmd->stdout_is_eq("${feh_name} version ${feh_version}\n"); +$cmd->stderr_is_eq(''); + +$cmd = Test::Command->new(cmd => "$feh --loadable $images"); + +$cmd->exit_is_num(0); +$cmd->stdout_like($re_loadable); +$cmd->stderr_is_eq(''); + +$cmd = Test::Command->new(cmd => "$feh --unloadable $images"); + +$cmd->exit_is_num(0); +$cmd->stdout_like($re_unloadable); +$cmd->stderr_is_eq(''); + +$cmd = Test::Command->new(cmd => "$feh --list $images"); + +$cmd->exit_is_num(0); +$cmd->stdout_is_file('test/list'); +$cmd->stderr_like($re_warning); + +for my $sort (qw/name filename width height pixels size format/) { + $cmd = Test::Command->new(cmd => "$feh --list $images --sort $sort"); + + $cmd->exit_is_num(0); + $cmd->stdout_is_file("test/list_$sort"); + $cmd->stderr_like($re_warning); +} + +$cmd = Test::Command->new(cmd => "$feh --list $images --sort format --reverse"); + +$cmd->exit_is_num(0); +$cmd->stdout_is_file('test/list_format_reverse'); +$cmd->stderr_like($re_warning); + +$cmd = Test::Command->new(cmd => "$feh --customlist '%f; %h; %l; %m; %n; %p; " + . "%s; %t; %u; %w' $images"); + +$cmd->exit_is_num(0); +$cmd->stdout_is_file('test/customlist'); +$cmd->stderr_like($re_warning); + +$cmd = Test::Command->new(cmd => "$feh --list --quiet $images"); +$cmd->exit_is_num(0); +$cmd->stdout_is_file('test/list'); +$cmd->stderr_is_eq(''); + +$cmd = Test::Command->new(cmd => + "$feh --quiet --list --action 'echo \"%f %wx%h (%P)\" >&2' $images"); + +$cmd->exit_is_num(0); +$cmd->stdout_is_file('test/list'); +$cmd->stderr_like($re_list_action); diff --git a/test/test.pl b/test/test.pl deleted file mode 100644 index 4b18ccc..0000000 --- a/test/test.pl +++ /dev/null @@ -1,83 +0,0 @@ -#!/usr/bin/env perl -use strict; -use warnings; -use 5.010; -use Test::Command tests => 48; - -my $feh = 'src/feh'; -my $images = 'test/ok.* test/fail.*'; - -my ($feh_name, $feh_version) = @ARGV; - -my $re_warning = - qr{${feh_name} WARNING: test/fail\.... \- No Imlib2 loader for that file format\n}; -my $re_loadable = qr{test/ok\....}; -my $re_unloadable = qr{test/fail\....}; -my $re_list_action = qr{test/ok\.... 16x16 \(${feh_name}\)}; - -my $cmd = Test::Command->new(cmd => $feh); - -# Insufficient Arguments -> Usage should return failure -$cmd->exit_is_num(1, 'missing arguments return 1'); -$cmd->stdout_is_eq('', 'missing arguments print usage (!stdout)'); -$cmd->stderr_is_eq(<<"EOF", 'missing arguments print usage (stderr)'); -${feh_name} - No loadable images specified. -Use ${feh_name} --help for detailed usage information -EOF - -$cmd = Test::Command->new(cmd => "$feh --version"); - -$cmd->exit_is_num(0); -$cmd->stdout_is_eq("${feh_name} version ${feh_version}\n"); -$cmd->stderr_is_eq(''); - -$cmd = Test::Command->new(cmd => "$feh --loadable $images"); - -$cmd->exit_is_num(0); -$cmd->stdout_like($re_loadable); -$cmd->stderr_is_eq(''); - -$cmd = Test::Command->new(cmd => "$feh --unloadable $images"); - -$cmd->exit_is_num(0); -$cmd->stdout_like($re_unloadable); -$cmd->stderr_is_eq(''); - -$cmd = Test::Command->new(cmd => "$feh --list $images"); - -$cmd->exit_is_num(0); -$cmd->stdout_is_file('test/list'); -$cmd->stderr_like($re_warning); - -for my $sort (qw/name filename width height pixels size format/) { - $cmd = Test::Command->new(cmd => "$feh --list $images --sort $sort"); - - $cmd->exit_is_num(0); - $cmd->stdout_is_file("test/list_$sort"); - $cmd->stderr_like($re_warning); -} - -$cmd = Test::Command->new(cmd => "$feh --list $images --sort format --reverse"); - -$cmd->exit_is_num(0); -$cmd->stdout_is_file('test/list_format_reverse'); -$cmd->stderr_like($re_warning); - -$cmd = Test::Command->new(cmd => "$feh --customlist '%f; %h; %l; %m; %n; %p; " - . "%s; %t; %u; %w' $images"); - -$cmd->exit_is_num(0); -$cmd->stdout_is_file('test/customlist'); -$cmd->stderr_like($re_warning); - -$cmd = Test::Command->new(cmd => "$feh --list --quiet $images"); -$cmd->exit_is_num(0); -$cmd->stdout_is_file('test/list'); -$cmd->stderr_is_eq(''); - -$cmd = Test::Command->new(cmd => - "$feh --quiet --list --action 'echo \"%f %wx%h (%P)\" >&2' $images"); - -$cmd->exit_is_num(0); -$cmd->stdout_is_file('test/list'); -$cmd->stderr_like($re_list_action); -- cgit v1.2.3