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 /src | |
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)
Diffstat (limited to 'src')
-rw-r--r-- | src/engine/SCons/ActionTests.py | 63 | ||||
-rw-r--r-- | src/engine/SCons/SConfTests.py | 2 |
2 files changed, 44 insertions, 21 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 |