__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
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):
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, [], {})
# 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
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' )
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
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
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' )
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'):
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()
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)
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)
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)
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)