fix reverted tests, ensure files are loaded before goals (#2315)

This commit is contained in:
Mark
2024-02-03 11:49:26 -07:00
parent 6a421dd8b0
commit 673329ddb7
3 changed files with 19 additions and 7 deletions

View File

@@ -40,10 +40,21 @@ load_scryerrc :-
(\+ disabled_init_file -> load_scryerrc ; true),
repl.
args_consults_goals([], [], []).
args_consults_goals([Arg|Args], Consults, Goals) :-
arg_consults_goals(Arg, Args, Consults, Goals).
arg_consults_goals(c(Mod), Args, [c(Mod)|Consults], Goals) :-
args_consults_goals(Args, Consults, Goals).
arg_consults_goals(g(Goal), Args, Consults, [g(Goal)|Goals]) :-
args_consults_goals(Args, Consults, Goals).
delegate_task([], []).
delegate_task([], Goals0) :-
reverse(Goals0, Goals),
(\+ disabled_init_file -> load_scryerrc ; true),
reverse(Goals0, Goals1),
args_consults_goals(Goals1, Consults, Goals),
run_goals(Consults),
run_goals(Goals),
repl.
@@ -57,7 +68,7 @@ delegate_task([Arg0|Args], Goals0) :-
!,
delegate_task(Args, Goals0)
; atom_chars(Mod, Arg0),
delegate_task(Args, [t(consult(Mod))|Goals0])
delegate_task(Args, [c(Mod)|Goals0])
).
print_help :-
@@ -98,6 +109,7 @@ ignore_machine_arg.
arg_type(g).
arg_type(t).
arg_type(c(_)).
arg_type(g(_)).
arg_type(t(_)).
@@ -134,12 +146,12 @@ run_goals([g(Gs0)|Goals]) :- !,
write_term(Goal, [variable_names(VNs),double_quotes(DQ)]), nl
),
run_goals(Goals).
run_goals([t(Goal)|Goals]) :- !,
( catch(user:Goal, E, print_exception(E)) ->
run_goals([c(Mod)|Goals]) :- !,
( catch(consult(Mod), E, print_exception(E)) ->
true
; write('% Warning: initialization failed for: '),
double_quotes_option(DQ),
write_term(Goal, [double_quotes(DQ)]), nl
write_term(consult(Mod), [double_quotes(DQ)]), nl
),
run_goals(Goals).
run_goals([Goal|_]) :-

View File

@@ -1,2 +1,2 @@
# issue 820
args = ["-f", "--no-add-history", "goals.pl", "-g", "test,halt"]
args = ["-f", "--no-add-history", "-g", "test,halt", "goals.pl"]

View File

@@ -1,2 +1,2 @@
# issue 820
args = ["-f", "--no-add-history", "goals.pl", "-g", "test", "-g", "halt"]
args = ["-f", "--no-add-history", "-g", "test", "-g", "halt", "goals.pl"]