Update for Coverage analysis in Cache
%ut1 and %uttcovr were updated so that coverage analysis could also be performed in Cache systems as well as in GT.M
This commit is contained in:
parent
22c042f8a1
commit
62d62c14cc
141
Routines/%ut1.m
141
Routines/%ut1.m
|
@ -1,4 +1,4 @@
|
|||
%ut1 ;VEN/SMH/JLI - CONTINUATION OF M-UNIT PROCESSING ;09/14/15 09:37
|
||||
%ut1 ;VEN/SMH/JLI - CONTINUATION OF M-UNIT PROCESSING ;11/21/15 11:50
|
||||
;;0.2;MASH UTILITIES;;Sep 14, 2015;Build 7
|
||||
; Submitted to OSEHRA Sep 14, 2015 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
|
||||
|
@ -236,45 +236,74 @@ COV(NMSP,COVCODE,VERBOSITY) ; VEN/SMH - PUBLIC ENTRY POINT; Coverage calculation
|
|||
; - 3 = Break down by routine and tag, and print lines that didn't execute for each tag.
|
||||
;
|
||||
; ZEXCEPT: %utcovxx - SET and KILLED in this code at top level
|
||||
Q:'(+$SY=47) ; GT.M only!
|
||||
; ZEXCEPT: %Monitor,%apiOBJ,DecomposeStatus,LineByLine,Start,Stop,System,class - not variables parts of classes
|
||||
N COVER,COVERSAV,I,NMSP1,RTN,RTNS,ERR,STATUS
|
||||
I (+$SY=47) D ; GT.M only!
|
||||
. N %ZR ; GT.M specific
|
||||
. D SILENT^%RSEL(NMSP,"SRC") ; GT.M specific. On Cache use $O(^$R(RTN)).
|
||||
. N RN S RN=""
|
||||
. W !,"Loading routines to test coverage...",!
|
||||
. F S RN=$O(%ZR(RN)) Q:RN="" W RN," " D
|
||||
. . N L2 S L2=$T(+2^@RN)
|
||||
. . S L2=$TR(L2,$C(9,32)) ; Translate spaces and tabs out
|
||||
. . I $E(L2,1,2)'=";;" K %ZR(RN) ; Not a human produced routine
|
||||
. ;
|
||||
. M RTNS=%ZR
|
||||
. K %ZR
|
||||
. Q
|
||||
;
|
||||
I (+$SY=0) D ; CACHE SPECIFIC
|
||||
. 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
|
||||
;
|
||||
; ZEXCEPT: CTRAP - not really a variable
|
||||
S VERBOSITY=+$G(VERBOSITY) ; Get 0 if not passed.
|
||||
N %ZR ; GT.M specific
|
||||
D SILENT^%RSEL(NMSP,"SRC") ; GT.M specific. On Cache use $O(^$R(RTN)).
|
||||
;
|
||||
N RN S RN=""
|
||||
W !,"Loading routines to test coverage...",!
|
||||
F S RN=$O(%ZR(RN)) Q:RN="" W RN," " D
|
||||
. N L2 S L2=$T(+2^@RN)
|
||||
. S L2=$TR(L2,$C(9,32)) ; Translate spaces and tabs out
|
||||
. I $E(L2,1,2)'=";;" K %ZR(RN) ; Not a human produced routine
|
||||
;
|
||||
N RTNS M RTNS=%ZR
|
||||
K %ZR
|
||||
;
|
||||
N GL
|
||||
S GL=$NA(^TMP("%utCOVCOHORT",$J))
|
||||
I '$D(^TMP("%utcovrunning",$J)) K @GL
|
||||
D RTNANAL(.RTNS,GL)
|
||||
I '$D(^TMP("%utcovrunning",$J)) D
|
||||
D RTNANAL(.RTNS,GL) ; save off any current coverage data
|
||||
I '$D(^TMP("%utcovrunning",$J)) N EXIT S EXIT=0 D Q:EXIT
|
||||
. K ^TMP("%utCOVCOHORTSAV",$J)
|
||||
. M ^TMP("%utCOVCOHORTSAV",$J)=^TMP("%utCOVCOHORT",$J)
|
||||
. K ^TMP("%utCOVRESULT",$J)
|
||||
. S ^TMP("%utcovrunning",$J)=1,%utcovxx=1
|
||||
. VIEW "TRACE":1:$NA(^TMP("%utCOVRESULT",$J)) ; GT.M START PROFILING
|
||||
. ;
|
||||
. I (+$SY=47) VIEW "TRACE":1:$NA(^TMP("%utCOVRESULT",$J)) ; GT.M START PROFILING
|
||||
. ;
|
||||
. I (+$SY=0) D ; CACHE CODE TO START PROFILING
|
||||
. . 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.
|
||||
. NEW $ETRAP,$ESTACK
|
||||
. SET $ETRAP="Q:($ES&$Q) -9 Q:$ES W ""CTRL-C ENTERED"""
|
||||
. USE $PRINCIPAL:(CTRAP=$C(3))
|
||||
. I (+$SY=47) D ; GT.M SPECIFIC
|
||||
. . SET $ETRAP="Q:($ES&$Q) -9 Q:$ES W ""CTRL-C ENTERED"""
|
||||
. . USE $PRINCIPAL:(CTRAP=$C(3))
|
||||
. . Q
|
||||
. NEW (DUZ,IO,COVCODE,U,DILOCKTM,DISYS,DT,DTIME,IOBS,IOF,IOM,ION,IOS,IOSL,IOST,IOT,IOXY)
|
||||
. XECUTE COVCODE
|
||||
. Q
|
||||
; GT.M STOP PROFILING if this is the original level that started it
|
||||
I $D(^TMP("%utcovrunning",$J)),$D(%utcovxx) VIEW "TRACE":0:$NA(^TMP("%utCOVRESULT",$J)) K %utcovxx,^TMP("%utcovrunning",$J)
|
||||
I $D(^TMP("%utcovrunning",$J)),$D(%utcovxx) D
|
||||
. I (+$SY=47) VIEW "TRACE":0:$NA(^TMP("%utCOVRESULT",$J)) ; GT.M SPECIFIC
|
||||
. I (+$SY=0) ; CACHE SPECIFIC
|
||||
. K %utcovxx,^TMP("%utcovrunning",$J)
|
||||
. Q
|
||||
;
|
||||
I '$D(^TMP("%utcovrunning",$J)) D
|
||||
. I (+$SY=0) D ; CACHE SPECIFIC CODE
|
||||
. . S COVERSAV=$NA(^TMP("%utCOVCOHORTSAV",$J)) K @COVERSAV
|
||||
. . S COVER=$NA(^TMP("%utCOVCOHORT",$J)) K @COVER
|
||||
. . D CACHECOV(COVERSAV,COVER)
|
||||
. . D TOTAGS(COVERSAV),TOTAGS(COVER)
|
||||
. . D ##class(%Monitor.System.LineByLine).Stop()
|
||||
. . Q
|
||||
. D COVCOV($NA(^TMP("%utCOVCOHORT",$J)),$NA(^TMP("%utCOVRESULT",$J))) ; Venn diagram matching between globals
|
||||
. ; Report
|
||||
. I VERBOSITY=-1 D
|
||||
|
@ -285,6 +314,68 @@ COV(NMSP,COVCODE,VERBOSITY) ; VEN/SMH - PUBLIC ENTRY POINT; Coverage calculation
|
|||
. Q
|
||||
QUIT
|
||||
;
|
||||
CACHECOV(GLOBSAV,GLOB) ;
|
||||
; ZEXCEPT: %Monitor,GetMetrics,GetRoutineCount,GetRoutineName,LineByLine,System,class - not variable names, part of classes
|
||||
N DIF,I,METRIC,METRICNT,METRICS,MTRICNUM,ROUNAME,ROUNUM,X,XCNP,XXX
|
||||
I $$ISUTEST S ROUNUM=1,METRICS="RtnLine",METRICNT=1,ROUNAME="%ut"
|
||||
I '$$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 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 '$$ISUTEST() 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")
|
||||
. M @GLOB@(ROUNAME)=@GLOBSAV@(ROUNAME)
|
||||
. Q
|
||||
;
|
||||
I '$$ISUTEST() F XXX=1:1:ROUNUM D GETVALS(XXX,GLOB,MTRICNUM)
|
||||
Q
|
||||
;
|
||||
GETVALS(ROUNUM,GLOB,MTRICNUM) ; get data on number of times a line seen (set into VAL)
|
||||
; ZEXCEPT: %Monitor,%New,%ResultSet,Execute,GetData,GetRoutineName,LineByLine,Next,System,class - not variables parts of Cache classes
|
||||
N LINE,MORE,ROUNAME,RSET,VAL,X
|
||||
;
|
||||
S RSET=##class(%ResultSet).%New("%Monitor.System.LineByLine:Result")
|
||||
S ROUNAME=##class(%Monitor.System.LineByLine).GetRoutineName(ROUNUM)
|
||||
S LINE=RSET.Execute(ROUNAME)
|
||||
F LINE=1:1 S MORE=RSET.Next() Q:'MORE D
|
||||
. S X=RSET.GetData(1)
|
||||
. S VAL=$LI(X,MTRICNUM)
|
||||
. S @GLOB@(ROUNAME,LINE,"C")=+VAL ; values are 0 if not seen, otherwises positive number
|
||||
. Q
|
||||
D RSET.Close()
|
||||
Q
|
||||
;
|
||||
TOTAGS(GLOBAL) ; convert to lines from tags and set value only if not seen
|
||||
N ACTIVCOD,LINE,LINENUM,ROU,ROUCODE
|
||||
S ROU="" F S ROU=$O(@GLOBAL@(ROU)) Q:ROU="" D
|
||||
. M ROUCODE(ROU)=@GLOBAL@(ROU) K @GLOBAL@(ROU)
|
||||
. N TAG,OFFSET,OLDTAG S TAG="",OFFSET=0,OLDTAG=""
|
||||
. F LINENUM=1:1 Q:'$D(ROUCODE(ROU,LINENUM,0)) D
|
||||
. . S LINE=ROUCODE(ROU,LINENUM,0)
|
||||
. . S ACTIVCOD=$$LINEDATA(LINE,.TAG,.OFFSET)
|
||||
. . I TAG'=OLDTAG S @GLOBAL@(ROU,TAG)=TAG
|
||||
. . I ACTIVCOD,(+$G(ROUCODE(ROU,LINENUM,"C"))'>0) S @GLOBAL@(ROU,TAG,OFFSET)=LINE
|
||||
. . Q
|
||||
. Q
|
||||
Q
|
||||
;
|
||||
LINEDATA(LINE,TAG,OFFSET) ;
|
||||
; LINE - input - the line of code
|
||||
; TAG - passed by reference -
|
||||
; OFFSET - passed by reference
|
||||
N CODE,NEWTAG
|
||||
S NEWTAG=""
|
||||
S OFFSET=$G(OFFSET)+1
|
||||
F Q:$E(LINE,1)=" " Q:$E(LINE,1)=$C(9) Q:LINE="" S NEWTAG=NEWTAG_$E(LINE,1),LINE=$E(LINE,2,$L(LINE))
|
||||
S NEWTAG=$P(NEWTAG,"(")
|
||||
I NEWTAG'="" S TAG=NEWTAG,OFFSET=0
|
||||
S CODE=1
|
||||
F S:(LINE="")!($E(LINE)=";") CODE=0 Q:'CODE Q:(" ."'[$E(LINE)) S LINE=$E(LINE,2,$L(LINE))
|
||||
Q CODE
|
||||
;
|
||||
RTNANAL(RTNS,GL) ; [Private] - Routine Analysis
|
||||
; Create a global similar to the trace global produced by GT.M in GL
|
||||
; Only non-comment lines are stored.
|
||||
|
@ -369,7 +460,7 @@ COVRPTLS(C,S,R,V,X) ;
|
|||
;W "LEFT: "_LEFTLINES,!
|
||||
S LINNUM=LINNUM+1,@X@(LINNUM)="LEFT: "_LEFTLINES
|
||||
;W "COVERAGE PERCENTAGE: "_$S(ORIGLINES:$J(ORIGLINES-LEFTLINES/ORIGLINES*100,"",2),1:100.00),!
|
||||
S LINNUM=LINNUM+1,@X@(LINNUM)="COVERAGE PERCENTAGE: "_$S(ORIGLINES:$J(ORIGLINES-LEFTLINES/ORIGLINES*100,"",2),1:100.00)
|
||||
S LINNUM=LINNUM+1,@X@(LINNUM)="COVERAGE PERCENTAGE: "_$S(ORIGLINES:$J((ORIGLINES-LEFTLINES)/ORIGLINES*100,"",2),1:100.00)
|
||||
;W !!
|
||||
S LINNUM=LINNUM+1,@X@(LINNUM)="",LINNUM=LINNUM+1,@X@(LINNUM)=""
|
||||
;W "BY ROUTINE:",!
|
||||
|
@ -380,8 +471,8 @@ COVRPTLS(C,S,R,V,X) ;
|
|||
. N O S O=$$ACTLINES($NA(@C@(RTN)))
|
||||
. N L S L=$$ACTLINES($NA(@S@(RTN)))
|
||||
. ;W ?3,RTN,?21,$S(O:$J(O-L/O*100,"",2),1:"100.00"),!
|
||||
. N XX S XX=" "_RTN_" ",XX=$E(XX,1,20)
|
||||
. S LINNUM=LINNUM+1,@X@(LINNUM)=XX+$S(O:$J(O-L/O*100,"",2),1:"100.00")
|
||||
. N XX,XY S XX=" "_RTN_" ",XX=$E(XX,1,20)
|
||||
. S LINNUM=LINNUM+1,@X@(LINNUM)=XX_$S(O:$J((O-L)/O*100,"",2),1:"---- ")
|
||||
. I V=1 QUIT ; Just print the routine coverage for V=1
|
||||
. N TAG S TAG=""
|
||||
. F S TAG=$O(@C@(RTN,TAG)) Q:TAG="" D
|
||||
|
@ -389,7 +480,9 @@ COVRPTLS(C,S,R,V,X) ;
|
|||
. . N L S L=$$ACTLINES($NA(@S@(RTN,TAG)))
|
||||
. . ;W ?5,TAG,?21,$S(O:$J(O-L/O*100,"",2),1:"100.00"),!
|
||||
. . S XX=" "_TAG_" ",XX=$E(XX,1,20)
|
||||
. . S LINNUM=LINNUM+1,@X@(LINNUM)=XX_$S(O:$J(O-L/O*100,"",2),1:"100.00")
|
||||
. . S XY=" ("_(O-L)_"/"_O_")",XY=$E(XY,$L(XY)-11,$L(XY)),XX=XX_XY
|
||||
. . S XY=" "_$S(O:$J((O-L)/O*100,"",2)_"%",1:"---- "),XY=$E(XY,$L(XY)-7,$L(XY))
|
||||
. . S LINNUM=LINNUM+1,@X@(LINNUM)=XX_XY
|
||||
. . I V=2 QUIT ; Just print routine/tags coverage for V=2; V=3 print uncovered lines
|
||||
. . N LN S LN=""
|
||||
. . ;F S LN=$O(@S@(RTN,TAG,LN)) Q:LN="" W TAG_"+"_LN_": "_^(LN),!
|
||||
|
@ -419,3 +512,5 @@ COVRPTGL(C,S,R,OUT) ; [Private] - Coverage Global for silent invokers
|
|||
. . F S LN=$O(@S@(RTN,TAG,LN)) Q:LN="" S @OUT@(RTN,TAG,LN)=@S@(RTN,TAG,LN)
|
||||
QUIT
|
||||
;
|
||||
ISUTEST() ;
|
||||
Q $$ISUTEST^%ut()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
%uttcovr ;JIVEYSOFT/JLI - runs coverage tests on %ut and %ut1 routines via unit tests ;09/14/15 09:35
|
||||
%uttcovr ;JIVEYSOFT/JLI - runs coverage tests on %ut and %ut1 routines via unit tests ;11/21/15 19:35
|
||||
;;0.2;MASH UTILITIES;;Sep 14, 2015;Build 7
|
||||
; Submitted to OSEHRA Sep 14, 2015 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
|
||||
|
@ -10,11 +10,6 @@
|
|||
; Have it run the following entry points or, if no ^, call EN^%ut with routine name
|
||||
S RUNCODE(1)="^%utt1,%utt1,^%utt6,VERBOSE^%utt6,%uttcovr,^%ut,^%ut1,^%utcover"
|
||||
S RUNCODE("ENTRY^%uttcovr")=""
|
||||
I '(+$SY=47) D Q ; GT.M only!
|
||||
. W !,"This coverage analysis is currently only available in GT.M"
|
||||
. N VAL R !,"Do you want to run the same tests using MULTAPIS Y/N ? ",VAL:$G(DTIME,300) Q:'$T
|
||||
. I "Yy"[$E(VAL) D MULTAPIS^%ut(.RUNCODE)
|
||||
. Q
|
||||
; Have the analysis EXCLUDE the following routines from coverage - unit test routines
|
||||
S XCLUDE(1)="%utt1,%utt2,%utt3,%utt4,%utt5,%utt6,%uttcovr"
|
||||
S XCLUDE(2)="%utf2hex" ; a GT.M system file, although it wasn't showing up anyway
|
||||
|
@ -64,9 +59,9 @@ RTNANAL ; @TEST - routine analysis
|
|||
S ROUS("%utt4")=""
|
||||
S GLB=$NA(^TMP("%uttcovr-rtnanal",$J)) K @GLB
|
||||
D RTNANAL^%ut1(.ROUS,GLB)
|
||||
D CHKTF^%ut($D(@GLB@("%utt4","MAIN"))>1,"Not enough 'MAIN' nodes found")
|
||||
D CHKTF^%ut($G(@GLB@("%utt4","MAIN",2))["+$SY=47","Check for GT.M not found in expected line")
|
||||
D CHKTF^%ut($G(@GLB@("%utt4","MAIN",8))=" QUIT","Final QUIT not on expected line")
|
||||
D CHKTF($D(@GLB@("%utt4","MAIN"))>1,"Not enough 'MAIN' nodes found")
|
||||
D CHKTF($G(@GLB@("%utt4","MAIN",2))["+$SY=47","Check for GT.M not found in expected line")
|
||||
D CHKTF($G(@GLB@("%utt4","MAIN",8))=" QUIT","Final QUIT not on expected line")
|
||||
K @GLB
|
||||
Q
|
||||
;
|
||||
|
@ -88,12 +83,12 @@ COVCOV ; @TEST - check COVCOV - remove seen lines
|
|||
S @C@("ROU3","TAG1",5)="EAA",@R@("ROU3","TAG1",5)="EAA"
|
||||
S @C@("ROU3","TAG1",6)="FAA",@R@("ROU3","TAG1",6)="FAA"
|
||||
D COVCOV^%ut1(C,R)
|
||||
D CHKTF^%ut($D(@C@("ROU2","TAG1",1)),"Invalid value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF^%ut('$D(@C@("ROU2","TAG1",2)),"Unexpected value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF^%ut($D(@C@("ROU2","TAG2",6)),"Invalid value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF^%ut('$D(@C@("ROU2","TAG2",7)),"Unexpected value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF^%ut($D(@C@("ROU3","TAG1",4)),"Invalid value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF^%ut('$D(@C@("ROU3","TAG1",5)),"Unexpected value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF($D(@C@("ROU2","TAG1",1)),"Invalid value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF('$D(@C@("ROU2","TAG1",2)),"Unexpected value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF($D(@C@("ROU2","TAG2",6)),"Invalid value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF('$D(@C@("ROU2","TAG2",7)),"Unexpected value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF($D(@C@("ROU3","TAG1",4)),"Invalid value for ""ROU2"",""TAG1"",1")
|
||||
D CHKTF('$D(@C@("ROU3","TAG1",5)),"Unexpected value for ""ROU2"",""TAG1"",1")
|
||||
K @C,@R
|
||||
Q
|
||||
;
|
||||
|
@ -105,10 +100,10 @@ COVRPTGL ; @TEST - coverage report returning global
|
|||
S GL4=$NA(^TMP("%utCOVREPORTx",$J)) K @GL4
|
||||
D SETGLOBS(GL1,GL2)
|
||||
D COVRPTGL^%ut1(GL1,GL2,GL3,GL4)
|
||||
D CHKEQ^%ut($G(@GL4@("%ut1","ACTLINES")),"0/9","Wrong number of lines covered f>>or ACTLINES")
|
||||
D CHKEQ^%ut($G(@GL4@("%ut1","ACTLINES",9))," QUIT CNT","Wrong result for last l>>ine not covered for ACTLINES")
|
||||
D CHKEQ^%ut($G(@GL4@("%ut1","CHEKTEST")),"8/10","Wrong number of lines covered >>for CHEKTEST")
|
||||
D CHKEQ^%ut($G(@GL4@("%ut1","CHEKTEST",39))," . Q","Wrong result for last line >>not covered for CHEKTEST")
|
||||
D CHKEQ($G(@GL4@("%ut1","ACTLINES")),"0/9","Wrong number of lines covered f>>or ACTLINES")
|
||||
D CHKEQ($G(@GL4@("%ut1","ACTLINES",9))," QUIT CNT","Wrong result for last l>>ine not covered for ACTLINES")
|
||||
D CHKEQ($G(@GL4@("%ut1","CHEKTEST")),"8/10","Wrong number of lines covered >>for CHEKTEST")
|
||||
D CHKEQ($G(@GL4@("%ut1","CHEKTEST",39))," . Q","Wrong result for last line >>not covered for CHEKTEST")
|
||||
K @GL1,@GL2,@GL3,@GL4
|
||||
Q
|
||||
;
|
||||
|
@ -122,23 +117,23 @@ COVRPT ; @TEST
|
|||
D SETGLOBS(GL1,GL2)
|
||||
S VRBOSITY=1
|
||||
D COVRPT^%ut1(GL1,GL2,GL3,VRBOSITY)
|
||||
D CHKEQ^%ut("COVERAGE PERCENTAGE: 42.11",$G(@GL5@(5)),"Verbosity 1 - not expected percentage value")
|
||||
D CHKEQ^%ut("42.11",$G(@GL5@(9)),"Verbosity 1 - not expected value for line 9")
|
||||
D CHKTF^%ut('$D(@GL5@(10)),"Verbosity 1 - unexpected data in 10th line")
|
||||
D CHKEQ("COVERAGE PERCENTAGE: 42.11",$G(@GL5@(5)),"Verbosity 1 - not expected percentage value")
|
||||
D CHKEQ(" %ut1 42.11",$G(@GL5@(9)),"Verbosity 1 - not expected value for line 9")
|
||||
D CHKTF('$D(@GL5@(10)),"Verbosity 1 - unexpected data in 10th line")
|
||||
;
|
||||
S VRBOSITY=2
|
||||
D COVRPT^%ut1(GL1,GL2,GL3,VRBOSITY)
|
||||
D CHKEQ^%ut(" ACTLINES 0.00",$G(@GL5@(10)),"Verbosity 2 - not expected value for 10th line")
|
||||
D CHKEQ^%ut(" CHEKTEST 80.00",$G(@GL5@(11)),"Verbosity 2 - not expected value for 11th line")
|
||||
D CHKTF^%ut('$D(@GL5@(12)),"Verbosity 2 - unexpected data for 12th line")
|
||||
D CHKEQ(" ACTLINES (0/9) 0.00%",$G(@GL5@(10)),"Verbosity 2 - not expected value for 10th line")
|
||||
D CHKEQ(" CHEKTEST (8/10) 80.00%",$G(@GL5@(11)),"Verbosity 2 - not expected value for 11th line")
|
||||
D CHKTF('$D(@GL5@(12)),"Verbosity 2 - unexpected data for 12th line")
|
||||
;
|
||||
S VRBOSITY=3
|
||||
D COVRPT^%ut1(GL1,GL2,GL3,VRBOSITY)
|
||||
D CHKEQ^%ut(" ACTLINES 0.00",$G(@GL5@(10)),"Verbosity 3 - unexpected value for line 10")
|
||||
D CHKEQ^%ut("ACTLINES+9: QUIT CNT",$G(@GL5@(19)),"Verbosity 3 - unexpected value for line 19")
|
||||
D CHKEQ^%ut(" CHEKTEST 80.00",$G(@GL5@(20)),"Verbosity 3 - unexpected value for line 20")
|
||||
D CHKEQ^%ut("CHEKTEST+39: . Q",$G(@GL5@(22)),"Verbosity 3 - unexpected value for line 22")
|
||||
D CHKTF^%ut('$D(@GL5@(23)),"Verbosity 3 - unexpected line 23")
|
||||
D CHKEQ(" ACTLINES (0/9) 0.00%",$G(@GL5@(10)),"Verbosity 3 - unexpected value for line 10")
|
||||
D CHKEQ("ACTLINES+9: QUIT CNT",$G(@GL5@(19)),"Verbosity 3 - unexpected value for line 19")
|
||||
D CHKEQ(" CHEKTEST (8/10) 80.00%",$G(@GL5@(20)),"Verbosity 3 - unexpected value for line 20")
|
||||
D CHKEQ("CHEKTEST+39: . Q",$G(@GL5@(22)),"Verbosity 3 - unexpected value for line 22")
|
||||
D CHKTF('$D(@GL5@(23)),"Verbosity 3 - unexpected line 23")
|
||||
;
|
||||
K @GL1,@GL2,@GL3,@GL4,@GL5
|
||||
Q
|
||||
|
@ -152,25 +147,25 @@ COVRPTLS ; @TEST - coverage report returning text in global
|
|||
D SETGLOBS(GL1,GL2)
|
||||
S VRBOSITY=1
|
||||
D COVRPTLS^%ut1(GL1,GL2,GL3,VRBOSITY,GL4)
|
||||
D CHKEQ^%ut("COVERAGE PERCENTAGE: 42.11",$G(@GL4@(5)),"Verbosity 1 - not expected percentage value")
|
||||
D CHKEQ^%ut("42.11",$G(@GL4@(9)),"Verbosity 1 - not expected value for line 9")
|
||||
D CHKTF^%ut('$D(@GL4@(10)),"Verbosity 1 - unexpected data in 10th line")
|
||||
D CHKEQ("COVERAGE PERCENTAGE: 42.11",$G(@GL4@(5)),"Verbosity 1 - not expected percentage value")
|
||||
D CHKEQ(" %ut1 42.11",$G(@GL4@(9)),"Verbosity 1 - not expected value for line 9")
|
||||
D CHKTF('$D(@GL4@(10)),"Verbosity 1 - unexpected data in 10th line")
|
||||
K @GL4
|
||||
;
|
||||
S VRBOSITY=2
|
||||
D COVRPTLS^%ut1(GL1,GL2,GL3,VRBOSITY,GL4)
|
||||
D CHKEQ^%ut(" ACTLINES 0.00",$G(@GL4@(10)),"Verbosity 2 - not expected value for 10th line")
|
||||
D CHKEQ^%ut(" CHEKTEST 80.00",$G(@GL4@(11)),"Verbosity 2 - not expected value for 11th line")
|
||||
D CHKTF^%ut('$D(@GL4@(12)),"Verbosity 2 - unexpected data for 12th line")
|
||||
D CHKEQ(" ACTLINES (0/9) 0.00%",$G(@GL4@(10)),"Verbosity 2 - not expected value for 10th line")
|
||||
D CHKEQ(" CHEKTEST (8/10) 80.00%",$G(@GL4@(11)),"Verbosity 2 - not expected value for 11th line")
|
||||
D CHKTF('$D(@GL4@(12)),"Verbosity 2 - unexpected data for 12th line")
|
||||
K @GL4
|
||||
;
|
||||
S VRBOSITY=3
|
||||
D COVRPTLS^%ut1(GL1,GL2,GL3,VRBOSITY,GL4)
|
||||
D CHKEQ^%ut(" ACTLINES 0.00",$G(@GL4@(10)),"Verbosity 3 - unexpected value for line 10")
|
||||
D CHKEQ^%ut("ACTLINES+9: QUIT CNT",$G(@GL4@(19)),"Verbosity 3 - unexpected value for line 19")
|
||||
D CHKEQ^%ut(" CHEKTEST 80.00",$G(@GL4@(20)),"Verbosity 3 - unexpected value for line 20")
|
||||
D CHKEQ^%ut("CHEKTEST+39: . Q",$G(@GL4@(22)),"Verbosity 3 - unexpected value for line 22")
|
||||
D CHKTF^%ut('$D(@GL4@(23)),"Verbosity 3 - unexpected line 23")
|
||||
D CHKEQ(" ACTLINES (0/9) 0.00%",$G(@GL4@(10)),"Verbosity 3 - unexpected value for line 10")
|
||||
D CHKEQ("ACTLINES+9: QUIT CNT",$G(@GL4@(19)),"Verbosity 3 - unexpected value for line 19")
|
||||
D CHKEQ(" CHEKTEST (8/10) 80.00%",$G(@GL4@(20)),"Verbosity 3 - unexpected value for line 20")
|
||||
D CHKEQ("CHEKTEST+39: . Q",$G(@GL4@(22)),"Verbosity 3 - unexpected value for line 22")
|
||||
D CHKTF('$D(@GL4@(23)),"Verbosity 3 - unexpected line 23")
|
||||
;
|
||||
K @GL1,@GL2,@GL3,@GL4
|
||||
Q
|
||||
|
@ -182,8 +177,8 @@ TRIMDATA ; @TEST - TRIMDATA in %utcover
|
|||
S @GL1@("BAD",1)="1"
|
||||
S XCLUD("BAD")=""
|
||||
D TRIMDATA^%utcover(.XCLUD,GL1)
|
||||
D CHKTF^%ut($D(@GL1@("GOOD")),"GOOD ENTRY WAS REMOVED")
|
||||
D CHKTF^%ut('$D(@GL1@("BAD")),"ENTRY WAS NOT TRIMMED")
|
||||
D CHKTF($D(@GL1@("GOOD")),"GOOD ENTRY WAS REMOVED")
|
||||
D CHKTF('$D(@GL1@("BAD")),"ENTRY WAS NOT TRIMMED")
|
||||
K @GL1,XCLUD
|
||||
Q
|
||||
;
|
||||
|
@ -204,24 +199,24 @@ LIST ; @TEST - LIST in %utcover
|
|||
S @GL1@("%ut1","CHEKTEST")="10/10"
|
||||
N XCLUD S XCLUD("%utt1")=""
|
||||
D LIST^%utcover(.XCLUD,1,GLT,GL1)
|
||||
D CHKEQ^%ut("Routine %ut1 89 out of 160 lines covered (55%)",$G(@GLT@(3)),"Verbosity 1 - Unexpected text for line 3")
|
||||
D CHKEQ^%ut("Overall Analysis 89 out of 160 lines covered (55% coverage)",$G(@GLT@(6)),"Verbosity 1 - unexpected text for line 6")
|
||||
D CHKTF^%ut('$D(@GLT@(7)),"Verbosity 1 - Unexpected line 7 present")
|
||||
D CHKEQ("Routine %ut1 89 out of 160 lines covered (55%)",$G(@GLT@(3)),"Verbosity 1 - Unexpected text for line 3")
|
||||
D CHKEQ("Overall Analysis 89 out of 160 lines covered (55% coverage)",$G(@GLT@(6)),"Verbosity 1 - unexpected text for line 6")
|
||||
D CHKTF('$D(@GLT@(7)),"Verbosity 1 - Unexpected line 7 present")
|
||||
K @GLT
|
||||
;
|
||||
D LIST^%utcover(.XCLUD,2,GLT,GL1)
|
||||
D CHKEQ^%ut(" - Summary",$G(@GLT@(4)),"Verbosity 2 - unexpected text at line 4")
|
||||
D CHKEQ^%ut(" Tag ACTLINES^%ut1 0 out of 8 lines covered",$G(@GLT@(6)),"Verbosity 2 - unexpected text at line 6")
|
||||
D CHKEQ^%ut(" Tag CHEKTEST^%ut1 10 out of 10 lines covered",$G(@GLT@(8)),"Verbosity 2 - unexpected text at line 8")
|
||||
D CHKTF^%ut($D(@GLT@(14)),"Verbosity 2 - expected line at line 14")
|
||||
D CHKTF^%ut('$D(@GLT@(15)),"Verbosity 2 - unexpected line at line 15")
|
||||
D CHKEQ(" - Summary",$G(@GLT@(4)),"Verbosity 2 - unexpected text at line 4")
|
||||
D CHKEQ(" Tag ACTLINES^%ut1 0 out of 8 lines covered",$G(@GLT@(6)),"Verbosity 2 - unexpected text at line 6")
|
||||
D CHKEQ(" Tag CHEKTEST^%ut1 10 out of 10 lines covered",$G(@GLT@(8)),"Verbosity 2 - unexpected text at line 8")
|
||||
D CHKTF($D(@GLT@(14)),"Verbosity 2 - expected line at line 14")
|
||||
D CHKTF('$D(@GLT@(15)),"Verbosity 2 - unexpected line at line 15")
|
||||
K @GLT
|
||||
;
|
||||
D LIST^%utcover(.XCLUD,3,GLT,GL1)
|
||||
D CHKEQ^%ut(" Tag %ut1^%ut1 2 out of 2 lines covered",$G(@GLT@(5)),"Verbosity 3 - Incorrect text at line 5")
|
||||
D CHKEQ^%ut(" ACTLINES+9 QUIT CNT",$G(@GLT@(15)),"Verbosity 3 - incorrect line 15")
|
||||
D CHKTF^%ut($D(@GLT@(31)),"Verbosity 3 - expected data in line 31")
|
||||
D CHKTF^%ut('$D(@GLT@(32)),"Verbosity 3 - did not expect a line 32")
|
||||
D CHKEQ(" Tag %ut1^%ut1 2 out of 2 lines covered",$G(@GLT@(5)),"Verbosity 3 - Incorrect text at line 5")
|
||||
D CHKEQ(" ACTLINES+9 QUIT CNT",$G(@GLT@(15)),"Verbosity 3 - incorrect line 15")
|
||||
D CHKTF($D(@GLT@(31)),"Verbosity 3 - expected data in line 31")
|
||||
D CHKTF('$D(@GLT@(32)),"Verbosity 3 - did not expect a line 32")
|
||||
;
|
||||
K @GL1,@GLT
|
||||
Q
|
||||
|
@ -263,3 +258,80 @@ SETGLOBS(GL1,GL2) ;
|
|||
S @GL2@("%ut1","CHEKTEST",39)=" . Q"
|
||||
Q
|
||||
;
|
||||
;
|
||||
CACHECOV ;@TEST - set up routine for analysis in globals
|
||||
N GLOB,GLOBT
|
||||
S GLOB=$NA(^TMP("%uttcovr1",$J)),GLOBT=$NA(@GLOB@("uttcovr2",$J)) K @GLOB,@GLOBT
|
||||
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
|
||||
Q
|
||||
;
|
||||
GETVALS ; no test - primarily calls to Cache classes
|
||||
Q
|
||||
;
|
||||
LINEDATA ; @TEST - convert code line to based on tags and offset, and identify active code lines
|
||||
N CODE,LINE,OFFSET,TAG
|
||||
S LINE="TEST1 ; COMMENT ON TAG",TAG="",OFFSET=0
|
||||
S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ;
|
||||
D CHKEQ(0,CODE,"Tag with comment identified as active code")
|
||||
D CHKEQ("TEST1",TAG,"Bad tag returned for TEST1")
|
||||
D CHKEQ(0,OFFSET,"Bad OFFSET returned for TEST1")
|
||||
;
|
||||
S LINE=" ; COMMENT ONLY"
|
||||
S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ;
|
||||
D CHKEQ(0,CODE,"Comment line identified as active code")
|
||||
D CHKEQ("TEST1",TAG,"Bad tag returned for TEST1+1")
|
||||
D CHKEQ(1,OFFSET,"Bad OFFSET returned for TEST1+1")
|
||||
;
|
||||
S LINE=" S X=VALUE"
|
||||
S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ;
|
||||
D CHKEQ(1,CODE,"Code line NOT identified as active code")
|
||||
D CHKEQ("TEST1",TAG,"Bad tag returned for TEST1+2")
|
||||
D CHKEQ(2,OFFSET,"Bad OFFSET returned for TEST1+2")
|
||||
;
|
||||
S LINE="TEST2 S X=VALUE"
|
||||
S CODE=$$LINEDATA^%ut1(LINE,.TAG,.OFFSET) ;
|
||||
D CHKEQ(1,CODE,"Tag line with code NOT identified as active code")
|
||||
D CHKEQ("TEST2",TAG,"Bad tag returned for TEST2")
|
||||
D CHKEQ(0,OFFSET,"Bad OFFSET returned for TEST2")
|
||||
;
|
||||
Q
|
||||
;
|
||||
TOTAGS ;@TEST - convert from lines of code by line number to lines ordered by tag, line from tag, and only not covered
|
||||
N GLOB,GLOBT,X1,X0
|
||||
S GLOB=$NA(^TMP("%uttcovr",$J)),GLOBT=$NA(@GLOB@("TEST1")) K @GLOB
|
||||
S @GLOBT@(1,0)="LINE1 ; CODE1 LINE1+0 NOT ACTIVE"
|
||||
S @GLOBT@(2,0)=" CODE2 LINE+1 SEEN"
|
||||
S @GLOBT@(2,"C")=2
|
||||
S @GLOBT@(3,0)=" CODE3 LINE1+2 NOT SEEN"
|
||||
S @GLOBT@(4,0)="LINE4 CODE4 LINE4+0 SEEN"
|
||||
S @GLOBT@(4,"C")=5
|
||||
S @GLOBT@(5,0)=" ; CODE5 LINE4+1 NOT ACTIVE"
|
||||
S @GLOBT@(6,0)=" CODE6 LINE4+2 COVERED"
|
||||
S @GLOBT@(6,"C")=2
|
||||
S @GLOBT@(7,0)="LINE7 CODE7 LINE7+0 NOT COVERED"
|
||||
S @GLOBT@(8,0)=" CODE8 LINE7+1 NOT COVERED"
|
||||
D TOTAGS^%ut1(GLOB)
|
||||
D CHKEQ(1,($D(@GLOBT@("LINE1"))#2),"LINE1 TAG NOT IDENTIFIED")
|
||||
D CHKEQ(1,($D(@GLOBT@("LINE4"))#2),"LINE4 TAG NOT IDENTIFIED")
|
||||
D CHKEQ(1,($D(@GLOBT@("LINE7"))#2),"LINE7 TAG NOT IDENTIFIED")
|
||||
D CHKEQ(0,$D(@GLOBT@("LINE1",0)),"LINE1+0 SHOULD NOT BE INCLUDED - IT IS A COMMENT")
|
||||
D CHKEQ(0,$D(@GLOBT@("LINE1",1)),"LINE1+1 SHOULD NOT BE INCLUDED - IT WAS COVERED")
|
||||
D CHKEQ(1,$D(@GLOBT@("LINE1",2)),"LINE1+2 SHOULD BE INCLUDED - IT WAS NOT COVERED")
|
||||
D CHKEQ(0,$D(@GLOBT@("LINE4",0)),"LINE4+0 SHOULD NOT BE INCLUDED - IT WAS COVERED")
|
||||
D CHKEQ(0,$D(@GLOBT@("LINE4",1)),"LINE4+1 SHOULD NOT BE INCLUDED - IT IS A COMMENT")
|
||||
D CHKEQ(0,$D(@GLOBT@("LINE4",2)),"LINE4+2 SHOULD NOT BE INCLUDED - IT WAS COVERED")
|
||||
D CHKEQ(1,$D(@GLOBT@("LINE7",0)),"LINE7+0 SHOULD BE INCLUDED - IT IS NOT COVERED")
|
||||
D CHKEQ(1,$D(@GLOBT@("LINE7",1)),"LINE7+1 SHOULD BE INCLUDED - IT IS NOT COVERED")
|
||||
K @GLOB,@GLOBT
|
||||
Q
|
||||
;
|
||||
CHKEQ(EXPECTED,SEEN,COMMENT) ;
|
||||
D CHKEQ^%ut(EXPECTED,SEEN,$G(COMMENT))
|
||||
Q
|
||||
;
|
||||
CHKTF(VALUE,COMMENT) ;
|
||||
D CHKTF^%ut(VALUE,$G(COMMENT))
|
||||
Q
|
||||
|
|
Loading…
Reference in New Issue