#QUALITY by cg
authorClaus Gittinger <cg@exept.de>
Wed, 26 Jul 2017 12:07:41 +0200
changeset 1643 a2c1786fc80e
parent 1641 e593c6c2e405
child 1644 2bdf26440ea1
#QUALITY by cg environment test
RegressionTests__OperatingSystemTest.st
--- a/RegressionTests__OperatingSystemTest.st	Fri Jul 21 15:24:53 2017 +0200
+++ b/RegressionTests__OperatingSystemTest.st	Wed Jul 26 12:07:41 2017 +0200
@@ -111,6 +111,101 @@
 
 !OperatingSystemTest methodsFor:'tests'!
 
+test01_environmentVariables
+    |batchFile output
+     expected50 expected101 expected203 expected407 expected815 expected1631 expected3263|
+
+    self 
+        skipIf:(OperatingSystem isMSWINDOWSlike not)
+        description:'This test is only for the Windows platform'.
+
+    "/ reading env-var
+
+    batchFile := 'test.bat' asFilename.
+    batchFile contents:'@set FOO=hello
+@stx --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''FOO'') "
+'.
+
+    output := 
+        String streamContents:[:out |
+            OperatingSystem executeCommand:'test.bat' outputTo:out.
+        ].
+
+    self assert:(output = 'hello').
+
+    "/ reading a longer env-var (50 chars)
+
+    batchFile := 'test.bat' asFilename.
+    batchFile contents:'@set FOO=12345678901234567890123456789012345678901234567890
+@stx --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''FOO'') "
+'.
+
+    output := 
+        String streamContents:[:out |
+            OperatingSystem executeCommand:'test.bat' outputTo:out.
+        ].
+
+    self assert:(output = '12345678901234567890123456789012345678901234567890').
+
+    "/ reading a longer env-var (1631 chars)
+
+    batchFile := 'test.bat' asFilename.
+    batchFile contents:'@set V50=12345678901234567890123456789012345678901234567890
+@set V101=%V50%;%V50%
+@set V203=%V101%;%V101%
+@set V407=%V203%;%V203%
+@set V815=%V407%;%V407%
+@set V1631=%V815%;%V815%
+@stx --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V1631'') "
+'.
+
+    output := 
+        String streamContents:[:out |
+            OperatingSystem executeCommand:'test.bat' outputTo:out.
+        ].
+
+    expected50 := '12345678901234567890123456789012345678901234567890'.
+    expected101 := expected50,';',expected50.
+    expected203 := expected101,';',expected101.
+    expected407 := expected203,';',expected203.
+    expected815 := expected407,';',expected407.
+    expected1631 := expected815,';',expected815.
+
+    self assert:(output = expected1631).
+
+    "/ reading a longer env-var (1631 chars)
+
+    batchFile := 'test.bat' asFilename.
+    batchFile contents:'@set V50=12345678901234567890123456789012345678901234567890
+@set V101=%V50%;%V50%
+@set V203=%V101%;%V101%
+@set V407=%V203%;%V203%
+@set V815=%V407%;%V407%
+@set V1631=%V815%;%V815%
+@set V3263=%V1631%;%V1631%
+@stx --eval "Stdout nextPutAll:(OperatingSystem getEnvironment:''V3263'') "
+'.
+
+    output := 
+        String streamContents:[:out |
+            OperatingSystem executeCommand:'test.bat' outputTo:out.
+        ].
+
+    expected50 := '12345678901234567890123456789012345678901234567890'.
+    expected101 := expected50,';',expected50.
+    expected203 := expected101,';',expected101.
+    expected407 := expected203,';',expected203.
+    expected815 := expected407,';',expected407.
+    expected1631 := expected815,';',expected815.
+    expected3263 := expected1631,';',expected1631.
+
+    self assert:(output = expected3263).
+
+    "
+     self new test01_environmentVariables
+    "
+!
+
 testActorStream
     OperatingSystem isMSDOSlike ifTrue:[
         self helperActorStreamWithCommand:'dir'.