Procházet zdrojové kódy

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 před 9 roky
rodič
revize
0bbc4f7b75
2 změnil soubory, kde provedl 15 přidání a 6 odebrání
  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 strict;
 use warnings;
 use warnings;
 
 
-use Test::More tests => 7;
+use Test::More tests => 12;
 use Test::Dpkg qw(test_neutralize_checksums);
 use Test::Dpkg qw(test_neutralize_checksums);
 
 
 use File::Spec::Functions qw(rel2abs);
 use File::Spec::Functions qw(rel2abs);
@@ -177,13 +177,18 @@ sub test_build
     set_build_type($type, 'buildtype', nocheck => 1);
     set_build_type($type, 'buildtype', nocheck => 1);
     my $typename = get_build_options_from_type();
     my $typename = get_build_options_from_type();
 
 
+    my $stderr;
+
     chdir $dirname;
     chdir $dirname;
     spawn(exec => [ "$srcdir/dpkg-buildpackage.pl", '--host-arch=amd64',
     spawn(exec => [ "$srcdir/dpkg-buildpackage.pl", '--host-arch=amd64',
                     "--build=$typename", '--check-command=' ],
                     "--build=$typename", '--check-command=' ],
-          error_to_file => '/dev/null',
-          wait_child => 1);
+          error_to_string => \$stderr,
+          wait_child => 1, nocheck => 1);
     chdir '..';
     chdir '..';
 
 
+    ok($? == 0, "dpkg-buildpackage --build=$typename succeeded");
+    diag($stderr) unless $? == 0;
+
     if (build_has_all(BUILD_ARCH_DEP)) {
     if (build_has_all(BUILD_ARCH_DEP)) {
         # Rename the file to preserve on consecutive invokations.
         # Rename the file to preserve on consecutive invokations.
         move("$basename\_amd64.changes", "$basename\_$typename.changes");
         move("$basename\_amd64.changes", "$basename\_$typename.changes");

+ 7 - 3
scripts/t/dpkg_source.t

@@ -16,7 +16,7 @@
 use strict;
 use strict;
 use warnings;
 use warnings;
 
 
-use Test::More tests => 4;
+use Test::More tests => 8;
 use Test::Dpkg qw(test_neutralize_checksums);
 use Test::Dpkg qw(test_neutralize_checksums);
 
 
 use File::Spec::Functions qw(rel2abs);
 use File::Spec::Functions qw(rel2abs);
@@ -132,11 +132,15 @@ sub test_diff
 sub test_build_source
 sub test_build_source
 {
 {
     my ($name) = shift;
     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);
           wait_child => 1, nocheck => 1);
 
 
+    ok($? == 0, 'dpkg-source --build succeeded');
+    diag($stderr) unless $? == 0;
+
     my $basename = $name =~ tr/-/_/r;
     my $basename = $name =~ tr/-/_/r;
 
 
     test_diff("$basename.dsc");
     test_diff("$basename.dsc");