diff --git a/packs_sys/logicmoo_utils/prolog/logicmoo_test.pl b/packs_sys/logicmoo_utils/prolog/logicmoo_test.pl index bd2e17f..31dd520 100755 --- a/packs_sys/logicmoo_utils/prolog/logicmoo_test.pl +++ b/packs_sys/logicmoo_utils/prolog/logicmoo_test.pl @@ -53,7 +53,7 @@ set_prolog_flag(ran_junit_tests,true), term_to_atom(Spec,SpecAtom), statistics(cputime,Y), - (getenv('TESTING_TEMP',TESTING_TEMP)->true;TESTING_TEMP='/tmp'), %tmp_file(SpecAtom,TmpName), + (getenv_safe('TESTING_TEMP',TESTING_TEMP)->true;TESTING_TEMP='/tmp'), %tmp_file(SpecAtom,TmpName), atomic_list_concat([TESTING_TEMP,'/',SpecAtom,Y,'-junit.xml'],FileName), capturing_user_error(string(UserErr), (run_junit_tests_user_error(Spec,UnitXml),plunit:check_for_test_errors)), sformat(JUnitStr,"~w~n~w]]>>\n",[UnitXml,UserErr]), @@ -140,16 +140,19 @@ forall( plunit:current_test_set(Unit), ( - format( " \n", [Unit]), + unit_to_sn(Unit,SuiteName,Package), + format( " \n", [SuiteName,Package]), output_unit_results(Unit), format( " \n", []) ) ), format('\n", [Name, Time]) + plunit:passed(Unit, Name, Line, _Det, Time), + (name_to_tc(Name,Line,TCName,Classname), + add_test_info(TCName,result,passed), + format( " \n", [TCName, Classname, Time])) ). % outputs a failure inside a testcase for each plunit:failed/4 entry output_failed_results(Unit) :- forall( - plunit:failed(Unit, Name, _Line, Error), + plunit:failed(Unit, Name, Line, Error), ( - format( " \n", [Name]), + name_to_tc(Name,Line,TCName,Classname), + add_test_info(TCName,result,failure), + format( " \n", [TCName,Classname]), format( " \n", [Error]), format( " \n", []) ) @@ -332,7 +349,7 @@ process_test_result(TestResult, G), TestResult=..[Type|Info],add_test_info(Testcase,Type,Info), add_test_info(Testcase,result,Type), - ignore((getenv('TEE_FILE',Tee), + ignore((getenv_safe('TEE_FILE',Tee), must_det_l(( read_file_to_string(Tee,Str,[]), add_test_info(Testcase,out,Str), @@ -343,7 +360,7 @@ Type == passed. kill_junit_tee:- - ignore((getenv('TEE_FILE',Tee), + ignore((getenv_safe('TEE_FILE',Tee), sformat(Exec,'cat /dev/null > ~w',[Tee]), shell(Exec))). @@ -373,11 +390,11 @@ why_was_true(P):- dmsg_pretty(justfied_true(P)),!. catch_timeout(P):- tracing,!,call(P). -%catch_timeout(P):- getenv('CMD_TIMEOUT',X), \+ atom_length(X,0),!, call(P). % Caller will kill it -catch_timeout(P):- getenv('CMD',X), atom_contains(X,"timeout"),!, call(P). % Caller will kill it +%catch_timeout(P):- getenv_safe('CMD_TIMEOUT',X), \+ atom_length(X,0),!, call(P). % Caller will kill it +catch_timeout(P):- getenv_safe('CMD',X), atom_contains(X,"timeout"),!, call(P). % Caller will kill it catch_timeout(P):- catch(call_with_time_limit(30,w_o_c(P)),E,wdmsg(P->E)). -%generate_test_name(G,Name):- getenv('JUNIT_CLASSNAME',Class), gtn_no_pack(G,NPack),sformat(Name,'~w ~w',[Class, NPack]),!. +%generate_test_name(G,Name):- getenv_safe('JUNIT_CLASSNAME',Class), gtn_no_pack(G,NPack),sformat(Name,'~w ~w',[Class, NPack]),!. generate_test_name(G,Name):- source_context_name(SCName), gtn_no_pack(G,GUName), trim_to_size(GUName,-30,GName), (atom_length(GName,0)-> SCName = Name ; sformat(Name,'~w__~w',[SCName,GName])). @@ -449,7 +466,7 @@ :- create_prolog_flag(logicmoo_message_hook,none,[keep(true),type(term)]). system:test_src(Src):- (current_prolog_flag(test_src,Src), Src\==[]);j_u:junit_prop(testsuite,file,Src). -system:is_junit_test:- getenv('JUNIT_PACKAGE',_),!. +system:is_junit_test:- getenv_safe('JUNIT_PACKAGE',_),!. system:is_junit_test:- system:is_junit_test_file. system:is_junit_test_file:- test_src(Src), prolog_load_context(file,Src),!. @@ -491,7 +508,7 @@ get_current_testcase(Testcase):- t_l:mpred_current_testcase(Testcase),!. -get_current_testcase(Testcase):- getenv('FileTestCase',Testcase), add_test_info(testsuite,testcase,Testcase),!. +get_current_testcase(Testcase):- getenv_safe('FileTestCase',Testcase), add_test_info(testsuite,testcase,Testcase),!. get_current_testcase(Testcase):- "suiteTestcase"=Testcase, add_test_info(testsuite,testcase,Testcase),!. % get_current_testcase(Testcase):- j_u:junit_prop(testsuite,file,Testcase). @@ -706,12 +723,12 @@ get_suite_attribs(SuiteAttribs):- with_output_to(string(SuiteAttribs), -(( ignore((getenv('JUNIT_PACKAGE',Package), format(' package="~w"', [Package]))), +(( ignore((getenv_safe('JUNIT_PACKAGE',Package), format(' package="~w"', [Package]))), ignore((j_u:junit_prop(testsuite,start,Start),get_time(End),Elapsed is End - Start,format(' time="~3f"',[Elapsed]))), forall((junit_count(F),flag(F,C,C)),format(' ~w="~w"',[F,C]))))). show_junit_suite(File):- - (getenv('JUNIT_SUITE',SuiteName);SuiteName=File),!, + (getenv_safe('JUNIT_SUITE',SuiteName);SuiteName=File),!, get_suite_attribs(SuiteAttribs), format(" \n", [SuiteName, SuiteAttribs]), findall(Name,j_u:junit_prop(testsuite,testcase,Name),L),list_to_set(L,S), @@ -736,7 +753,7 @@ issue_labels(Name,[Package,ShortClass,TestNum]):- - getenv('JUNIT_CLASSNAME',Classname), + getenv_safe('JUNIT_CLASSNAME',Classname), classname_to_package(Classname,Package,ShortClass), sub_string(Name,1,9,_,TestNum). @@ -758,7 +775,7 @@ must_det_l(( j_u:junit_prop(testsuite,file,File), writeln(" "), - (getenv('JUNIT_SUITE',SuiteName);SuiteName=File),!, + (getenv_safe('JUNIT_SUITE',SuiteName);SuiteName=File),!, get_suite_attribs(SuiteAttribs), format(" \n", [SuiteName, SuiteAttribs]), show_junit_testcase(File,Name), @@ -820,7 +837,7 @@ save_to_junit_file(Name,DirtyText,FileName):- must_det_l((clean_away_ansi(DirtyText,Text), - getenv('TEST_STEM_PATH',Dir),!, + getenv_safe('TEST_STEM_PATH',Dir),!, shorten_and_clean_name(Name,-150,SName), atomic_list_concat([Dir,'-',SName],Full), write_testcase_env(Name), @@ -829,7 +846,7 @@ save_junit_results_single:- % $TESTING_TEMP - getenv('TESTING_TEMP',Dir), + getenv_safe('TESTING_TEMP',Dir), directory_file_path(Dir,'junit_single.ansi',Full),!, tell(Full), show_all_junit_suites, @@ -850,10 +867,10 @@ show_junit_testcase(Suite,Testcase):- j_u:junit_prop(Testcase,goal,Goal), - (getenv('JUNIT_CLASSNAME',Classname)-> true ; suite_to_package(Suite,Classname)), - %(getenv('JUNIT_PACKAGE',Package) -> true ; classname_to_package(Classname,Package,_ShortClass)), - %ignore((getenv('JUNIT_SHORTCLASS',ShortClass))), - %ignore((getenv('JUNIT_SUITE',JUNIT_SUITE))), + (getenv_safe('JUNIT_CLASSNAME',Classname)-> true ; suite_to_package(Suite,Classname)), + %(getenv_safe('JUNIT_PACKAGE',Package) -> true ; classname_to_package(Classname,Package,_ShortClass)), + %ignore((getenv_safe('JUNIT_SHORTCLASS',ShortClass))), + %ignore((getenv_safe('JUNIT_SUITE',JUNIT_SUITE))), %(nonvar(ShortClass)-> true; atom_concat(Package,ShortClass,Classname)), sformat(DisplayName,'~w@~w: ~p',[Classname,Testcase,Goal]), escape_attribute(DisplayName,EDisplayName), @@ -868,7 +885,7 @@ write_testcase_env(Name):- write_testcase_prop(name,Name), - forall(junit_env_var(N),ignore((getenv(N,V),write_testcase_prop(N,V)))),!. + forall(junit_env_var(N),ignore((getenv_safe(N,V),write_testcase_prop(N,V)))),!. junit_env_var('JUNIT_CLASSNAME'). %junit_env_var('JUNIT_PACKAGE'). diff --git a/packs_sys/logicmoo_utils/t/loop_check_tests_01.plt b/packs_sys/logicmoo_utils/t/loop_check_tests_01.plt index 5957b07..129811f 100755 --- a/packs_sys/logicmoo_utils/t/loop_check_tests_01.plt +++ b/packs_sys/logicmoo_utils/t/loop_check_tests_01.plt @@ -43,3 +43,9 @@ % :- run_tests. + +% 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 +% JENKINS: https://jenkins.logicmoo.org/job/logicmoo_workspace/lastBuild/testReport/logicmoo.utils.utils.t/LOOP_CHECK_TESTS_01/ +% ISSUE_SEARCH: https://github.com/logicmoo/logicmoo_workspace/issues?q=is%3Aissue+label%3ALOOP_CHECK_TESTS_01 +% ISSUE: https://github.com/logicmoo/logicmoo_workspace/issues/ +