95 |
95 |
96 !TestReportFormat methodsFor:'writing - utilities'! |
96 !TestReportFormat methodsFor:'writing - utilities'! |
97 |
97 |
98 writeContext: context on: s |
98 writeContext: context on: s |
99 |
99 |
100 |home mthd src| |
100 |home mthd src vars args argAndVarNames | |
101 [ |
101 [ |
102 context printOn: s. |
102 context printOn: s. |
103 s cr. |
103 s cr. |
104 s nextPutAll:'receiver: '. context receiver printOn: s. s cr. |
104 s nextPutAll:'receiver: '. context receiver printOn: s. s cr. |
105 s nextPutAll:'selector: '. context selector printOn: s. s cr. |
105 s nextPutAll:'selector: '. context selector storeOn: s. s cr. |
|
106 |
|
107 args := context args. |
|
108 vars := context vars. |
|
109 argAndVarNames := context argAndVarNames. |
106 s nextPutAll:'args: '; cr. |
110 s nextPutAll:'args: '; cr. |
107 context args keysAndValuesDo:[:idx :eachArg | |
111 |
108 s nextPutAll:' '. idx printOn: s. s nextPutAll:': '. eachArg printOn: s.s cr. |
112 args keysAndValuesDo:[:idx :eachArg | |
|
113 s nextPutAll:' '. idx printOn: s leftPaddedTo:2 . s space. (argAndVarNames at: idx ifAbsent:['']) printOn: s paddedTo:12. s nextPutAll:': '. eachArg printOn: s.s cr. |
109 ]. |
114 ]. |
110 s nextPutAll:'vars: '; cr. |
115 s nextPutAll:'vars: '; cr. |
111 context vars keysAndValuesDo:[:idx :eachVar | |
116 vars keysAndValuesDo:[:idx :eachVar | |
112 s nextPutAll:' '. idx printOn: s. s nextPutAll:': '. |
117 s nextPutAll:' '. idx printOn: s leftPaddedTo:2. s space. (argAndVarNames at: idx + args size ifAbsent:['']) printOn: s paddedTo:12. s nextPutAll:': '. |
113 eachVar isString ifTrue:[ |
118 eachVar isString ifTrue:[ |
114 eachVar storeOn: s. |
119 eachVar storeOn: s. |
115 ] ifFalse:[ |
120 ] ifFalse:[ |
116 eachVar printOn: s. |
121 eachVar printOn: s. |
117 ]. |
122 ]. |
118 s cr. |
123 s cr. |
119 ]. |
124 ]. |
|
125 home := context methodHome. |
|
126 mthd := home method. |
|
127 |
|
128 s nextPutAll:'bytecode: '; cr. |
|
129 mthd notNil ifTrue:[ |
|
130 (mthd isJavaMethod and:[mthd class ~~ JavaNativeMethod]) ifFalse:[ |
|
131 Decompiler decompile: mthd to: s. |
|
132 ] ifTrue:[ |
|
133 (Smalltalk at: #JavaByteCodeDisassembler) notNil ifTrue:[ |
|
134 (Smalltalk at: #JavaByteCodeDisassembler) diassemble: mthd to: s. |
|
135 ] ifFalse:[ |
|
136 s nextPutAll: ' ** no JavaByteCodeDisassembler **' |
|
137 ]. |
|
138 ]. |
|
139 ]. |
|
140 |
|
141 s cr. |
120 s nextPutAll:'source: '; cr. |
142 s nextPutAll:'source: '; cr. |
121 |
|
122 [ |
143 [ |
123 home := context methodHome. |
|
124 mthd := home method. |
|
125 mthd isNil ifTrue:[ |
144 mthd isNil ifTrue:[ |
126 s nextPutAll: '** no source **'. s cr. s cr. |
145 s nextPutAll: '** no source **'. s cr. s cr. |
127 ^ self. |
146 ^ self. |
128 ]. |
147 ]. |
129 src := mthd source. |
148 src := mthd source. |
151 s cr. |
170 s cr. |
152 ] on: Error do:[:ex| |
171 ] on: Error do:[:ex| |
153 s cr; |
172 s cr; |
154 nextPutAll:'!!!!!!ERROR WHEN GETTING STACK TRACE!!!!!!'; cr; |
173 nextPutAll:'!!!!!!ERROR WHEN GETTING STACK TRACE!!!!!!'; cr; |
155 nextPutAll: ex description; cr |
174 nextPutAll: ex description; cr |
156 ] |
175 ]. |
|
176 |
|
177 " |
|
178 String streamContents:[ :s | Builder::TestReportFormat basicNew writeContext: thisContext on: s ] |
|
179 " |
157 |
180 |
158 "Created: / 03-08-2011 / 14:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
181 "Created: / 03-08-2011 / 14:53:52 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
182 "Modified: / 18-01-2016 / 08:12:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
159 ! |
183 ! |
160 |
184 |
161 writeStackTrace:err of:aTestCase on: str |
185 writeStackTrace:err of:aTestCase on: str |
162 |
186 |
163 | context stop | |
187 | context stop | |