I am trying to build a rudimentary test that launches Python, which runs some code, which launches “swipl”. swipl is on the path as evidenced by running “swipl” from the bash shell and getting it to run. This is currently on macos catalina, but needs to work cross platform.
The Python code that gets run uses subprocess.Popen(["swipl"])
(i.e. no path provided) to use the user’s path to find swipl.
It works fine if I launch SWI Prolog from the bash command line using ? swipl
and then run the test using ?- test_language_server.
in Prolog.
It fails when I launch SWI Prolog from the mac os UI by clicking on the icon in the task bar (or whatever that bar on the bottom of the mac is called) and run the test from there. The failure in Python is that Python subprocess.Popen()
can’t find swipl on the path.
Any ideas what is going on? It seems like running from the Mac shell UI is not inheriting the user PATH environment variable and thus not sending to process_create. If true, any workaround?
:- use_module(language_server).
test_language_server :-
run_tests([py_language_server]).
run_test_script(Script, Status):-
process_create(path(python3), [Script],
[stdin(std), stdout(pipe(Out)), stderr(pipe(Out)), process(PID)]),
read_lines(Out, Lines),
writeln(Lines),
process_wait(PID, Status).
:- begin_tests(py_language_server, []).
test(language_server):-
run_test_script('/Users/ericzinda/Enlistments/swiplserver/swiplserver/test_prologserver.py', Status),
assertion(Status == exit(0)).
:- end_tests(py_language_server).