本文整理汇总了Python中TestSCons.re_escape方法的典型用法代码示例。如果您正苦于以下问题:Python TestSCons.re_escape方法的具体用法?Python TestSCons.re_escape怎么用?Python TestSCons.re_escape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TestSCons
的用法示例。
在下文中一共展示了TestSCons.re_escape方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: cat
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
cat(["bbb.out"], ["bbb.in"])
%(_python_)s my-bk-get.py ccc.in
cat(["ccc.out"], ["ccc.in"])
cat(["all"], ["aaa.out", "bbb.out", "ccc.out"])
%(_python_)s my-bk-get.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-bk-get.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_bk + warn_sc)
test.must_match('all',
"BitKeeper/aaa.in\nchecked-out bbb.in\nBitKeeper/ccc.in\n")
test.must_match(['sub', 'all'],
"BitKeeper/sub/ddd.in\nchecked-out sub/eee.in\nBitKeeper/sub/fff.in\n")
test.pass_test()
# Local Variables:
# tab-width:4
# indent-tabs-mode:nil
# End:
示例2: TargetSignatures
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
__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)
示例3: build2
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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:
示例4: open
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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:
示例5: build
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
_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()
示例6: SConscript
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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'], """
示例7: open
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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 = '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')
python_expr = string.replace(TestSCons.python, '\\', '\\\\')
act = TestSCons.re_escape('"%s" build.py \$foo \$TARGET \$SOURCES' % python_expr)
expect = ("""
scons: warning: Two different environments were specified for target file4.out,
\tbut they appear to have the same action: %s
""" % act) + TestSCons.file_expr
test.run(arguments='file4.out', stderr=expect)
test.must_match('file4.out', "3\nfile4a.in\nfile4b.in\n")
test.pass_test()
示例8: Environment
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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:
示例9:
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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: cat
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
cat(["sub/fff.out"], ["sub/fff.in"])
cat(["sub/all"], ["sub/ddd.out", "sub/eee.out", "sub/fff.out"])
"""
stdout = test.wrap_stdout(read_str = read_str, build_str = build_str)
stderr = """\
sub/SConscript 1.1 -> 1.2: 5 lines
aaa.in 1.1 -> 1.2: 1 lines
ccc.in 1.1 -> 1.2: 1 lines
sub/ddd.in 1.1 -> 1.2: 1 lines
sub/fff.in 1.1 -> 1.2: 1 lines
"""
test.run(arguments = '.',
stdout = TestSCons.re_escape(stdout),
stderr = warn_bk + warn_sc + TestSCons.re_escape(stderr))
test.must_match(['work1', 'all'], "work1/aaa.in\nchecked-out work1/bbb.in\nwork1/ccc.in\n")
test.must_be_writable(test.workpath('work1', 'sub', 'SConscript'))
test.must_be_writable(test.workpath('work1', 'aaa.in'))
test.must_be_writable(test.workpath('work1', 'ccc.in'))
test.must_be_writable(test.workpath('work1', 'sub', 'ddd.in'))
test.must_be_writable(test.workpath('work1', 'sub', 'fff.in'))
# Test using BitKeeper to fetch from RCS/file,v files.
rcs = test.where_is('rcs')
ci = test.where_is('ci')
if not rcs:
print "Could not find RCS,\nskipping sub-test of BitKeeper using RCS files."
示例11: cat
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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:
示例12: build
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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:
示例13: build
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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()
示例14: build
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
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()
示例15:
# 需要导入模块: import TestSCons [as 别名]
# 或者: from TestSCons import re_escape [as 别名]
#include "bar.h"
#endif
""")
test.write('bar.h', """
#ifndef BAR_H
#define BAR_H
#include "foo.h"
#endif
""")
expect = """
scons: warning: The --debug=dtree option is deprecated; please use --tree=derived instead.
"""
stderr = TestSCons.re_escape(expect) + TestSCons.file_expr
dtree1 = """
+-foo.xxx
+-foo.ooo
+-bar.ooo
"""
test.run(arguments = "--debug=dtree foo.xxx",
stderr = stderr)
test.must_contain_all_lines(test.stdout(), [dtree1])
dtree2 = """
+-.
+-bar.ooo
+-foo.ooo