[debsums] 05/06: Test suite: Further refactoring to reduce amount of hardcoded paths

Axel Beckert abe at deuxchevaux.org
Thu Mar 26 00:53:56 UTC 2015


This is an automated email from the git hooks/post-receive script.

abe pushed a commit to branch master
in repository debsums.

commit 8af382375afda21a7de196927c74b099fd150797
Author: Axel Beckert <abe at deuxchevaux.org>
Date:   Thu Mar 26 01:40:13 2015 +0100

    Test suite: Further refactoring to reduce amount of hardcoded paths
---
 t/debsums.t | 40 ++++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 16 deletions(-)

diff --git a/t/debsums.t b/t/debsums.t
index 97f6fbe..4e1d599 100644
--- a/t/debsums.t
+++ b/t/debsums.t
@@ -29,24 +29,24 @@ foreach my $state (qw(clean dirty)) {
     $chroot = "t/fakechroot-$state";
     my $exit_code = $state eq 'clean' ? 0 : 2;
 
-    foreach my $pkg ('', 'fakepkg') {
-        @command = ($command, "--root=$chroot");
-        @command = (@command, $pkg) if $pkg;
-
-        my $expected = <<"EOT";
+    my $expected = <<"EOT";
 $chroot/usr/share/doc/fakepkg/copyright                            OK
 $chroot/usr/share/doc/fakepkg/changelog.Debian.gz                  OK
 $chroot/usr/share/doc/fakepkg/README                           FAILED
 EOT
-        $expected = remove_failed($expected)
-            if $state eq 'clean';
+    $expected = remove_failed($expected)
+        if $state eq 'clean';
 
-        my $expected_conffiles = <<"EOT";
+    my $expected_conffiles = <<"EOT";
 $chroot/etc/fakepkg.cfg                                            OK
 $chroot/etc/fakepkg-broken.cfg                                 FAILED
 EOT
-        $expected_conffiles = remove_failed($expected_conffiles)
-            if $state eq 'clean';
+    $expected_conffiles = remove_failed($expected_conffiles)
+        if $state eq 'clean';
+
+    foreach my $pkg ('', 'fakepkg') {
+        @command = ($command, "--root=$chroot");
+        @command = (@command, $pkg) if $pkg;
 
         # Test running without any further parameters
         run(@command);
@@ -58,8 +58,7 @@ EOT
         run(@command, '-c');
         is(stderr, '', 'STDERR is empty');
         is(stdout,
-           $state eq 'clean' ? '' :
-           "$chroot/usr/share/doc/fakepkg/README\n",
+           $state eq 'clean' ? '' : failed_only($expected),
            'STDOUT as expected');
         expected_rc($exit_code);
 
@@ -76,8 +75,7 @@ EOT
             run(@command, $option);
             is(stderr, '', 'STDERR is empty');
             is(stdout,
-               $state eq 'clean' ? '' :
-               "$chroot/etc/fakepkg-broken.cfg\n",
+               $state eq 'clean' ? '' : failed_only($expected_conffiles),
                'STDOUT as expected');
             expected_rc($exit_code);
         }
@@ -94,8 +92,18 @@ sub sort_lines {
 
 sub remove_failed {
     my $string = shift;
-    return join("\n", grep { !/FAILED/ } split("\n", $string)).
-        ($string =~ m/\n\z/ ? "\n" : '');
+    return join("\n",
+                grep { !/FAILED/ }
+                split("\n", $string))
+        . ($string =~ m/\n\z/ ? "\n" : '');
+}
+
+sub failed_only {
+    my $string = shift;
+    return join("\n",
+                grep { /FAILED/ && s/\s*FAILED// }
+                split("\n", $string))
+        . ($string =~ m/\n\z/ ? "\n" : '');
 }
 
 sub expected_rc {

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/debsums.git



More information about the Pkg-perl-cvs-commits mailing list