diff options
author | Marcin Owsiany <porridge@debian.org> | 2012-09-09 12:13:20 +0100 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-09-09 14:17:20 -0400 |
commit | a3494762925e5a42a42ce82c688f62f163ffad1b (patch) | |
tree | 17ebd0bc0a1d852670cf139286341d2f4379b59b /t | |
parent | b3c00de156adf9c52da3cd0fa7c46414d5eb6982 (diff) | |
download | debhelper-a3494762925e5a42a42ce82c688f62f163ffad1b.tar.gz |
Make it possible to pass perl code to autoscript.
The shell-quoted sed code passed as parameter 4 is fragile (see Bug#665296).
Make it possible to pass a sub that operates on each line via $_ instead.
Also add a basic unit test for Dh_Lib, for now just with tests for autoscript.
Diffstat (limited to 't')
-rwxr-xr-x | t/dh-lib | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/t/dh-lib b/t/dh-lib new file mode 100755 index 00000000..772b1a1e --- /dev/null +++ b/t/dh-lib @@ -0,0 +1,31 @@ +#!/usr/bin/perl +package Debian::Debhelper::Dh_Lib::Test; +use strict; +use warnings; +use Test::More; + +plan(tests => 10); + +use_ok('Debian::Debhelper::Dh_Lib'); + +sub ok_autoscript_result { + ok(-f 'debian/testpackage.postinst.debhelper'); + open(F, 'debian/testpackage.postinst.debhelper') or die; + my (@c) = <F>; + close(F) or die; + like(join('',@c), qr{update-rc\.d test-script test parms with"quote >/dev/null}); +} + +ok(unlink('debian/testpackage.postinst.debhelper') >= 0); + +ok(autoscript('testpackage', 'postinst', 'postinst-init', + 's/#SCRIPT#/test-script/g; s/#INITPARMS#/test parms with\\"quote/g')); +ok_autoscript_result; + +ok(unlink('debian/testpackage.postinst.debhelper') >= 0); + +ok(autoscript('testpackage', 'postinst', 'postinst-init', + sub { s/#SCRIPT#/test-script/g; s/#INITPARMS#/test parms with"quote/g } )); +ok_autoscript_result; + +ok(unlink('debian/testpackage.postinst.debhelper') >= 0); |