本文整理汇总了Python中TestSCons类的典型用法代码示例。如果您正苦于以下问题:Python TestSCons类的具体用法?Python TestSCons怎么用?Python TestSCons使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TestSCons类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: build2
def build2(env, target, source):
build(env, target, source)
# Put the names on the Builder objects and in the environment so
# the error output should be consistent regardless of Python version
# or how we mess with the Builder internals.
B = Builder(action=build, multi=1, name='B')
C = Builder(action=build2, multi=1, name='C')
env = Environment(BUILDERS = { 'B' : B, 'C' : C })
env.B(target = 'file8.out', source = 'file8.in')
env.C(target = 'file8.out', source = 'file8.in')
""")
test.write('file8a.in', 'file8a.in\n')
test.write('file8b.in', 'file8b.in\n')
expect = TestSCons.re_escape("""
scons: *** Two different builders (B and C) were specified for the same target: file8.out
""") + TestSCons.file_expr
test.run(arguments='file8.out', status=2, stderr=expect)
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
示例2: build
_python_ = TestSCons._python_
test.write('build.py', r"""#!/usr/bin/env python
import sys
def build(num, target, source):
file = open(str(target), 'wb')
file.write('%s\n'%num)
for s in source:
file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")
test.write('SConstruct', """\
B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file03.out', source = 'file03a.in', foo=1)
env.B(target = 'file03.out', source = 'file03b.in', foo=2)
""" % locals())
test.write('file03a.in', 'file03a.in\n')
test.write('file03b.in', 'file03b.in\n')
expect = TestSCons.re_escape("""
scons: *** Two environments with different actions were specified for the same target: file03.out
""") + TestSCons.file_expr
test.run(arguments='file03.out', status=2, stderr=expect)
test.pass_test()
示例3: SConscript
import TestSCons
test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
test.write('SConscript', """
SConscript('DummyScript', build_dir = 'build')
""")
test.write('DummyScript', """
""")
msg = """The build_dir keyword has been deprecated; use the variant_dir keyword instead."""
test.deprecated_warning('deprecated-build-dir', msg)
warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \
+ '\n' + TestSCons.file_expr
all1 = test.workpath('test', 'build', 'var1', 'all')
all2 = test.workpath('test', 'build', 'var2', 'all')
all3 = test.workpath('test', 'build', 'var3', 'all')
all4 = test.workpath('test', 'build', 'var4', 'all')
all5 = test.workpath('build', 'var5', 'all')
all6 = test.workpath('build', 'var6', 'all')
all7 = test.workpath('build', 'var7', 'all')
all8 = test.workpath('build', 'var8', 'all')
all9 = test.workpath('test', 'build', 'var9', 'src', 'all')
test.subdir('test')
test.write(['test', 'SConstruct'], """
示例4: Environment
#c++
#link
""")
test.write('test3.F', r"""test3.F
#g77
#link
""")
test.run(arguments = '.', stderr=None)
test.must_match('test1.obj', "test1.c\n#link\n")
test.must_match('test2.obj', "test2.cpp\n#link\n")
test.must_match('test3.obj', "test3.F\n#link\n")
test.must_match('foo.exe', "test1.c\ntest2.cpp\ntest3.F\n")
if TestSCons.case_sensitive_suffixes('.F', '.f'):
test.must_match('mygcc.out', "cc\nc++\ng77\n")
else:
test.must_match('mygcc.out', "cc\nc++\n")
test.write('SConstruct', """
env = Environment(CPPFLAGS = '-x',
SHLINK = r'%(_python_)s mylink.py',
SHLINKFLAGS = [],
CC = r'%(_python_)s mygcc.py cc',
CXX = r'%(_python_)s mygcc.py c++',
CXXFLAGS = [],
FORTRAN = r'%(_python_)s mygcc.py g77',
OBJSUFFIX = '.obj',
SHOBJPREFIX = '',
SHOBJSUFFIX = '.shobj',
示例5: build
file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")
test.write('SConstruct', """\
B = Builder(action='%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file4.out', source = 'file4a.in', foo=3)
env.B(target = 'file4.out', source = 'file4b.in', foo=3)
""" % locals())
test.write('file4a.in', 'file4a.in\n')
test.write('file4b.in', 'file4b.in\n')
expect = ("""
scons: warning: Two different environments were specified for target file4.out,
\tbut they appear to have the same action: %s build.py .foo .TARGET .SOURCES
""" % TestSCons.re_escape(_python_)) + TestSCons.file_expr
test.run(arguments='file4.out', stderr=expect)
test.must_match('file4.out', "3\nfile4a.in\nfile4b.in\n")
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
示例6: TargetSignatures
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
Verify basic interaction of the historic TargetSignatures('build')
and TargetSignatures('content') settings, overriding one with
the other in specific construction environments.
"""
import re
import TestSCons
test = TestSCons.TestSCons(match = TestSCons.match_re_dotall)
expect = TestSCons.re_escape("""
scons: warning: The env.TargetSignatures() method is deprecated;
\tconvert your build to use the env.Decider() method instead.
""") + TestSCons.file_expr
sconstruct_contents = """\
SetOption('warn', 'deprecated-target-signatures')
env = Environment()
def copy1(env, source, target):
open(str(target[0]), 'wb').write(open(str(source[0]), 'rb').read())
def copy2(env, source, target):
%s
return copy1(env, source, target)
env['BUILDERS']['Copy1'] = Builder(action=copy1)
示例7: build
import TestSCons
test = TestSCons.TestSCons(match=TestSCons.match_re)
test.write('SConstruct', """\
def build(env, target, source):
for t in target:
file = open(str(target[0]), 'wb')
for s in source:
file.write(open(str(s), 'rb').read())
B = Builder(action=build, multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = ['file12a.out', 'file12b.out'], source = 'file12a.in')
env.B(target = 'file12a.out', source = 'file12b.in')
""")
test.write('file12a.in', 'file12a.in\n')
test.write('file12b.in', 'file12b.in\n')
expect = TestSCons.re_escape("""
scons: *** Two different target lists have a target in common: file12a.out (from ['file12a.out', 'file12b.out'] and from ['file12a.out'])
""") + TestSCons.file_expr
test.run(arguments='file12.out', status=2, stderr=expect)
test.pass_test()
示例8: cat
cat(["bbb.out"], ["bbb.in"])
%(_python_)s my-cvs-co-.py ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
%(_python_)s my-cvs-co-.py %(sub_ddd_in)s
cat(["%(sub_ddd_out)s"], ["%(sub_ddd_in)s"])
cat(["%(sub_eee_out)s"], ["%(sub_eee_in)s"])
%(_python_)s my-cvs-co-.py %(sub_fff_in)s
cat(["%(sub_fff_out)s"], ["%(sub_fff_in)s"])
cat(["%(sub_all)s"], ["%(sub_ddd_out)s", "%(sub_eee_out)s", "%(sub_fff_out)s"])
"""
% locals()
)
stdout = test.wrap_stdout(read_str=read_str, build_str=build_str)
test.run(arguments=".", stdout=TestSCons.re_escape(stdout), stderr=warn_cvs + warn_sc)
test.must_match("all", "CVS/aaa.in\nchecked-out bbb.in\nCVS/ccc.in\n")
test.must_match(["sub", "all"], "CVS/sub/ddd.in\nchecked-out sub/eee.in\nCVS/sub/fff.in\n")
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
示例9:
os.environ['SCONSFLAGS'] = '-h'
test.run(stdout = expect,
stderr = TestSCons.deprecated_python_expr)
# No TestSCons.deprecated_python_expr because the -H option gets
# processed before the SConscript files and therefore before we check
# for the deprecation warning.
test.run(arguments = "-H")
test.must_not_contain_any_line(test.stdout(), ['Help text.'])
test.must_contain_all_lines(test.stdout(), ['-H, --help-options'])
os.environ['SCONSFLAGS'] = '-Z'
expect = r"""usage: scons [OPTION] [TARGET] ...
SCons error: no such option: -Z
"""
test.run(arguments = "-H", status = 2,
stderr = TestSCons.re_escape(expect))
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
示例10: build
for s in source:
file.write(open(str(s), 'rb').read())
build(sys.argv[1],sys.argv[2],sys.argv[3:])
""")
test.write('SConstruct', """\
B = Builder(action=r'%(_python_)s build.py $foo $TARGET $SOURCES', multi=1)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file03.out', source = 'file03a.in', foo=1)
env.B(target = 'file03.out', source = 'file03b.in', foo=2)
""" % locals())
test.write('file03a.in', 'file03a.in\n')
test.write('file03b.in', 'file03b.in\n')
expect = TestSCons.re_escape("""
scons: *** Two environments with different actions were specified for the same target: file03.out
(action 1: %s build.py 1 file03.out file03b.in)
(action 2: %s build.py 2 file03.out file03b.in)
""" % (sys.executable, sys.executable )) + TestSCons.file_expr
test.run(arguments='file03.out', status=2, stderr=expect)
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
示例11: BuildDir
import TestSCons
_exe = TestSCons._exe
test = TestSCons.TestSCons()
test.write('SConscript', """
BuildDir('build', 'src')
""")
msg = """BuildDir() and the build_dir keyword have been deprecated;
\tuse VariantDir() and the variant_dir keyword instead."""
test.deprecated_warning('deprecated-build-dir', msg)
warning = '\nscons: warning: ' + TestSCons.re_escape(msg) \
+ '\n' + TestSCons.file_expr
foo11 = test.workpath('work1', 'build', 'var1', 'foo1' + _exe)
foo12 = test.workpath('work1', 'build', 'var1', 'foo2' + _exe)
foo21 = test.workpath('work1', 'build', 'var2', 'foo1' + _exe)
foo22 = test.workpath('work1', 'build', 'var2', 'foo2' + _exe)
foo31 = test.workpath('work1', 'build', 'var3', 'foo1' + _exe)
foo32 = test.workpath('work1', 'build', 'var3', 'foo2' + _exe)
foo41 = test.workpath('work1', 'build', 'var4', 'foo1' + _exe)
foo42 = test.workpath('work1', 'build', 'var4', 'foo2' + _exe)
foo51 = test.workpath('build', 'var5', 'foo1' + _exe)
foo52 = test.workpath('build', 'var5', 'foo2' + _exe)
test.subdir('work1')
示例12: build
Verify that a builder with "multi" not set generates an error on the
second call.
"""
import TestSCons
test = TestSCons.TestSCons(match=TestSCons.match_re)
test.write('SConstruct', """\
def build(env, target, source):
file = open(str(target[0]), 'wb')
for s in source:
file.write(open(str(s), 'rb').read())
B = Builder(action=build, multi=0)
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'file2.out', source = 'file2a.in')
env.B(target = 'file2.out', source = 'file2b.in')
""")
test.write('file2a.in', 'file2a.in\n')
test.write('file2b.in', 'file2b.in\n')
expect = TestSCons.re_escape("""
scons: *** Multiple ways to build the same target were specified for: file2.out (from ['file2a.in'] and from ['file2b.in'])
""") + TestSCons.file_expr
test.run(arguments='file2.out', status=2, stderr=expect)
test.pass_test()
示例13: Environment
actions generate an error.
"""
import TestSCons
test = TestSCons.TestSCons(match=TestSCons.match_re)
test.write('SConstruct', """\
e1 = Environment()
e2 = Environment()
e1.Command('out.txt', [], 'echo 1 > $TARGET')
e2.Command('out.txt', [], 'echo 2 > $TARGET')
""",'w')
expect = TestSCons.re_escape("""
scons: *** Two environments with different actions were specified for the same target: out.txt
(action 1: echo 1 > out.txt)
(action 2: echo 2 > out.txt)
""") + TestSCons.file_expr
test.run(arguments='out.txt', status=2, stderr=expect)
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4:
示例14:
import os
import re
import TestCmd
import TestSCons
test = TestSCons.TestSCons(match = TestCmd.match_re_dotall,ignore_python_version=0)
test.write('SConstruct', "\n")
test.write('SetOption-deprecated', "SetOption('warn', 'no-deprecated')\n")
test.write('SetOption-python', "SetOption('warn', ['no-python-version'])\n")
if TestSCons.unsupported_python_version():
error = "scons: \*\*\* SCons version \S+ does not run under Python version %s."
error = error % re.escape(TestSCons.python_version_string()) + "\n"
test.run(arguments = '-Q', status = 1, stderr = error)
else:
if TestSCons.deprecated_python_version():
test.run(arguments = '-Q', stderr = TestSCons.deprecated_python_expr)
else:
test.run(arguments = '-Q')
示例15: open
file = open(str(target[0]), 'wb')
for s in source:
file.write(open(str(s), 'rb').read())
B = Builder(action=build, multi=1)
env = Environment(BUILDERS = { 'B' : B })
env2 = env.Clone(DIFFERENT_VARIABLE = 'true')
env.B(target = 'file5.out', source = 'file5a.in')
env2.B(target = 'file5.out', source = 'file5b.in')
""")
test.write('file5a.in', 'file5a.in\n')
test.write('file5b.in', 'file5b.in\n')
expect = TestSCons.re_escape("""
scons: warning: Two different environments were specified for target file5.out,
\tbut they appear to have the same action: build(target, source, env)
""") + TestSCons.file_expr
test.run(arguments='file5.out', stderr=expect)
test.must_match('file5.out', "file5a.in\nfile5b.in\n")
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
# vim: set expandtab tabstop=4 shiftwidth=4: