153
|
1 |
"{ Package: 'exept:regression' }"
|
|
2 |
|
|
3 |
"{ NameSpace: RegressionTests }"
|
|
4 |
|
|
5 |
TestCase subclass:#OperatingSystemTest
|
|
6 |
instanceVariableNames:''
|
|
7 |
classVariableNames:''
|
|
8 |
poolDictionaries:''
|
181
|
9 |
category:'tests-Regression'
|
153
|
10 |
!
|
|
11 |
|
|
12 |
|
|
13 |
!OperatingSystemTest methodsFor:'release'!
|
|
14 |
|
|
15 |
tearDown
|
|
16 |
'/tmp/lsOut' asFilename delete.
|
|
17 |
! !
|
|
18 |
|
|
19 |
!OperatingSystemTest methodsFor:'tests'!
|
|
20 |
|
154
|
21 |
testActorStream
|
|
22 |
|expected outStr errStr exitStatus|
|
|
23 |
|
|
24 |
OperatingSystem executeCommand:'ls > /tmp/lsOut'.
|
|
25 |
expected := '/tmp/lsOut' asFilename contentsOfEntireFile.
|
|
26 |
|
|
27 |
outStr := ActorStream new.
|
|
28 |
outStr nextPutLineBlock:[:line | Transcript normal; showCR:line ].
|
|
29 |
errStr := ActorStream new.
|
|
30 |
outStr nextPutLineBlock:[:line | Transcript bold; showCR:line ].
|
|
31 |
|
|
32 |
OperatingSystem
|
|
33 |
executeCommand:'ls'
|
|
34 |
inputFrom:nil
|
|
35 |
outputTo:outStr
|
|
36 |
errorTo:errStr
|
|
37 |
inDirectory:nil
|
|
38 |
lineWise:true
|
|
39 |
onError:[:status | exitStatus := status].
|
|
40 |
|
|
41 |
"
|
|
42 |
self new testActorStream
|
|
43 |
"
|
|
44 |
!
|
|
45 |
|
153
|
46 |
testCommandOutput1
|
|
47 |
|expected outStr errStr exitStatus|
|
|
48 |
|
|
49 |
OperatingSystem executeCommand:'ls > /tmp/lsOut'.
|
|
50 |
expected := '/tmp/lsOut' asFilename contentsOfEntireFile.
|
|
51 |
|
154
|
52 |
1 to:50 do:[:counter |
|
155
|
53 |
"/ Transcript show:counter; showCR:':'.
|
153
|
54 |
outStr := '' writeStream.
|
|
55 |
errStr := '' writeStream.
|
|
56 |
OperatingSystem
|
|
57 |
executeCommand:'ls'
|
|
58 |
inputFrom:nil
|
|
59 |
outputTo:outStr
|
|
60 |
errorTo:errStr
|
|
61 |
onError:[:status | exitStatus := status].
|
|
62 |
self assert:(outStr contents = expected).
|
|
63 |
self assert:(errStr contents isEmpty).
|
|
64 |
self assert:(exitStatus isNil).
|
|
65 |
].
|
|
66 |
|
|
67 |
"
|
|
68 |
self new testCommandOutput1
|
|
69 |
"
|
|
70 |
!
|
|
71 |
|
|
72 |
testCommandOutput2
|
|
73 |
|outStr errStr exitStatus|
|
|
74 |
|
154
|
75 |
1 to:50 do:[:counter |
|
155
|
76 |
"/ Transcript show:counter; showCR:':'.
|
153
|
77 |
outStr := '' writeStream.
|
|
78 |
errStr := '' writeStream.
|
|
79 |
OperatingSystem
|
|
80 |
executeCommand:'ls /fooBar'
|
|
81 |
inputFrom:nil
|
|
82 |
outputTo:outStr
|
|
83 |
errorTo:errStr
|
|
84 |
onError:[:status | exitStatus := status].
|
|
85 |
self assert:(outStr contents isEmpty).
|
|
86 |
self assert:(errStr contents notEmpty).
|
|
87 |
self assert:(exitStatus success not).
|
|
88 |
self assert:(exitStatus stillAlive not).
|
|
89 |
self assert:(exitStatus couldNotExecute not).
|
|
90 |
].
|
|
91 |
|
|
92 |
"
|
|
93 |
self new testCommandOutput2
|
|
94 |
"
|
|
95 |
!
|
|
96 |
|
|
97 |
testInvalidCommand
|
|
98 |
|outStr errStr exitStatus|
|
|
99 |
|
154
|
100 |
1 to:50 do:[:counter |
|
155
|
101 |
"/ Transcript show:counter; showCR:':'.
|
153
|
102 |
outStr := '' writeStream.
|
|
103 |
errStr := '' writeStream.
|
|
104 |
OperatingSystem
|
|
105 |
executeCommand:'blabla /fooBar'
|
|
106 |
inputFrom:nil
|
|
107 |
outputTo:outStr
|
|
108 |
errorTo:errStr
|
|
109 |
onError:[:status | exitStatus := status].
|
|
110 |
self assert:(exitStatus success not).
|
|
111 |
self assert:(exitStatus stillAlive not).
|
|
112 |
self assert:(exitStatus couldNotExecute).
|
|
113 |
self assert:(outStr contents isEmpty).
|
|
114 |
self assert:(errStr contents notEmpty).
|
|
115 |
].
|
|
116 |
|
|
117 |
"
|
|
118 |
self new testInvalidCommand
|
|
119 |
"
|
|
120 |
! !
|
|
121 |
|
|
122 |
!OperatingSystemTest class methodsFor:'documentation'!
|
|
123 |
|
|
124 |
version
|
|
125 |
^ '$Header$'
|
|
126 |
! !
|