summaryrefslogtreecommitdiff
path: root/test/feh.t
diff options
context:
space:
mode:
Diffstat (limited to 'test/feh.t')
-rw-r--r--test/feh.t78
1 files changed, 50 insertions, 28 deletions
diff --git a/test/feh.t b/test/feh.t
index a3a5650..ac9262f 100644
--- a/test/feh.t
+++ b/test/feh.t
@@ -2,38 +2,33 @@
use strict;
use warnings;
use 5.010;
-use Test::Command tests => 48;
+use Test::Command tests => 59;
-my $fehrc = "/tmp/.fehrc-$$";
-my $feh = "src/feh --rcfile $fehrc";
+$ENV{HOME} = 'test';
+
+my $feh = "src/feh";
my $images = 'test/ok/gif test/ok/jpg test/ok/png test/ok/pnm '
. 'test/fail/gif test/fail/jpg test/fail/png test/fail/pnm';
-my ($feh_name, $feh_version) = @ENV{'PACKAGE', 'VERSION'};
+my $feh_name = $ENV{'PACKAGE'};
# These tests are meant to run non-interactively and without X.
# make sure they are capable of doing so.
delete $ENV{'DISPLAY'};
-# Create empty fehrc so that feh does not create one in $HOME
-# (mostly for build servers)
-open(my $fh, '>', $fehrc) or die("Can't create $fehrc: $!");
-close($fh) or die("Can't close $fehrc: $!");
-
my $err_no_env = <<'EOF';
-Unable to determine feh PACKAGE or VERSION.
+Unable to determine feh PACKAGE.
This is most likely because you ran 'prove test' or 'perl test/feh.t'.
-Sinc this test uses make variables and is therefore designed to be run from
+Since this test uses make variables and is therefore designed to be run from
the Makefile only, use 'make test' instead.
If you absolutely need to run it the other way, use
- PACKAGE=feh VERSION=1.5 ${your_command}
-(with the appropiate values, of course).
+ PACKAGE=feh ${your_command}
EOF
-if (length($feh_name) == 0 or length($feh_version) == 0) {
+if (length($feh_name) == 0) {
die($err_no_env);
}
@@ -43,20 +38,9 @@ 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");
+my $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");
@@ -65,6 +49,38 @@ $cmd->exit_is_num(0);
$cmd->stdout_like($re_loadable);
$cmd->stderr_is_eq('');
+$cmd = Test::Command->new(
+ cmd => "$feh --loadable --action 'echo touch %f' $images"
+);
+
+$cmd->exit_is_num(0);
+$cmd->stdout_is_file('test/nx_action/loadable_action');
+$cmd->stderr_is_eq('');
+
+$cmd = Test::Command->new(
+ cmd => "$feh --loadable --action ';echo touch %f' $images"
+);
+
+$cmd->exit_is_num(0);
+$cmd->stdout_is_file('test/nx_action/loadable_naction');
+$cmd->stderr_is_eq('');
+
+$cmd = Test::Command->new(
+ cmd => "$feh --unloadable --action 'echo rm %f' $images"
+);
+
+$cmd->exit_is_num(0);
+$cmd->stdout_is_file('test/nx_action/unloadable_action');
+$cmd->stderr_is_eq('');
+
+$cmd = Test::Command->new(
+ cmd => "$feh --unloadable --action ';echo rm %f' $images"
+);
+
+$cmd->exit_is_num(0);
+$cmd->stdout_is_file('test/nx_action/unloadable_naction');
+$cmd->stderr_is_eq('');
+
$cmd = Test::Command->new(cmd => "$feh --unloadable $images");
$cmd->exit_is_num(0);
@@ -91,6 +107,14 @@ $cmd->exit_is_num(0);
$cmd->stdout_is_file('test/list/format_reverse');
$cmd->stderr_like($re_warning);
+$cmd = Test::Command->new(
+ cmd => "$feh --list --recursive --sort filename test/ok"
+);
+
+$cmd->exit_is_num(0);
+$cmd->stdout_is_file('test/list/filename_recursive');
+$cmd->stderr_is_eq('');
+
$cmd = Test::Command->new(cmd => "$feh --customlist '%f; %h; %l; %m; %n; %p; "
. "%s; %t; %u; %w' $images");
@@ -109,5 +133,3 @@ $cmd = Test::Command->new(cmd =>
$cmd->exit_is_num(0);
$cmd->stdout_is_file('test/list/default');
$cmd->stderr_like($re_list_action);
-
-unlink($fehrc);