@@ -8,11 +8,20 @@ Class TestCoverage.Utils.LineByLineMonitor Extends %Monitor.System.LineByLine
8
8
/// True if the line-by-line monitor has been started.
9
9
Property Started As %Boolean [ Calculated , Private , ReadOnly ];
10
10
11
+ /// True if the Python trace has been set
12
+ Property PyStarted As %Boolean [ Calculated , Private , ReadOnly ];
13
+
11
14
Method StartedGet () As %Boolean [ CodeMode = expression ]
12
15
{
13
16
$zu (84 ,8 )
14
17
}
15
18
19
+ Method PyStartedGet () As %Boolean [ Language = python ]
20
+ {
21
+ import sys
22
+ return sys .gettrace () is not None
23
+ }
24
+
16
25
/// True if the line-by-line monitor is paused
17
26
Property Paused As %Boolean [ Calculated , Private , ReadOnly ];
18
27
@@ -30,6 +39,8 @@ Property LastMetricList As %List [ Private ];
30
39
31
40
Property LastProcessList As %List [ Private ];
32
41
42
+ Property LastPythonList As %List [ Private ];
43
+
33
44
/// This callback method is invoked by the <METHOD>%Close</METHOD> method to
34
45
/// provide notification that the current object is being closed.
35
46
///
@@ -98,33 +109,43 @@ Method StartWithScope(pRoutineList As %List, pPyClasses As %List, pMetricList As
98
109
Set tSC = $$$OK
99
110
Try {
100
111
Set ..PythonClassList = pPyClasses
101
- Set tDifferentScope = (..LastRoutineList '= pRoutineList ) || (..LastMetricList '= pMetricList ) || (..LastProcessList '= pProcessList )
102
- If tDifferentScope && ..Started {
112
+ Set tDifferentScope = (..LastRoutineList '= pRoutineList ) || (..LastMetricList '= pMetricList ) || (..LastProcessList '= pProcessList ) || (.. LastPythonList '= pPyClasses )
113
+ If tDifferentScope && ( ..Started || .. PyStarted ) {
103
114
// If we need to track different routines/metrics/processes, need to stop the monitor before restarting with the new context.
104
- Do ..Stop ()
105
- Do ..PyStop ()
115
+ If (..Started ) {
116
+ Do ..Stop ()
117
+ }
118
+ Do ..PyStop () // setting the trace to None can and should always be done
106
119
Set ..LastRoutineList = pRoutineList
107
120
Set ..LastMetricList = pMetricList
108
121
Set ..LastProcessList = pProcessList
122
+ Set ..LastPythonList = pPyClasses
109
123
}
110
124
111
- If '.. Started {
112
- Do .. PyClearCounters ()
125
+ // take care of starting the ObjectScript Monitor
126
+ If ('.. Started && $ListLength ( pRoutineList ) '= 0 ) {
113
127
Set tSC = ..Start (pRoutineList , pMetricList , pProcessList )
114
- Do ..PyStartWithScope (pPyClasses )
115
128
If $System .Status .Equals (tSC ,$$$ERRORCODE($$$MonitorMemoryAlloc)) {
116
129
// Construct a more helpful error message.
117
130
Set tSC = $$$EMBEDSC(..CheckAvailableMemory ($ListLength (pProcessList ),$ListLength (pRoutineList ),1 ),tSC )
118
131
}
119
132
$$$ThrowOnError(tSC )
120
133
} Else {
121
134
// If the monitor was already running, clear the counters.
122
- Set tSC = ..ClearCounters ()
123
- $$$ThrowOnError(tSC )
124
- If ..Paused {
125
- $$$ThrowOnError(..Resume ())
126
- Do ..PyStartWithScope (pPyClasses )
135
+ if (..Started ) {
136
+ Set tSC = ..ClearCounters ()
137
+ $$$ThrowOnError(tSC )
127
138
}
139
+ If (..Paused && $ListLength (pRoutineList ) '= 0 ){
140
+ $$$ThrowOnError(..Resume ())
141
+ }
142
+ }
143
+
144
+ If ('..PyStarted && $ListLength (pPyClasses ) '= 0 ) {
145
+ // whether we're resuming or restarting, we either way want to clear counters
146
+ // since StoreIntCoverage should have already
147
+ Do ..PyClearCounters ()
148
+ Do ..PyStartWithScope (pPyClasses )
128
149
}
129
150
} Catch e {
130
151
Set tSC = e .AsStatus ()
0 commit comments