Skip to content

View Last Changes of build #2

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