Skip to content

Commit 4a04fdc

Browse files
JanWielemakerclaude
andcommitted
FIXED: predicate_options drift check failed where foreign source locations are unavailable
On platforms such as WASM predicate_location/2 does not resolve foreign (C) predicates to their source file, so the drift check scanned no C files and reported every option array as stale. Gate the check on a drift_testable/0 probe that verifies a foreign predicate can be located, skipping the drift test otherwise. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 16c6274 commit 4a04fdc

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

tests/library/test_predicate_options.pl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,23 @@
6464
directory_file_path(Dir, 'src/pl-prims.c', Prims),
6565
exists_file(Prims).
6666

67+
%! drift_testable is semidet.
68+
%
69+
% True when the drift check can run: the source tree is present and
70+
% predicate_location/2 resolves a foreign (C) predicate to its source
71+
% file. The latter fails on some platforms (e.g. WASM), where every C
72+
% option array would otherwise be reported as stale.
73+
74+
drift_testable :-
75+
source_dir(_),
76+
prolog_edit:predicate_location(open(_,_,_,_), Loc),
77+
get_dict(file, Loc, _).
78+
6779
test_predicate_options :-
6880
run_tests([ predicate_options_check,
6981
predicate_options_lint
7082
]),
71-
( source_dir(_)
83+
( drift_testable
7284
-> run_tests([ predicate_options_drift
7385
])
7486
; true
@@ -148,7 +160,7 @@
148160

149161
:- end_tests(predicate_options_lint).
150162

151-
:- if(source_dir(_)).
163+
:- if(drift_testable).
152164

153165
/*******************************
154166
* DRIFT CHECK *

0 commit comments

Comments
 (0)