Test portability fixes for Cygwin. (Chad Austin)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 30 Apr 2003 19:38:19 +0000 (19:38 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 30 Apr 2003 19:38:19 +0000 (19:38 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@666 fdb21ef1-2011-0410-befe-b5e4ea1792b1

36 files changed:
etc/TestSCons.py
src/engine/SCons/Action.py
src/engine/SCons/ActionTests.py
src/engine/SCons/EnvironmentTests.py
src/engine/SCons/Tool/gs.py
test/AR.py
test/ARFLAGS.py
test/AS.py
test/ASFLAGS.py
test/CC.py
test/CPPFLAGS.py
test/CPPPATH.py
test/CXX.py
test/ENV.py
test/F77.py
test/F77FLAGS.py
test/LEX.py
test/LEXFLAGS.py
test/LIBPATH.py
test/LINK.py
test/LINKFLAGS.py
test/Program-j.py
test/Program.py
test/RANLIB.py
test/RANLIBFLAGS.py
test/SHF77.py
test/SHLIBPREFIX.py
test/SHLIBSUFFIX.py
test/SHLINK.py
test/SHLINKFLAGS.py
test/YACC.py
test/YACCFLAGS.py
test/long-lines.py
test/option--implicit-cache.py
test/pre-post-actions.py
test/special-filenames.py

index f9c4edfbb27ea3c402ab7ade431b2895bbf63523..4fe8b5b8d1dbd24c11eabc8feaa3e41eab12291c 100644 (file)
@@ -24,9 +24,33 @@ import TestCmd
 
 python = TestCmd.python_executable
 
-if string.find(sys.platform, 'irix') != -1:
+if sys.platform == 'win32':
+    _exe   = '.exe'
+    _obj   = '.obj'
+    _shobj = '.obj'
+    _dll   = '.dll'
+    lib_   = ''
+    fortran_lib = 'g2c'
+elif sys.platform == 'cygwin':
+    _exe   = '.exe'
+    _obj   = '.o'
+    _shobj = '.os'
+    _dll   = '.dll'
+    lib_   = ''
+    fortran_lib = 'g2c'
+elif string.find(sys.platform, 'irix') != -1:
+    _exe   = ''
+    _obj   = '.o'
+    _shobj = '.o'
+    _dll   = '.so'
+    lib_   = 'lib'
     fortran_lib = 'ftn'
 else:
+    _exe   = ''
+    _obj   = '.o'
+    _shobj = '.os'
+    _dll   = '.so'
+    lib_   = 'lib'
     fortran_lib = 'g2c'
 
 class TestFailed(Exception):
index 12608504861568e7adfa487eb1e346c06d23a192..d7be1276851cfd0deb699c3b7781fd94fb415cbd 100644 (file)
@@ -346,6 +346,9 @@ class LazyCmdGenerator:
             # The variable reference substitutes to nothing.
             return ''
 
+    def __cmp__(self, other):
+        return cmp(self.__dict__, other.__dict__)
+
 class FunctionAction(ActionBase):
     """Class for Python function actions."""
 
index 9189b4cf01fddfc9e8ca8770f3479ddfd42d62b4..4aee748a7b69910bcbd89e767ca7f2e4c0bea8e5 100644 (file)
@@ -412,11 +412,24 @@ class CommandActionTestCase(unittest.TestCase):
         assert c == "act.py: 'three' 'four'\n", c
 
         cmd5 = r'%s %s %s $TARGET XYZZY' % (python, act_py, outfile)
+        
+        act = SCons.Action.CommandAction(cmd5)
+        env5 = Environment()
+        if scons_env.has_key('ENV'):
+            env5['ENV'] = scons_env['ENV']
+            PATH = scons_env['ENV'].get('PATH', '')
+        else:
+            env5['ENV'] = {}
+            PATH = ''
+        
+        env5['ENV']['XYZZY'] = 'xyzzy'
+        r = act(target = 'out5', source = [], env = env5)
 
         act = SCons.Action.CommandAction(cmd5)
         r = act(target = 'out5',
                         source = [],
-                        env = env.Copy(ENV = {'XYZZY' : 'xyzzy'}))
+                        env = env.Copy(ENV = {'XYZZY' : 'xyzzy',
+                                              'PATH' : PATH}))
         assert r == 0
         c = test.read(outfile, 'r')
         assert c == "act.py: 'out5' 'XYZZY'\nact.py: 'xyzzy'\n", c
@@ -460,6 +473,9 @@ class CommandActionTestCase(unittest.TestCase):
             # as "file not found" errors
             expect_nonexistent = 1
             expect_nonexecutable = 1
+        elif sys.platform == 'cygwin':
+            expect_nonexistent = 127
+            expect_nonexecutable = 127
         else:
             expect_nonexistent = 127
             expect_nonexecutable = 126
index c041755d9d0806b913eaa2d065674a7b82c1b322..e99ea0d0db30dbc8dd8a1163ef190d5f03498133 100644 (file)
@@ -54,6 +54,28 @@ def diff_env(env1, env2):
     s2 = s2 + "}\n"
     return s1 + s2
 
+def diff_dict(d1, d2):
+    s1 = "d1 = {\n"
+    s2 = "d2 = {\n"
+    d = {}
+    for k in d1.keys() + d2.keys():
+       d[k] = None
+    keys = d.keys()
+    keys.sort()
+    for k in keys:
+        if d1.has_key(k):
+           if d2.has_key(k):
+               if d1[k] != d2[k]:
+                   s1 = s1 + "    " + repr(k) + " : " + repr(d1[k]) + "\n"
+                   s2 = s2 + "    " + repr(k) + " : " + repr(d2[k]) + "\n"
+           else:
+               s1 = s1 + "    " + repr(k) + " : " + repr(d1[k]) + "\n"
+        elif env2.has_key(k):
+           s2 = s2 + "    " + repr(k) + " : " + repr(d2[k]) + "\n"
+    s1 = s1 + "}\n"
+    s2 = s2 + "}\n"
+    return s1 + s2
+
 called_it = {}
 built_it = {}
 
@@ -372,6 +394,11 @@ class EnvironmentTestCase(unittest.TestCase):
     def test_Append(self):
         """Test appending to construction variables in an Environment
         """
+
+        b1 = Environment()['BUILDERS']
+        b2 = Environment()['BUILDERS']
+        assert b1 == b2, diff_dict(b1, b2)
+        
         import UserList
         UL = UserList.UserList
         env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', DDD = 'd',
index 5aa83d510c7c3b5a473b6d3a3f52620f5c34205d..79d50e4e0bae1df26b19868ea9ae386644c9c690 100644 (file)
@@ -41,7 +41,7 @@ platform = SCons.Platform.platform_default()
 
 if platform == 'os2':
     gs = 'gsos2'
-elif platform == 'cygwin' or platform == 'win32':
+elif platform == 'win32':
     gs = 'gswin32c'
 else:
     gs = 'gs'
index 57ec04d4d3e5a36d3daf3b05ba3b8a6f03236baf..f077c72cd3f8a8639ff609868f3e4fccccb41c45 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 49367218083c55af18bc8e2057043c7fef49a09b..54cb463cb833b0346edb964b74be18245d7431fa 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 22eb17c22e6a74e1035d1cadf7697c5458cc78d1..0bafdc14ceb8d51a04db5372e6fa389b1414a09c 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
@@ -67,11 +63,14 @@ inf = None
 while args:
     a = args[0]
     args = args[1:]
-    if a[0] != '/':
+    if not a[0] in "/-":
         if not inf:
             inf = a
         continue
     if a[:3] == '/Fo': out = a[3:]
+    if a == '-o':
+        out = args[0]
+        args = args[1:]
 infile = open(inf, 'rb')
 outfile = open(out, 'wb')
 for l in infile.readlines():
index 0331aed9b904fdd007e1a32f651f639c1c0dbfc6..d750a6a46d1d948be570c18ed43cec6f5fe9b08a 100644 (file)
@@ -32,12 +32,11 @@ import TestSCons
 python = TestSCons.python
 
 test = TestSCons.TestSCons()
+_exe = TestSCons._exe
 
 
 if sys.platform == 'win32':
 
-    _exe = '.exe'
-
     o = ' -x'
 
     o_c = ' -x'
@@ -89,8 +88,6 @@ sys.exit(0)
 
 else:
 
-    _exe = ''
-
     o = ' -x'
 
     o_c = ' -x -c'
index 93b0ed5a7b4c02c1f546742aed35a9bd26a99a70..ca4867b3399ea8a9cf122c46bf243e2559c65979 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index d8587c663dac8aa731fdbf24771905d8183431e3..87f5603b8e57b9aef3ee9b65a28041b05a18e67e 100644 (file)
@@ -30,18 +30,9 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-    _obj = '.obj'
-    _shobj = '.obj'
-else:
-    _exe = ''
-    _obj = '.o'
-    if string.find(sys.platform, 'irix') > -1:
-        _shobj = '.o'
-    else:
-        _shobj = '.os'
+_exe   = TestSCons._exe
+_obj   = TestSCons._obj
+_shobj = TestSCons._shobj
 
 test = TestSCons.TestSCons()
 
index cb650fa3fce03aa54c725bfcc88a0d1300aad9ef..1f93bf5d5a505246a38222e00216e85c26e31516 100644 (file)
@@ -28,10 +28,7 @@ import os
 import sys
 import TestSCons
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 prog = 'prog' + _exe
 subdir_prog = os.path.join('subdir', 'prog' + _exe)
index cd2c7a917590fff2c79494d21412e6adea9d2210..bff7708c416376012a8bc948525261d002ddf4b4 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index f92a2d8b754a420a46aa353c0511e6becaa288bc..31ad970b883e66a4a4426d7d3f87cb7b4f19ef94 100644 (file)
@@ -37,8 +37,10 @@ bin2_build_py = test.workpath('bin2', 'build.py')
 test.write('SConstruct', """
 import os
 Bld = Builder(action = r"%s build.py $TARGET $SOURCES")
-env1 = Environment(ENV = {'X' : 'env1'}, BUILDERS = { 'Bld' : Bld })
-env2 = Environment(ENV = {'X' : 'env2'}, BUILDERS = { 'Bld' : Bld })
+env1 = Environment(BUILDERS = { 'Bld' : Bld })
+env2 = Environment(BUILDERS = { 'Bld' : Bld })
+env1['ENV']['X'] = 'env1'
+env2['ENV']['X'] = 'env2'
 env1.Bld(target = 'env1.out', source = 'input')
 env2.Bld(target = 'env2.out', source = 'input')
 """ % python)
index f95dee995ae5820b21ec95131756cea0f18c0f02..034676526f42838c9094df10f102398b46ab24ef 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index b9147014c591dc71ef614b591f2adb5430a6cafd..b72c6183662f33563b26d87dff9eaa6c2b78dd4c 100644 (file)
@@ -32,12 +32,10 @@ import TestSCons
 python = TestSCons.python
 
 test = TestSCons.TestSCons()
-
+_exe = TestSCons._exe
 
 if sys.platform == 'win32':
 
-    _exe = '.exe'
-
     test.write('mylink.py', r"""
 import string
 import sys
@@ -58,8 +56,6 @@ sys.exit(0)
 
 else:
 
-    _exe = ''
-
     test.write('mylink.py', r"""
 import getopt
 import sys
index 38d73fb5dc1ebc9c2374efdf6e6f3b4fb5ede2d0..90549bd937ec77905a492a5d2a51dcb36856c3ed 100644 (file)
@@ -31,11 +31,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index c3ae18255acfd6b54845b7855fc7979f40704cbd..ba440daa84269d9a42d3f4aa7a6b8be0f715a5ff 100644 (file)
@@ -31,11 +31,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 2730be366a73e44492a14e36c1b77282e7d39312..6e2a8368ce500d6395f1863160f77263ad2c6865 100644 (file)
@@ -29,14 +29,9 @@ import sys
 import os.path
 import time
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-    _dll = '.dll'
-    lib_ = ''
-else:
-    _exe = ''
-    _dll = '.so'
-    lib_ = 'lib'
+_exe = TestSCons._exe
+_dll = TestSCons._dll
+lib_ = TestSCons.lib_
     
 test = TestSCons.TestSCons()
 
index 982cc888aa056dd3161781ca60c1768303f647bd..e3c21bc3dbcfd218fb2752dbe9e550cb2768349d 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index d5a1e401c42098702aaea6699905fada01112319..58efcf377d52ae04e6d09911ad0567e75fb2552e 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 3e290408603bd9ef69ad6dd2af9279c8ab1ba6ac..fe778b338cc17e4ec9929a106a83dcc1c529479e 100644 (file)
@@ -27,10 +27,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 import sys
 import TestSCons
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 f1 = 'f1' + _exe
 f2 = 'f2' + _exe
index b05a73a053058b7c5f98fd8f720a9258e364e088..30301722c8f5e3ef2225d926825fc8b42b35d6d7 100644 (file)
@@ -29,10 +29,7 @@ import sys
 import time
 import TestSCons
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 4879a83701fd9f57714b7c4f8464e858684dab31..cb8f1dbbd5da050c2f28c68569bb2f62dccac621 100644 (file)
@@ -32,10 +32,7 @@ import TestSCons
 
 python = TestSCons.python
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 0554d4ce916d2d285a8539ca375c8d95ea50841a..fec606dd9798f674ae0d875d115c7834ec2ae86e 100644 (file)
@@ -30,11 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe   = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index 23e9bf39d1e6cb8fbdb850ad30a2098319bc708c..d78ef821690abecda6cf3714689ff4c5c8c7d643 100644 (file)
@@ -30,14 +30,7 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    _obj = '.obj'
-else:
-    if string.find(sys.platform, 'irix') > -1:
-        _obj = '.o'
-    else:
-        _obj = '.os'
+_obj   = TestSCons._shobj
 
 test = TestSCons.TestSCons()
 
index f830b68284ce6900af1fa57ded09433b44b007a3..25bca5f05ff0f4d79e2b52e7aeaf540e45d32531 100644 (file)
@@ -28,10 +28,7 @@ import os
 import sys
 import TestSCons
 
-if sys.platform == 'win32':
-    _lib = '.dll'
-else:
-    _lib = '.so'
+_lib = TestSCons._dll
 
 test = TestSCons.TestSCons()
 
index 734f6c6d2212e74d99ce8414ffc502331b8ed39c..4c2d7ac6f097c74e1501cd66bfefe1c8531e62d6 100644 (file)
@@ -28,10 +28,7 @@ import os
 import sys
 import TestSCons
 
-if sys.platform == 'win32':
-    lib_ = ''
-else:
-    lib_ = 'lib'
+lib_ = TestSCons.lib_
 
 test = TestSCons.TestSCons()
 
index 3fd8e75d8de2db367382e3ad6343573e2dc6b905..7f1c63dee04a707b8987299cdd9c4c40ee8b2685 100644 (file)
@@ -30,14 +30,9 @@ import sys
 import TestSCons
 
 python = TestSCons.python
+lib_   = TestSCons.lib_
+_shlib = TestSCons._dll
 
-if sys.platform == 'win32':
-    lib_ = ''
-    _shlib='.dll'
-else:
-    lib_ = 'lib'
-    _shlib='.so'
-    
 test = TestSCons.TestSCons()
 
 test.write("wrapper.py",
index 85ad6a3abeeb09079e7ce64d5c27cc379966cc36..9a4a6ccb2632e6925de17a0639372162b9b7d659 100644 (file)
@@ -30,13 +30,8 @@ import sys
 import TestSCons
 
 python = TestSCons.python
-
-if sys.platform == 'win32':
-    lib_ = ''
-    _shlib = '.dll'
-else:
-    lib_ = 'lib'
-    _shlib = '.so'
+lib_   = TestSCons.lib_
+_shlib = TestSCons._dll
 
 test = TestSCons.TestSCons()
 
index 48549056495d7c95b11d578c54c6edfad1624d35..b44add173c9cdf8ce3703ae621a9e050af91773f 100644 (file)
@@ -31,13 +31,12 @@ import sys
 import TestSCons
 
 python = TestSCons.python
+_exe = TestSCons._exe
 
 if sys.platform == 'win32':
-    _exe = '.exe'
     compiler = 'msvc'
     linker = 'mslink'
 else:
-    _exe = ''
     compiler = 'gcc'
     linker = 'gnulink'
 
index 987025ff53f8ed69a6a945c91d85c5e356626de4..3ed6b6b25b33581c51ab397f7b4fa1c0135e0c18 100644 (file)
@@ -31,13 +31,12 @@ import sys
 import TestSCons
 
 python = TestSCons.python
+_exe   = TestSCons._exe
 
 if sys.platform == 'win32':
-    _exe = '.exe'
     compiler = 'msvc'
     linker = 'mslink'
 else:
-    _exe = ''
     compiler = 'gcc'
     linker = 'gnulink'
 
index 3999f621f50880bc2988452bb0337eeb7b0a0ab2..9d385048ca2b0d2d90fa935c383c93b80f6e7934 100644 (file)
@@ -32,13 +32,20 @@ import TestSCons
 
 test = TestSCons.TestSCons()
 
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform == 'win32':
     lib_static_lib = 'static.lib'
     lib_shared_dll ='shared.dll'
     arflag_init = '/LIBPATH:' + test.workpath()
     arflag = ' /LIBPATH:' + test.workpath()
     linkflag_init = '/LIBPATH:' + test.workpath()
     linkflag = ' /LIBPATH:' + test.workpath()
+elif sys.platform == 'cygwin':
+    lib_static_lib = 'libstatic.a'
+    lib_shared_dll ='shared.dll'
+    arflag_init = 'r'
+    arflag = 'o'
+    linkflag_init = '-L' + test.workpath()
+    linkflag = ' -L' + test.workpath()
 else:
     lib_shared_dll = 'libshared.so'
     lib_static_lib = 'libstatic.a'
index e959856a1440f9da325bbfbcd5de33975b5ebb21..ac11b2a38434ebfd996f8766beae200e4783d81f 100644 (file)
@@ -29,12 +29,8 @@ import sys
 import TestSCons
 import string
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-    _obj = '.obj'
-else:
-    _exe = ''
-    _obj = '.o'
+_exe = TestSCons._exe
+_obj = TestSCons._obj
 
 prog = 'prog' + _exe
 subdir_prog = os.path.join('subdir', 'prog' + _exe)
index d3139bb8e981dd4ee64ca29c6543e83c370adf5d..91fcb3b4f5c7b05a93e5293f586df00b478fc6d4 100644 (file)
@@ -32,10 +32,7 @@ import stat
 import sys
 import TestSCons
 
-if sys.platform == 'win32':
-    _exe = '.exe'
-else:
-    _exe = ''
+_exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
index d152e52081ab9f235a13dff4340eaae7d29b5ef4..2002b37bf0d5836ac8ad691e9a3d8cda787d76bc 100644 (file)
@@ -32,7 +32,7 @@ import TestSCons
 
 test = TestSCons.TestSCons()
 
-file_names = [ 
+attempt_file_names = [ 
     'File with spaces',
     'File"with"double"quotes',
     "File'with'single'quotes",
@@ -49,17 +49,20 @@ file_names = [
     "Combination '\"\n\\;<>?|*\t&"
     ]
 
-if os.name == 'nt':
-    # Windows only supports spaces.
-    file_names = file_names[0:1]
-
 test.write("cat.py", """\
 import sys
 open(sys.argv[1], 'wb').write(open(sys.argv[2], 'rb').read())
 """)
 
-for fn in file_names:
-    test.write(fn + '.in', fn + '\n')
+file_names = []
+for fn in attempt_file_names:
+    try:
+        test.write(fn + '.in', fn + '\n')
+        file_names.append(fn)
+    except IOError:
+        # if the Python interpreter can't handle it, don't bother
+        # testing to see if SCons can
+        pass
 
 def buildFileStr(fn):
     return "env.Build(source=r\"\"\"%s.in\"\"\", target=r\"\"\"%s.out\"\"\")" % ( fn, fn )