Re: easier debugging of unit tests

Jan Wielemaker <[email protected]>
Newsgroups gmane.comp.ai.prolog.swi
Message-ID <[email protected]>
On 04/01/2014 08:01 PM, Ross Boylan wrote:
> A few questions.
> 1. guitracer. trace. run_tests('disk rules':vl1).
>
> takes me into the debugger and I need to step through all the testing
> machinery, including matching the right test, before I get to my code.
> Is there a better way?

I've added a few declarations and did some small changes to
hide most of the internals now.  That was always intended,
but got a bit rusty.

> I tried putting stops on various points in
> matching_test(X, X) :- !.
> matching_test(Name, Set) :-
> 	is_list(Set),
> 	memberchk(Name, Set).
>
> and using continue to breakpoint, but this either yields the same number
> of stops as before or no stops at all.  In particular, putting a stop
> before the first line doesn't cause a stop.

Would need real details to comment.

> 2. Is there a way to proceed to the next line on the same level?  In
> other words, given I just evaluated the first line of
> pred1(A),
> pred2(B, A),
> pred3(C).
> can I have the system evaluate pred2 without the debugger stepping into
> it?

Use 's' (skip).  There is also an icon for it.

> Two work-arounds are to step into pred2 and then use finish, or put a
> stop before pred3 and continue to breakpoint.  I'm hoping there's a
> better way.
>
> 3. Sometimes, particularly after I execute make, the tests seem to lose
> the ability to see the definitions they need (both within the debugger
> and doing run_tests without the debugger).  I think the problem is that
> the facts it needs are inside a namespace that the test loses access to
> (even though the test is in the same namespace, I think).  Is there a
> solution?
>
> The tests are in rulesTest.plt.  That program starts
> :- begin_tests('disk rules').
> :- ['rules.pl'].
>
> Then it has the facts to which I lose access, and then the unit tests.

Tests where surely not meant to be defined by consulting a file
between begin/end tests.  Why do you try that?  If you really want,
:- include(rules). might work, but probably only in recent versions.

As is, make/0 will reload rules.pl if it was modified, but unaware of
the fact that it appears in a testing environment.

	Cheers --- Jan

>
> Prolog 6.4.1.
>
> Thanks.
> Ross Boylan
>
>
>
>
> _______________________________________________
> SWI-Prolog mailing list
> [email protected]
> https://lists.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.