[m-rev.] for review: pipe expected output through command

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 23 03:56:23 AEDT 2002


On 22-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> 
> Allow the user to pipe the expected output of a mercury program
> through another command.  This allows one to avoid problems on systems
> where the expected output is stored in a different format to that
> generated by an executable.
> 
> tests/Mmake.common:
> 	Define the output variable CAT before including Mmake.params
> 	so that it can be overridden.
> 
> tests/Mmake.common:
> tests/general/string_format/Mmakefile:
> 	Pipe the expected output through CAT before placing it in the .out
> 	file.

> +++ Mmake.common	22 Nov 2002 16:03:25 -0000
>  
> +CAT=cat

This variable should be documented.  Also, the name used should correspond
to the variable's purpose, not its default value.  I suggest CONV_EXP
or perhaps CONVERT_EXP_FILE.

Also, I think there are other places which may also need to be modified,
because they also have rules which invoke `diff':
	tests/warnings/Mmakefile
	tests/term/Mmakefile
and
	extras/complex_numbers/tests/Mmakefile
	extras/dynamic_linking/Mmakefile
	extras/morphine/non-regression-tests/Mmake.common
	extras/references/samples/Mmakefile
	extras/references/tests/Mmakefile
	extras/trailed_update/samples/Mmakefile
	extras/trailed_update/tests/Mmakefile
	extras/clpr/samples/Mmakefile


BTW, another possible way of doing it, instead of defining CAT or CONV_EXP
and using `$(CAT) $*.exp | diff $*.inp -' in all the Mmakefiles,
would be to define DIFF_EXP_OUT = diff $(DIFF_OPTS) and then use
`$(DIFF_EXP_OUT) $*.exp $*.out' and such like in all the Mmakefiles.
Then put a couple of scripts `diff_dos_unix'
and `diff_unix_dos' in tools that can be used instead
of `diff' for diffing files in the respective formats,

e.g. (untested):

	#!/bin/sh
	# diff_dos_usix
	usage="\
	Usage: diff_dos_unix [-o "options"] file1 file2
	 
	This has the same effect as `diff [options] file1 file2',
	except that it pipes the first file through dos2unix
	before running the comparison.
	"

	options=
	case "$1" in
	"-o")
		options="$2";
		shift; shift;
	esac
	case "$#" in
	2)
		dos2unix < "$1" | exec diff $options - "$2"
		;;
	*)
		echo "$usage" 1>&2
		exit 1
	esac

Hmm.  That way sounded cleaner until I saw how much code diff_dos_unix took.
Now I think your original way is better.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
The University of Melbourne         |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list