summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorWilliam Deegan <bill@baddogconsulting.com>2017-03-19 18:46:12 (GMT)
committerWilliam Deegan <bill@baddogconsulting.com>2017-03-19 18:46:12 (GMT)
commitb5760962b94cb1b91845ff4104d88699f899a012 (patch)
tree071343b7117a42f07ac9b23893454159ee14fc60 /test
parentbbcb88b0be70ae0bd3e578efa7a8558427b2f0ee (diff)
parentdb3d6ab23631f6e9bd5684bac7002b94feef81eb (diff)
downloadSCons-b5760962b94cb1b91845ff4104d88699f899a012.zip
SCons-b5760962b94cb1b91845ff4104d88699f899a012.tar.gz
SCons-b5760962b94cb1b91845ff4104d88699f899a012.tar.bz2
Merged in bdbaddog/scons (pull request #419)
More py2/py3 fixes.
Diffstat (limited to 'test')
-rw-r--r--test/Configure/ConfigureDryRunError.py32
-rw-r--r--test/Configure/config-h.py2
-rw-r--r--test/Scanner/Scanner.py81
-rw-r--r--test/option/taskmastertrace.py2
-rw-r--r--test/srcchange.py23
5 files changed, 72 insertions, 68 deletions
diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py
index fa85042..b87162c 100644
--- a/test/Configure/ConfigureDryRunError.py
+++ b/test/Configure/ConfigureDryRunError.py
@@ -78,25 +78,25 @@ scons: *** Cannot update configure test "%(conftest_0_c)s" within a dry-run.
test.run(arguments='-n', status=2, stderr=expect)
test.run()
-test.checkLogAndStdout( ["Checking for C library %s... " % lib,
- "Checking for C library hopefullynolib... "],
- ["yes", "no"],
- [[((".c", NCR), (_obj, NCR))],
- [((".c", NCR), (_obj, NCF))]],
- "config.log", ".sconf_temp", "SConstruct")
+test.checkLogAndStdout(["Checking for C library %s... " % lib,
+ "Checking for C library hopefullynolib... "],
+ ["yes", "no"],
+ [[((".c", NCR), (_obj, NCR))],
+ [((".c", NCR), (_obj, NCF))]],
+ "config.log", ".sconf_temp", "SConstruct")
-oldLog = test.read(test.workpath('config.log'))
+oldLog = test.read(test.workpath('config.log'), mode='r')
test.run(arguments='-n')
-test.checkLogAndStdout( ["Checking for C library %s... " % lib,
- "Checking for C library hopefullynolib... "],
- ["yes", "no"],
- [[((".c", CR), (_obj, CR))],
- [((".c", CR), (_obj, CF))]],
- "config.log", ".sconf_temp", "SConstruct",
- doCheckLog=0)
-
-newLog = test.read(test.workpath('config.log'))
+test.checkLogAndStdout(["Checking for C library %s... " % lib,
+ "Checking for C library hopefullynolib... "],
+ ["yes", "no"],
+ [[((".c", CR), (_obj, CR))],
+ [((".c", CR), (_obj, CF))]],
+ "config.log", ".sconf_temp", "SConstruct",
+ doCheckLog=0)
+
+newLog = test.read(test.workpath('config.log'), mode='r')
if newLog != oldLog:
print("Unexpected update of log file within a dry run")
test.fail_test()
diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py
index ff5e5b2..a5c1998 100644
--- a/test/Configure/config-h.py
+++ b/test/Configure/config-h.py
@@ -130,7 +130,7 @@ expected_config_h = ("""\
/* #undef HAVE_LIBHOPEFULLYNOLIB2 */
#endif /* CONFIG_H_SEEN */
-""" % locals()).replace("\n", os.linesep)
+""" % locals())
test.run(stdout=expected_stdout)
diff --git a/test/Scanner/Scanner.py b/test/Scanner/Scanner.py
index d5e5c3a..e5516bd 100644
--- a/test/Scanner/Scanner.py
+++ b/test/Scanner/Scanner.py
@@ -25,6 +25,7 @@
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
import TestSCons
+import os
_python_ = TestSCons._python_
@@ -50,19 +51,19 @@ def process(infp, outfp):
process(input, output)
sys.exit(0)
-""")
+""", mode='w')
# Execute a subsidiary SConscript just to make sure we can
# get at the Scanner keyword from there.
test.write('SConstruct', """
SConscript('SConscript')
-""")
+""", mode='w')
test.write('SConscript', """
import re
-include_re = re.compile(r'^include\s+(\S+)$', re.M)
+include_re = re.compile(r'^include\s+(\S+)\s*$', re.M)
def kfile_scan(node, env, scanpaths, arg):
contents = node.get_text_contents()
@@ -113,69 +114,71 @@ bar = env.BarBld(target='bar', source='bar.in')
# Test specifying a source scanner for a Builder that gets
# automatically applied to targets generated from that Builder
-def blork(env, target, source):
- open(str(target[0]), 'w').write(
- source[0].get_text_contents().replace('getfile', 'MISSEDME'))
+def third(env, target, source):
+ contents = source[0].get_contents()
+ # print("TYPE:"+str(type(contents)))
+ contents = contents.replace(b'getfile', b'MISSEDME')
+ open(str(target[0]), 'wb').write(contents)
kbld = Builder(action=r'%(_python_)s build.py $SOURCES $TARGET',
- src_suffix='.lork',
- suffix='.blork',
+ src_suffix='.first',
+ suffix='.second',
source_scanner=kscan)
-blorkbld = Builder(action=blork,
- src_suffix='.blork',
- suffix='.ork')
+thirdbld = Builder(action=third,
+ src_suffix='.second',
+ suffix='.third')
-env.Append(BUILDERS={'BLORK':blorkbld, 'KB':kbld})
+env.Append(BUILDERS={'Second':thirdbld, 'KB':kbld})
-blork = env.KB('moo.lork')
-ork = env.BLORK(blork)
+blork = env.KB('moo.first')
+ork = env.Second(blork)
Alias('make_ork', ork)
-""" % locals())
+""" % locals(),mode='w')
test.write('foo.k',
"""foo.k 1 line 1
include xxx
include yyy
foo.k 1 line 4
-""")
+""", mode='w')
-test.write('bar.in',
+test.write('bar.in',
"""include yyy
bar.in 1 line 2
bar.in 1 line 3
include zzz
-""")
+""", mode='w')
test.write('junk.k2',
"""include yyy
junk.k2 1 line 2
junk.k2 1 line 3
include zzz
-""")
+""", mode='w')
-test.write('moo.lork',
+test.write('moo.first',
"""include xxx
-moo.lork 1 line 2
+moo.first 1 line 2
include yyy
-moo.lork 1 line 4
+moo.first 1 line 4
include moo.inc
-""")
+""", mode='w')
test.write('moo.inc',
"""getfile zzz
-""")
+""", mode='w')
-test.write('xxx', "xxx 1\n")
-test.write('yyy', "yyy 1\n")
-test.write('zzz', "zzz 1\n")
+test.write('xxx', "xxx 1\n",mode='w')
+test.write('yyy', "yyy 1\n",mode='w')
+test.write('zzz', "zzz 1\n",mode='w')
expect = test.wrap_stdout("""\
%(_python_)s build.py bar.in bar
%(_python_)s build.py foo.k foo
%(_python_)s build.py junk.k2 junk
-%(_python_)s build.py moo.lork moo.blork
-blork(["moo.ork"], ["moo.blork"])
+%(_python_)s build.py moo.first moo.second
+third(["moo.third"], ["moo.second"])
""" % locals())
test.run(arguments = '.', stdout=expect)
@@ -183,16 +186,16 @@ test.run(arguments = '.', stdout=expect)
test.must_match('foo', "foo.k 1 line 1\nxxx 1\nyyy 1\nfoo.k 1 line 4\n", mode='r')
test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r')
test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r')
-test.must_match('moo.ork', "xxx 1\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n", mode='r')
+test.must_match('moo.third', "xxx 1\nmoo.first 1 line 2\nyyy 1\nmoo.first 1 line 4\ninclude zzz\n", mode='r')
test.up_to_date(arguments = '.')
-test.write('xxx', "xxx 2\n")
+test.write('xxx', "xxx 2\n",mode='w')
expect = test.wrap_stdout("""\
%(_python_)s build.py foo.k foo
-%(_python_)s build.py moo.lork moo.blork
-blork(["moo.ork"], ["moo.blork"])
+%(_python_)s build.py moo.first moo.second
+third(["moo.third"], ["moo.second"])
""" % locals())
test.run(arguments = '.', stdout=expect)
@@ -200,16 +203,16 @@ test.run(arguments = '.', stdout=expect)
test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 1\nfoo.k 1 line 4\n", mode='r')
test.must_match('bar', "yyy 1\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r')
test.must_match('junk', "yyy 1\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r')
-test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 1\nmoo.lork 1 line 4\ninclude zzz\n", mode='r')
+test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 1\nmoo.first 1 line 4\ninclude zzz\n", mode='r')
-test.write('yyy', "yyy 2\n")
+test.write('yyy', "yyy 2\n",mode='w')
expect = test.wrap_stdout("""\
%(_python_)s build.py bar.in bar
%(_python_)s build.py foo.k foo
%(_python_)s build.py junk.k2 junk
-%(_python_)s build.py moo.lork moo.blork
-blork(["moo.ork"], ["moo.blork"])
+%(_python_)s build.py moo.first moo.second
+third(["moo.third"], ["moo.second"])
""" % locals())
test.run(arguments = '.', stdout=expect)
@@ -217,7 +220,7 @@ test.run(arguments = '.', stdout=expect)
test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r')
test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 1\n", mode='r')
test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 1\n", mode='r')
-test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n", mode='r')
+test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n", mode='r')
test.write('zzz', "zzz 2\n")
@@ -231,7 +234,7 @@ test.run(arguments = '.', stdout=expect)
test.must_match('foo', "foo.k 1 line 1\nxxx 2\nyyy 2\nfoo.k 1 line 4\n", mode='r')
test.must_match('bar', "yyy 2\nbar.in 1 line 2\nbar.in 1 line 3\nzzz 2\n", mode='r')
test.must_match('junk', "yyy 2\njunk.k2 1 line 2\njunk.k2 1 line 3\nzzz 2\n", mode='r')
-test.must_match('moo.ork', "xxx 2\nmoo.lork 1 line 2\nyyy 2\nmoo.lork 1 line 4\ninclude zzz\n", mode='r')
+test.must_match('moo.third', "xxx 2\nmoo.first 1 line 2\nyyy 2\nmoo.first 1 line 4\ninclude zzz\n", mode='r')
test.up_to_date(arguments = 'foo')
diff --git a/test/option/taskmastertrace.py b/test/option/taskmastertrace.py
index 28f4574..c426692 100644
--- a/test/option/taskmastertrace.py
+++ b/test/option/taskmastertrace.py
@@ -218,7 +218,7 @@ Taskmaster: No candidate anymore.
"""
-test.must_match('trace.out', expect_trace)
+test.must_match('trace.out', expect_trace, mode='r')
test.pass_test()
diff --git a/test/srcchange.py b/test/srcchange.py
index bbad4e7..bef3589 100644
--- a/test/srcchange.py
+++ b/test/srcchange.py
@@ -45,7 +45,7 @@ test = TestSCons.TestSCons()
test.write('getrevision', """
#!/usr/bin/env python
from __future__ import print_function
-print(open('revnum.in','r').read().strip())
+print(open('revnum.in','r').read().strip(), end='')
""")
test.write('SConstruct', """
@@ -72,41 +72,42 @@ exe = env.Program('main.c')
env.Default(exe)
""" % locals())
-test.write('main.c', """\
+test.write('main.c', r"""\
#include <stdio.h>
#include <stdlib.h>
#include <stdio.h>
int
main(int argc, char *argv[])
{
- printf("Revision $REV$\\n");
+ printf("Revision $REV$\n");
exit (0);
}
+
""")
test.write('revnum.in', '3.2\n')
-prog = 'main' + TestSCons._exe
+program_name = 'main' + TestSCons._exe
-light_build=test.wrap_stdout("""\
+light_build = test.wrap_stdout("""\
%(_python_)s getrevision > revision.in
""" % locals())
test.run(arguments='.')
-test.must_exist(prog)
-test.run(program=test.workpath(prog), stdout='Revision $REV: 3.2$\n')
+test.must_exist(program_name)
+test.run(program=test.workpath(program_name), stdout='Revision $REV: 3.2$\n')
test.run(arguments='.', stdout=light_build)
-test.must_exist(prog)
+test.must_exist(program_name)
test.run(arguments='.', stdout=light_build)
-test.must_exist(prog)
+test.must_exist(program_name)
test.write('revnum.in', '3.3\n')
test.run(arguments='.')
-test.must_exist(prog)
-test.run(program=test.workpath(prog), stdout='Revision $REV: 3.3$\n')
+test.must_exist(program_name)
+test.run(program=test.workpath(program_name), stdout='Revision $REV: 3.3$\n')
test.pass_test()