/
load.pl
108 lines (85 loc) · 3.45 KB
/
load.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
% Acts as an interface to the system. Configures load paths, loads external
% libraries and provides predicates for initiating the system.
% prolongo_external_library_loader(-RelativePathToLoader) is multi.
%
% Facts with paths to external dependencies relative to this project's root.
% These facts should point to other loader scripts (usually 'load.pl' files)
% found in the root of the respective project.
prolongo_external_library_loader('/../bson/load.pl').
% prolongo_configure_globals is det.
%
% Configures useful globals used throughout the session.
prolongo_configure_globals :-
% For optimized compiles, tests are by default ignored.
set_test_options([load(always)]).
% Try to make everything as UTF-8 as possible.
% set_prolog_flag(encoding, utf8). % When using streams, global setting.
% Hunting implicit dependencies is easier without autoload.
% set_prolog_flag(autoload, false),
% Displays how modules and such are located.
% set_prolog_flag(verbose_file_search, true).
% prolongo_load_external_libraries is det.
%
% Loads external load.pl scripts required by this library.
prolongo_load_external_libraries :-
prolog_load_context(directory, Root), % Available only during compilation.
prolongo_external_library_loader(Loader),
prolongo_load_external_library(Root, Loader),
fail. % Loop through all prolongo_external_library_loader/1.
prolongo_load_external_libraries.
prolongo_load_external_library(Root, RelativePathToLoader) :-
atom_concat(Root, RelativePathToLoader, Loader),
[Loader].
% prolongo_configure_load_paths is det.
%
% Configures internal load paths in preparation of use_module calls.
prolongo_configure_load_paths :-
prolog_load_context(directory, Root), % Available only during compilation.
prolongo_configure_path(Root, '/src/misc', misc),
prolongo_configure_path(Root, '/src', mongo).
prolongo_configure_path(PathPrefix, PathSuffix, Name) :-
atom_concat(PathPrefix, PathSuffix, Path),
asserta(user:file_search_path(Name, Path)).
% Set everything up.
:- prolongo_configure_globals.
:- prolongo_load_external_libraries.
:- prolongo_configure_load_paths.
% Simply loading this module claims to speed up phrase, maplist, etc.,
% but I haven't noticed much difference.
% :- use_module(library(apply_macros)).
:- include(misc(common)).
prolongo_load_project_modules :-
use_module(library(pldoc), []), % Load first to enable comment processing.
use_module(mongo(mongo), []).
prolongo_load_project_tests :-
plunit:load_test_files([]).
%% prolongo_test is det.
%
% Loads everything and runs the test suite.
prolongo_test :-
prolongo_load_project_modules,
prolongo_load_project_tests,
prolongo_run_test_suite.
prolongo_run_test_suite :-
core:format('~n% Run tests ...~n'),
call_cleanup(
plunit:run_tests,
mongo_test_helper:drop_all_test_databases).
%% prolongo_cov is det.
%
% Loads everything and runs the test suite with coverage analysis.
prolongo_cov :-
prolongo_load_project_modules,
prolongo_load_project_tests,
prolongo_run_test_suite_with_coverage.
prolongo_run_test_suite_with_coverage :-
core:format('~n% Run tests ...~n'),
call_cleanup(
plunit:show_coverage(plunit:run_tests),
mongo_test_helper:drop_all_test_databases).
%% prolongo_repl is det.
%
% Loads everything and enters interactive mode.
prolongo_repl :-
prolongo_load_project_modules,
prolongo_load_project_tests.