From 44cf9c6d2d274eac37502e835155f7e985f1b8e6 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 7 Aug 2024 15:30:08 +0200 Subject: Adding upstream version 1.22.7. Signed-off-by: Daniel Baumann --- scripts/t/Dpkg_Substvars.t | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'scripts/t/Dpkg_Substvars.t') diff --git a/scripts/t/Dpkg_Substvars.t b/scripts/t/Dpkg_Substvars.t index 61ac027..b1c5b1b 100644 --- a/scripts/t/Dpkg_Substvars.t +++ b/scripts/t/Dpkg_Substvars.t @@ -16,7 +16,7 @@ use strict; use warnings; -use Test::More tests => 56; +use Test::More tests => 60; use Test::Dpkg qw(:paths); use Dpkg (); @@ -247,6 +247,32 @@ is($output, '', 'disabled unused variables warnings'); $s->delete('var_used'); +# Required variables +my $sr; + +$expected = <<'VARS'; +required-var!=Required value +VARS +$sr = Dpkg::Substvars->new("$datadir/substvars-req"); +is($sr->output(), $expected, 'Required variable preserved'); + +is($sr->substvars('This is a string with missing the required variable'), + 'This is a string with missing the required variable', + 'substvars required substitution missing'); + +eval { + $sr->warn_about_unused(); + 1; +}; +$output = $@ // q{}; +is($output, + 'Dpkg_Substvars.t: error: required substitution variable ${required-var} not used' . "\n", + 'substvars required substitution not used'); + +is($sr->substvars('This is a string with a required variable ${required-var}'), + 'This is a string with a required variable Required value', + 'substvars required substitution present'); + # Variable filters my $sf; -- cgit v1.2.3