Skip to content

Commit

Permalink
Merge pull request #31 from ChristopherEdwards/more-coverage-fixes
Browse files Browse the repository at this point in the history
More coverage fixes
  • Loading branch information
ChristopherEdwards committed Aug 30, 2019
2 parents ce9c9a1 + 8766028 commit 13adf84
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 65 deletions.
88 changes: 40 additions & 48 deletions Routines/_ut1.m
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%ut1 ;VEN/SMH/JLI - CONTINUATION OF M-UNIT PROCESSING ;04/26/17 21:10
%ut1 ;VEN/SMH/JLI - CONTINUATION OF M-UNIT PROCESSING ;Aug 30, 2019@16:49
;;1.6;M-UNIT;;Aug 28, 2019;Build 6
; Submitted to OSEHRA Jul 8, 2017 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html)
; Original routine authored by Joel L. Ivey as XTMUNIT1 while working for U.S. Department of Veterans Affairs 2003-2012
Expand Down Expand Up @@ -160,84 +160,80 @@ D NEWSTYLE(.LIST,%utROU)
;
; ZEXCEPT: %utcovxx - SET and KILLED in this code at top level
; ZEXCEPT: %Monitor,%apiOBJ,DecomposeStatus,LineByLine,Start,Stop,System,class - not variables parts of classes
N COVER,COVERSAV,I,NMSP1,RTN,RTNS,ERR,STATUS
W !,"Loading routines to test coverage...",!
D GETRTNS(.RTNS,NMSPS)
;
; ZEXCEPT: CTRAP - not really a variable
N I,NMSP1,RTN,RTNS,ERR,STATUS
S VERBOSITY=+$G(VERBOSITY) ; Get 0 if not passed.
;
; Globals used throughout
N COVGL,ORIGGL,SURVGL,RESGL
S RESGL=$NA(^TMP("%utRESULT",$J))
S COVGL=$NA(^TMP("%utCOVERAGE",$J))
S ORIGGL=$NA(^TMP("%utORIGINAL-COHORT",$J))
S SURVGL=$NA(^TMP("%utSURVIVING-COHORT",$J))
;
W !,"Loading routines to test coverage...",!
D GETRTNS(.RTNS,NMSPS)
;
N GL
S GL=$NA(^TMP("%utORIGINAL-COHORT",$J))
I '$D(^TMP("%utcovrunning",$J)) K @GL
D RTNANAL(.RTNS,GL) ; save off any current coverage data
; Turn on Coverage Checking if we are not already running coverage
I '$D(^TMP("%utcovrunning",$J)) N EXIT S EXIT=0 D Q:EXIT
. K ^TMP("%utSURVIVING-COHORT",$J)
. M ^TMP("%utSURVIVING-COHORT",$J)=^TMP("%utORIGINAL-COHORT",$J)
. K ^TMP("%utCOVERAGE",$J)
. K @COVGL,@RESGL,@ORIGGL,@SURVGL
. D RTNANAL(.RTNS,ORIGGL)
. S ^TMP("%utcovrunning",$J)=1,%utcovxx=1
. ;
. I ($$GETSYS^%ut()=47) VIEW "TRACE":1:$NA(^TMP("%utCOVERAGE",$J)) ; GT.M START PROFILING
. I ($$GETSYS^%ut()=47) VIEW "TRACE":1:COVGL ; GT.M START PROFILING
. ;
. I ($$GETSYS^%ut()=0) D ; CACHE CODE TO START PROFILING
. . N NMSP,NMSPV S NMSP="",NMSPV="" F S NMSPV=$O(RTNS(NMSPV)) Q:NMSPV="" S NMSP=NMSP_NMSPV_","
. . S NMSP=$E(NMSP,1,$L(NMSP)-1)
. . S STATUS=##class(%Monitor.System.LineByLine).Start($lb(NMSP),$lb("RtnLine"),$lb($j))
. . I +STATUS'=1 D DecomposeStatus^%apiOBJ(STATUS,.ERR,"-d") F I=1:1:ERR W ERR(I),!
. . I +STATUS'=1 K ERR S EXIT=1
. . Q
. Q
DO ; Run the code, but keep our variables to ourselves.
;
; Run the code, but keep our variables to ourselves
DO
. NEW $ETRAP,$ESTACK
. I ($$GETSYS^%ut()=47) D ; GT.M SPECIFIC
. . SET $ETRAP="Q:($ES&$Q) -9 Q:$ES W ""CTRL-C ENTERED"""
. . ;USE $PRINCIPAL:(CTRAP=$C(3)) ; JLI 170403
. . USE %utIO:(CTRAP=$C(3)) ; JLI 170403
. . Q
. NEW (DUZ,IO,COVCODE,U,DILOCKTM,DISYS,DT,DTIME,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY,%utIO)
. XECUTE COVCODE
. Q
; GT.M STOP PROFILING if this is the original level that started it
;
;
; STOP PROFILING if this is the original level that started it and save into Coverage Global
I $D(^TMP("%utcovrunning",$J)),$D(%utcovxx) D
. I ($$GETSYS^%ut()=47) VIEW "TRACE":0:$NA(^TMP("%utCOVERAGE",$J)) ; GT.M SPECIFIC
. I ($$GETSYS^%ut()=0) ; CACHE SPECIFIC
. I ($$GETSYS^%ut()=47) D GTMCOV(COVGL,ORIGGL,SURVGL) I 1
. I ($$GETSYS^%ut()=0) D CACHECOV(SURVGL) I 1
. K %utcovxx,^TMP("%utcovrunning",$J)
. Q
;
; Don't calculate coverage if we are still running (inception scenario)
I $D(^TMP("%utcovrunning",$J)) QUIT
;
I ($$GETSYS^%ut()=0) D ; CACHE SPECIFIC CODE
. S COVERSAV=$NA(^TMP("%utSURVIVING-COHORT",$J)) K @COVERSAV
. S COVER=$NA(^TMP("%utORIGINAL-COHORT",$J)) K @COVER
. D CACHECOV(COVERSAV,COVER)
. D TOTAGS(COVERSAV,0),TOTAGS(COVER,1)
. D ##class(%Monitor.System.LineByLine).Stop()
;
D COVCOV($NA(^TMP("%utSURVIVING-COHORT",$J)),$NA(^TMP("%utCOVERAGE",$J))) ; Venn diagram matching between globals
; Report
D COVRPT($NA(^TMP("%utORIGINAL-COHORT",$J)),$NA(^TMP("%utSURVIVING-COHORT",$J)),$NA(^TMP("%utRESULT",$J)),VERBOSITY)
D COVRPT(ORIGGL,SURVGL,RESGL,VERBOSITY)
QUIT
;
CACHECOV(GLOBSAV,GLOB) ;
GTMCOV(COVGL,ORIGGL,SURVGL) ;
M @SURVGL=@ORIGGL
VIEW "TRACE":0:COVGL ; GT.M SPECIFIC
D COVCOV(SURVGL,COVGL) ; Venn diagram matching between globals
QUIT
;
CACHECOV(SURVGL) ;
; ZEXCEPT: %Monitor,GetMetrics,GetRoutineCount,GetRoutineName,LineByLine,System,class - not variable names, part of classes
N %N,DIF,I,METRIC,METRICNT,METRICS,MTRICNUM,ROUNAME,ROUNUM,X,XCNP,XXX
I $$ISUTEST(),'$D(^TMP("%utt4val",$J)) S ROUNUM=1,METRICS="RtnLine",METRICNT=1,ROUNAME="%ut"
I $D(^TMP("%utt4val",$J))!'$$ISUTEST() S ROUNUM=##class(%Monitor.System.LineByLine).GetRoutineCount(),METRICS=##class(%Monitor.System.LineByLine).GetMetrics(),METRICNT=$l(METRICS,",")
; if only running to do coverage, should be 1
S ROUNUM=##class(%Monitor.System.LineByLine).GetRoutineCount(),METRICS=##class(%Monitor.System.LineByLine).GetMetrics(),METRICNT=$l(METRICS,",")
S MTRICNUM=0 F I=1:1:METRICNT S METRIC=$P(METRICS,",",I) I METRIC="RtnLine" S MTRICNUM=I Q
;
F I=1:1:ROUNUM D
. I $D(^TMP("%utt4val",$J))!'$$ISUTEST() S ROUNAME=##class(%Monitor.System.LineByLine).GetRoutineName(I)
. S ROUNAME=##class(%Monitor.System.LineByLine).GetRoutineName(I)
. ; get routine loaded into location
. S DIF=$NA(@GLOBSAV@(ROUNAME)),DIF=$E(DIF,1,$L(DIF)-1)_",",XCNP=0,X=ROUNAME
. ;X ^%ZOSF("LOAD") ; JLI 160912 see 160701 note in comments at top
. S DIF=$NA(@SURVGL@(ROUNAME)),DIF=$E(DIF,1,$L(DIF)-1)_",",XCNP=0,X=ROUNAME
. X "N %,%N S %N=0 X ""ZL @X F XCNP=XCNP+1:1 S %N=%N+1,%=$T(+%N) Q:$L(%)=0 S @(DIF_XCNP_"""",0)"""")=%""" ; JLI see 160701 note in comments at top
. M @GLOB@(ROUNAME)=@GLOBSAV@(ROUNAME)
. Q
;
I $D(^TMP("%utt4val",$J))!'$$ISUTEST() F XXX=1:1:ROUNUM D GETVALS(XXX,GLOB,MTRICNUM)
F XXX=1:1:ROUNUM D GETVALS(XXX,SURVGL,MTRICNUM)
D TOTAGS(SURVGL,1)
D ##class(%Monitor.System.LineByLine).Stop()
Q
;
GETVALS(ROUNUM,GLOB,MTRICNUM) ; get data on number of times a line seen (set into VAL)
Expand Down Expand Up @@ -401,9 +397,6 @@ D COVRPTLS(C,S,R,V)
. Q
QUIT
;
ISUTEST() ;
Q $$ISUTEST^%ut()
;
GETRTNS(RTNS,NMSPS) ; [Public] Get routines for namespaces
; .RTNS - Output. Initially empty
; NMSPS - Input: Namespaces
Expand All @@ -423,13 +416,12 @@ D COVRPTLS(C,S,R,V)
. . . I $E($P(L2," ",2),1,2)'=";;" K %ZR(RN) W !,"Routine "_RN_" removed from analysis, since it doesn't have the standard second line",! ; JLI 160316 inserted to replace above
.. M RTNS=%ZR
.. K %ZR
. Q
;
I ($$GETSYS^%ut()=0) D ; CACHE SPECIFIC
. N NMSP S NMSP=$G(NMSPS)
. D:NMSP]"" S NMSP="" F S NMSP=$O(NMSPS(NMSP)) Q:NMSP="" D
. . S NMSP1=NMSP I NMSP["*" S NMSP1=$P(NMSP,"*")
. . I $D(^$R(NMSP1)) S RTNS(NMSP1)=""
. . I NMSP["*" S RTN=NMSP1 F S RTN=$O(^$R(RTN)) Q:RTN'[NMSP1 S RTNS(RTN)=""
. . Q
. Q
. . I NMSP["*" S RTN=NMSP1 F S RTN=$O(^$R(RTN)) Q:RTN'[NMSP1 W RTN," " S RTNS(RTN)=""
;
QUIT
8 changes: 3 additions & 5 deletions Routines/_utt4.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%utt4 ; VEN/SMH/JLI - Coverage Test Runner;2019-08-29 4:27 PM
%utt4 ; VEN/SMH/JLI - Coverage Test Runner;2019-08-30 11:02 AM
;;1.6;M-UNIT;;Aug 28, 2019;Build 6
; Submitted to OSEHRA Jul 8, 2017 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html)
; Original routine authored by Sam H. Habiel 07/2013-04/2014
Expand All @@ -12,15 +12,13 @@
QUIT
;
MAIN ; @TEST - Test coverage calculations
Q:$D(^TMP("%uttcovr",$J)) ; already running coverage analysis from %uttcovr
Q:$D(^TMP("%utRESULT",$J)) ; another coverage already running
S ^TMP("%utt4val",$J)=1
K ^TMP("%utRESULT",$J)
D COV^%ut("%utt3","D EN^%ut(""%utt3"",1)",-1) ; Only produce output global.
I $D(^TMP("%utcovrunning",$J)) QUIT
D CHKEQ^%ut("14/19",^TMP("%utRESULT",$J))
D CHKEQ^%ut("2/5",^TMP("%utRESULT",$J,"%utt3","INTERNAL"))
D CHKTF^%ut($D(^TMP("%utRESULT",$J,"%utt3","T2",4)))
D CHKEQ^%ut("1/1",^TMP("%utRESULT",$J,"%utt3","SETUP"))
K ^TMP("%utt4val",$J)
QUIT
;
; The following code was copied from the routine XLFDT so that unit tests for LEAKSOK
Expand Down
23 changes: 11 additions & 12 deletions Routines/_uttcovr.m
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
%uttcovr ;JIVEYSOFT/JLI - runs coverage tests on %ut and %ut1 routines via unit tests ;2019-08-29 4:28 PM
%uttcovr ;JIVEYSOFT/JLI - runs coverage tests on %ut and %ut1 routines via unit tests ;Aug 30, 2019@17:01
;;1.6;M-UNIT;;Aug 28, 2019;Build 6
; Submitted to OSEHRA Jul 8, 2017 by Joel L. Ivey under the Apache 2 license (http://www.apache.org/licenses/LICENSE-2.0.html)
; Original routine authored by Joel L. Ivey 05/2014-12/2015
Expand Down Expand Up @@ -62,8 +62,7 @@ S ROUS("%utt4")=""
S GLB=$NA(^TMP("%uttcovr-rtnanal",$J)) K @GLB
D RTNANAL^%ut1(.ROUS,GLB)
D CHKTF($D(@GLB@("%utt4","MAIN"))>1,"Not enough 'MAIN' nodes found")
D CHKTF($G(@GLB@("%utt4","MAIN",4))["D COV^%ut(""%utt3"",""D EN^%ut(""""%utt3"""",1)"",-1)","Incorrect data for line 2 in MAIN")
D CHKTF($G(@GLB@("%utt4","MAIN",10))=" QUIT","Final QUIT not on expected line")
D CHKTF($G(@GLB@("%utt4","MAIN",8))=" QUIT","Final QUIT expected on line 8")
K @GLB
Q
;
Expand Down Expand Up @@ -242,15 +241,15 @@ D CHKTF('$D(@GLT@(32)),"Verbosity 3 - did not expect a line 32")
Q
;
;
CACHECOV ;@TEST - set up routine for analysis in globals
I +$SY=47 QUIT
N GLOB,GLOBT
S GLOB=$NA(^TMP("%uttcovr1",$J)),GLOBT=$NA(@GLOB@("uttcovr2",$J)) K @GLOB,@GLOBT
K ^TMP("%utt4val",$J)
D CACHECOV^%ut1(GLOB,GLOBT)
D CHKEQ($T(+1^%ut),@GLOB@("%ut",1,0),"BAD FIRST LINE LOADED FOR %ut")
D CHKEQ($T(+14^%ut),@GLOBT@("%ut",14,0),"Bad 14th line loaded for %ut")
K @GLOB,@GLOBT
CACHECOV ;#TEST - set up routine for analysis in globals
; CACHECOV was re-written and won't produce any output w/o profiling first being turned on.
; I +$SY=47 QUIT
; N GLOB,GLOBT
; S GLOB=$NA(^TMP("%uttcovr1",$J)) K @GLOB
; D CACHECOV^%ut1(GLOB)
; D CHKEQ($T(+1^%ut),@GLOB@("%ut",1,0),"BAD FIRST LINE LOADED FOR %ut")
; D CHKEQ($T(+14^%ut),@GLOBT@("%ut",14,0),"Bad 14th line loaded for %ut")
; K @GLOB,@GLOBT
Q
;
GETVALS ; no test - primarily calls to Cache classes
Expand Down

0 comments on commit 13adf84

Please sign in to comment.