rokucommunity / rooibos

simple, flexible, fun brightscript test framework for roku scenegraph apps
MIT License
75 stars 29 forks source link

Divide by zero crash in code coverage #74

Closed chrisdp closed 3 years ago

chrisdp commented 4 years ago

Below is the log:

...Generating code coverage report

BRIGHTSCRIPT: ERROR: Runtime: FOR EACH value is Invalid: CodeCoverageSupport.brs(16)

BrightScript Micro Debugger.
Enter any BrightScript statement, debug commands, or HELP.

Suspending threads...
Thread selected:  0*   ...ource/CodeCoverageSupport.brs(33)    allLinesPercent = (allLinesHit / allLinesCount) * 100

Current Function:
025:          hitFiles.push({percent:resolvedPercent, text:filename + ": " +str(resolvedPercent).trim() + "% (" + stri(resolvedCount).trim() + "/" + stri(expectedCount).trim() + ")"})
026:        else
027:          resolvedCount = 0
028:          resolvedPercent = 0
029:          missFiles.push(filename + ": MISS!")
030:        end if
031:      end if
032:    end for
033:*   allLinesPercent = (allLinesHit / allLinesCount) * 100
034:    ? ""
035:    ? ""
036:    ? "+++++++++++++++++++++++++++++++++++++++++++"
037:    ? "Code Coverage Report"
Divide by Zero. (runtime error &h14) in CodeCoverageSupport.brs(33)
033:   allLinesPercent = (allLinesHit / allLinesCount) * 100
Backtrace:
#3  Function rbs_reportcodecoverage() As Void
   file/line: CodeCoverageSupport.brs(33)
#2  Function rbs_tr_run() As Void
   file/line: rooibosDist.brs(2053)
#1  Function rooibos__init(pretestsetup As Dynamic) As Dynamic
   file/line: rooibosDist.brs(57)
#0  Function main() As Void
   file/line: main.brs(2)
Local Variables:
global           Interface:ifGlobal
m                roAssociativeArray refcnt=4 count:4
cc               roSGNode:CodeCoverage refcnt=1
hitfiles         roArray refcnt=1 count:0
missfiles        roArray refcnt=1 count:0
alllinescount    Integer val:0 (&h0)
alllineshit      Integer val:0 (&h0)
key              <uninitialized>
filename         <uninitialized>
expectedcount    <uninitialized>
resolvedcount    <uninitialized>
resolvedpercent  <uninitialized>
alllinespercent  <uninitialized>
i                <uninitialized>
Threads:
ID    Location                                Source Code
 0*   ...ource/CodeCoverageSupport.brs(33)    allLinesPercent = (allLinesHit / allLinesCount) * 100
  *selected

Brightscript Debugger> 

I was able to cause this by adding the following print to one of the functions I was testing:

    ' Format the time string to [XX:]XX:XX and strip the white space added by Integers
    time$ = (prefix$ + timeParts.join(":")).replace(" ", "")
    print timer.TotalMilliseconds()
  return time$
end function

Commenting out the print like so stopped the crash:

    ' Format the time string to [XX:]XX:XX and strip the white space added by Integers
    time$ = (prefix$ + timeParts.join(":")).replace(" ", "")
    ' print timer.TotalMilliseconds()
    return time$
end function
georgejecook commented 3 years ago

note relevant in rooibos 4 - need to redo code coverage