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.
--- 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 <jan.vrany@fit.cvut.cz>"
- "Modified: / 26-03-2017 / 07:11:05 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 28-07-2017 / 10:55:53 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+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 <jan.vrany@fit.cvut.cz>"
! !
!VMSpawningTestCase class methodsFor:'documentation'!