diff options
author | Steven Knight <knight@baldmt.com> | 2004-04-28 11:57:44 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2004-04-28 11:57:44 (GMT) |
commit | 31e22cb37b82c626158506282733b8a646bd863e (patch) | |
tree | 30857787f3fc35878a7710242020daa735637168 | |
parent | 00403c6ffe98e56807ece34499265e3602bcc38a (diff) | |
download | SCons-31e22cb37b82c626158506282733b8a646bd863e.zip SCons-31e22cb37b82c626158506282733b8a646bd863e.tar.gz SCons-31e22cb37b82c626158506282733b8a646bd863e.tar.bz2 |
Test fixes for Python 2.3.3 on Win32. (Anthony Roach)
-rw-r--r-- | src/engine/SCons/ActionTests.py | 63 | ||||
-rw-r--r-- | src/engine/SCons/SConfTests.py | 2 | ||||
-rw-r--r-- | test/Configure.py | 12 | ||||
-rw-r--r-- | test/SetBuildSignatureType.py | 4 | ||||
-rw-r--r-- | test/TargetSignatures.py | 4 |
5 files changed, 54 insertions, 31 deletions
diff --git a/src/engine/SCons/ActionTests.py b/src/engine/SCons/ActionTests.py index 589d1d3..bc8e39f 100644 --- a/src/engine/SCons/ActionTests.py +++ b/src/engine/SCons/ActionTests.py @@ -23,13 +23,17 @@ __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, [], {}) diff --git a/src/engine/SCons/SConfTests.py b/src/engine/SCons/SConfTests.py index b17cbff..b8502b0 100644 --- a/src/engine/SCons/SConfTests.py +++ b/src/engine/SCons/SConfTests.py @@ -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 diff --git a/test/Configure.py b/test/Configure.py index d3a8db7..7da4e9e 100644 --- a/test/Configure.py +++ b/test/Configure.py @@ -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() diff --git a/test/SetBuildSignatureType.py b/test/SetBuildSignatureType.py index 54f967f..3449304 100644 --- a/test/SetBuildSignatureType.py +++ b/test/SetBuildSignatureType.py @@ -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) diff --git a/test/TargetSignatures.py b/test/TargetSignatures.py index 5060157..2ee016e 100644 --- a/test/TargetSignatures.py +++ b/test/TargetSignatures.py @@ -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) |