fix tests, use '$first_answer' to print indentation before errors (#1408)

This commit is contained in:
Mark Thom
2022-04-09 20:32:52 -06:00
parent 00eab4d415
commit 8bf3d4ea71
6 changed files with 17 additions and 17 deletions

View File

@@ -18,7 +18,14 @@
write_error(Error) :-
write(' '),
% '$fetch_global_var' is the core system call of bb_get/2, but
% bb_get may not exist when write_error is first called, so fall
% back on '$fetch_global_var'.
( '$fetch_global_var'('$first_answer', false) ->
true
; write(' ') % if '$first_answer' isn't defined yet or true,
% print indentation.
),
( nonvar(Error),
functor(Error, error, 2) ->
writeq(Error)

View File

@@ -10,8 +10,7 @@ project_attributes(QueryVars, AttrVars) :-
; E = error(evaluation_error((Module:project_attributes)/2), _)
) ->
true
; write_term('caught: ', [quoted(false)]),
writeq(E),
; loader:write_error(E),
nl
).
@@ -34,8 +33,7 @@ call_attribute_goals([Module|Modules], GoalCaller, AttrVars) :-
'$print_attribute_goals_exception'(Module, E) :-
( E = error(evaluation_error((Module:attribute_goals)/3), attribute_goals/3)
-> true
; write_term('caught: ', [quoted(false)]),
writeq(E),
; loader:write_error(E),
nl
).

View File

@@ -100,7 +100,7 @@ run :-
Dss
),
E,
( write('caught: '), write(E), nl,
( loader:write_error(E), nl,
portray_clause([N, Settings, Vs, Gs4, Dss]), nl,
false
)

View File

@@ -134,6 +134,7 @@ run_goals([Goal|_]) :-
halt.
repl :-
bb_put('$first_answer', true),
catch(read_and_match, E, print_exception(E)),
false. %% this is for GC, until we get actual GC.
repl :-
@@ -198,9 +199,8 @@ submit_query_and_print_results(Term0, VarList) :-
% in the first argument, which is done by call/N
; expand_goal(Term0, user, Term)
),
setup_call_cleanup(bb_put('$first_answer', true),
submit_query_and_print_results_(Term, VarList),
bb_put('$first_answer', false)).
bb_put('$first_answer', true),
submit_query_and_print_results_(Term, VarList).
needs_bracketing(Value, Op) :-