diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 21:06:40 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-27 21:06:40 +0000 |
commit | d827c6cf1631209f5042a9d1d8a7ecc24223c8a0 (patch) | |
tree | 91a431d301efd0e524bdfb0c46e97d591a9d7b03 /t/dh-lib.t | |
parent | Initial commit. (diff) | |
download | debhelper-d827c6cf1631209f5042a9d1d8a7ecc24223c8a0.tar.xz debhelper-d827c6cf1631209f5042a9d1d8a7ecc24223c8a0.zip |
Adding upstream version 13.11.4.upstream/13.11.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 't/dh-lib.t')
-rwxr-xr-x | t/dh-lib.t | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/t/dh-lib.t b/t/dh-lib.t new file mode 100755 index 0000000..6e6f3cb --- /dev/null +++ b/t/dh-lib.t @@ -0,0 +1,63 @@ +#!/usr/bin/perl +package Debian::Debhelper::Dh_Lib::Test; +use strict; +use warnings; +use Test::More; + +use File::Basename qw(dirname); +use lib dirname(__FILE__); +use Test::DH; + +use Debian::Debhelper::Dh_Lib qw(!dirname); + +plan(tests => 2); + + +sub ok_autoscript_result { + ok(-f 'debian/testpackage.postinst.debhelper'); + open(my $fd, '<', 'debian/testpackage.postinst.debhelper') or die("open test-poinst: $!"); + my (@c) = <$fd>; + close($fd); + like(join('',@c), qr{update-rc\.d test-script test parms with"quote >/dev/null}); +} + + +each_compat_subtest { + + ok(autoscript('testpackage', 'postinst', 'postinst-init', + 's/#SCRIPT#/test-script/g; s/#INITPARMS#/test parms with\\"quote/g')); + ok_autoscript_result; + + ok(rm_files('debian/testpackage.postinst.debhelper')); + + ok(autoscript('testpackage', 'postinst', 'postinst-init', + sub { s/\#SCRIPT\#/test-script/g; s/\#INITPARMS\#/test parms with"quote/g } )); + ok_autoscript_result; + + ok(rm_files('debian/testpackage.postinst.debhelper')); + + ok(autoscript('testpackage', 'postinst', 'postinst-init', + { 'SCRIPT' => 'test-script', 'INITPARMS' => 'test parms with"quote' } )); + ok_autoscript_result; + + ok(rm_files('debian/testpackage.postinst.debhelper')); +}; + +$ENV{'FOO'} = "test"; +my @SUBST_TEST_OK = ( + ['unchanged', 'unchanged'], + ["unchanged\${\n}", "unchanged\${\n}"], # Newline is not an allowed part of ${} + ['raw dollar-sign ${}', 'raw dollar-sign $'], + ['${Dollar}${Space}${Dollar}', '$ $'], + ['Hello ${env:FOO}', 'Hello test'], + ['${Dollar}{Space}${}{Space}', '${Space}${Space}'], # We promise that ${Dollar}/${} never cause recursion + ['/usr/lib/${DEB_HOST_MULTIARCH}', '/usr/lib/' . dpkg_architecture_value('DEB_HOST_MULTIARCH')], +); + +each_compat_subtest { + for my $test (@SUBST_TEST_OK) { + my ($input, $expected_output) = @{$test}; + my $actual_output = Debian::Debhelper::Dh_Lib::_variable_substitution($input, 'test'); + is($actual_output, $expected_output, qq{${input}" => "${actual_output}" (should be: "${expected_output})"}); + } +}; |