Kaynağa Gözat

build: Fix u-a test suite to behave correctly on non-Debian binary paths

The test suite got fixed to not hardcode binary paths, so that it
can work on other systems than Debian, where those binaries might
be located in a different place. Dynamically generate the expected
database file to match the file system layout.

Known to be affecting Gentoo and Mac OS X.
Guillem Jover 14 yıl önce
ebeveyn
işleme
79274f4c4e
2 değiştirilmiş dosya ile 22 ekleme ve 17 silme
  1. 2 0
      debian/changelog
  2. 20 17
      utils/t/100_update_alternatives.t

+ 2 - 0
debian/changelog

@@ -14,6 +14,8 @@ dpkg (1.16.9) UNRELEASED; urgency=low
     Closes: #685677
     Closes: #685677
   * Cleanup dpkg-divert unit-test environment to avoid build failures.
   * Cleanup dpkg-divert unit-test environment to avoid build failures.
     Closes: #687656
     Closes: #687656
+  * Fix update-alternatives test suite to behave correctly on non-Debian
+    binary paths. Known to be affecting at least Gentoo and Mac OS X.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * Czech (Miroslav Kure).
   * Czech (Miroslav Kure).

+ 20 - 17
utils/t/100_update_alternatives.t

@@ -260,7 +260,8 @@ check_choice(0, "auto", "initial install 3");
     open(FILE, "<", "$admindir/generic-test") or die $!;
     open(FILE, "<", "$admindir/generic-test") or die $!;
     my $content = <FILE>;
     my $content = <FILE>;
     close(FILE);
     close(FILE);
-    is($content,
+
+    my $expected =
 "auto
 "auto
 $bindir/generic-test
 $bindir/generic-test
 slave1
 slave1
@@ -272,26 +273,28 @@ $bindir/slave3
 slave4
 slave4
 $bindir/slave4
 $bindir/slave4
 
 
-$paths{false}
-10
-$paths{date}
-
-
-
-$paths{sleep}
-5
-
+";
 
 
+    my %slaves;
 
 
+    # Store slaves in a hash to easily retrieve present and missing ones.
+    foreach my $alt (@choices) {
+        foreach my $slave (@{$alt->{slaves}}) {
+            $slaves{$slave->{name}}{$alt->{path}} = $slave;
+        }
+    }
 
 
-$paths{true}
-20
-$paths{yes}
-$paths{cat}
-$paths{cat}
-$paths{cat}
+    foreach my $alt (sort { $a->{path} cmp $b->{path} } @choices) {
+        $expected .= $alt->{path} . "\n";
+        $expected .= $alt->{priority} . "\n";
+        foreach my $slave_name (sort keys %slaves) {
+            $expected .= $slaves{$slave_name}{$alt->{path}}{path} || "";
+            $expected .= "\n";
+        }
+    }
+    $expected .= "\n";
 
 
-", "administrative file is as expected");
+    is($content, $expected, "administrative file is as expected");
 }
 }
 
 
 # manual change with --set-selections
 # manual change with --set-selections