# HG changeset patch # User Jan Vrany # Date 1501237101 -3600 # Node ID ebdc4db610c1f0f16fd249b2b352072bde08ef3f # Parent 281f5999cc6c36f21ee30b17f1e7068af7c378ef VMSpawningTestCase: Kill the spawned VM on timeout and report its output ...when run under test report harness. Useful for debugging runaway tests on CI server. diff -r 281f5999cc6c -r ebdc4db610c1 RegressionTests__VMSpawningTestCase.st --- a/RegressionTests__VMSpawningTestCase.st Wed Jul 26 11:50:35 2017 +0100 +++ b/RegressionTests__VMSpawningTestCase.st Fri Jul 28 11:18:21 2017 +0100 @@ -208,54 +208,59 @@ self error:'Failed to spawn test'. ^ self. ]. - blocker wait. - status code == EXIT_CODE_SUCCESS ifFalse:[ - status code == EXIT_CODE_SKIPPED ifTrue:[ - self skipIf:true description:'Skipped'. - ] ifFalse:[ - status code == EXIT_CODE_FAILURE ifTrue:[ - (outputFile notNil and:[ outputFile exists ]) ifTrue:[ - Stdout - nextPutAll:'== TEST FAILED: '; - nextPutAll:testSelector; - nextPutLine:' =='. - outputFile - readingFileDo:[:s | - [ s atEnd ] whileFalse:[ - Stdout nextPutLine:s nextLine. - ]. - ]. - ]. - self assert:false description:'Assertion failed, see log'. + [ + blocker wait. + status code == EXIT_CODE_SUCCESS ifFalse:[ + status code == EXIT_CODE_SKIPPED ifTrue:[ + self skipIf:true description:'Skipped'. ] ifFalse:[ - (outputFile notNil and:[ outputFile exists ]) ifTrue:[ - Stdout - nextPutAll:'== TEST ERROR: '; - nextPutAll:testSelector; - nextPutLine:' =='. - outputFile - readingFileDo:[:s | - [ s atEnd ] whileFalse:[ - | l | - - l := s nextLine. - Stdout nextPutLine:l. - Transcript ~~ Stdout ifTrue:[ - Transcript nextPutLine:l. - ]. - ]. - ]. + status code == EXIT_CODE_FAILURE ifTrue:[ + " + directory inspect + " + self writeFile: outputFile to: Stdout labeled: 'TEST FAILED'. + self assert:false description:'Assertion failed, see log'. + ] ifFalse:[ + " + directory inspect + " + self writeFile: outputFile to: Stdout labeled: 'TEST ERROR'. + self error:'Error occured'. ]. - " - directory inspect - " - self error:'Error occured'. ]. ]. + ] on: TerminateProcessRequest do:[:ex| + pid notNil ifTrue:[ OperatingSystem killProcess: pid ]. + self writeFile: outputFile to: Stdout labeled: 'TEST TERMINATED'. + ex pass. ]. "Created: / 06-01-2017 / 11:25:04 / Jan Vrany " - "Modified: / 26-03-2017 / 07:11:05 / Jan Vrany " + "Modified: / 28-07-2017 / 10:55:53 / Jan Vrany " +! + +writeFile: aFilename to: aStream labeled: aString + " + Write contents of given `aFilename` to given `aStream` with given label (`aString`). + Utility method for spawnSmalltalk:inDirectory: to ease the debugging. + " + aStream + nextPutAll: '== '; + nextPutAll: aString; + nextPutAll: ' (testcase '; + nextPutAll: self printString; + nextPutLine:') =='. + aFilename isNil ifTrue:[ + aStream nextPutLine: 'No file given!!' + ] ifFalse:[ aFilename exists ifFalse:[ + aStream nextPutAll: 'File does not exist: '; nextPutLine: aFilename pathName + ] ifTrue:[ + aFilename readingFileDo:[:s | + [ s atEnd ] whileFalse:[ aStream nextPutLine:s nextLine.]. + ]. + ]]. + + "Created: / 28-07-2017 / 10:48:53 / Jan Vrany " ! ! !VMSpawningTestCase class methodsFor:'documentation'!