Commit changes
Revision: 3efbf8cd7654a801c73b7b3d35ec8de7fbd8f690
Author: Douglas R Miles
E-mail: logicmoo@gmail.com
Date: Sep 27, 2021 12:53:52 AM GMT-07:00
Message: bout to Jenkins
Author: Douglas R Miles
E-mail: logicmoo@gmail.com
Date: Sep 27, 2021 12:53:52 AM GMT-07:00
Message: bout to Jenkins
Files changed (2)
show
packs_sys/logicmoo_utils/prolog/logicmoo_test.pl
CHANGED
@@ -53,7 +53,7 @@
|
|
53 |
set_prolog_flag(ran_junit_tests,true),
|
54 |
term_to_atom(Spec,SpecAtom),
|
55 |
statistics(cputime,Y),
|
56 |
-
(
|
57 |
atomic_list_concat([TESTING_TEMP,'/',SpecAtom,Y,'-junit.xml'],FileName),
|
58 |
capturing_user_error(string(UserErr), (run_junit_tests_user_error(Spec,UnitXml),plunit:check_for_test_errors)),
|
59 |
sformat(JUnitStr,"~w~n~w]]>></system-out></testsuites>\n",[UnitXml,UserErr]),
|
@@ -140,16 +140,19 @@
|
|
140 |
forall(
|
141 |
plunit:current_test_set(Unit),
|
142 |
(
|
143 |
-
|
|
|
144 |
output_unit_results(Unit),
|
145 |
format( " </testsuite>\n", [])
|
146 |
)
|
147 |
),
|
148 |
format('<system-out><![C~w[',['DATA']),
|
149 |
-
|
150 |
-
format("
|
151 |
writeln(TotalConverage))).
|
152 |
|
|
|
|
|
153 |
:- meta_predicate(capturing_user_error(+,:)).
|
154 |
capturing_user_error(To, Goal):-
|
155 |
with_output_to(To,
|
@@ -214,12 +217,22 @@
|
|
214 |
call_cleanup(
|
215 |
(
|
216 |
run_junit_tests(Spec),
|
217 |
-
|
218 |
),
|
219 |
-
|
220 |
).
|
221 |
|
222 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
% scans plunit dynamic predicates and outputs corresponding info to XML
|
224 |
output_unit_results(Unit) :-
|
225 |
output_passed_results(Unit),
|
@@ -229,17 +242,21 @@
|
|
229 |
% outputs a successful testcase with its time for each plunit:passed/5 entry
|
230 |
output_passed_results(Unit) :-
|
231 |
forall(
|
232 |
-
plunit:passed(Unit, Name,
|
233 |
-
|
|
|
|
|
234 |
).
|
235 |
|
236 |
|
237 |
% outputs a failure inside a testcase for each plunit:failed/4 entry
|
238 |
output_failed_results(Unit) :-
|
239 |
forall(
|
240 |
-
plunit:failed(Unit, Name,
|
241 |
(
|
242 |
-
|
|
|
|
|
243 |
format( " <failure message=\"~w\" />\n", [Error]),
|
244 |
format( " </testcase>\n", [])
|
245 |
)
|
@@ -332,7 +349,7 @@
|
|
332 |
process_test_result(TestResult, G),
|
333 |
TestResult=..[Type|Info],add_test_info(Testcase,Type,Info),
|
334 |
add_test_info(Testcase,result,Type),
|
335 |
-
ignore((
|
336 |
must_det_l((
|
337 |
read_file_to_string(Tee,Str,[]),
|
338 |
add_test_info(Testcase,out,Str),
|
@@ -343,7 +360,7 @@
|
|
343 |
Type == passed.
|
344 |
|
345 |
kill_junit_tee:-
|
346 |
-
ignore((
|
347 |
sformat(Exec,'cat /dev/null > ~w',[Tee]),
|
348 |
shell(Exec))).
|
349 |
|
@@ -373,11 +390,11 @@
|
|
373 |
why_was_true(P):- dmsg_pretty(justfied_true(P)),!.
|
374 |
|
375 |
catch_timeout(P):- tracing,!,call(P).
|
376 |
-
%catch_timeout(P):-
|
377 |
-
catch_timeout(P):-
|
378 |
catch_timeout(P):- catch(call_with_time_limit(30,w_o_c(P)),E,wdmsg(P->E)).
|
379 |
|
380 |
-
%generate_test_name(G,Name):-
|
381 |
generate_test_name(G,Name):- source_context_name(SCName), gtn_no_pack(G,GUName), trim_to_size(GUName,-30,GName),
|
382 |
(atom_length(GName,0)-> SCName = Name ; sformat(Name,'~w__~w',[SCName,GName])).
|
383 |
|
@@ -449,7 +466,7 @@
|
|
449 |
:- create_prolog_flag(logicmoo_message_hook,none,[keep(true),type(term)]).
|
450 |
|
451 |
system:test_src(Src):- (current_prolog_flag(test_src,Src), Src\==[]);j_u:junit_prop(testsuite,file,Src).
|
452 |
-
system:is_junit_test:-
|
453 |
system:is_junit_test:- system:is_junit_test_file.
|
454 |
system:is_junit_test_file:- test_src(Src), prolog_load_context(file,Src),!.
|
455 |
|
@@ -491,7 +508,7 @@
|
|
491 |
|
492 |
get_current_testcase(Testcase):- t_l:mpred_current_testcase(Testcase),!.
|
493 |
|
494 |
-
get_current_testcase(Testcase):-
|
495 |
get_current_testcase(Testcase):- "suiteTestcase"=Testcase, add_test_info(testsuite,testcase,Testcase),!.
|
496 |
% get_current_testcase(Testcase):- j_u:junit_prop(testsuite,file,Testcase).
|
497 |
|
@@ -706,12 +723,12 @@
|
|
706 |
|
707 |
get_suite_attribs(SuiteAttribs):-
|
708 |
with_output_to(string(SuiteAttribs),
|
709 |
-
(( ignore((
|
710 |
ignore((j_u:junit_prop(testsuite,start,Start),get_time(End),Elapsed is End - Start,format(' time="~3f"',[Elapsed]))),
|
711 |
forall((junit_count(F),flag(F,C,C)),format(' ~w="~w"',[F,C]))))).
|
712 |
|
713 |
show_junit_suite(File):-
|
714 |
-
(
|
715 |
get_suite_attribs(SuiteAttribs),
|
716 |
format(" <testsuite name=\"~w\" ~w>\n", [SuiteName, SuiteAttribs]),
|
717 |
findall(Name,j_u:junit_prop(testsuite,testcase,Name),L),list_to_set(L,S),
|
@@ -736,7 +753,7 @@
|
|
736 |
|
737 |
|
738 |
issue_labels(Name,[Package,ShortClass,TestNum]):-
|
739 |
-
|
740 |
classname_to_package(Classname,Package,ShortClass),
|
741 |
sub_string(Name,1,9,_,TestNum).
|
742 |
|
@@ -758,7 +775,7 @@
|
|
758 |
must_det_l((
|
759 |
j_u:junit_prop(testsuite,file,File),
|
760 |
writeln(" <testsuites>"),
|
761 |
-
(
|
762 |
get_suite_attribs(SuiteAttribs),
|
763 |
format(" <testsuite name=\"~w\" ~w>\n", [SuiteName, SuiteAttribs]),
|
764 |
show_junit_testcase(File,Name),
|
@@ -820,7 +837,7 @@
|
|
820 |
|
821 |
save_to_junit_file(Name,DirtyText,FileName):-
|
822 |
must_det_l((clean_away_ansi(DirtyText,Text),
|
823 |
-
|
824 |
shorten_and_clean_name(Name,-150,SName),
|
825 |
atomic_list_concat([Dir,'-',SName],Full),
|
826 |
write_testcase_env(Name),
|
@@ -829,7 +846,7 @@
|
|
829 |
|
830 |
save_junit_results_single:-
|
831 |
% $TESTING_TEMP
|
832 |
-
|
833 |
directory_file_path(Dir,'junit_single.ansi',Full),!,
|
834 |
tell(Full),
|
835 |
show_all_junit_suites,
|
@@ -850,10 +867,10 @@
|
|
850 |
|
851 |
show_junit_testcase(Suite,Testcase):-
|
852 |
j_u:junit_prop(Testcase,goal,Goal),
|
853 |
-
(
|
854 |
-
%(
|
855 |
-
%ignore((
|
856 |
-
%ignore((
|
857 |
%(nonvar(ShortClass)-> true; atom_concat(Package,ShortClass,Classname)),
|
858 |
sformat(DisplayName,'~w@~w: ~p',[Classname,Testcase,Goal]),
|
859 |
escape_attribute(DisplayName,EDisplayName),
|
@@ -868,7 +885,7 @@
|
|
868 |
|
869 |
write_testcase_env(Name):-
|
870 |
write_testcase_prop(name,Name),
|
871 |
-
forall(junit_env_var(N),ignore((
|
872 |
|
873 |
junit_env_var('JUNIT_CLASSNAME').
|
874 |
%junit_env_var('JUNIT_PACKAGE').
|
53 |
set_prolog_flag(ran_junit_tests,true),
|
54 |
term_to_atom(Spec,SpecAtom),
|
55 |
statistics(cputime,Y),
|
56 |
+
(getenv_safe('TESTING_TEMP',TESTING_TEMP)->true;TESTING_TEMP='/tmp'), %tmp_file(SpecAtom,TmpName),
|
57 |
atomic_list_concat([TESTING_TEMP,'/',SpecAtom,Y,'-junit.xml'],FileName),
|
58 |
capturing_user_error(string(UserErr), (run_junit_tests_user_error(Spec,UnitXml),plunit:check_for_test_errors)),
|
59 |
sformat(JUnitStr,"~w~n~w]]>></system-out></testsuites>\n",[UnitXml,UserErr]),
|
140 |
forall(
|
141 |
plunit:current_test_set(Unit),
|
142 |
(
|
143 |
+
unit_to_sn(Unit,SuiteName,Package),
|
144 |
+
format( " <testsuite name=\"~w\" package=\"~w\">\n", [SuiteName,Package]),
|
145 |
output_unit_results(Unit),
|
146 |
format( " </testsuite>\n", [])
|
147 |
)
|
148 |
),
|
149 |
format('<system-out><![C~w[',['DATA']),
|
150 |
+
current_prolog_flag(version, V2),
|
151 |
+
format("Running on SWI-Prolog ~w~n", [ V2]),
|
152 |
writeln(TotalConverage))).
|
153 |
|
154 |
+
|
155 |
+
|
156 |
:- meta_predicate(capturing_user_error(+,:)).
|
157 |
capturing_user_error(To, Goal):-
|
158 |
with_output_to(To,
|
217 |
call_cleanup(
|
218 |
(
|
219 |
run_junit_tests(Spec),
|
220 |
+
test_completed(64)
|
221 |
),
|
222 |
+
test_completed(8)
|
223 |
).
|
224 |
|
225 |
|
226 |
+
getenv_safe(N,V):- getenv(N,V),!.
|
227 |
+
getenv_safe(N,N).
|
228 |
+
|
229 |
+
unit_to_sn(Unit,SuiteName,Package):- getenv_safe('JUNIT_PACKAGE',Package),getenv_safe('JUNIT_SUITE',Suite),
|
230 |
+
sformat(SuiteName,"~w_~w",[Suite,Unit]).
|
231 |
+
name_to_tc(Name,Line,SCName,Classname):-
|
232 |
+
getenv_safe('JUNIT_CLASSNAME',Classname),
|
233 |
+
sformat(TCName,"~w@Test_0001_Line_~4d ~w",[Classname,Line,Name]),
|
234 |
+
replace_in_string(['_0.'='_'],TCName,SCName),!.
|
235 |
+
|
236 |
% scans plunit dynamic predicates and outputs corresponding info to XML
|
237 |
output_unit_results(Unit) :-
|
238 |
output_passed_results(Unit),
|
242 |
% outputs a successful testcase with its time for each plunit:passed/5 entry
|
243 |
output_passed_results(Unit) :-
|
244 |
forall(
|
245 |
+
plunit:passed(Unit, Name, Line, _Det, Time),
|
246 |
+
(name_to_tc(Name,Line,TCName,Classname),
|
247 |
+
add_test_info(TCName,result,passed),
|
248 |
+
format( " <testcase name=\"~w\" classname=\"~w\" time=\"~w\" />\n", [TCName, Classname, Time]))
|
249 |
).
|
250 |
|
251 |
|
252 |
% outputs a failure inside a testcase for each plunit:failed/4 entry
|
253 |
output_failed_results(Unit) :-
|
254 |
forall(
|
255 |
+
plunit:failed(Unit, Name, Line, Error),
|
256 |
(
|
257 |
+
name_to_tc(Name,Line,TCName,Classname),
|
258 |
+
add_test_info(TCName,result,failure),
|
259 |
+
format( " <testcase name=\"~w\" classname=\"~w\">\n", [TCName,Classname]),
|
260 |
format( " <failure message=\"~w\" />\n", [Error]),
|
261 |
format( " </testcase>\n", [])
|
262 |
)
|
349 |
process_test_result(TestResult, G),
|
350 |
TestResult=..[Type|Info],add_test_info(Testcase,Type,Info),
|
351 |
add_test_info(Testcase,result,Type),
|
352 |
+
ignore((getenv_safe('TEE_FILE',Tee),
|
353 |
must_det_l((
|
354 |
read_file_to_string(Tee,Str,[]),
|
355 |
add_test_info(Testcase,out,Str),
|
360 |
Type == passed.
|
361 |
|
362 |
kill_junit_tee:-
|
363 |
+
ignore((getenv_safe('TEE_FILE',Tee),
|
364 |
sformat(Exec,'cat /dev/null > ~w',[Tee]),
|
365 |
shell(Exec))).
|
366 |
|
390 |
why_was_true(P):- dmsg_pretty(justfied_true(P)),!.
|
391 |
|
392 |
catch_timeout(P):- tracing,!,call(P).
|
393 |
+
%catch_timeout(P):- getenv_safe('CMD_TIMEOUT',X), \+ atom_length(X,0),!, call(P). % Caller will kill it
|
394 |
+
catch_timeout(P):- getenv_safe('CMD',X), atom_contains(X,"timeout"),!, call(P). % Caller will kill it
|
395 |
catch_timeout(P):- catch(call_with_time_limit(30,w_o_c(P)),E,wdmsg(P->E)).
|
396 |
|
397 |
+
%generate_test_name(G,Name):- getenv_safe('JUNIT_CLASSNAME',Class), gtn_no_pack(G,NPack),sformat(Name,'~w ~w',[Class, NPack]),!.
|
398 |
generate_test_name(G,Name):- source_context_name(SCName), gtn_no_pack(G,GUName), trim_to_size(GUName,-30,GName),
|
399 |
(atom_length(GName,0)-> SCName = Name ; sformat(Name,'~w__~w',[SCName,GName])).
|
400 |
|
466 |
:- create_prolog_flag(logicmoo_message_hook,none,[keep(true),type(term)]).
|
467 |
|
468 |
system:test_src(Src):- (current_prolog_flag(test_src,Src), Src\==[]);j_u:junit_prop(testsuite,file,Src).
|
469 |
+
system:is_junit_test:- getenv_safe('JUNIT_PACKAGE',_),!.
|
470 |
system:is_junit_test:- system:is_junit_test_file.
|
471 |
system:is_junit_test_file:- test_src(Src), prolog_load_context(file,Src),!.
|
472 |
|
508 |
|
509 |
get_current_testcase(Testcase):- t_l:mpred_current_testcase(Testcase),!.
|
510 |
|
511 |
+
get_current_testcase(Testcase):- getenv_safe('FileTestCase',Testcase), add_test_info(testsuite,testcase,Testcase),!.
|
512 |
get_current_testcase(Testcase):- "suiteTestcase"=Testcase, add_test_info(testsuite,testcase,Testcase),!.
|
513 |
% get_current_testcase(Testcase):- j_u:junit_prop(testsuite,file,Testcase).
|
514 |
|
723 |
|
724 |
get_suite_attribs(SuiteAttribs):-
|
725 |
with_output_to(string(SuiteAttribs),
|
726 |
+
(( ignore((getenv_safe('JUNIT_PACKAGE',Package), format(' package="~w"', [Package]))),
|
727 |
ignore((j_u:junit_prop(testsuite,start,Start),get_time(End),Elapsed is End - Start,format(' time="~3f"',[Elapsed]))),
|
728 |
forall((junit_count(F),flag(F,C,C)),format(' ~w="~w"',[F,C]))))).
|
729 |
|
730 |
show_junit_suite(File):-
|
731 |
+
(getenv_safe('JUNIT_SUITE',SuiteName);SuiteName=File),!,
|
732 |
get_suite_attribs(SuiteAttribs),
|
733 |
format(" <testsuite name=\"~w\" ~w>\n", [SuiteName, SuiteAttribs]),
|
734 |
findall(Name,j_u:junit_prop(testsuite,testcase,Name),L),list_to_set(L,S),
|
753 |
|
754 |
|
755 |
issue_labels(Name,[Package,ShortClass,TestNum]):-
|
756 |
+
getenv_safe('JUNIT_CLASSNAME',Classname),
|
757 |
classname_to_package(Classname,Package,ShortClass),
|
758 |
sub_string(Name,1,9,_,TestNum).
|
759 |
|
775 |
must_det_l((
|
776 |
j_u:junit_prop(testsuite,file,File),
|
777 |
writeln(" <testsuites>"),
|
778 |
+
(getenv_safe('JUNIT_SUITE',SuiteName);SuiteName=File),!,
|
779 |
get_suite_attribs(SuiteAttribs),
|
780 |
format(" <testsuite name=\"~w\" ~w>\n", [SuiteName, SuiteAttribs]),
|
781 |
show_junit_testcase(File,Name),
|
837 |
|
838 |
save_to_junit_file(Name,DirtyText,FileName):-
|
839 |
must_det_l((clean_away_ansi(DirtyText,Text),
|
840 |
+
getenv_safe('TEST_STEM_PATH',Dir),!,
|
841 |
shorten_and_clean_name(Name,-150,SName),
|
842 |
atomic_list_concat([Dir,'-',SName],Full),
|
843 |
write_testcase_env(Name),
|
846 |
|
847 |
save_junit_results_single:-
|
848 |
% $TESTING_TEMP
|
849 |
+
getenv_safe('TESTING_TEMP',Dir),
|
850 |
directory_file_path(Dir,'junit_single.ansi',Full),!,
|
851 |
tell(Full),
|
852 |
show_all_junit_suites,
|
867 |
|
868 |
show_junit_testcase(Suite,Testcase):-
|
869 |
j_u:junit_prop(Testcase,goal,Goal),
|
870 |
+
(getenv_safe('JUNIT_CLASSNAME',Classname)-> true ; suite_to_package(Suite,Classname)),
|
871 |
+
%(getenv_safe('JUNIT_PACKAGE',Package) -> true ; classname_to_package(Classname,Package,_ShortClass)),
|
872 |
+
%ignore((getenv_safe('JUNIT_SHORTCLASS',ShortClass))),
|
873 |
+
%ignore((getenv_safe('JUNIT_SUITE',JUNIT_SUITE))),
|
874 |
%(nonvar(ShortClass)-> true; atom_concat(Package,ShortClass,Classname)),
|
875 |
sformat(DisplayName,'~w@~w: ~p',[Classname,Testcase,Goal]),
|
876 |
escape_attribute(DisplayName,EDisplayName),
|
885 |
|
886 |
write_testcase_env(Name):-
|
887 |
write_testcase_prop(name,Name),
|
888 |
+
forall(junit_env_var(N),ignore((getenv_safe(N,V),write_testcase_prop(N,V)))),!.
|
889 |
|
890 |
junit_env_var('JUNIT_CLASSNAME').
|
891 |
%junit_env_var('JUNIT_PACKAGE').
|
packs_sys/logicmoo_utils/t/loop_check_tests_01.plt
CHANGED
@@ -43,3 +43,9 @@
|
|
43 |
:- run_tests.
|
44 |
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
43 |
:- run_tests.
|
44 |
|
45 |
|
46 |
+
|
47 |
+
% EDIT: https://github.com/logicmoo/logicmoo_workspace/edit/master//var/lib/jenkins/workspace/logicmoo_workspace/packs_sys/logicmoo_utils/t/loop_check_tests_01.plt
|
48 |
+
% JENKINS: https://jenkins.logicmoo.org/job/logicmoo_workspace/lastBuild/testReport/logicmoo.utils.utils.t/LOOP_CHECK_TESTS_01/
|
49 |
+
% ISSUE_SEARCH: https://github.com/logicmoo/logicmoo_workspace/issues?q=is%3Aissue+label%3ALOOP_CHECK_TESTS_01
|
50 |
+
% ISSUE: https://github.com/logicmoo/logicmoo_workspace/issues/
|
51 |
+
|