Fixed exit code checking logic in VMCrashTestTest
When spawned VM exit code is
* 0 (success), test passed
* 1 (failure), mark test as failure
* anything else, mark it as error.
--- a/RegressionTests__VMCrashTestCase.st Thu Jun 30 20:52:32 2016 +0100
+++ b/RegressionTests__VMCrashTestCase.st Thu Jul 07 11:00:03 2016 +0100
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"{ Package: 'stx:goodies/regression' }"
"{ NameSpace: RegressionTests }"
@@ -92,108 +90,108 @@
spawn := (self class lookupMethodFor: testSelector) annotationAt: #spawn:.
spawn isNil ifTrue:[
- self error: 'No <spawn:> annotation'.
+ self error: 'No <spawn:> annotation'.
].
(spawn argumentAt: 1) == false ifTrue:[
- ^ super runCase.
+ ^ super runCase.
] ifFalse:[
- (spawn argumentAt: 1) ~~ true ifTrue:[
- self error: 'Argument to <spawn:> must be either `true` or `false`'.
- ]
+ (spawn argumentAt: 1) ~~ true ifTrue:[
+ self error: 'Argument to <spawn:> must be either `true` or `false`'.
+ ]
].
[
- tempDir := Filename newTemporary.
- tempDir makeDirectory.
- testcaseFile := tempDir / ((Smalltalk fileNameForClass: self class) , '.st').
- self class fileOutAs: testcaseFile.
+ tempDir := Filename newTemporary.
+ tempDir makeDirectory.
+ testcaseFile := tempDir / ((Smalltalk fileNameForClass: self class) , '.st').
+ self class fileOutAs: testcaseFile.
- script := 'Smalltalk packagePath: %1.
- Smalltalk loadPackage:%2.
- Smalltalk fileIn: %3.
- (%4 selector: %5) runCaseInternal.'
- bindWith: Smalltalk packagePath asArray storeString
- with: self class package storeString
- with: testcaseFile pathName storeString
- with: self class name
- with: testSelector storeString.
+ script := 'Smalltalk packagePath: %1.
+ Smalltalk loadPackage:%2.
+ Smalltalk fileIn: %3.
+ (%4 selector: %5) runCaseInternal.'
+ bindWith: Smalltalk packagePath asArray storeString
+ with: self class package storeString
+ with: testcaseFile pathName storeString
+ with: self class name
+ with: testSelector storeString.
- exe := OperatingSystem pathOfSTXExecutable.
- args := { exe . '--abortOnSEGV' . '--execute' . ( tempDir / 'run.st' ) pathName }.
+ exe := OperatingSystem pathOfSTXExecutable.
+ args := { exe . '--abortOnSEGV' . '--execute' . ( tempDir / 'run.st' ) pathName }.
- OperatingSystem isMSWINDOWSlike ifTrue:[
- args := String streamContents:[:s|
- args
- do:[:each | s nextPut:$"; nextPutAll: each; nextPut: $"]
- separatedBy: [ s space ]
- ]
- ].
+ OperatingSystem isMSWINDOWSlike ifTrue:[
+ args := String streamContents:[:s|
+ args
+ do:[:each | s nextPut:$"; nextPutAll: each; nextPut: $"]
+ separatedBy: [ s space ]
+ ]
+ ].
- outputFile := tempDir / 'output.txt'.
- output := outputFile writeStream.
+ outputFile := tempDir / 'output.txt'.
+ output := outputFile writeStream.
- "/ Now, spit out some helper files that for debugging.
- ( tempDir / 'run.st' ) writingFileDo:[ :f |
- f nextPutAll: script.
- ].
- environment := OperatingSystem isUNIXlike
- ifTrue:[OperatingSystem getEnvironment copy]
- ifFalse:[environment := Dictionary new].
- blocker := Semaphore new.
+ "/ Now, spit out some helper files that for debugging.
+ ( tempDir / 'run.st' ) writingFileDo:[ :f |
+ f nextPutAll: script.
+ ].
+ environment := OperatingSystem isUNIXlike
+ ifTrue:[OperatingSystem getEnvironment copy]
+ ifFalse:[environment := Dictionary new].
+ blocker := Semaphore new.
- Processor monitor:[
- pid := OperatingSystem exec: exe withArguments:args
- environment:environment
- fileDescriptors:{0 . output fileDescriptor . output fileDescriptor }
- fork:true
- newPgrp:false
- inDirectory: Filename currentDirectory pathName
- ] action: [ :s |
- status := s.
- blocker signal.
- ].
+ Processor monitor:[
+ pid := OperatingSystem exec: exe withArguments:args
+ environment:environment
+ fileDescriptors:{0 . output fileDescriptor . output fileDescriptor }
+ fork:true
+ newPgrp:false
+ inDirectory: Filename currentDirectory pathName
+ ] action: [ :s |
+ status := s.
+ blocker signal.
+ ].
- output close.
+ output close.
- pid isNil ifTrue:[
- self error: 'Failed to spawn test'.
- ^ self.
- ].
-
- blocker wait.
+ pid isNil ifTrue:[
+ self error: 'Failed to spawn test'.
+ ^ self.
+ ].
- 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'.
- ].
- (status code == EXIT_CODE_ERROR or:[status status == #signal]) ifTrue:[
- (outputFile notNil and:[ outputFile exists ]) ifTrue:[
- Stdout nextPutAll: '== TEST ERROR: '; nextPutAll: testSelector; nextPutLine:' =='.
- outputFile readingFileDo:[:s|
- [ s atEnd ] whileFalse:[
- Stdout nextPutLine: s nextLine.
- ].
- ].
- ].
- self error: 'Error occured'.
- ].
+ blocker wait.
+ status code == EXIT_CODE_SUCCESS 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'.
+ ] ifFalse:[
+ (outputFile notNil and:[ outputFile exists ]) ifTrue:[
+ Stdout nextPutAll: '== TEST ERROR: '; nextPutAll: testSelector; nextPutLine:' =='.
+ outputFile readingFileDo:[:s|
+ [ s atEnd ] whileFalse:[
+ Stdout nextPutLine: s nextLine.
+ ].
+ ].
+ ].
+ self error: 'Error occured'.
+ ].
+ ].
] ensure:[
- (tempDir notNil and:[tempDir exists]) ifTrue:[
- [
- tempDir recursiveRemove.
- ] on: Error do:[:ex |
- OperatingSystem isMSWINDOWSlike ifFalse:[
- ex reject.
- ].
- ]
- ].
+ (tempDir notNil and:[tempDir exists]) ifTrue:[
+ [
+ tempDir recursiveRemove.
+ ] on: Error do:[:ex |
+ OperatingSystem isMSWINDOWSlike ifFalse:[
+ ex reject.
+ ].
+ ]
+ ].
].
"
@@ -202,6 +200,7 @@
"Created: / 04-09-2014 / 18:13:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
"Modified: / 19-09-2014 / 16:43:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+ "Modified: / 07-07-2016 / 10:53:30 / jv"
!
runCaseInternal
@@ -306,6 +305,11 @@
version_CVS
^ '$Header$'
+!
+
+version_HG
+
+ ^ '$Changeset: <not expanded> $'
! !