Run_tests forall output

Is there a way to make forall tests show a diff or even just the bindings.

For example I have the following module:

:- module(sample,[]).

foo("x", 1).
foo("y", 2).
foo("z", 3).

:- begin_tests(sample).

f("x", 1).
f("q", 2).
f("y", 2).
f("z", 42).

test(all_foos, [forall(f(Name, Answer))]) :-
    foo(Name, Answer).

:- end_tests(sample).

when I run the tests I only get the number of the failure:

?- run_tests(sample).
[1-2/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /tmp/sample.pl:14:
ERROR:     test sample:all_foos: failed
[1-4/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /tmp/sample.pl:14:
ERROR:     test sample:all_foos: failed
ERROR: 2 tests failed
% 2 tests passed
% Test run completed in 0.016 seconds (0.013 cpu)
false.

I need to manually count from source to see which test is the [1-2/1].
For a larger suite with many test cases, it would be better to see the actual f(Name,Answer) that failed.

1 Like

Thanks. That was also the intend, but it was broken in the rewrite supporting concurrent testing. Fixed and changed the report to print the generator rather than just its variable values as you suggest. So, now I get

109 ?- run_tests.
[1-2/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /home/jan/src/swipl-devel/build.pgo/sample.pl:14:
ERROR:     test sample:all_foos (2-th forall generator = f("q",2)): failed
[1-4/1] sample:all_foos ........................ **FAILED (0.000 sec)
ERROR: /home/jan/src/swipl-devel/build.pgo/sample.pl:14:
ERROR:     test sample:all_foos (4-th forall generator = f("z",42)): failed
ERROR: 2 tests failed
% 2 tests passed
% Test run completed in 0.001 seconds (0.001 cpu)
false.
5 Likes

That’s great!

Thanks for the quick reply, can’t wait to try it.

Install from GIT :slight_smile: Or just fetch plunit.pl from the git source and put it into your library.

Pulled plunit.pl from git, works great :+1:

@jan Thank you so much for this improvement and @tatut for reporting it !
This always bothered me but never thought it was a bug…