On 19-04-16 15:20, Nick Bowler wrote: | On 4/16/19, Jannick <thirdedition@xxxxxxx> wrote: | > I am wondering if there is an elegant way to pass additional diff options | > on to AT_CHECK in a testsuite - ideally on the level of .ac, .am, .at files | > or alike? | [...] | > configure translates this code snip into the script testsuite where - and | > this is really evil hackery I solemnly confess and I would like to avoid - | > I changed the definition of the variable at_diff. In my cases the diff | > options are the same for all tests in each of the relevant projects. | > | > I am aware that the test output could be restructured, but this question | > focuses at autoconf, autotest, AT_CHECK and friends. Using a customized | > version of autotest/general.m4 would not be optimal, since the project | > should automatically benefit from updates of autoconf/automake out of the | > box. | | Aside from hackery like you describe, I do not believe there is any | built-in way to modify the behaviour of AT_CHECK like this. | | But you can just do whatever comparison you want directly in AT_CHECK... | there is no reason to use the built-in diff when it is inadequate for | your test case. | | For example, if I want to use 'cmp' instead of 'diff' I might write | (untested): | | AT_CHECK([:; { commands_to_generate_output | } >stdout && cmp stdout expected_output]) | | And if I did that a lot I would define a macro for it. I used another solution where wanted to use a different diff implementation for AT_CHECK() that that allowed for regexes to be used in places where the output changes each test run. See my "pyrediff" project: https://github.com/lukem/pyrediff In pyrediff, I implemented a new macro with similar semantics to AT_CHECK() which temporarily overrode the setting of at_diff before calling AT_CHECK(), and set at_diff back before AT_CHECK() returns. Per ax_at_check_pyrediff.m4, the definition is: m4_defun([AX_AT_CHECK_PYREDIFF], [dnl AS_REQUIRE([_AX_AT_CHECK_PYRE_PREPARE]) _ax_at_check_pyrediff_prepare_original_at_diff="$at_diff" at_diff='ax_at_diff_pyre' AT_CHECK(m4_expand([$1]), [$2], m4_expand([$3]), m4_expand([$4]), [at_diff="$_ax_at_check_pyrediff_prepare_original_at_diff";$5], [at_diff="$_ax_at_check_pyrediff_prepare_original_at_diff";$6]) ])dnl AX_AT_CHECK_PYREDIFF The _AX_AT_CHECK_PYRE_PREPARE does some preparation including defining the shell function ax_at_diff_pyre that is used as the replacement at_diff. Note: if autotest's AT_CHECK() was extended in the future to support a new (optional) argument as the overload for at_diff, I would adapt to using that. I hope that's useful, Luke.
Attachment:
pgp4rX_0ZSJlp.pgp
Description: PGP signature
_______________________________________________ Autoconf mailing list Autoconf@xxxxxxx https://lists.gnu.org/mailman/listinfo/autoconf