diff options
author | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-05-30 13:28:21 +0100 |
---|---|---|
committer | Ian Jackson <ijackson@chiark.greenend.org.uk> | 2015-05-31 12:21:36 +0100 |
commit | cbe483c32df06d2babbcf99d7ee947c645e7aea3 (patch) | |
tree | fb1fc8ce3e1836ede7445a374afbfa9e0776c9a6 /tests | |
parent | 7fc714261baac8630925cd57ab5408ea33a444c4 (diff) |
Test suite: Use stunt dpkg-parsechangelog
This program takes 16ms instead of ~700ms on my computer. This saves
15s out of 100s for the debpolicy-newreject test (in its current
state).
Currently this is only used by various things in devscripts because
dpkg-source uses /usr/lib/dpkg/parsechangelog/debian directly via a
Perl module Dpkg::Changelog::Parse.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/tests/debpolicy-newreject | 2 | ||||
-rwxr-xr-x | tests/tstunt/dpkg-parsechangelog | 53 |
2 files changed, 55 insertions, 0 deletions
diff --git a/tests/tests/debpolicy-newreject b/tests/tests/debpolicy-newreject index f161149..c6260a7 100755 --- a/tests/tests/debpolicy-newreject +++ b/tests/tests/debpolicy-newreject @@ -2,6 +2,8 @@ set -e . tests/lib +t-tstunt dpkg-parsechangelog + t-debpolicy t-prep-newpackage example 1.0 diff --git a/tests/tstunt/dpkg-parsechangelog b/tests/tstunt/dpkg-parsechangelog new file mode 100755 index 0000000..2e0360d --- /dev/null +++ b/tests/tstunt/dpkg-parsechangelog @@ -0,0 +1,53 @@ +#!/usr/bin/perl -w +# +# In an example: +# +# $ time dpkg-parsechangelog >/dev/null +# +# real 0m0.712s +# user 0m0.656s +# sys 0m0.048s +# $ time ~/things/Dgit/dgit/tests/tstunt/dpkg-parsechangelog >/dev/null +# +# real 0m0.016s +# user 0m0.000s +# sys 0m0.012s +# $ + +die if @ARGV; + +use strict; +open C, "debian/changelog" or die $!; + +$!=0; $_ = <C>; +m/^(\S+) \(([^()]+)\) (\S+)\; urgency=(\S+)$/ or die "$!, $_ ?"; +print <<END or die $!; +Source: $1 +Version: $2 +Distribution: $3 +Urgency: $4 +Changes: + $& +END + +my $blanks = 0; +for (;;) { + $!=0; $_ = <C>; + if (m/^ -- ([^<>]+\<\S+\>) (\w[^<>]+\w)$/) { + print <<END or die $!; +Maintainer: $1 +Date: $2 +END + last; + } elsif (m/^ --\s*$/) { + last; + } elsif (!m/\S/) { + $blanks++; + } elsif (m/^ .*\n/) { + print " .\n" x $blanks or die $!; + $blanks=0; + print " $_" or die $!; + } else { + die "$!, $_ ?"; + } +} |