Bladeren bron

scripts/t: Output STDERR when commands fail

Store the STDERR output and emit it as diag() output on exit failure.
Also check the exit value for expected success. And do not abort on
error from the dpkg-buildpackage command.
Guillem Jover 9 jaren geleden
bovenliggende
commit
0bbc4f7b75
2 gewijzigde bestanden met toevoegingen van 15 en 6 verwijderingen
  1. 8 3
      scripts/t/dpkg_buildpackage.t
  2. 7 3
      scripts/t/dpkg_source.t

+ 8 - 3
scripts/t/dpkg_buildpackage.t

@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 12;
 use Test::Dpkg qw(test_neutralize_checksums);
 
 use File::Spec::Functions qw(rel2abs);
@@ -177,13 +177,18 @@ sub test_build
     set_build_type($type, 'buildtype', nocheck => 1);
     my $typename = get_build_options_from_type();
 
+    my $stderr;
+
     chdir $dirname;
     spawn(exec => [ "$srcdir/dpkg-buildpackage.pl", '--host-arch=amd64',
                     "--build=$typename", '--check-command=' ],
-          error_to_file => '/dev/null',
-          wait_child => 1);
+          error_to_string => \$stderr,
+          wait_child => 1, nocheck => 1);
     chdir '..';
 
+    ok($? == 0, "dpkg-buildpackage --build=$typename succeeded");
+    diag($stderr) unless $? == 0;
+
     if (build_has_all(BUILD_ARCH_DEP)) {
         # Rename the file to preserve on consecutive invokations.
         move("$basename\_amd64.changes", "$basename\_$typename.changes");

+ 7 - 3
scripts/t/dpkg_source.t

@@ -16,7 +16,7 @@
 use strict;
 use warnings;
 
-use Test::More tests => 4;
+use Test::More tests => 8;
 use Test::Dpkg qw(test_neutralize_checksums);
 
 use File::Spec::Functions qw(rel2abs);
@@ -132,11 +132,15 @@ sub test_diff
 sub test_build_source
 {
     my ($name) = shift;
+    my $stderr;
 
-    spawn(exec => [ "$srcdir/dpkg-source.pl", '-b', $name ],
-          error_to_file => '/dev/null',
+    spawn(exec => [ "$srcdir/dpkg-source.pl", '--build', $name ],
+          error_to_string => \$stderr,
           wait_child => 1, nocheck => 1);
 
+    ok($? == 0, 'dpkg-source --build succeeded');
+    diag($stderr) unless $? == 0;
+
     my $basename = $name =~ tr/-/_/r;
 
     test_diff("$basename.dsc");