author | sr |
Fri, 07 Jul 2017 11:17:22 +0200 | |
changeset 1633 | 10a8f2029f10 |
parent 1447 | 2351db93aa5b |
child 1639 | b52780155182 |
permissions | -rw-r--r-- |
1633 | 1 |
"{ Encoding: utf8 }" |
2 |
||
1447 | 3 |
"{ Package: 'stx:goodies/regression' }" |
153 | 4 |
|
5 |
"{ NameSpace: RegressionTests }" |
|
6 |
||
7 |
TestCase subclass:#OperatingSystemTest |
|
8 |
instanceVariableNames:'' |
|
9 |
classVariableNames:'' |
|
10 |
poolDictionaries:'' |
|
1265
df1555a5fb95
class: RegressionTests::OperatingSystemTest
Claus Gittinger <cg@exept.de>
parents:
181
diff
changeset
|
11 |
category:'tests-Regression-RuntimeSystem' |
153 | 12 |
! |
13 |
||
14 |
||
1633 | 15 |
!OperatingSystemTest methodsFor:'constants'! |
16 |
||
17 |
targetFile |
|
18 |
|baseName| |
|
19 |
||
20 |
baseName := 'lsOut'. |
|
153 | 21 |
|
1633 | 22 |
OperatingSystem isMSDOSlike ifTrue:[ |
23 |
^ Filename homeDirectory "ensure write permission" / baseName |
|
24 |
]. |
|
25 |
OperatingSystem isUNIXlike ifTrue:[ |
|
26 |
^ '/tmp' asFilename / baseName |
|
27 |
]. |
|
28 |
||
29 |
self notYetImplemented |
|
153 | 30 |
! ! |
31 |
||
1633 | 32 |
!OperatingSystemTest methodsFor:'helpers'! |
33 |
||
34 |
helperActorStreamWithCommand:aCommand |
|
35 |
|targetFile expected outStr errStr exitStatus| |
|
153 | 36 |
|
1633 | 37 |
OperatingSystem isMSDOSlike ifFalse:[ |
38 |
^ self |
|
39 |
]. |
|
154 | 40 |
|
1633 | 41 |
targetFile := self targetFile. |
42 |
||
43 |
OperatingSystem executeCommand:aCommand, ' > ', targetFile pathName. |
|
44 |
expected := targetFile contentsOfEntireFile. |
|
154 | 45 |
|
46 |
outStr := ActorStream new. |
|
47 |
outStr nextPutLineBlock:[:line | Transcript normal; showCR:line ]. |
|
48 |
errStr := ActorStream new. |
|
49 |
outStr nextPutLineBlock:[:line | Transcript bold; showCR:line ]. |
|
50 |
||
51 |
OperatingSystem |
|
1633 | 52 |
executeCommand:aCommand |
53 |
inputFrom:nil |
|
54 |
outputTo:outStr |
|
55 |
errorTo:errStr |
|
56 |
inDirectory:nil |
|
57 |
lineWise:true |
|
58 |
onError:[:status | exitStatus := status]. |
|
59 |
! |
|
60 |
||
61 |
helperCommandOutput1WithCommand:aCommand |
|
62 |
|targetFile expected outStr errStr exitStatus| |
|
63 |
||
64 |
targetFile := self targetFile. |
|
65 |
||
66 |
OperatingSystem executeCommand:aCommand, ' > ', targetFile pathName. |
|
67 |
expected := targetFile contentsOfEntireFile. |
|
68 |
||
69 |
1 to:50 do:[:counter | |
|
70 |
"/ Transcript show:counter; showCR:':'. |
|
71 |
outStr := '' writeStream. |
|
72 |
errStr := '' writeStream. |
|
73 |
OperatingSystem |
|
74 |
executeCommand:aCommand |
|
75 |
inputFrom:nil |
|
76 |
outputTo:outStr |
|
77 |
errorTo:errStr |
|
78 |
onError:[:status | exitStatus := status]. |
|
79 |
self assert:(outStr contents = expected). |
|
80 |
self assert:(errStr contents isEmpty). |
|
81 |
self assert:(exitStatus isNil). |
|
82 |
]. |
|
83 |
! |
|
84 |
||
85 |
helperCommandOutput2WithCommand:aCommand |
|
86 |
|outStr errStr exitStatus| |
|
87 |
||
88 |
1 to:50 do:[:counter | |
|
89 |
"/ Transcript show:counter; showCR:':'. |
|
90 |
outStr := '' writeStream. |
|
91 |
errStr := '' writeStream. |
|
92 |
OperatingSystem |
|
93 |
executeCommand:aCommand |
|
94 |
inputFrom:nil |
|
95 |
outputTo:outStr |
|
96 |
errorTo:errStr |
|
97 |
onError:[:status | exitStatus := status]. |
|
98 |
self assert:(outStr contents isEmpty). |
|
99 |
self assert:(errStr contents notEmpty). |
|
100 |
self assert:(exitStatus success not). |
|
101 |
self assert:(exitStatus stillAlive not). |
|
102 |
self assert:(exitStatus couldNotExecute not). |
|
103 |
]. |
|
104 |
! ! |
|
105 |
||
106 |
!OperatingSystemTest methodsFor:'release'! |
|
107 |
||
108 |
tearDown |
|
109 |
self targetFile delete. |
|
110 |
! ! |
|
111 |
||
112 |
!OperatingSystemTest methodsFor:'tests'! |
|
113 |
||
114 |
testActorStream |
|
115 |
OperatingSystem isMSDOSlike ifTrue:[ |
|
116 |
self helperActorStreamWithCommand:'dir'. |
|
117 |
^ self |
|
118 |
]. |
|
119 |
OperatingSystem isUNIXlike ifTrue:[ |
|
120 |
self helperActorStreamWithCommand:'ls'. |
|
121 |
^ self |
|
122 |
]. |
|
123 |
||
124 |
self notYetImplemented |
|
154 | 125 |
|
126 |
" |
|
1633 | 127 |
self new testActorStream |
154 | 128 |
" |
129 |
! |
|
130 |
||
153 | 131 |
testCommandOutput1 |
1633 | 132 |
OperatingSystem isMSDOSlike ifTrue:[ |
133 |
self helperCommandOutput1WithCommand:'dir /b'. "/ /b print just filenames, because the filesize differs... |
|
134 |
^ self |
|
135 |
]. |
|
136 |
OperatingSystem isUNIXlike ifTrue:[ |
|
137 |
self helperCommandOutput1WithCommand:'ls'. |
|
138 |
^ self |
|
153 | 139 |
]. |
140 |
||
1633 | 141 |
self notYetImplemented |
142 |
||
153 | 143 |
" |
1633 | 144 |
self new testCommandOutput1 |
153 | 145 |
" |
146 |
! |
|
147 |
||
148 |
testCommandOutput2 |
|
1633 | 149 |
OperatingSystem isMSDOSlike ifTrue:[ |
150 |
self helperCommandOutput2WithCommand:'dir /fooBar'. |
|
151 |
^ self |
|
152 |
]. |
|
153 |
OperatingSystem isUNIXlike ifTrue:[ |
|
154 |
self helperCommandOutput2WithCommand:'ls /fooBar'. |
|
155 |
^ self |
|
153 | 156 |
]. |
157 |
||
1633 | 158 |
self notYetImplemented |
159 |
||
153 | 160 |
" |
1633 | 161 |
self new testCommandOutput2 |
153 | 162 |
" |
163 |
! |
|
164 |
||
165 |
testInvalidCommand |
|
166 |
|outStr errStr exitStatus| |
|
167 |
||
154 | 168 |
1 to:50 do:[:counter | |
155 | 169 |
"/ Transcript show:counter; showCR:':'. |
1447 | 170 |
outStr := '' writeStream. |
171 |
errStr := '' writeStream. |
|
172 |
OperatingSystem |
|
173 |
executeCommand:'blabla /fooBar' |
|
174 |
inputFrom:nil |
|
175 |
outputTo:outStr |
|
176 |
errorTo:errStr |
|
177 |
onError:[:status | exitStatus := status]. |
|
178 |
self assert:(exitStatus success not). |
|
179 |
self assert:(exitStatus stillAlive not). |
|
180 |
self assert:(exitStatus couldNotExecute). |
|
181 |
self assert:(outStr contents isEmpty). |
|
182 |
self assert:(errStr contents notEmpty). |
|
153 | 183 |
]. |
184 |
||
185 |
" |
|
186 |
self new testInvalidCommand |
|
187 |
" |
|
188 |
! ! |
|
189 |
||
190 |
!OperatingSystemTest class methodsFor:'documentation'! |
|
191 |
||
192 |
version |
|
193 |
^ '$Header$' |
|
1351 | 194 |
! |
195 |
||
196 |
version_CVS |
|
197 |
^ '$Header$' |
|
153 | 198 |
! ! |
1265
df1555a5fb95
class: RegressionTests::OperatingSystemTest
Claus Gittinger <cg@exept.de>
parents:
181
diff
changeset
|
199 |