Test fixes for Python 2.3.3 on Win32. (Anthony Roach)
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 28 Apr 2004 11:57:44 +0000 (11:57 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Wed, 28 Apr 2004 11:57:44 +0000 (11:57 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@962 fdb21ef1-2011-0410-befe-b5e4ea1792b1

src/engine/SCons/ActionTests.py
src/engine/SCons/SConfTests.py
test/Configure.py
test/SetBuildSignatureType.py
test/TargetSignatures.py

index 589d1d30e1986901d7903b1de5e070d9f7fa8349..bc8e39f83afcc52fbfdb6d46107294f7e0c0bfbd 100644 (file)
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-# Define a null function for use as a builder action.
-# Where this is defined in the file seems to affect its
-# byte-code contents, so try to minimize changes by
-# defining it here, before we even import anything.
-def Func():
+# Define a null function and a null class for use as builder actions.
+# Where these are defined in the file seems to affect their byte-code
+# contents, so try to minimize changes by defining them here, before we
+# even import anything.
+def GlobalFunc():
     pass
 
+class GlobalActFunc:
+    def __call__(self):
+        pass
+
 import os
 import re
 import StringIO
@@ -1091,17 +1095,27 @@ class FunctionActionTestCase(unittest.TestCase):
     def test_get_contents(self):
         """Test fetching the contents of a function Action
         """
-        a = SCons.Action.FunctionAction(Func)
+
+        a = SCons.Action.FunctionAction(GlobalFunc)
+
+        matches = [
+            "\177\036\000\177\037\000d\000\000S",
+            "d\x00\x00S",
+        ]
+
         c = a.get_contents(target=[], source=[], env=Environment())
-        assert c == "\177\036\000\177\037\000d\000\000S", repr(c)
+        assert c in matches, repr(c)
         c = a.get_contents(target=[], source=[], env=Environment(), dict={})
-        assert c == "\177\036\000\177\037\000d\000\000S", repr(c)
+        assert c in matches, repr(c)
+
+        a = SCons.Action.FunctionAction(GlobalFunc, varlist=['XYZ'])
+
+        matches_foo = map(lambda x: x + "foo", matches)
 
-        a = SCons.Action.FunctionAction(Func, varlist=['XYZ'])
         c = a.get_contents(target=[], source=[], env=Environment())
-        assert c == "\177\036\000\177\037\000d\000\000S", repr(c)
+        assert c in matches, repr(c)
         c = a.get_contents(target=[], source=[], env=Environment(XYZ = 'foo'))
-        assert c == "\177\036\000\177\037\000d\000\000Sfoo", repr(c)
+        assert c in matches_foo, repr(c)
 
         class Foo:
             def get_contents(self, target, source, env, dict=None):
@@ -1282,24 +1296,33 @@ class ActionCallerTestCase(unittest.TestCase):
 
     def test_get_contents(self):
         """Test fetching the contents of an ActionCaller"""
-        def actfunc():
-            pass
         def strfunc():
             pass
 
-        af = SCons.Action.ActionFactory(actfunc, strfunc)
+        matches = [
+            "\177\036\000\177\037\000d\000\000S",
+            "d\x00\x00S"
+        ]
+
+        af = SCons.Action.ActionFactory(GlobalFunc, strfunc)
         ac = SCons.Action.ActionCaller(af, [], {})
         c = ac.get_contents([], [], Environment())
-        assert c == "\177\005\005\177\006\005d\000\000S", repr(c)
+        assert c in matches, repr(c)
 
-        class ActFunc:
-            def __call__(self):
-                pass
+        matches = [
+            '\177"\000\177#\000d\000\000S',
+            "d\x00\x00S"
+        ]
 
-        af = SCons.Action.ActionFactory(ActFunc(), strfunc)
+        af = SCons.Action.ActionFactory(GlobalActFunc(), strfunc)
         ac = SCons.Action.ActionCaller(af, [], {})
         c = ac.get_contents([], [], Environment())
-        assert c == "\177\020\005\177\021\005d\000\000S", repr(c)
+        assert c in matches, repr(c)
+
+        matches = [
+            "<built-in function str>",
+            "<type 'str'>",
+        ]
 
         af = SCons.Action.ActionFactory(str, strfunc)
         ac = SCons.Action.ActionCaller(af, [], {})
index b17cbff0b57b826c02d44edf58c7ca5cd27fa5f1..b8502b09707c3071b5795ed05673d258eb5ecd95 100644 (file)
@@ -71,7 +71,7 @@ class SConfTestCase(unittest.TestCase):
         # and we need a new environment, cause references may point to
         # old modules (well, at least this is safe ...)
         self.scons_env = self.Environment.Environment()
-        self.scons_env['ENV']['PATH'] = os.environ['PATH']
+        self.scons_env.AppendENVPath('PATH', os.environ['PATH'])
 
         # we want to do some autodetection here
         # this stuff works with
index d3a8db735f7893e96ff0b88cd2685f9a04a0b701..7da4e9e0c7cd5b7c919b2fb8621bde168d6e4325 100644 (file)
@@ -84,7 +84,7 @@ try:
     test.write([work_dir,  'SConstruct'], """
 env = Environment()
 import os
-env['ENV']['PATH'] = os.environ['PATH']
+env.AppendENVPath('PATH', os.environ['PATH'])
 conf = Configure(env)
 r1 = conf.CheckLibWithHeader( '%s', 'math.h', 'c' )
 r2 = conf.CheckLibWithHeader( None, 'math.h', 'c' )
@@ -121,7 +121,7 @@ Checking for C++ header file vector... yes
     test.write([work_dir,  'SConstruct'], """
 env = Environment()
 import os
-env['ENV']['PATH'] = os.environ['PATH']
+env.AppendENVPath('PATH', os.environ['PATH'])
 conf = env.Configure()
 r1 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error
 r2 = conf.CheckLib( 'no_c_library_SAFFDG' )   # leads to link error
@@ -152,7 +152,7 @@ Checking for main() in C library no_c_library_SAFFDG... no
     test.write([work_dir,  'SConstruct'], """
 env = Environment()
 import os
-env['ENV']['PATH'] = os.environ['PATH']
+env.AppendENVPath('PATH', os.environ['PATH'])
 conf = Configure(env)
 r1 = conf.CheckCHeader( 'math.h' )
 r2 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error
@@ -190,7 +190,7 @@ Checking for C header file no_std_c_header.h... no
     test.write([work_dir,  'SConstruct'], """
 env = Environment(LOGFILE='build/config.log')
 import os
-env['ENV']['PATH'] = os.environ['PATH']
+env.AppendENVPath('PATH', os.environ['PATH'])
 BuildDir( 'build', '.' )
 conf = env.Configure(conf_dir='build/config.tests', log_file='$LOGFILE')
 r1 = conf.CheckCHeader( 'math.h' )
@@ -253,7 +253,7 @@ def CustomTest(context):
 env = Environment(FOO='fff')
 env.Append( CPPPATH='local' )
 import os
-env['ENV']['PATH'] = os.environ['PATH']
+env.AppendENVPath('PATH', os.environ['PATH'])
 conf = Configure( env, custom_tests = {'CustomTest' : CustomTest,
                                        '$FOO' : CustomTest} )
 if hasattr(conf, 'fff'):
@@ -335,7 +335,7 @@ def CheckCustom(test):
 
 env = Environment()
 import os
-env['ENV']['PATH'] = os.environ['PATH']
+env.AppendENVPath('PATH', os.environ['PATH'])
 conf = Configure( env, custom_tests={'CheckCustom' : CheckCustom} )
 conf.CheckCustom()
 env = conf.Finish()
index 54f967f932ef6cf0901e9023f9fb878fb8273fa2..3449304cbc7355d4400f4a5c34c958564e118c5c 100644 (file)
@@ -73,7 +73,7 @@ def copy1(env, source, target):
     open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
 
 def copy2(env, source, target):
-    # added this line
+    x = 2 # added this line
     return copy1(env, source, target)
 
 env['BUILDERS']['Copy1'] = Builder(action=copy1)
@@ -99,7 +99,7 @@ def copy1(env, source, target):
     open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
 
 def copy2(env, source, target):
-    # added this line
+    x = 2 # added this line
     return copy1(env, source, target)
 
 env['BUILDERS']['Copy1'] = Builder(action=copy1)
index 5060157f3003cb598cd2d4cf607368584c0f8796..2ee016e798e3df9b06cf9e5ab84f1323472eacb7 100644 (file)
@@ -71,7 +71,7 @@ def copy1(env, source, target):
     open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
 
 def copy2(env, source, target):
-    # added this line
+    x = 2 # added this line
     return copy1(env, source, target)
 
 env['BUILDERS']['Copy1'] = Builder(action=copy1)
@@ -103,7 +103,7 @@ def copy1(env, source, target):
     open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
 
 def copy2(env, source, target):
-    # added this line
+    x = 2 # added this line
     return copy1(env, source, target)
 
 env['BUILDERS']['Copy1'] = Builder(action=copy1)