From 1cffd68005a6cfce7a069453f4d9142a712c6af1 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 5 May 2010 19:05:13 +0200 Subject: [PATCH] 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. --- Makefile | 8 +++++-- test/customlist | 4 ++++ test/fail.gif | 0 test/fail.jpg | 0 test/fail.png | 0 test/fail.pnm | 0 test/list | 5 ++++ test/ok.gif | Bin 0 -> 953 bytes test/ok.jpg | Bin 0 -> 354 bytes test/ok.png | Bin 0 -> 403 bytes test/ok.pnm | Bin 0 -> 269 bytes test/test.pl | 52 +++++++++++++++++++++++++++++++++++++++++ test/warning-no-loader | 4 ++++ 13 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 test/customlist create mode 100644 test/fail.gif create mode 100644 test/fail.jpg create mode 100644 test/fail.png create mode 100644 test/fail.pnm create mode 100644 test/list create mode 100644 test/ok.gif create mode 100644 test/ok.jpg create mode 100644 test/ok.png create mode 100644 test/ok.pnm create mode 100644 test/test.pl create mode 100644 test/warning-no-loader diff --git a/Makefile b/Makefile index f2ca42f..53a1b5d 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,12 @@ include config.mk -default: +all: @${MAKE} -C src +test: all + mandoc -Tlint man/* + perl test/test.pl ${PACKAGE} ${VERSION} + install: install-man install-doc install-bin install-font install-img install-man: @@ -59,5 +63,5 @@ uninstall: clean: @${MAKE} -C src clean -.PHONY: default install uninstall clean install-man install-doc install-bin \ +.PHONY: all test install uninstall clean install-man install-doc install-bin \ install-font install-img 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 diff --git a/test/fail.jpg b/test/fail.jpg new file mode 100644 index 0000000..e69de29 diff --git a/test/fail.png b/test/fail.png new file mode 100644 index 0000000..e69de29 diff --git a/test/fail.pnm b/test/fail.pnm new file mode 100644 index 0000000..e69de29 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 0000000000000000000000000000000000000000..613264e17d845a10e72b531db4abe8604f1bdd2c GIT binary patch literal 953 zcmZ?wbhEHb6krfw`2L@Pfq{XMk&%gsiJ6(1g@uKcm6eT+jh&sHgM)*Ulaq^!i<_I9 zhlhukmzR%^kDs4kKtMoHP*6xnNLW}{L_|bXR8&k%Ok7-CLPA1PQc_AvN?KZ4Mn*U3h*4EC>&febM z!NI}N(b37t$=TW2#l^+d)z!_-&E4JI!^6YV)6>h#%iG)A$H&Ll*VoU_&)?raARr(x zFfb@6C^$GcBqSs>G&C$MEId3sA|fI(GBPSEDmpqkCMG5}Ha0FUELwBO@a-GczkID?2+oCnqO2H#aXYFF!xOprD|zu&}78sJOVe zq@<*@w6v_Oth~IuqN1X*va+hGs=B(mrlzL0wzjUWuD-s$p`oF%v9YPCskynirKP2{ zwY9CSt-ZayqobpCd4x3{maufM;4!h{JECr+F+Y0~7$lc!9XGIi?I zY15`npFVxYj2Sa$&YU%C*6i7{=ggTickbMI^XAQ;KYzi31q&B0T(oG>;>C-XELpO2 z>C$D(mMvete8q|tD_5>uwQAMs)vMR6S+jQS+I8#JtzW->!-fqTH*VatY18J-o40J) zvUTg$ZQHhO-@bjvjvYI9?%cI&*Y4fB_w3oTckkYP`}XbMzyH920|yTtJap*L;lqcI z9656I=+R@xjvYUK{KSb9Cr_R{b?VgV)2GjzIdk^x*>mU4oj-s6!i5VLFJ8QK>C)xP zm#CC@-WpTB(h^7ZT2Z{NOs|Ni~Qj~_pO{`~dp*YDrI|NQy$_wV0-|Ni~||6lPZ3n&jT z=zvI2o?zgZ#=ywKAi%)Tz{JKXp|e8Z!2bF_|3p<11RRdk|7Cgg`TP0%j!i5~B|RDn z4la|JwC!3l3ZCxoV)3>6;=WOVp^J@ONr6N7@%~yR#eF;i2?`91f33W}OrJ78u+>Gs zDrV*S2H(XJmO=-%Z(79I#8JugBkF?Ina$j+4z{y4Ck1Zd)Yg)TNO-`&SYBB-mAg3i OaFbb~nT(78gEatA5xf@w literal 0 HcmV?d00001 diff --git a/test/ok.jpg b/test/ok.jpg new file mode 100644 index 0000000000000000000000000000000000000000..060565edc4bb9b92db7973a6ec93e6532bc7c981 GIT binary patch literal 354 zcmex=N4?hnVHy<}AC$AtcAHRTrpa2(-kg$+|Fu#C+!2bgb+#C!73<8Xdf(-wUFo-fR zGBTh5cDDaV7*qrp7+6?Ym=SV}Ow25-Z0v%<96}eol`f5bF04*zF+rnX9EvwsMkvW(q+}1S58freV68OPA>bN emhPuVE*;BXyR`Uh^HmZ*vamWPPf5xC|4jff^=5hi literal 0 HcmV?d00001 diff --git a/test/ok.png b/test/ok.png new file mode 100644 index 0000000000000000000000000000000000000000..2f06506f2222001f8d9526d8b659f1c0200ac5a2 GIT binary patch literal 403 zcmeAS@N?(olHy`uVBq!ia0y~yU=RRd4mJh`2Kmqb6B!s7Sc;uILpV4%IBGajIv5xj zI14-?iy0UgFM=>5&qSZk3=9mCC9V-A!TD(=<%vb94CUqJdYO6I#mR{Use1WE>9gP2 zNHH)l3V6CWhFJ7Yy=>^k94K(?>Y=I`JwX*;@XU(8;&8{HCDO-*?#)~&pLB~PND_xcL;7uR_;9-UiRHSxaE_lvhL zggZorPBnQYvCZ(92=f%*@Ec2lV_a(+KC21;U-CcC;Gi8}Ve_7AN7#~=3tD!Gm3?Ru z)+y}QwRtG9dxtZ3f7m&BSNX7a=hpoD&UHB9aZ7JAudtc(%yxd)O|KrVk2&6DvHFPX z8hdB;8w~FSn-k`~h&(pa==0|}w|{snGq-*I{@y!rlZBzTWNzC{W?*1o@O1TaS?83{ F1OTAtr=b7< literal 0 HcmV?d00001 diff --git a/test/ok.pnm b/test/ok.pnm new file mode 100644 index 0000000000000000000000000000000000000000..d62d0623688ab392cf953c294f3da4a25f753095 GIT binary patch literal 269 zcmWGAQ zz{p?4~PTR1v2UvDsk zkh2)r7#JBq@*s=An30JI;#`nJK<0u)LGEV&IgXW?ftiUJq=XG5!2}_|{$m6=iv{do ICI$v30Iu3XVgLXD literal 0 HcmV?d00001 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 -- GitLab