[dh-make-perl] 04/09: t/dists.t: rework running dh-make-perl and give all diagnostics when a test fails

Damyan Ivanov dmn at alioth.debian.org
Fri Aug 16 12:32:50 UTC 2013


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

dmn pushed a commit to branch master
in repository dh-make-perl.

commit 6c3d7907ab482b9ce990fd518716aa0354d04651
Author: Damyan Ivanov <dmn at debian.org>
Date:   Fri Aug 16 12:48:34 2013 +0200

    t/dists.t: rework running dh-make-perl and give all diagnostics when a test fails
---
 t/dists.t |  202 ++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 105 insertions(+), 97 deletions(-)

diff --git a/t/dists.t b/t/dists.t
index c709ba8..fecf6b8 100755
--- a/t/dists.t
+++ b/t/dists.t
@@ -84,100 +84,113 @@ sub compare_tree {
         'Generated tree matches template' . ( $hint ? " ($hint)" : '' ) );
 }
 
-sub dist_ok($) {
-    my $dist_dir = shift;
-    my $dist = "$Bin/dists/$dist_dir";
+sub run_and_compare {
+    my $p        = shift;
+    my $run      = $p->{run};
+    my $compare  = $p->{compare};
+    my $dist_dir = $p->{dist_dir};
+    my $comment  = $p->{comment};
 
-    my ( @cmd, $out, $err );
+    my ( $cmd, $in, $out, $err );
 
     use IPC::Run qw( run );
 
-# plain make
+    $in = $out = $err = '';
 
-    $out = $err = '';
-    @cmd = (
-        "$Bin/../dh-make-perl", "--no-verbose",
-        "--home-dir",           "$Bin/contents",
-        "--apt-contents-dir",   "$Bin/contents",
-        "--data-dir",           "$Bin/../share",
-        $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
-        "none",                       "--sources-list",
-        "$Bin/contents/sources.list", "--email",
-        "joemaint\@test.local",       $dist
-    );
+    my $ok = run $run, \$in, \$out, \$err;
 
-    my $ok = run \@cmd, \undef, \$out, \$err;
+    ok( $ok, "$dist_dir run ok ($comment)" );
 
-    unless ($ok) {
-        diag "\$! = $!, \$? = $?";
-        diag $out if $out;
-        diag $err if $err;
-    }
+SKIP: {
+        unless ($ok) {
+            diag "\$! = $!, \$? = $?";
+            diag $out if $out;
+            diag $err if $err;
+        }
 
-    ok( $ok, "$dist_dir run ok" );
+        skip "dh-make-run failed", 1, unless $ok;
 
-    compare_tree( "$dist/debian", "$dist/wanted-debian", 'initial' );
+        compare_tree( $compare->{result}, $compare->{wanted}, $comment )
+            or do {
+            diag $out if $out;
+            diag $err if $err;
+            };
+    }
+}
 
-# --refresh
+sub dist_ok($) {
+    my $dist_dir = shift;
+    my $dist = "$Bin/dists/$dist_dir";
 
-    $out = $err = '';
-    @cmd = (
-        "$Bin/../dh-make-perl", "--no-verbose",
-        "--home-dir",           "$Bin/contents",
-        "--apt-contents-dir",   "$Bin/contents",
-        "--data-dir",           "$Bin/../share",
-        $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
-        "none",                       "--sources-list",
-        "$Bin/contents/sources.list", "--email",
-        "joemaint\@test.local",       "refresh",
-        $dist
-    );
+# plain make
 
-    $ok = run \@cmd, \undef, \$out, \$err;
+    run_and_compare {
+        run => [
+            "$Bin/../dh-make-perl", "--no-verbose",
+            "--home-dir",           "$Bin/contents",
+            "--apt-contents-dir",   "$Bin/contents",
+            "--data-dir",           "$Bin/../share",
+            $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
+            "none",                       "--sources-list",
+            "$Bin/contents/sources.list", "--email",
+            "joemaint\@test.local",       $dist
+        ],
+        dist_dir => $dist_dir,
+        comment  => 'initial',
+        compare  => {
+            result => "$dist/debian",
+            wanted => "$dist/wanted-debian",
+        },
+    };
 
-    unless ($ok) {
-        diag "\$! = $!, \$? = $?";
-        diag $out if $out;
-        diag $err if $err;
-    }
 
-    ok( $ok, "$dist_dir refresh: run ok" );
 
-    compare_tree( "$dist/debian", "$dist/wanted-debian--refresh", 'refresh' );
+# --refresh
+
+    run_and_compare {
+        run => [
+            "$Bin/../dh-make-perl", "--no-verbose",
+            "--home-dir",           "$Bin/contents",
+            "--apt-contents-dir",   "$Bin/contents",
+            "--data-dir",           "$Bin/../share",
+            $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
+            "none",                       "--sources-list",
+            "$Bin/contents/sources.list", "--email",
+            "joemaint\@test.local",       "refresh",
+            $dist,
+        ],
+        comment => 'refresh',
+        dist_dir => $dist_dir,
+        compare => {
+            result => "$dist/debian",
+            wanted => "$dist/wanted-debian--refresh",
+        },
+    };
 
     unlink File::Find::Rule->file->name('*.bak')->in("$dist/debian");
 
 # --refresh --source-format '3.0 (quilt)'
 
-    $out = $err = '';
-    @cmd = (
-        "$Bin/../dh-make-perl", "--no-verbose",
-        "--home-dir",           "$Bin/contents",
-        "--apt-contents-dir",   "$Bin/contents",
-        "--data-dir",           "$Bin/../share",
-        $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
-        "none",                       "--sources-list",
-        "$Bin/contents/sources.list", "--email",
-        "joemaint\@test.local",       "refresh",
-        '--source-format',            '3.0 (quilt)',
-        $dist
-    );
-
-    $ok = run \@cmd, \undef, \$out, \$err;
-
-    unless ($ok) {
-        diag "\$! = $!, \$? = $?";
-        diag $out if $out;
-        diag $err if $err;
-    }
-
-    ok( $ok, "$dist_dir refresh --source-format '3.0 (quilt)': run ok" );
-
-    compare_tree(
-        "$dist/debian",
-        "$dist/wanted-debian--refresh--source-format=3.0_quilt",
-        'refresh --source-format 3.0 (quilt)'
-    );
+    run_and_compare {
+        run => [
+            "$Bin/../dh-make-perl", "--no-verbose",
+            "--home-dir",           "$Bin/contents",
+            "--apt-contents-dir",   "$Bin/contents",
+            "--data-dir",           "$Bin/../share",
+            $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
+            "none",                       "--sources-list",
+            "$Bin/contents/sources.list", "--email",
+            "joemaint\@test.local",       "refresh",
+            '--source-format',            '3.0 (quilt)',
+            $dist
+        ],
+        dist_dir => $dist_dir,
+        comment  => 'refresh --source-format \'3.0 (quilt)\'',
+        compare  => {
+            result => "$dist/debian",
+            wanted => "$dist/wanted-debian--refresh--source-format=3.0_quilt",
+        },
+    };
 
 # refresh with changed email
 
@@ -186,29 +199,24 @@ sub dist_ok($) {
     local $ENV{DEBFULLNAME} = 'Florian Geekwurt';
     local $ENV{DEBEMAIL} = 'florian at geekwurt.org';
 
-    $out = $err = '';
-    @cmd = (
-        "$Bin/../dh-make-perl", "--no-verbose",
-        "--home-dir",           "$Bin/contents",
-        "--apt-contents-dir",   "$Bin/contents",
-        "--data-dir",           "$Bin/../share",
-        $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
-        "none",                       "--sources-list",
-        "$Bin/contents/sources.list", "refresh",
-        $dist
-    );
-
-    $ok = run \@cmd, \undef, \$out, \$err;
-
-    unless ($ok) {
-        diag "\$! = $!, \$? = $?";
-        diag $out if $out;
-        diag $err if $err;
-    }
-
-    ok( $ok, "$dist_dir refresh with changed email: run ok" );
-
-    compare_tree( "$dist/debian", "$dist/wanted-debian--refresh-email", 'email' );
+    run_and_compare {
+        run => [
+            "$Bin/../dh-make-perl", "--no-verbose",
+            "--home-dir",           "$Bin/contents",
+            "--apt-contents-dir",   "$Bin/contents",
+            "--data-dir",           "$Bin/../share",
+            $ENV{NO_NETWORK} ? '--no-network' : (), "--vcs",
+            "none",                       "--sources-list",
+            "$Bin/contents/sources.list", "refresh",
+            $dist
+        ],
+        dist_dir => $dist_dir,
+        comment  => 'refresh email',
+        compare  => {
+            result => "$dist/debian",
+            wanted => "$dist/wanted-debian--refresh-email",
+        },
+    };
 
 # clean up
 

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



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