]> Repositorios git - scryer-prolog.git/commitdiff
fix reverted tests, ensure files are loaded before goals (#2315)
authorMark <[email protected]>
Sat, 3 Feb 2024 18:49:26 +0000 (11:49 -0700)
committerMark <[email protected]>
Sat, 3 Feb 2024 18:49:26 +0000 (11:49 -0700)
src/toplevel.pl
tests/scryer/cli/issues/goals_compound_goal.toml
tests/scryer/cli/issues/goals_multiple_goals.toml

index 86ba085f70e56b9cee87ba4fd268ee332989acb1..67408cd2533984c6835dfeb0770dbfee12f27f38 100644 (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|_]) :-
index 6cc3d16c8f18ea118b1ce7b6b1e5a3a4e3799e1f..4fd7d5ba9dd9c6a5c24176e62a9cac912de13902 100644 (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"]
index 676c61dc1b5ce475d46297dac3441b53a6ab3154..25e739dd0dfe08618d5126d120df0853c09c7973 100644 (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"]