Skip to content

Commit

Permalink
Refactoring fuel out stack debug action and users to call the new ser…
Browse files Browse the repository at this point in the history
…ializer object
  • Loading branch information
StevenCostiou committed Dec 18, 2020
1 parent 7aa26ee commit 8e671ba
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 47 deletions.
37 changes: 3 additions & 34 deletions src/Fuel-Tools-Pharo/FuelOutStackDebugAction.class.st
Expand Up @@ -42,19 +42,9 @@ FuelOutStackDebugAction class >> encodeDebugInformationOn: aSerializer [
]

{ #category : #serialization }
FuelOutStackDebugAction class >> serializeTestFailureContext: aContext toFileNamed: aFilename [
FuelOutStackDebugAction class >> serializeTestFailureContext: aContext [

| serializer |
serializer := FLSerializer newDefault.
self encodeDebugInformationOn: serializer.
serializer addPostMaterializationAction: [ :materialization |
(OupsDebugRequest newForContext: materialization root)
process: Processor activeProcess;
label: 'External stack';
submit ].

serializer serialize: aContext toFileNamed: aFilename
" use the sender context, generally the current context is not interesting"
FLDebuggerStackSerializer new serializeStackFromContext: aContext
]

{ #category : #accessing }
Expand All @@ -72,7 +62,7 @@ FuelOutStackDebugAction >> defaultOrder [
{ #category : #actions }
FuelOutStackDebugAction >> executeAction [

self serializeStack
self class serializeTestFailureContext: self interruptedContext copyStack
]

{ #category : #accessing }
Expand All @@ -85,24 +75,3 @@ FuelOutStackDebugAction >> id [

^ #fuelOutStack
]

{ #category : #actions }
FuelOutStackDebugAction >> serializeStack [
| date fileName |
"Serialize a portion of the current stack trace using fuel.."
date := DateAndTime now.

fileName := String streamContents: [ :s|
s
<< 'Debugger-Stack-';
<< self interruptedContext receiver class instanceSide name;
<< '-'.
date printYMDOn: s.
s
<< '-'; print: date hour24; print: date minute; print: date second;
<< '.fuel'].

self class
serializeTestFailureContext: self interruptedContext copyStack
toFileNamed: fileName
]
30 changes: 17 additions & 13 deletions src/JenkinsTools-Core/HDTestReport.class.st
Expand Up @@ -278,21 +278,25 @@ HDTestReport >> runSuite: aTestSuite [

{ #category : #running }
HDTestReport >> serializeError: error of: aTestCase [
"We got an error from a test, let's serialize it so we can properly debug it later on..."
self shouldSerializeError ifFalse: [ ^self ].
self class environment at: #FuelOutStackDebugAction ifPresent: [ :fuelOutStackDebugAction |
| context testCaseMethodContext fileName |
context := error signalerContext.
testCaseMethodContext := context findContextSuchThat: [ :ctx|
ctx receiver == aTestCase and: [ ctx methodSelector == #performTest ]].
context := context copyTo: testCaseMethodContext.

[fileName := self fuelFileNameForNextErrorDuring: aTestCase.
fuelOutStackDebugAction serializeTestFailureContext: context sender toFileNamed: fileName ]
on: Error do: [:err| "simply continue..." ]
].

"We got an error from a test, let's serialize it so we can properly debug it later on..."

self shouldSerializeError ifFalse: [ ^ self ].
self class environment
at: #FuelOutStackDebugAction
ifPresent: [ :fuelOutStackDebugAction |
| context testCaseMethodContext fileName |
context := error signalerContext.
testCaseMethodContext := context findContextSuchThat: [ :ctx |
ctx receiver == aTestCase and: [
ctx methodSelector == #performTest ] ].
context := context copyTo: testCaseMethodContext.

[
fileName := self fuelFileNameForNextErrorDuring: aTestCase.
fuelOutStackDebugAction serializeTestFailureContext: context sender ]
on: Error
do: [ :err | "simply continue..." ] ]
]

{ #category : #running }
Expand Down

0 comments on commit 8e671ba

Please sign in to comment.