112 !OperatingSystemTest methodsFor:'tests'! |
112 !OperatingSystemTest methodsFor:'tests'! |
113 |
113 |
114 test01_environmentVariables |
114 test01_environmentVariables |
115 |cr content batchFile output |
115 |cr content batchFile output |
116 expected50 expected101 expected203 expected407 expected815 expected1631 expected3263 |
116 expected50 expected101 expected203 expected407 expected815 expected1631 expected3263 |
117 expected6527| |
117 expected6527 pathOfSTXExecutable| |
|
118 |
|
119 pathOfSTXExecutable := OperatingSystem pathOfSTXExecutable. |
|
120 (pathOfSTXExecutable endsWith:'stx.com') ifFalse:[ |
|
121 "we are started by /stx/goodies/builder/quickSelfTest/quickSelfTest.com |
|
122 but do need stx.com" |
|
123 pathOfSTXExecutable := '../../../projects/smalltalk/stx.com' |
|
124 ]. |
118 |
125 |
119 self |
126 self |
120 skipIf:(OperatingSystem isMSWINDOWSlike not) |
127 skipIf:(OperatingSystem isMSWINDOWSlike not) |
121 description:'This test is only for the Windows platform'. |
128 description:'This test is only for the Windows platform'. |
122 |
129 |
123 cr := Character cr asString. |
130 cr := Character cr asString. |
124 |
131 |
125 "/ creates a batch file and starts another stx inside it, which retrieves a previously |
132 "/ creates a batch file and starts another stx inside it, which retrieves a previously |
126 "/ set environment variable... |
133 "/ set environment variable... |
127 "/ reading env-var |
134 "/ reading env-var |
128 content := |
135 content := |
129 '@set FOO=hello', cr, |
136 '@set FOO=hello', cr, |
130 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''FOO'') "' |
137 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''FOO'') "' |
131 bindWith:OperatingSystem pathOfSTXExecutable). |
138 bindWith:pathOfSTXExecutable). |
132 |
139 |
133 batchFile := 'test.bat' asFilename. |
140 batchFile := 'test.bat' asFilename. |
134 batchFile contents:content. |
141 batchFile contents:content. |
135 |
142 |
136 output := |
143 output := |
137 String streamContents:[:out | |
144 String streamContents:[:out | |
138 OperatingSystem executeCommand:'test.bat' outputTo:out. |
145 OperatingSystem executeCommand:'test.bat' outputTo:out. |
139 ]. |
146 ]. |
140 |
147 |
141 self assert:(output = 'hello'). |
148 self assert:(output = 'hello'). |
142 |
149 |
143 |
150 |
144 "/ reading a longer env-var (50 chars) |
151 "/ reading a longer env-var (50 chars) |
145 content := |
152 content := |
146 '@set FOO=12345678901234567890123456789012345678901234567890', cr, |
153 '@set FOO=12345678901234567890123456789012345678901234567890', cr, |
147 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''FOO'') "' |
154 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''FOO'') "' |
148 bindWith:OperatingSystem pathOfSTXExecutable). |
155 bindWith:pathOfSTXExecutable). |
149 |
156 |
150 batchFile := 'test.bat' asFilename. |
157 batchFile := 'test.bat' asFilename. |
151 batchFile contents:content. |
158 batchFile contents:content. |
152 |
159 |
153 output := |
160 output := |
154 String streamContents:[:out | |
161 String streamContents:[:out | |
155 OperatingSystem executeCommand:'test.bat' outputTo:out. |
162 OperatingSystem executeCommand:'test.bat' outputTo:out. |
156 ]. |
163 ]. |
157 |
164 |
158 self assert:(output = '12345678901234567890123456789012345678901234567890'). |
165 self assert:(output = '12345678901234567890123456789012345678901234567890'). |
159 |
166 |
160 |
167 |
161 "/ reading a longer env-var (1631 chars) |
168 "/ reading a longer env-var (1631 chars) |
162 content := |
169 content := |
163 '@set V50=12345678901234567890123456789012345678901234567890', cr, |
170 '@set V50=12345678901234567890123456789012345678901234567890', cr, |
164 '@set V101=%V50%;%V50%', cr, |
171 '@set V101=%V50%;%V50%', cr, |
165 '@set V203=%V101%;%V101%', cr, |
172 '@set V203=%V101%;%V101%', cr, |
166 '@set V407=%V203%;%V203%', cr, |
173 '@set V407=%V203%;%V203%', cr, |
167 '@set V815=%V407%;%V407%', cr, |
174 '@set V815=%V407%;%V407%', cr, |
168 '@set V1631=%V815%;%V815%', cr, |
175 '@set V1631=%V815%;%V815%', cr, |
169 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V1631'') "' |
176 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V1631'') "' |
170 bindWith:OperatingSystem pathOfSTXExecutable). |
177 bindWith:pathOfSTXExecutable). |
171 |
178 |
172 batchFile := 'test.bat' asFilename. |
179 batchFile := 'test.bat' asFilename. |
173 batchFile contents:content. |
180 batchFile contents:content. |
174 |
181 |
175 output := |
182 output := |
176 String streamContents:[:out | |
183 String streamContents:[:out | |
177 OperatingSystem executeCommand:'test.bat' outputTo:out. |
184 OperatingSystem executeCommand:'test.bat' outputTo:out. |
178 ]. |
185 ]. |
179 |
186 |
184 expected815 := expected407,';',expected407. |
191 expected815 := expected407,';',expected407. |
185 expected1631 := expected815,';',expected815. |
192 expected1631 := expected815,';',expected815. |
186 |
193 |
187 self assert:(output = expected1631). |
194 self assert:(output = expected1631). |
188 |
195 |
189 |
196 |
190 "/ reading a longer env-var (3263 chars) |
197 "/ reading a longer env-var (3263 chars) |
191 content := |
198 content := |
192 '@set V50=12345678901234567890123456789012345678901234567890', cr, |
199 '@set V50=12345678901234567890123456789012345678901234567890', cr, |
193 '@set V101=%V50%;%V50%', cr, |
200 '@set V101=%V50%;%V50%', cr, |
194 '@set V203=%V101%;%V101%', cr, |
201 '@set V203=%V101%;%V101%', cr, |
195 '@set V407=%V203%;%V203%', cr, |
202 '@set V407=%V203%;%V203%', cr, |
196 '@set V815=%V407%;%V407%', cr, |
203 '@set V815=%V407%;%V407%', cr, |
197 '@set V1631=%V815%;%V815%', cr, |
204 '@set V1631=%V815%;%V815%', cr, |
198 '@set V3263=%V1631%;%V1631%', cr, |
205 '@set V3263=%V1631%;%V1631%', cr, |
199 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V3263'') "' |
206 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V3263'') "' |
200 bindWith:OperatingSystem pathOfSTXExecutable). |
207 bindWith:pathOfSTXExecutable). |
201 |
208 |
202 batchFile := 'test.bat' asFilename. |
209 batchFile := 'test.bat' asFilename. |
203 batchFile contents:content. |
210 batchFile contents:content. |
204 |
211 |
205 output := |
212 output := |
206 String streamContents:[:out | |
213 String streamContents:[:out | |
215 expected1631 := expected815,';',expected815. |
222 expected1631 := expected815,';',expected815. |
216 expected3263 := expected1631,';',expected1631. |
223 expected3263 := expected1631,';',expected1631. |
217 |
224 |
218 self assert:(output = expected3263). |
225 self assert:(output = expected3263). |
219 |
226 |
220 |
227 |
221 "/ reading a very long env-var (6527 chars) |
228 "/ reading a very long env-var (6527 chars) |
222 content := |
229 content := |
223 '@set V50=12345678901234567890123456789012345678901234567890', cr, |
230 '@set V50=12345678901234567890123456789012345678901234567890', cr, |
224 '@set V101=%V50%;%V50%', cr, |
231 '@set V101=%V50%;%V50%', cr, |
225 '@set V203=%V101%;%V101%', cr, |
232 '@set V203=%V101%;%V101%', cr, |
226 '@set V407=%V203%;%V203%', cr, |
233 '@set V407=%V203%;%V203%', cr, |
227 '@set V815=%V407%;%V407%', cr, |
234 '@set V815=%V407%;%V407%', cr, |
228 '@set V1631=%V815%;%V815%', cr, |
235 '@set V1631=%V815%;%V815%', cr, |
229 '@set V3263=%V1631%;%V1631%', cr, |
236 '@set V3263=%V1631%;%V1631%', cr, |
230 '@set V6527=%V3263%;%V3263%', cr, |
237 '@set V6527=%V3263%;%V3263%', cr, |
231 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V6527'') "' |
238 ('@"%1" --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V6527'') "' |
232 bindWith:OperatingSystem pathOfSTXExecutable). |
239 bindWith:pathOfSTXExecutable). |
233 |
240 |
234 batchFile := 'test.bat' asFilename. |
241 batchFile := 'test.bat' asFilename. |
235 batchFile contents:content. |
242 batchFile contents:content. |
236 |
243 |
237 output := |
244 output := |