[debhelper-devel] [Git][debian/debhelper][master] 4 commits: t: Refactor test

Niels Thykier gitlab at salsa.debian.org
Wed Mar 7 21:02:19 UTC 2018


Niels Thykier pushed to branch master at Debian / debhelper


Commits:
53697e65 by Niels Thykier at 2018-03-07T20:26:58+00:00
t: Refactor test

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
d68d6751 by Niels Thykier at 2018-03-07T20:37:07+00:00
SequencerUtil: Always inline when asked to always inline

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
b1ea7c88 by Niels Thykier at 2018-03-07T20:37:07+00:00
t: Add test for compat 8 handling of sequences

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
0e8a8e4e by Niels Thykier at 2018-03-07T20:40:00+00:00
dh: Simplify sequence definitions

As of commit d68d6751a86052246433bf4381a5f8daac45f90d, the
SequencerUtil function "unpack_sequence" should correctly transform
the "compat 9"-style sequences into "compat 8"-style sequences.
Exploit this to avoid the duplicated definitions.

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -


4 changed files:

- debian/changelog
- dh
- lib/Debian/Debhelper/SequencerUtil.pm
- t/dh-sequencer.t


Changes:

=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,7 @@ debhelper (11.1.6) UNRELEASED; urgency=medium
     attempt to make pkgfile() use "DEB_TARGET_ARCH{,_OS}"
     (see 11.1.5~alpha1).  Thanks to Andreas Beckmann for reporting
     the issue.  (Closes: #891546)
+  * dh: Refactor handling of sequences to simplify some code paths.
 
  -- Niels Thykier <niels at thykier.net>  Mon, 26 Feb 2018 19:32:52 +0000
 


=====================================
dh
=====================================
--- a/dh
+++ b/dh
@@ -452,25 +452,13 @@ $sequences{clean} = [@bd_minimal, qw{
 }];
 $sequences{'build-indep'} = [@bd];
 $sequences{'build-arch'} = [@bd];
-if (! compat(8)) {
-	# From v9, sequences take standard rules targets into account.
-	$sequences{build} = [to_rules_target("build-arch"), to_rules_target("build-indep")];
-	$sequences{'install-indep'} = [to_rules_target("build-indep"), @i];
-	$sequences{'install-arch'} = [to_rules_target("build-arch"), @i];
-	$sequences{'install'} = [to_rules_target("build"), to_rules_target("install-arch"), to_rules_target("install-indep")];
-	$sequences{'binary-indep'} = [to_rules_target("install-indep"), @b];
-	$sequences{'binary-arch'} = [to_rules_target("install-arch"), @ba, @b];
-	$sequences{binary} = [to_rules_target("install"), to_rules_target("binary-arch"), to_rules_target("binary-indep")];
-}
-else {
-	$sequences{build} = [@bd];
-	$sequences{'install'} = [@{$sequences{build}}, @i];
-	$sequences{'install-indep'} = [@{$sequences{'build-indep'}}, @i];
-	$sequences{'install-arch'} = [@{$sequences{'build-arch'}}, @i];
-	$sequences{binary} = [@{$sequences{install}}, @ba, @b];
-	$sequences{'binary-indep'} = [@{$sequences{'install-indep'}}, @b];
-	$sequences{'binary-arch'} = [@{$sequences{'install-arch'}}, @ba, @b];
-}
+$sequences{build} = [to_rules_target("build-arch"), to_rules_target("build-indep")];
+$sequences{'install-indep'} = [to_rules_target("build-indep"), @i];
+$sequences{'install-arch'} = [to_rules_target("build-arch"), @i];
+$sequences{'install'} = [to_rules_target("build"), to_rules_target("install-arch"), to_rules_target("install-indep")];
+$sequences{'binary-indep'} = [to_rules_target("install-indep"), @b];
+$sequences{'binary-arch'} = [to_rules_target("install-arch"), @ba, @b];
+$sequences{binary} = [to_rules_target("install"), to_rules_target("binary-arch"), to_rules_target("binary-indep")];
 
 # Additional command options
 my %command_opts;


=====================================
lib/Debian/Debhelper/SequencerUtil.pm
=====================================
--- a/lib/Debian/Debhelper/SequencerUtil.pm
+++ b/lib/Debian/Debhelper/SequencerUtil.pm
@@ -45,9 +45,9 @@ sub unpack_sequence {
 			my $command = shift(@{$current_sequence});
 			my $rules_target=extract_rules_target_name($command);
 			next if (defined($rules_target) and exists($completed_sequences->{$rules_target}));
-			if (defined($rules_target) &&
+			if (defined($rules_target) && ($always_inline ||
 				! exists($non_inlineable_targets{$rules_target}) &&
-				! defined(rules_explicit_target($rules_target))) {
+				! defined(rules_explicit_target($rules_target)))) {
 
 				# inline the sequence for this implicit target.
 				push(@stack, $current_sequence);


=====================================
t/dh-sequencer.t
=====================================
--- a/t/dh-sequencer.t
+++ b/t/dh-sequencer.t
@@ -46,8 +46,21 @@ my %sequences = (
     'binary'       => [to_rules_target("install"), to_rules_target("binary-arch"), to_rules_target("binary-indep")],
 );
 
+my %sequences_unpacked = (
+	'build-indep' => [@bd],
+	'build-arch'  => [@bd],
+	'build'       => [@bd],
+
+	'install-indep' => [@bd, @i],
+	'install-arch'  => [@bd, @i],
+	'install'       => [@bd, @i],
+
+	'binary-indep' => [@bd, @i, @b],
+	'binary-arch'  => [@bd, @i, @ba, @b],
+	'binary'       => [@bd, @i, @ba, @b],
+);
 
-plan tests => 11;
+plan tests => 11 + 3 * scalar(keys(%sequences));
 
 # We will horse around with %EXPLICIT_TARGETS in this test; it should
 # definitely not attempt to read d/rules or the test will be break.
@@ -56,27 +69,27 @@ $Debian::Debhelper::SequencerUtil::RULES_PARSED = 1;
 
 is_deeply(
     [unpack_sequence(\%sequences, 'build')],
-    [[], [@bd]],
+    [[], $sequences_unpacked{'build'}],
     'Inlined build sequence matches build-indep/build-arch');
 
 is_deeply(
     [unpack_sequence(\%sequences, 'install')],
-    [[], [@bd, @i]],
+    [[], $sequences_unpacked{'install'}],
     'Inlined install sequence matches build-indep/build-arch + install commands');
 
 is_deeply(
     [unpack_sequence(\%sequences, 'binary-arch')],
-    [[], [@bd, @i, @ba, @b]],
+    [[], $sequences_unpacked{'binary-arch'}],
     'Inlined binary-arch sequence has all the commands');
 
 is_deeply(
     [unpack_sequence(\%sequences, 'binary-indep')],
-    [[], [@bd, @i, @b]],
+    [[], $sequences_unpacked{'binary-indep'}],
     'Inlined binary-indep sequence has all the commands except @bd');
 
 is_deeply(
     [unpack_sequence(\%sequences, 'binary')],
-    [[], [@bd, @i, @ba, @b]],
+    [[], $sequences_unpacked{'binary'}],
     'Inlined binary sequence has all the commands');
 
 
@@ -100,9 +113,17 @@ is_deeply(
 
     is_deeply(
         [unpack_sequence(\%sequences, 'build')],
-        [[], [@bd]],
+        [[], $sequences_unpacked{'build'}],
         'build sequence is inlineable');
 
+
+	# Compat <= 8 ignores explicit targets!
+	for my $seq_name (sort(keys(%sequences))) {
+		is_deeply(
+			[unpack_sequence(\%sequences, $seq_name, 1)],
+			[[], $sequences_unpacked{$seq_name}],
+			"Compat <= 8 ignores explicit build target in sequence ${seq_name}");
+	}
 }
 
 {
@@ -114,6 +135,14 @@ is_deeply(
 		# Unfortunately, unpack_sequence cannot show that.
         [[to_rules_target('install-arch')], [@bd, @i, @ba, @b]],
         'Inlined binary sequence has all the commands');
+
+	# Compat <= 8 ignores explicit targets!
+	for my $seq_name (sort(keys(%sequences))) {
+		is_deeply(
+			[unpack_sequence(\%sequences, $seq_name, 1)],
+			[[], $sequences_unpacked{$seq_name}],
+			"Compat <= 8 ignores explicit install-arch target in sequence ${seq_name}");
+	}
 }
 
 {
@@ -133,4 +162,12 @@ is_deeply(
 		$actual,
 		$expected,
 		'Inlined binary sequence has all the commands');
+
+	# Compat <= 8 ignores explicit targets!
+	for my $seq_name (sort(keys(%sequences))) {
+		is_deeply(
+			[unpack_sequence(\%sequences, $seq_name, 1)],
+			[[], $sequences_unpacked{$seq_name}],
+			"Compat <= 8 ignores explicit build + install-arch targets in sequence ${seq_name}");
+	}
 }



View it on GitLab: https://salsa.debian.org/debian/debhelper/compare/30ea2c148eb780c3bdbc2269348794c2ef27b80a...0e8a8e4ef4980405ba66cd42fa0c67e8b366143c

---
View it on GitLab: https://salsa.debian.org/debian/debhelper/compare/30ea2c148eb780c3bdbc2269348794c2ef27b80a...0e8a8e4ef4980405ba66cd42fa0c67e8b366143c
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debhelper-devel/attachments/20180307/8f37eae6/attachment-0001.html>


More information about the debhelper-devel mailing list