Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
Class {
#name : #OSSAbstractUnixSubprocessTest,
#superclass : #TestCase,
#category : 'OSSubprocess-Tests-Unit'
#name : 'OSSAbstractUnixSubprocessTest',
#superclass : 'TestCase',
#category : 'OSSubprocess-Tests-Unit',
#package : 'OSSubprocess-Tests-Unit'
}

{ #category : #helpers }
{ #category : 'helpers' }
OSSAbstractUnixSubprocessTest >> commandClass [
^ OSSUnixSubprocess
]

{ #category : #'instance creation' }
{ #category : 'instance creation' }
OSSAbstractUnixSubprocessTest >> newCommand [

^ self commandClass new
]

{ #category : #private }
{ #category : 'private' }
OSSAbstractUnixSubprocessTest >> systemAccessor [
^ OSSVMProcess vmProcess systemAccessor
]
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
Class {
#name : #OSSFileBasedUnixSubprocessTest,
#superclass : #OSSUnixSubprocessTest,
#category : 'OSSubprocess-Tests-Unit'
#name : 'OSSFileBasedUnixSubprocessTest',
#superclass : 'OSSUnixSubprocessTest',
#category : 'OSSubprocess-Tests-Unit',
#package : 'OSSubprocess-Tests-Unit'
}

{ #category : #helpers }
{ #category : 'helpers' }
OSSFileBasedUnixSubprocessTest >> assertStreamsInfoWithPrevious: beforeArray [
| afterArray |
afterArray := self getStreamsInfoForRunningTest.
self assert: beforeArray first equals: afterArray first.
self assert: beforeArray second equals: afterArray second.
]

{ #category : #helpers }
{ #category : 'helpers' }
OSSFileBasedUnixSubprocessTest >> getStreamsInfoForRunningTest [
"We obtain the open tmp files before the open files because in Pharo 7 and ealier getting the entries of /tmp using

Expand All @@ -25,7 +26,7 @@ OSSFileBasedUnixSubprocessTest >> getStreamsInfoForRunningTest [
^ Array with: self numberOfOpenFiles with: openTmpFiles
]

{ #category : #helpers }
{ #category : 'helpers' }
OSSFileBasedUnixSubprocessTest >> newCommand [
| command |
command := self commandClass new.
Expand All @@ -35,7 +36,7 @@ OSSFileBasedUnixSubprocessTest >> newCommand [

]

{ #category : #helpers }
{ #category : 'helpers' }
OSSFileBasedUnixSubprocessTest >> numberOfExistingTempStreamFiles [
"This answers the number of files that were created for mapping standard files.
Note that in OSSUnixSubprocessTest >> newCommand we define that temp files must be created in /tmp
Expand All @@ -46,7 +47,7 @@ OSSFileBasedUnixSubprocessTest >> numberOfExistingTempStreamFiles [
(each name beginsWith: 'OSSUnixSubprocess-p') and: [ each name endsWith: '.deleteme' ] ]) size
]

{ #category : #tests }
{ #category : 'tests' }
OSSFileBasedUnixSubprocessTest >> testBasicCommandWriteToStdin [
"testBasicCommandWriteToStdin fails because of what the documentation says:
> **Important** We have found some problems when using regular files for the `stdin`. While we do not strictly forbid that, we recommend you do so only if you know very well what you are doing. Otherwise, use blocking pipes for `stdin` (default behavior).
Expand All @@ -55,7 +56,7 @@ OSSFileBasedUnixSubprocessTest >> testBasicCommandWriteToStdin [

]

{ #category : #tests }
{ #category : 'tests' }
OSSFileBasedUnixSubprocessTest >> testReadingFromStdoutAfterCommandFinishesDoesNotBlocksVM [

"testReadingFromStdoutAfterCommandFinishesDoesNotBlocksVM fails on Travis on OSX. It looks like if another test would have run while this one was sleeping and hence in #assertStreamsInfoWithPrevious: it fails because there are 2 new not-closed files...which I suspect that those are from another running test..."
Expand All @@ -65,7 +66,7 @@ OSSFileBasedUnixSubprocessTest >> testReadingFromStdoutAfterCommandFinishesDoesN

]

{ #category : #tests }
{ #category : 'tests' }
OSSFileBasedUnixSubprocessTest >> testReadingFromStdoutDoesNotBlocksVM [
| command |
"With files, the reading from stdout does not lock the VM"
Expand All @@ -80,7 +81,7 @@ OSSFileBasedUnixSubprocessTest >> testReadingFromStdoutDoesNotBlocksVM [
command closeAndCleanStreams.
]

{ #category : #'tests - signals' }
{ #category : 'tests - signals' }
OSSFileBasedUnixSubprocessTest >> testSigTerm [
"Same as super impl but special handling for #assertStreamsInfoWithPrevious:. Read comment at the bottom"
| process exited streamsInfo |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Class {
#name : #OSSPipeBasedUnixSubprocessTest,
#superclass : #OSSUnixSubprocessTest,
#category : 'OSSubprocess-Tests-Unit'
#name : 'OSSPipeBasedUnixSubprocessTest',
#superclass : 'OSSUnixSubprocessTest',
#category : 'OSSubprocess-Tests-Unit',
#package : 'OSSubprocess-Tests-Unit'
}

{ #category : #helper }
{ #category : 'helper' }
OSSPipeBasedUnixSubprocessTest >> newCommand [

^ self commandClass new
Expand All @@ -16,7 +17,7 @@ OSSPipeBasedUnixSubprocessTest >> newCommand [

]

{ #category : #'tests - streams' }
{ #category : 'tests - streams' }
OSSPipeBasedUnixSubprocessTest >> testCommandTryToWriteToStdoutButHasNoReader [
| command errString |
command := self newCommand
Expand All @@ -36,7 +37,7 @@ OSSPipeBasedUnixSubprocessTest >> testCommandTryToWriteToStdoutButHasNoReader [
command closeAndCleanStreams.
]

{ #category : #'tests - streams' }
{ #category : 'tests - streams' }
OSSPipeBasedUnixSubprocessTest >> testReadingFromStdoutBlocksVM [
| command customStream |
customStream := self systemAccessor makeBlockingPipe.
Expand All @@ -51,7 +52,7 @@ OSSPipeBasedUnixSubprocessTest >> testReadingFromStdoutBlocksVM [
command closeAndCleanStreams.
]

{ #category : #'tests - streams' }
{ #category : 'tests - streams' }
OSSPipeBasedUnixSubprocessTest >> testReadingFromStdoutDoesNotBlocksVM [
| command customStream |
customStream := self systemAccessor makeNonBlockingPipe.
Expand Down
33 changes: 17 additions & 16 deletions repository/OSSubprocess-Tests-Unit/OSSPipeTest.class.st
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
Class {
#name : #OSSPipeTest,
#superclass : #OSSAbstractUnixSubprocessTest,
#category : 'OSSubprocess-Tests-Unit'
#name : 'OSSPipeTest',
#superclass : 'OSSAbstractUnixSubprocessTest',
#category : 'OSSubprocess-Tests-Unit',
#package : 'OSSubprocess-Tests-Unit'
}

{ #category : #private }
{ #category : 'private' }
OSSPipeTest >> blockingPipe [
^ self systemAccessor makeBlockingPipe

]

{ #category : #private }
{ #category : 'private' }
OSSPipeTest >> nonBlockingPipe [
^ self systemAccessor makeNonBlockingPipe

]

{ #category : #private }
{ #category : 'private' }
OSSPipeTest >> readFromAndClose: aPipe writingTo: aStream [

| s |
Expand All @@ -29,7 +30,7 @@ OSSPipeTest >> readFromAndClose: aPipe writingTo: aStream [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testBasicWriteAndRead [
| pipe string readString |
string := 'this is a testing string'.
Expand All @@ -39,7 +40,7 @@ OSSPipeTest >> testBasicWriteAndRead [
self assert: string equals: readString
]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testBlocking [

| pipe |
Expand All @@ -63,7 +64,7 @@ OSSPipeTest >> testBlocking [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testBlockingPeek [

| pipe |
Expand All @@ -84,7 +85,7 @@ OSSPipeTest >> testBlockingPeek [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testIsAtEndOfFile [

| pipe |
Expand Down Expand Up @@ -130,7 +131,7 @@ OSSPipeTest >> testIsAtEndOfFile [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testIsAtEndOfFile2 [

| pipe string |
Expand All @@ -148,7 +149,7 @@ OSSPipeTest >> testIsAtEndOfFile2 [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testNonBlocking [

| pipe writeStream string |
Expand All @@ -161,7 +162,7 @@ OSSPipeTest >> testNonBlocking [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testNonBlockingPeek [

| pipe |
Expand All @@ -181,7 +182,7 @@ OSSPipeTest >> testNonBlockingPeek [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testReadAfterClosedReadEnd [
| pipe writeStream readStream string |
string := 'this is a testing string'.
Expand All @@ -195,7 +196,7 @@ OSSPipeTest >> testReadAfterClosedReadEnd [

]

{ #category : #testing }
{ #category : 'testing' }
OSSPipeTest >> testWriteAfterClosedWriteEnd [
| pipe writeStream string |
string := 'this is a testing string'.
Expand All @@ -205,7 +206,7 @@ OSSPipeTest >> testWriteAfterClosedWriteEnd [

]

{ #category : #private }
{ #category : 'private' }
OSSPipeTest >> writeStuffOnThenClose: aPipe [

^ [(1 to: 10) do:
Expand Down
Loading