print self.stderr()
raise TestFailed
+ def detect(self, var, prog):
+ """
+ Detect a program named 'prog' by first checking the construction
+ variable named 'var' and finally searching the path. If either method
+ fails to detect the program, then false is returned, otherwise
+ the programs full path is returned.
+ """
+
+ import SCons.Environment
+ try:
+ return SCons.Environment.Environment()[var] == prog and self.where_is(prog)
+ except KeyError:
+ return None
+
def wrap_stdout(self, build_str = "", read_str = ""):
"""Wraps standard output string(s) in the normal
"Reading ... done" and "Building ... done" strings
def cvt(str):
return string.replace(str, '/', os.sep)
-
newcom = scons_subst("test $TARGETS $SOURCES", loc, {})
assert newcom == cvt("test foo/bar.exe /bar/baz.obj ../foo/baz.obj foo/blah.cpp /bar/ack.cpp ../foo/ack.c")
assert newcom == cvt("test foo")
newcom = scons_subst("test ${TARGET.abspath}", loc, {})
- assert newcom == cvt("test %s/foo/bar.exe"%os.getcwd()), newcom
+ assert newcom == cvt("test %s/foo/bar.exe"%SCons.Util.updrive(os.getcwd())), newcom
newcom = scons_subst("test ${SOURCES.abspath}", loc, {})
- assert newcom == cvt("test %s/foo/blah.cpp %s %s/foo/ack.c"%(os.getcwd(),
- os.path.abspath(os.path.normpath("/bar/ack.cpp")),
- os.path.normpath(os.getcwd()+"/.."))), newcom
+ assert newcom == cvt("test %s/foo/blah.cpp %s %s/foo/ack.c"%(SCons.Util.updrive(os.getcwd()),
+ SCons.Util.updrive(os.path.abspath(os.path.normpath("/bar/ack.cpp"))),
+ SCons.Util.updrive(os.path.normpath(os.getcwd()+"/..")))), newcom
newcom = scons_subst("test ${SOURCE.abspath}", loc, {})
- assert newcom == cvt("test %s/foo/blah.cpp"%os.getcwd()), newcom
+ assert newcom == cvt("test %s/foo/blah.cpp"%SCons.Util.updrive(os.getcwd())), newcom
newcom = scons_subst("test $xxx", loc, {})
assert newcom == cvt("test"), newcom
test.fail_test(test.read('test6' + _exe) != "This is a .SPP file.\n")
-
-as = test.where_is('as')
+as = test.detect('AS', 'as')
if as:
test = TestSCons.TestSCons()
-ranlib = test.where_is('ranlib')
+ranlib = test.detect('RANLIB', 'ranlib')
test.no_result(not ranlib)
test = TestSCons.TestSCons()
-ranlib = test.where_is('ranlib')
+ranlib = test.detect('RANLIB', 'ranlib')
test.no_result(not ranlib)
scanners = Environment().Dictionary('SCANNERS')
env = Environment(SCANNERS = scanners + [kscan])
-env.Command('foo', 'foo.k', '%s build.py $SOURCES $TARGET')
+env.Command('foo', 'foo.k', r'%s build.py $SOURCES $TARGET')
bar_in = File('bar.in')
-env.Command('bar', bar_in, '%s build.py $SOURCES $TARGET')
+env.Command('bar', bar_in, r'%s build.py $SOURCES $TARGET')
bar_in.source_scanner = kscan
""" % (python, python))
test.fail_test(test.read('bbb.tar') != "sub1/file5\nsub1/file6\nfile4\n")
-
-tar = test.where_is('tar')
+tar = test.detect('TAR', 'tar')
if tar:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(tools = ['tar'])
+foo = Environment()
tar = foo.Dictionary('TAR')
-bar = Environment(tools = ['tar'], TAR = r'%s wrapper.py ' + tar)
+bar = Environment(TAR = r'%s wrapper.py ' + tar)
foo.Tar(target = 'foo.tar', source = ['file10', 'file11'])
foo.Tar(target = 'foo.tar', source = 'file12')
bar.Tar(target = 'bar.tar', source = ['file13', 'file14'])
-tar = test.where_is('tar')
+tar = test.detect('TAR', 'tar')
if tar:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(tools = ['tar'])
+foo = Environment()
tar = foo['TAR']
-bar = Environment(tools = ['tar'],
- TAR = '',
- TARFLAGS = '%s wrapper.py ' + tar + ' -c -b 1')
+bar = Environment(TAR = '',
+ TARFLAGS = r'%s wrapper.py ' + tar + ' -c -b 1')
foo.Tar(target = 'foo.tar', source = ['file10', 'file11'])
foo.Tar(target = 'foo.tar', source = 'file12')
bar.Tar(target = 'bar.tar', source = ['file13', 'file14'])
test.write('SConstruct', """
import SCons.Defaults
-B = Builder(action='%s build.py $TARGET $SOURCES')
+B = Builder(action=r'%s build.py $TARGET $SOURCES')
env = Environment()
env['BUILDERS']['B'] = B
env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')
""")
test.write('SConstruct', """
-B = Builder(action='%s build.py $TARGET $SOURCES')
+B = Builder(action=r'%s build.py $TARGET $SOURCES')
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'aaa.out', source = 'aaa.in')
env.B(target = 'bbb.out', source = 'bbb.in')
test.write('SConstruct', """
import SCons.Defaults
env = Environment()
-env['BUILDERS']['B'] = Builder(action='%s build.py $TARGET $SOURCES')
+env['BUILDERS']['B'] = Builder(action=r'%s build.py $TARGET $SOURCES')
env.B(target = 'sub1/foo.out', source = 'sub1/foo.in')
Default('.')
Export('env')