summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2010-05-05 19:05:13 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2010-05-05 19:05:13 +0200
commit1cffd68005a6cfce7a069453f4d9142a712c6af1 (patch)
treebea5cf9d30cef52f464611ec7ff2595cf549451a /test
parente70bc120e82090d705fee0db5272b1ccb4b57cc5 (diff)
Add a test script
I know that there is one in the old SVN repo, but I think a rewrite (with an automated test script) is due.
Diffstat (limited to 'test')
-rw-r--r--test/customlist4
-rw-r--r--test/fail.gif0
-rw-r--r--test/fail.jpg0
-rw-r--r--test/fail.png0
-rw-r--r--test/fail.pnm0
-rw-r--r--test/list5
-rw-r--r--test/ok.gifbin0 -> 953 bytes
-rw-r--r--test/ok.jpgbin0 -> 354 bytes
-rw-r--r--test/ok.pngbin0 -> 403 bytes
-rw-r--r--test/ok.pnmbin0 -> 269 bytes
-rw-r--r--test/test.pl52
-rw-r--r--test/warning-no-loader4
12 files changed, 65 insertions, 0 deletions
diff --git a/test/customlist b/test/customlist
new file mode 100644
index 0000000..3595be4
--- /dev/null
+++ b/test/customlist
@@ -0,0 +1,4 @@
+test/ok.gif; 16; 4; list; ok.gif; 256; 953; gif; 0; 16
+test/ok.jpg; 16; 4; list; ok.jpg; 256; 354; jpeg; 0; 16
+test/ok.png; 16; 4; list; ok.png; 256; 403; png; 0; 16
+test/ok.pnm; 16; 4; list; ok.pnm; 256; 269; pnm; 0; 16
diff --git a/test/fail.gif b/test/fail.gif
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/fail.gif
diff --git a/test/fail.jpg b/test/fail.jpg
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/fail.jpg
diff --git a/test/fail.png b/test/fail.png
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/fail.png
diff --git a/test/fail.pnm b/test/fail.pnm
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/fail.pnm
diff --git a/test/list b/test/list
new file mode 100644
index 0000000..036b0f4
--- /dev/null
+++ b/test/list
@@ -0,0 +1,5 @@
+NUM FORMAT WIDTH HEIGHT PIXELS SIZE(bytes) ALPHA FILENAME
+1 gif 16 16 256 953 - test/ok.gif
+2 jpeg 16 16 256 354 - test/ok.jpg
+3 png 16 16 256 403 X test/ok.png
+4 pnm 16 16 256 269 - test/ok.pnm
diff --git a/test/ok.gif b/test/ok.gif
new file mode 100644
index 0000000..613264e
--- /dev/null
+++ b/test/ok.gif
Binary files differ
diff --git a/test/ok.jpg b/test/ok.jpg
new file mode 100644
index 0000000..060565e
--- /dev/null
+++ b/test/ok.jpg
Binary files differ
diff --git a/test/ok.png b/test/ok.png
new file mode 100644
index 0000000..2f06506
--- /dev/null
+++ b/test/ok.png
Binary files differ
diff --git a/test/ok.pnm b/test/ok.pnm
new file mode 100644
index 0000000..d62d062
--- /dev/null
+++ b/test/ok.pnm
Binary files differ
diff --git a/test/test.pl b/test/test.pl
new file mode 100644
index 0000000..69ba824
--- /dev/null
+++ b/test/test.pl
@@ -0,0 +1,52 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use 5.010;
+use Test::Command tests => 18;
+
+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 $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
+
+# feh --version / feh -v
+$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);
+
+$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);
diff --git a/test/warning-no-loader b/test/warning-no-loader
new file mode 100644
index 0000000..0ab95a5
--- /dev/null
+++ b/test/warning-no-loader
@@ -0,0 +1,4 @@
+feh WARNING: test/fail.pnm - No Imlib2 loader for that file format
+feh WARNING: test/fail.png - No Imlib2 loader for that file format
+feh WARNING: test/fail.jpg - No Imlib2 loader for that file format
+feh WARNING: test/fail.gif - No Imlib2 loader for that file format