<div dir="ltr">Hello thanks for the above way to auto test the printers, however it maybe hard to only test what matters the variables as the diff may include texts not related to the variables, and may need to rewrite test and the cpp file <div><br></div><div>I was looking at the way boost implement it printers [here](<a href="https://github.com/ruediger/Boost-Pretty-Printer/blob/master/tests/testsuite.py">https://github.com/ruediger/Boost-Pretty-Printer/blob/master/tests/testsuite.py</a>).</div><div>i would try to implement something of that sort if it does not work i will fall back to creating the gdb  batch test </div><div><br></div><div>thanks </div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, 5 Jul 2021 at 09:23, Ralf Habacker <<a href="mailto:ralf.habacker@freenet.de">ralf.habacker@freenet.de</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">        Am 02.07.21 um 11:55 schrieb Thomas Baumgart:<br>
> On Mittwoch, 30. Juni 2021 20:09:27 CEST Da Viper wrote:<br>
> <br>
> [...]<br>
> <br>
>> The current problem i am facing now is how to automate the test cases,<br>
>> i am not sure how to go about that, it is to make sure that older classes<br>
>> are not affected when new printer classes are created<br>
> <br>
> I investigated this a bit and here's what I came up with: you can use<br>
> the gdb -batch mode feature to automate tests, collect the results in a<br>
> first run and store them as ground truth. When run again, compare the<br>
> current output against the ground truth and make sure it does not differ.<br>
> <br>
> Here's what I did in the tests subdir:<br>
> <br>
> a) I compiled your test program with<br>
> <br>
>    g++ -g -I /usr/include/qt5/QtCore/ -I /usr/include/qt5  -lstdc++ -lQt5Core -o test qstring.cpp<br>
> <br>
> b) Next I wrote a file and called it 'autotest'. Its content is<br>
> <br>
> ---8<---<br>
> file test<br>
> break main<br>
> run<br>
> n<br>
> p str<br>
> n<br>
> p str<br>
> p flist<br>
> n<br>
> n<br>
> n<br>
> p flist<br>
> ---8<---<br>
<br>
To reduce the required number of steps here something like the<br>
following recipe may be useful:<br>
<br>
#include <signal.h><br>
<br>
int main()<br>
{<br>
        // add test code<br>
        ...<br>
<br>
        // enter gdb<br>
        raise(SIGTRAP);<br>
<br>
        return 0;<br>
}<br>
<br>
then compile the code as mentioned by Thomas and create the mentioned<br>
`autotest` file as<br>
<br>
> ---8<---<br>
file test<br>
run<br>
frame 1<br>
info local<br>
> ---8<---<br>
<br>
then run<br>
<br>
    gdb -batch -x autotest<br>
<br>
to inspect the results manually or run<br>
<br>
    gdb -batch -x autotest  > ground.truth<br>
<br>
to create the mentioned reference file.<br>
<br>
Regards<br>
Ralf<br>
<br>
<br>
<br>
<br>
<br>
<br>
</blockquote></div>