[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: test suite data

Howard Chu writes:
> Oops. Except piping to sort loses the field boundaries, so
> continuation lines are messed up.

Also the POSIX folks in their wisdom normalized the arguments to sort.
Thus GNU sort no longer accepts sort +0, you must say sort -k 1.
And of course comparison obeys the current locale, which may do
"interesting" things to the ordering.  But then, so does awk.  And
several perl versions have had broken locale support.  Maybe
defines.sh should hunt down $LC_*, $LANG etc and unset them:-(

Anyway, I don't expect we lose much by dropping proper compares if
perl is absent.  So I've been doing something like this.
Though that was for back-ldif where only some test outputs need
to be sorted.

# With arguments -S backend,backend,...backend, also sort the input for
#	those backends:  By entries+attrs if possible, just by lines otherwise.
#	That's a poor man's testdata verification for backends that return
#	entries in a different order than the test expects.  It allows us
#	to at least get some verification.
if test "$BACKEND" = null ; then
	# Do not output anything to compare for null backend
case $1,$2, in
	grep -v '^#' |
	if (perl -e 0) >/dev/null 2>&1 ; then
		# There is a Perl in $PATH
		perl -ne '
			if    (/^ /)	{ $entry[-1] .= $_; }
			elsif (/^\r?$/)	{ &entry; }
			else		{ push @entry, $_; }
			sub entry {
				$dn = shift(@entry);
				push @out, join "", ($dn || ""), sort @entry;
				@entry = ();
			END {
				print join "\n", sort @out;
	grep -v '^#'