[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: unable to escape ! in autotest stdout comparison text
From: |
Nick Bowler |
Subject: |
Re: unable to escape ! in autotest stdout comparison text |
Date: |
Tue, 29 May 2018 21:34:32 -0400 |
On 2018-05-29, John Calcote <address@hidden> wrote:
> I'm trying to create a test using autotest that compares the stdout of my
> program with a string. Unfortunately, the output of the program contains
> the path of the program. As part of its output, it writes its own program
> name (from argv[0]) to stdout, so I have to use ${abs_top_builddir} as part
> of the comparison text - which means I need to use AT_CHECK_UNQUOTED.
[snip problems with unwanted shell expansion]
> Any ideas?
There might be ways to avoid your problems with AC_CHECK_UNQUOTED, but
it is probably simplest to just sidestep the issue. In your test group,
you can write the expected standard output to a file named expout. You
can generate this in any manner you would like (likely with some shell
commands).
Then, instead of specifying the expected output directly in AT_CHECK,
you put 'expout' for the standard output:
AT_CHECK([blah],,[expout])
which will compare the standard output against the contents of the file.
> Here's my testsuite.at:
>
> AT_INIT
> AT_SETUP([tg1])
> AT_CHECK_UNQUOTED(["${abs_top_builddir}/src/prog"],,
> [Hello from ${abs_top_builddir}/src/prog!])
> AT_CLEANUP
So, we can do (totally untested)
AT_INIT
AT_SETUP([tg1])
printf 'Hello from %s/src/prog!\n' "$abs_top_builddir" >expout
AT_CHECK(["$abs_top_builddir/src/prog"],,[expout])
AT_CLEANUP
Hope that helps,
Nick