The unit test fails at two “subtests”:
- First one is something with /dev/null:
test(stream_input, [condition(has_exe(wc)), X == "0"]) :-
open('/dev/null', read, In, [type(binary)]),
process_create(path(wc),
['-c'],
[stdin(stream(In)), stdout(pipe(Out))]),
close(In),
read_process(Out, X0),
split_string(X0, "", " \r\n", [X]).
I invoked it from MSYS2 that has a “wc” program. The test fails since there’s no such device /dev/null on Windows. I tried to fix it by replacing by “NUL:”, but then I get a bad file descriptor because one cannot set the type to binary. This works, but I am unsure if this makes sense:
test(stream_input, [condition(has_exe(wc)), X == "0"]) :-
process_create(path(wc),
['-c'],
[stdin(null), stdout(pipe(Out))]),
read_process(Out, X0),
split_string(X0, "", " \r\n", [X]).
Obviously, that would be called on Windows only.
- The other one seems a bug to me:
% Seems to be able to kill itself on MacOS if this is ran
% concurrently. Too quick reuse of PIDs?
test(kill_gone, [ error(existence_error(process, PID)),
condition(\+((current_prolog_flag(windows, true),
current_prolog_flag(apple,true))))
]) :-
process_create(path(sleep), [2], [process(PID)]),
process_kill(PID),
process_wait(PID, X),
assertion(X == killed(15)),
process_kill(PID).
Doesn’t this mean something like “if not on Windows and Apple at the same time?”, and shouldn’t it read as “not on Win and not on Apple”, e.g. like this
condition((+ current_prolog_flag(windows, true), + current_prolog_flag(apple,true)))