diff options
author | William Deegan <bill@baddogconsulting.com> | 2016-05-23 23:21:26 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2016-05-23 23:21:26 (GMT) |
commit | aa5a0468340338cc3423a06d6d55e1b52a713bc5 (patch) | |
tree | 71ff4e88b1e418ff32ba89ae0f4cf0b3f0d180a1 /test | |
parent | 15bd909b178ba5271125fca6846fa8c069be79f1 (diff) | |
parent | b387e34357c968d0855c525c7e838657a957ff01 (diff) | |
download | SCons-aa5a0468340338cc3423a06d6d55e1b52a713bc5.zip SCons-aa5a0468340338cc3423a06d6d55e1b52a713bc5.tar.gz SCons-aa5a0468340338cc3423a06d6d55e1b52a713bc5.tar.bz2 |
merge python3 branch to default
Diffstat (limited to 'test')
156 files changed, 1209 insertions, 1156 deletions
diff --git a/test/ARGLIST.py b/test/ARGLIST.py index 186ad06..e246ba3 100644 --- a/test/ARGLIST.py +++ b/test/ARGLIST.py @@ -31,7 +31,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ i = 0 for key, value in ARGLIST: - print "%d: %s = %s" % (i, key, value) + print("%d: %s = %s" % (i, key, value)) i = i + 1 """) diff --git a/test/Actions/actions.py b/test/Actions/actions.py index 03d67a0..785a0cb 100644 --- a/test/Actions/actions.py +++ b/test/Actions/actions.py @@ -70,7 +70,7 @@ import os def func(env, target, source): cmd = r'%(_python_)s build.py %%s 3 %%s' %% (' '.join(map(str, target)), ' '.join(map(str, source))) - print cmd + print(cmd) return os.system(cmd) B = Builder(action = func) env = Environment(BUILDERS = { 'B' : B }) @@ -91,7 +91,7 @@ class bld(object): self.cmd = r'%(_python_)s build.py %%s 4 %%s' def __call__(self, env, target, source): cmd = self.get_contents(env, target, source) - print cmd + print(cmd) return os.system(cmd) def get_contents(self, env, target, source): return self.cmd %% (' '.join(map(str, target)), @@ -114,9 +114,9 @@ def func(env, target, source): env = Environment(S = Action('foo'), F = Action(func), L = Action(['arg1', 'arg2'])) -print env.subst('$S') -print env.subst('$F') -print env.subst('$L') +print(env.subst('$S')) +print(env.subst('$F')) +print(env.subst('$L')) """) test.run(arguments = '-Q .', stdout = """\ diff --git a/test/Actions/pre-post.py b/test/Actions/pre-post.py index 38a55df..f6997e2 100644 --- a/test/Actions/pre-post.py +++ b/test/Actions/pre-post.py @@ -118,14 +118,14 @@ def b(target, source, env): env1 = Environment(X='111') env2 = Environment(X='222') B = Builder(action = b, env = env1, multi=1) -print "B =", B -print "B.env =", B.env +print("B =", B) +print("B.env =", B.env) env1.Append(BUILDERS = {'B' : B}) env2.Append(BUILDERS = {'B' : B}) env3 = env1.Clone(X='333') -print "env1 =", env1 -print "env2 =", env2 -print "env3 =", env3 +print("env1 =", env1) +print("env2 =", env2) +print("env3 =", env3) f1 = env1.B(File('file1.out'), []) f2 = env2.B('file2.out', []) f3 = env3.B('file3.out', []) @@ -133,12 +133,12 @@ def do_nothing(env, target, source): pass AddPreAction(f2[0], do_nothing) AddPostAction(f3[0], do_nothing) -print "f1[0].builder =", f1[0].builder -print "f2[0].builder =", f2[0].builder -print "f3[0].builder =", f3[0].builder -print "f1[0].env =", f1[0].env -print "f2[0].env =", f2[0].env -print "f3[0].env =", f3[0].env +print("f1[0].builder =", f1[0].builder) +print("f2[0].builder =", f2[0].builder) +print("f3[0].builder =", f3[0].builder) +print("f1[0].env =", f1[0].env) +print("f2[0].env =", f2[0].env) +print("f3[0].env =", f3[0].env) """) test.run(chdir='work2', arguments = '.') diff --git a/test/Actions/unicode-signature.py b/test/Actions/unicode-signature.py index 0d0c469..d91bfa8 100644 --- a/test/Actions/unicode-signature.py +++ b/test/Actions/unicode-signature.py @@ -35,12 +35,12 @@ import TestSCons test = TestSCons.TestSCons() -try: - unicode -except NameError: - import sys - msg = "Unicode not supported by Python version %s; skipping test\n" - test.skip_test(msg % sys.version[:3]) +## try: +## unicode +## except NameError: +## import sys +## msg = "Unicode not supported by Python version %s; skipping test\n" +## test.skip_test(msg % sys.version[:3]) test.write('SConstruct', """ fnode = File(u'foo.txt') diff --git a/test/AddMethod.py b/test/AddMethod.py index af84cb3..6049ae2 100644 --- a/test/AddMethod.py +++ b/test/AddMethod.py @@ -40,10 +40,10 @@ def foo(self): AddMethod(Environment, foo) env = Environment(FOO = '111') -print env.foo() +print(env.foo()) env = Environment(FOO = '222') -print env.foo() +print(env.foo()) env.AddMethod(foo, 'bar') env['FOO'] = '333' @@ -51,8 +51,8 @@ env['FOO'] = '333' e = env.Clone() e['FOO'] = '444' -print env.bar() -print e.bar() +print(env.bar()) +print(e.bar()) """) expect = """\ diff --git a/test/AddOption/basic.py b/test/AddOption/basic.py index a1bb7b3..b1b8f2e 100644 --- a/test/AddOption/basic.py +++ b/test/AddOption/basic.py @@ -48,8 +48,8 @@ AddOption('--prefix', f = GetOption('force') if f: f = "True" -print f -print GetOption('prefix') +print(f) +print(GetOption('prefix')) """) test.run('-Q -q .', diff --git a/test/AddOption/help.py b/test/AddOption/help.py index d50e595..7b886cb 100644 --- a/test/AddOption/help.py +++ b/test/AddOption/help.py @@ -20,6 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -57,10 +58,10 @@ lines = test.stdout().split('\n') missing = [e for e in expected_lines if e not in lines] if missing: - print "====== STDOUT:" - print test.stdout() - print "====== Missing the following lines in the above AddOption() help output:" - print "\n".join(missing) + print("====== STDOUT:") + print(test.stdout()) + print("====== Missing the following lines in the above AddOption() help output:") + print("\n".join(missing)) test.fail_test() test.unlink('SConstruct') @@ -70,10 +71,10 @@ lines = test.stdout().split('\n') unexpected = [e for e in expected_lines if e in lines] if unexpected: - print "====== STDOUT:" - print test.stdout() - print "====== Unexpected lines in the above non-AddOption() help output:" - print "\n".join(unexpected) + print("====== STDOUT:") + print(test.stdout()) + print("====== Unexpected lines in the above non-AddOption() help output:") + print("\n".join(unexpected)) test.fail_test() test.pass_test() diff --git a/test/AddOption/optional-arg.py b/test/AddOption/optional-arg.py index f976ad9..b88b796 100644 --- a/test/AddOption/optional-arg.py +++ b/test/AddOption/optional-arg.py @@ -43,7 +43,7 @@ AddOption('--install', type='string', metavar='DIR', help='installation directory') -print GetOption('install') +print(GetOption('install')) """) test.run('-Q -q', diff --git a/test/Batch/action-changed.py b/test/Batch/action-changed.py index dc2805a..d031432 100644 --- a/test/Batch/action-changed.py +++ b/test/Batch/action-changed.py @@ -54,7 +54,7 @@ sys.exit(0) """ test.write('build.py', build_py_contents % (python, 'one')) -os.chmod(test.workpath('build.py'), 0755) +os.chmod(test.workpath('build.py'), 0o755) test.write('SConstruct', """ env = Environment() @@ -81,7 +81,7 @@ test.must_match('f3.out', "one\nf3.in\n") test.up_to_date(arguments = '.') test.write('build.py', build_py_contents % (python, 'two')) -os.chmod(test.workpath('build.py'), 0755) +os.chmod(test.workpath('build.py'), 0o755) test.not_up_to_date(arguments = '.') diff --git a/test/CC/CFLAGS.py b/test/CC/CFLAGS.py index 6ea87ad..590d6b5 100644 --- a/test/CC/CFLAGS.py +++ b/test/CC/CFLAGS.py @@ -32,10 +32,10 @@ test = TestSCons.TestSCons() # Make sure CFLAGS is not passed to CXX by just expanding CXXCOM test.write('SConstruct', """ env = Environment(CFLAGS='-xyz', CCFLAGS='-abc') -print env.subst('$CXXCOM') -print env.subst('$CXXCOMSTR') -print env.subst('$SHCXXCOM') -print env.subst('$SHCXXCOMSTR') +print(env.subst('$CXXCOM')) +print(env.subst('$CXXCOMSTR')) +print(env.subst('$SHCXXCOM')) +print(env.subst('$SHCXXCOMSTR')) """) test.run(arguments = '.') test.must_not_contain_any_line(test.stdout(), ["-xyz"]) @@ -46,7 +46,7 @@ _obj = TestSCons._obj # Test passing CFLAGS to C compiler by actually compiling programs if sys.platform == 'win32': import SCons.Tool.MSCommon as msc - + if not msc.msvc_exists(): fooflags = '-DFOO' barflags = '-DBAR' diff --git a/test/CPPDEFINES/append.py b/test/CPPDEFINES/append.py index 6e69d09..14ea7b3 100644 --- a/test/CPPDEFINES/append.py +++ b/test/CPPDEFINES/append.py @@ -40,17 +40,17 @@ test.write('SConstruct', """\ env_1738_2 = Environment(CPPDEFPREFIX='-D') env_1738_2['CPPDEFINES'] = ['FOO'] env_1738_2.Append(CPPDEFINES={'value' : '1'}) -print env_1738_2.subst('$_CPPDEFFLAGS') +print(env_1738_2.subst('$_CPPDEFFLAGS')) #env_1738_2.Object('test_1738_2', 'main.c') # http://scons.tigris.org/issues/show_bug.cgi?id=2300 env_2300_1 = Environment(CPPDEFINES = 'foo', CPPDEFPREFIX='-D') env_2300_1.Append(CPPDEFINES='bar') -print env_2300_1.subst('$_CPPDEFFLAGS') +print(env_2300_1.subst('$_CPPDEFFLAGS')) env_2300_2 = Environment(CPPDEFINES = ['foo'], CPPDEFPREFIX='-D') # note the list env_2300_2.Append(CPPDEFINES='bar') -print env_2300_2.subst('$_CPPDEFFLAGS') +print(env_2300_2.subst('$_CPPDEFFLAGS')) # http://scons.tigris.org/issues/show_bug.cgi?id=1152 # http://scons.tigris.org/issues/show_bug.cgi?id=2900 @@ -62,18 +62,18 @@ cases=[('string', 'FOO'), for (t1, c1) in cases: for (t2, c2) in cases: - print "==== Testing CPPDEFINES, appending a %s to a %s"%(t2, t1) - print " orig = %s, append = %s"%(c1, c2) + print("==== Testing CPPDEFINES, appending a %s to a %s"%(t2, t1)) + print(" orig = %s, append = %s"%(c1, c2)) env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D') env.Append(CPPDEFINES = c2) final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt") - print 'Append: \\n\\tresult=%s\\n\\tfinal=%s'%\\ - (env['CPPDEFINES'], final) + print('Append:\\n\\tresult=%s\\n\\tfinal=%s'%\\ + (env['CPPDEFINES'], final)) env=Environment(CPPDEFINES = c1, CPPDEFPREFIX='-D') env.AppendUnique(CPPDEFINES = c2) final=env.subst('$_CPPDEFFLAGS',source="src", target="tgt") - print 'AppendUnique:\\n\\tresult=%s\\n\\tfinal=%s'%\\ - (env['CPPDEFINES'], final) + print('AppendUnique:\\n\\tresult=%s\\n\\tfinal=%s'%\\ + (env['CPPDEFINES'], final)) """) @@ -83,7 +83,7 @@ expect_print_output="""\ -Dfoo -Dbar ==== Testing CPPDEFINES, appending a string to a string orig = FOO, append = FOO -Append: +Append: result=['FOO', 'FOO'] final=-DFOO -DFOO AppendUnique: @@ -91,7 +91,7 @@ AppendUnique: final=-DFOO ==== Testing CPPDEFINES, appending a list to a string orig = FOO, append = ['NAME1', 'NAME2'] -Append: +Append: result=['FOO', 'NAME1', 'NAME2'] final=-DFOO -DNAME1 -DNAME2 AppendUnique: @@ -99,7 +99,7 @@ AppendUnique: final=-DFOO -DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a string orig = FOO, append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=['FOO', ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -107,7 +107,7 @@ AppendUnique: final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 ==== Testing CPPDEFINES, appending a dict to a string orig = FOO, append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result=['FOO', {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}] final=-DFOO -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 AppendUnique: @@ -115,7 +115,7 @@ AppendUnique: final=-DFOO -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a string to a list orig = ['NAME1', 'NAME2'], append = FOO -Append: +Append: result=['NAME1', 'NAME2', 'FOO'] final=-DNAME1 -DNAME2 -DFOO AppendUnique: @@ -123,7 +123,7 @@ AppendUnique: final=-DNAME1 -DNAME2 -DFOO ==== Testing CPPDEFINES, appending a list to a list orig = ['NAME1', 'NAME2'], append = ['NAME1', 'NAME2'] -Append: +Append: result=['NAME1', 'NAME2', 'NAME1', 'NAME2'] final=-DNAME1 -DNAME2 -DNAME1 -DNAME2 AppendUnique: @@ -131,7 +131,7 @@ AppendUnique: final=-DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a list orig = ['NAME1', 'NAME2'], append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=['NAME1', 'NAME2', ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DNAME1 -DNAME2 -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -139,7 +139,7 @@ AppendUnique: final=-DNAME1 -DNAME2 -DNAME1=VAL1 -DNAME2=VAL2 ==== Testing CPPDEFINES, appending a dict to a list orig = ['NAME1', 'NAME2'], append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result=['NAME1', 'NAME2', {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}] final=-DNAME1 -DNAME2 -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 AppendUnique: @@ -147,7 +147,7 @@ AppendUnique: final=-DNAME1 -DNAME2 -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a string to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = FOO -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], 'FOO'] final=-DNAME1=VAL1 -DNAME2=VAL2 -DFOO AppendUnique: @@ -155,7 +155,7 @@ AppendUnique: final=-DNAME1=VAL1 -DNAME2=VAL2 -DFOO ==== Testing CPPDEFINES, appending a list to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = ['NAME1', 'NAME2'] -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], 'NAME1', 'NAME2'] final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME1 -DNAME2 AppendUnique: @@ -163,7 +163,7 @@ AppendUnique: final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -171,7 +171,7 @@ AppendUnique: final=-DNAME1=VAL1 -DNAME2=VAL2 ==== Testing CPPDEFINES, appending a dict to a list-of-2lists orig = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']], append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result=[('NAME1', 'VAL1'), ['NAME2', 'VAL2'], {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}] final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 AppendUnique: @@ -179,7 +179,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a string to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = FOO -Append: +Append: result={'FOO': None, 'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} final=-DFOO -DNAME1=VAL1 -DNAME2=VAL2 -DNAME3 AppendUnique: @@ -187,7 +187,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DFOO ==== Testing CPPDEFINES, appending a list to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = ['NAME1', 'NAME2'] -Append: +Append: result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), 'NAME1', 'NAME2'] final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DNAME1 -DNAME2 AppendUnique: @@ -195,7 +195,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DNAME1 -DNAME2 ==== Testing CPPDEFINES, appending a list-of-2lists to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = [('NAME1', 'VAL1'), ['NAME2', 'VAL2']] -Append: +Append: result=[('NAME2', 'VAL2'), ('NAME3',), ('NAME1', 'VAL1'), ('NAME1', 'VAL1'), ['NAME2', 'VAL2']] final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 -DNAME1=VAL1 -DNAME2=VAL2 AppendUnique: @@ -203,7 +203,7 @@ AppendUnique: final=-DNAME2=VAL2 -DNAME3 -DNAME1=VAL1 ==== Testing CPPDEFINES, appending a dict to a dict orig = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'}, append = {'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} -Append: +Append: result={'NAME2': 'VAL2', 'NAME3': None, 'NAME1': 'VAL1'} final=-DNAME1=VAL1 -DNAME2=VAL2 -DNAME3 AppendUnique: @@ -213,7 +213,7 @@ AppendUnique: build_output="scons: `.' is up to date.\n" -expect = test.wrap_stdout(build_str=build_output, +expect = test.wrap_stdout(build_str=build_output, read_str = expect_print_output) test.run(arguments = '.', stdout=expect) test.pass_test() diff --git a/test/CPPDEFINES/basic.py b/test/CPPDEFINES/basic.py index b54a421..57d7260 100644 --- a/test/CPPDEFINES/basic.py +++ b/test/CPPDEFINES/basic.py @@ -41,13 +41,13 @@ test_list = [ ] for i in test_list: env = Environment(CPPDEFPREFIX='-D', CPPDEFSUFFIX='', INTEGER=0) - print env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS') + print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS')) for i in test_list: env = Environment(CPPDEFPREFIX='|', CPPDEFSUFFIX='|', INTEGER=1) - print env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS') + print(env.Clone(CPPDEFINES=i).subst('$_CPPDEFFLAGS')) """) -expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", +expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", read_str = """\ -Dxyz -Dx -Dy -Dz diff --git a/test/CPPDEFINES/pkg-config.py b/test/CPPDEFINES/pkg-config.py index 1b308d3..4e81dec 100644 --- a/test/CPPDEFINES/pkg-config.py +++ b/test/CPPDEFINES/pkg-config.py @@ -60,26 +60,26 @@ test.write('SConstruct', """\ # Passing test cases env_1 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) env_1.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') -print env_1.subst('$_CPPDEFFLAGS') +print(env_1.subst('$_CPPDEFFLAGS')) env_2 = Environment(CPPDEFINES=[('DEBUG','1'), 'TEST']) env_2.MergeFlags('-DSOMETHING -DVARIABLE=2') -print env_2.subst('$_CPPDEFFLAGS') +print(env_2.subst('$_CPPDEFFLAGS')) # Failing test cases env_3 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) env_3.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags bug') -print env_3.subst('$_CPPDEFFLAGS') +print(env_3.subst('$_CPPDEFFLAGS')) env_4 = Environment(CPPDEFINES={'DEBUG':1, 'TEST':None}) env_4.MergeFlags('-DSOMETHING -DVARIABLE=2') -print env_4.subst('$_CPPDEFFLAGS') +print(env_4.subst('$_CPPDEFFLAGS')) # http://scons.tigris.org/issues/show_bug.cgi?id=1738 env_1738_1 = Environment(tools=['default']) env_1738_1.ParseConfig('PKG_CONFIG_PATH=. %(pkg_config_path)s --cflags --libs bug') env_1738_1.Append(CPPDEFINES={'value' : '1'}) -print env_1738_1.subst('$_CPPDEFFLAGS') +print(env_1738_1.subst('$_CPPDEFFLAGS')) """%locals() ) expect_print_output="""\ @@ -92,7 +92,7 @@ expect_print_output="""\ build_output="scons: `.' is up to date.\n" -expect = test.wrap_stdout(build_str=build_output, +expect = test.wrap_stdout(build_str=build_output, read_str = expect_print_output) test.run(arguments = '.', stdout=expect) test.pass_test() diff --git a/test/CPPDEFINES/undefined.py b/test/CPPDEFINES/undefined.py index 47825b6..b26b05a 100644 --- a/test/CPPDEFINES/undefined.py +++ b/test/CPPDEFINES/undefined.py @@ -34,10 +34,10 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ env = Environment() -print env.subst('$_CPPDEFFLAGS') +print(env.subst('$_CPPDEFFLAGS')) """) -expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", +expect = test.wrap_stdout(build_str="scons: `.' is up to date.\n", read_str = "\n") test.run(arguments = '.', stdout=expect) diff --git a/test/CacheDir/scanner-target.py b/test/CacheDir/scanner-target.py index 645b597..c39042e 100644 --- a/test/CacheDir/scanner-target.py +++ b/test/CacheDir/scanner-target.py @@ -52,7 +52,7 @@ def docopy(target,source,env): f.close() def sillyScanner(node, env, dirs): - print 'This is never called (unless we build file.out)' + print('This is never called (unless we build file.out)') return [] SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res']) diff --git a/test/CacheDir/source-scanner.py b/test/CacheDir/source-scanner.py index e7db5e9..2359872 100644 --- a/test/CacheDir/source-scanner.py +++ b/test/CacheDir/source-scanner.py @@ -54,7 +54,7 @@ def docopy(target,source,env): f.close() def sillyScanner(node, env, dirs): - print 'This is never called (unless we build file.out)' + print('This is never called (unless we build file.out)') return [] SillyScanner = SCons.Scanner.Base(function = sillyScanner, skeys = ['.res']) diff --git a/test/Chmod.py b/test/Chmod.py index c5b2a8d..e5bb85f 100644 --- a/test/Chmod.py +++ b/test/Chmod.py @@ -98,26 +98,25 @@ test.subdir('d16') test.subdir('d17') test.subdir('d18') -os.chmod(test.workpath('f1'), 0444) -os.chmod(test.workpath('f1-File'), 0444) -os.chmod(test.workpath('d2'), 0555) -os.chmod(test.workpath('d2-Dir'), 0555) -os.chmod(test.workpath('f3'), 0444) -os.chmod(test.workpath('d4'), 0555) -os.chmod(test.workpath('f5'), 0444) -os.chmod(test.workpath('Chmod-f7.in'), 0444) -os.chmod(test.workpath('f7.out-Chmod'), 0444) -os.chmod(test.workpath('f9'), 0444) -os.chmod(test.workpath('f10'), 0444) -os.chmod(test.workpath('d11'), 0555) -os.chmod(test.workpath('d12'), 0555) -os.chmod(test.workpath('f13'), 0444) -os.chmod(test.workpath('f14'), 0444) -os.chmod(test.workpath('f15'), 0444) -os.chmod(test.workpath('d16'), 0555) -os.chmod(test.workpath('d17'), 0555) -os.chmod(test.workpath('d18'), 0555) - +os.chmod(test.workpath('f1'), 0o444) +os.chmod(test.workpath('f1-File'), 0o444) +os.chmod(test.workpath('d2'), 0o555) +os.chmod(test.workpath('d2-Dir'), 0o555) +os.chmod(test.workpath('f3'), 0o444) +os.chmod(test.workpath('d4'), 0o555) +os.chmod(test.workpath('f5'), 0o444) +os.chmod(test.workpath('Chmod-f7.in'), 0o444) +os.chmod(test.workpath('f7.out-Chmod'), 0o444) +os.chmod(test.workpath('f9'), 0o444) +os.chmod(test.workpath('f10'), 0o444) +os.chmod(test.workpath('d11'), 0o555) +os.chmod(test.workpath('d12'), 0o555) +os.chmod(test.workpath('f13'), 0o444) +os.chmod(test.workpath('f14'), 0o444) +os.chmod(test.workpath('f15'), 0o444) +os.chmod(test.workpath('d16'), 0o555) +os.chmod(test.workpath('d17'), 0o555) +os.chmod(test.workpath('d18'), 0o555) expect = test.wrap_stdout(read_str = """\ Chmod("f1", 0666) Chmod("f1-File", 0666) @@ -145,92 +144,92 @@ cat(["f8.out"], ["f8.in"]) test.run(options = '-n', arguments = '.', stdout = expect) s = stat.S_IMODE(os.stat(test.workpath('f1'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f1-File'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d2'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('d2-Dir'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) test.must_not_exist('bar.out') s = stat.S_IMODE(os.stat(test.workpath('f3'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d4'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('f5'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) test.must_not_exist('f6.out') test.must_not_exist('f7.out') s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) test.must_not_exist('f8.out') s = stat.S_IMODE(os.stat(test.workpath('f9'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f10'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d11'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('f13'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f14'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f15'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('d16'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('d17'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) s = stat.S_IMODE(os.stat(test.workpath('d18'))[stat.ST_MODE]) -test.fail_test(s != 0555) +test.fail_test(s != 0o555) test.run() s = stat.S_IMODE(os.stat(test.workpath('f1'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f1-File'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d2'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('d2-Dir'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) test.must_match('bar.out', "bar.in\n") s = stat.S_IMODE(os.stat(test.workpath('f3'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d4'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('f5'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) test.must_match('f6.out', "f6.in\n") test.must_match('f7.out', "f7.in\n") s = stat.S_IMODE(os.stat(test.workpath('Chmod-f7.in'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f7.out-Chmod'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) test.must_match('f8.out', "f8.in\n") s = stat.S_IMODE(os.stat(test.workpath('f9'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f10'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d11'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('d12'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('f13'))[stat.ST_MODE]) -test.fail_test(s != 0444) +test.fail_test(s != 0o444) s = stat.S_IMODE(os.stat(test.workpath('f14'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('f15'))[stat.ST_MODE]) -test.fail_test(s != 0666) +test.fail_test(s != 0o666) s = stat.S_IMODE(os.stat(test.workpath('d16'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('d17'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) s = stat.S_IMODE(os.stat(test.workpath('d18'))[stat.ST_MODE]) -test.fail_test(s != 0777) +test.fail_test(s != 0o777) test.pass_test() diff --git a/test/Clean/mkfifo.py b/test/Clean/mkfifo.py index 0ef7662..01e4d98 100644 --- a/test/Clean/mkfifo.py +++ b/test/Clean/mkfifo.py @@ -38,35 +38,40 @@ test = TestSCons.TestSCons() if not hasattr(os, 'mkfifo'): test.skip_test('No os.mkfifo() function; skipping test\n') +test_dir_name = 'testdir' +pipe_path = os.path.join(test_dir_name, 'namedpipe') + test.write('SConstruct', """\ -Execute(Mkdir("testdir")) -dir = Dir("testdir") -Clean(dir, 'testdir') -""") +Execute(Mkdir("{0}")) +dir = Dir("{0}") +Clean(dir, '{0}') +""".format(test_dir_name)) + +test.run(arguments='-Q -q', stdout='Mkdir("{0}")\n'.format(test_dir_name)) -test.run(arguments='-Q -q', stdout='Mkdir("testdir")\n') +os.mkfifo(pipe_path) -os.mkfifo('testdir/namedpipe') +test.must_exist(test.workpath(pipe_path)) expect1 = """\ -Mkdir("testdir") -Path '%s' exists but isn't a file or directory. -scons: Could not remove 'testdir': Directory not empty -""" % os.path.join('testdir', 'namedpipe') +Mkdir("{0}") +Path '{1}' exists but isn't a file or directory. +scons: Could not remove '{0}': Directory not empty +""".format(test_dir_name, pipe_path) expect2 = """\ -Mkdir("testdir") -Path '%s' exists but isn't a file or directory. -scons: Could not remove 'testdir': File exists -""" % os.path.join('testdir', 'namedpipe') +Mkdir("{0}") +Path '{1}' exists but isn't a file or directory. +scons: Could not remove '{0}': File exists +""".format(test_dir_name, pipe_path) test.run(arguments='-c -Q -q') +test.must_exist(test.workpath(pipe_path)) + if test.stdout() not in [expect1, expect2]: test.diff(expect1, test.stdout(), 'STDOUT ') test.fail_test() - -test.must_exist(test.workpath('testdir/namedpipe')) test.pass_test() diff --git a/test/Climb/filename--D.py b/test/Climb/filename--D.py index 06d95e7..6fea9bc 100644 --- a/test/Climb/filename--D.py +++ b/test/Climb/filename--D.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.subdir('subdir', 'other') test.write('main.scons', """\ -print "main.scons" +print("main.scons") SConscript('subdir/sub.scons') """) test.write(['subdir', 'sub.scons'], """\ -print "subdir/sub.scons" +print("subdir/sub.scons") """) diff --git a/test/Climb/filename--U.py b/test/Climb/filename--U.py index 7f2e60d..49ccc0a 100644 --- a/test/Climb/filename--U.py +++ b/test/Climb/filename--U.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.subdir('subdir', 'other') test.write('main.scons', """\ -print "main.scons" +print("main.scons") SConscript('subdir/sub.scons') """) test.write(['subdir', 'sub.scons'], """\ -print "subdir/sub.scons" +print("subdir/sub.scons") """) read_str = """\ diff --git a/test/Climb/filename-u.py b/test/Climb/filename-u.py index 7bae153..4485c4b 100644 --- a/test/Climb/filename-u.py +++ b/test/Climb/filename-u.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.subdir('subdir', 'other') test.write('main.scons', """\ -print "main.scons" +print("main.scons") SConscript('subdir/sub.scons') """) test.write(['subdir', 'sub.scons'], """\ -print "subdir/sub.scons" +print("subdir/sub.scons") """) read_str = """\ diff --git a/test/Clone-compatibility.py b/test/Clone-compatibility.py index 089b7a4..a2f6362 100644 --- a/test/Clone-compatibility.py +++ b/test/Clone-compatibility.py @@ -48,8 +48,8 @@ except AttributeError: env1 = Environment(X = 1) env2 = env1.Clone(X = 2) -print env1['X'] -print env2['X'] +print(env1['X']) +print(env2['X']) """) test.run(arguments = '-q -Q', stdout = "1\n2\n") diff --git a/test/Configure/ConfigureDryRunError.py b/test/Configure/ConfigureDryRunError.py index b4be67e..fa85042 100644 --- a/test/Configure/ConfigureDryRunError.py +++ b/test/Configure/ConfigureDryRunError.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -97,7 +98,7 @@ test.checkLogAndStdout( ["Checking for C library %s... " % lib, newLog = test.read(test.workpath('config.log')) if newLog != oldLog: - print "Unexpected update of log file within a dry run" + print("Unexpected update of log file within a dry run") test.fail_test() test.pass_test() diff --git a/test/Configure/Streamer1.py b/test/Configure/Streamer1.py index 8f35308..318a936 100644 --- a/test/Configure/Streamer1.py +++ b/test/Configure/Streamer1.py @@ -45,7 +45,7 @@ test.write('SConstruct', """ def hello(target, source, env): import traceback try: - print 'hello!\\n' # this breaks the script + print('hello!\\n') # this breaks the script with open(env.subst('$TARGET', target = target),'w') as f: f.write('yes') except: diff --git a/test/Configure/cache-not-ok.py b/test/Configure/cache-not-ok.py index ccbb7d5..7502f7a 100644 --- a/test/Configure/cache-not-ok.py +++ b/test/Configure/cache-not-ok.py @@ -53,7 +53,7 @@ r1 = conf.CheckCHeader( 'no_std_c_header.h' ) # leads to compile error r2 = conf.CheckLib( 'no_c_library_SAFFDG' ) # leads to link error env = conf.Finish() if not (not r1 and not r2): - print "FAIL: ", r1, r2 + print("FAIL: ", r1, r2) Exit(1) """) diff --git a/test/Configure/config-h.py b/test/Configure/config-h.py index cda6c3b..ed95055 100644 --- a/test/Configure/config-h.py +++ b/test/Configure/config-h.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -135,19 +136,19 @@ test.run(stdout=expected_stdout) config_h = test.read(test.workpath('config.h')) if expected_config_h != config_h: - print "Unexpected config.h" - print "Expected: " - print "---------------------------------------------------------" - print repr(expected_config_h) - print "---------------------------------------------------------" - print "Found: " - print "---------------------------------------------------------" - print repr(config_h) - print "---------------------------------------------------------" - print "Stdio: " - print "---------------------------------------------------------" - print test.stdout() - print "---------------------------------------------------------" + print("Unexpected config.h") + print("Expected: ") + print("---------------------------------------------------------") + print(repr(expected_config_h)) + print("---------------------------------------------------------") + print("Found: ") + print("---------------------------------------------------------") + print(repr(config_h)) + print("---------------------------------------------------------") + print("Stdio: ") + print("---------------------------------------------------------") + print(test.stdout()) + print("---------------------------------------------------------") test.fail_test() expected_read_str = re.sub(r'\b((yes)|(no))\b', @@ -162,19 +163,19 @@ test.run(stdout=expected_stdout) config_h = test.read(test.workpath('config.h')) if expected_config_h != config_h: - print "Unexpected config.h" - print "Expected: " - print "---------------------------------------------------------" - print repr(expected_config_h) - print "---------------------------------------------------------" - print "Found: " - print "---------------------------------------------------------" - print repr(config_h) - print "---------------------------------------------------------" - print "Stdio: " - print "---------------------------------------------------------" - print test.stdout() - print "---------------------------------------------------------" + print("Unexpected config.h") + print("Expected: ") + print("---------------------------------------------------------") + print(repr(expected_config_h)) + print("---------------------------------------------------------") + print("Found: ") + print("---------------------------------------------------------") + print(repr(config_h)) + print("---------------------------------------------------------") + print("Stdio: ") + print("---------------------------------------------------------") + print(test.stdout()) + print("---------------------------------------------------------") test.fail_test() test.pass_test() diff --git a/test/Configure/implicit-cache.py b/test/Configure/implicit-cache.py index 0f04b1e..1a9ff34 100644 --- a/test/Configure/implicit-cache.py +++ b/test/Configure/implicit-cache.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -93,11 +94,11 @@ test.run_sconsign('-d .sconf_temp -e conftest_0.c --raw .sconsign.dblite') new_sconsign_dblite = test.stdout() if old_sconsign_dblite != new_sconsign_dblite: - print ".sconsign.dblite did not match:" - print "FIRST RUN ==========" - print old_sconsign_dblite - print "SECOND RUN ==========" - print new_sconsign_dblite + print(".sconsign.dblite did not match:") + print("FIRST RUN ==========") + print(old_sconsign_dblite) + print("SECOND RUN ==========") + print(new_sconsign_dblite) test.fail_test() test.pass_test() diff --git a/test/ConstructionEnvironment.py b/test/ConstructionEnvironment.py index bec46b9..e25f86a 100644 --- a/test/ConstructionEnvironment.py +++ b/test/ConstructionEnvironment.py @@ -38,7 +38,7 @@ import SCons.Defaults SCons.Defaults.ConstructionEnvironment.update({ 'XXX' : 777, }) -print DefaultEnvironment()['XXX'] +print(DefaultEnvironment()['XXX']) """) expect = test.wrap_stdout(read_str = "777\n", diff --git a/test/Copy-Action.py b/test/Copy-Action.py index 51635c5..ded158a 100644 --- a/test/Copy-Action.py +++ b/test/Copy-Action.py @@ -84,8 +84,8 @@ test.subdir('d5') test.write(['d5', 'f12.in'], "f12.in\n") test.write('f 13.in', "f 13.in\n") -os.chmod('f1.in', 0646) -os.chmod('f4.in', 0644) +os.chmod('f1.in', 0o646) +os.chmod('f4.in', 0o644) test.sleep() diff --git a/test/D/SharedObjects/Common/common.py b/test/D/SharedObjects/Common/common.py index e81cf5b..280c6f2 100644 --- a/test/D/SharedObjects/Common/common.py +++ b/test/D/SharedObjects/Common/common.py @@ -46,7 +46,7 @@ def testForTool(tool): test.skip_test("Required executable for tool '{0}' not found, skipping test.\n".format(tool)) if tool == 'gdc': - test.skip_test('gdc does not, as at version 4.9.1, support shared libraries.\n') + test.skip_test('gdc in GCC distribution does not, as at version 5.3.1, support shared libraries.\n') if tool == 'dmd' and Base()['DC'] == 'gdmd': test.skip_test('gdmd does not recognize the -shared option so cannot support linking of shared objects.\n') diff --git a/test/Deprecated/Options/BoolOption.py b/test/Deprecated/Options/BoolOption.py index 563939b..5d12fc6 100644 --- a/test/Deprecated/Options/BoolOption.py +++ b/test/Deprecated/Options/BoolOption.py @@ -55,8 +55,8 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/EnumOption.py b/test/Deprecated/Options/EnumOption.py index 57ae7eb..02afef1 100644 --- a/test/Deprecated/Options/EnumOption.py +++ b/test/Deprecated/Options/EnumOption.py @@ -43,6 +43,7 @@ def check(expect): test.write(SConstruct_path, """\ + from SCons.Options.EnumOption import EnumOption EO = EnumOption @@ -66,9 +67,9 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['debug'] -print env['guilib'] -print env['some'] +print(env['debug']) +print(env['guilib']) +print(env['some']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/ListOption.py b/test/Deprecated/Options/ListOption.py index bb3775b..42af511 100644 --- a/test/Deprecated/Options/ListOption.py +++ b/test/Deprecated/Options/ListOption.py @@ -67,15 +67,18 @@ env = Environment(options=opts) opts.Save(optsfile, env) Help(opts.GenerateHelpText(env)) -print env['shared'] -if 'ical' in env['shared']: print '1' -else: print '0' -for x in env['shared']: - print x, -print -print env.subst('$shared') +print(env['shared']) + +if 'ical' in env['shared']: + print('1') +else: + print('0') + +print(" ".join(env['shared'])) + +print(env.subst('$shared')) # Test subst_path() because it's used in $CPPDEFINES expansions. -print env.subst_path('$shared') +print(env.subst_path('$shared')) Default(env.Alias('dummy', None)) """) @@ -169,7 +172,7 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['gpib'] +print(env['gpib']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/Options.py b/test/Deprecated/Options/Options.py index 8116a63..e435b9e 100644 --- a/test/Deprecated/Options/Options.py +++ b/test/Deprecated/Options/Options.py @@ -30,8 +30,8 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """ env = Environment() -print env['CC'] -print " ".join(env['CCFLAGS']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) Default(env.Alias('dummy', None)) """) test.run() @@ -99,12 +99,12 @@ env = Environment(options=opts, tools=['default', test_tool]) Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env)) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['CC'] -print " ".join(env['CCFLAGS']) -print env['VALIDATE'] -print env['valid_key'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) +print(env['VALIDATE']) +print(env['valid_key']) # unspecified options should not be set: assert 'UNSPECIFIED' not in env @@ -226,8 +226,8 @@ opts.Add('UNSPECIFIED', env = Environment(options = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) opts.Save('options.saved', env) """) @@ -237,7 +237,7 @@ opts.Save('options.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec open(file, 'rU').read() in gdict, ldict + exec(open(file, 'rU').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line options @@ -282,9 +282,9 @@ opts.Add('LISTOPTION_TEST', env = Environment(options = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['LISTOPTION_TEST'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['LISTOPTION_TEST']) opts.Save('options.saved', env) """) diff --git a/test/Deprecated/Options/PackageOption.py b/test/Deprecated/Options/PackageOption.py index 424e5a7..ec8990c 100644 --- a/test/Deprecated/Options/PackageOption.py +++ b/test/Deprecated/Options/PackageOption.py @@ -59,7 +59,7 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['x11'] +print(env['x11']) Default(env.Alias('dummy', None)) """) diff --git a/test/Deprecated/Options/PathOption.py b/test/Deprecated/Options/PathOption.py index 4701420..0e6949c 100644 --- a/test/Deprecated/Options/PathOption.py +++ b/test/Deprecated/Options/PathOption.py @@ -25,7 +25,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ -Test the PathOption canned option type, with tests for its +Test the PathOption canned option type, with tests for its various canned validators. """ @@ -65,9 +65,9 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['qtdir'] -print env['qt_libraries'] -print env.subst('$qt_libraries') +print(env['qtdir']) +print(env['qt_libraries']) +print(env.subst('$qt_libraries')) Default(env.Alias('dummy', None)) """ % (workpath, os.path.join('$qtdir', 'lib') )) @@ -144,7 +144,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -177,7 +177,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_file) @@ -218,7 +218,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -263,7 +263,7 @@ opts.AddOptions( env = Environment(options=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) diff --git a/test/Deprecated/Options/chdir.py b/test/Deprecated/Options/chdir.py index a8fb6c6..977a351 100644 --- a/test/Deprecated/Options/chdir.py +++ b/test/Deprecated/Options/chdir.py @@ -46,7 +46,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", repr(env['VARIABLE']) +print("VARIABLE =", repr(env['VARIABLE'])) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/Deprecated/Options/help.py b/test/Deprecated/Options/help.py index 8c240e3..ad8a96b 100644 --- a/test/Deprecated/Options/help.py +++ b/test/Deprecated/Options/help.py @@ -49,7 +49,7 @@ libdirvar_re = re.escape(libdirvar) test.subdir(qtpath) test.subdir(libpath) - + test.write('SConstruct', """ from SCons.Options import BoolOption, EnumOption, ListOption, \ PackageOption, PathOption @@ -86,8 +86,8 @@ opts.AddOptions( env = Environment(options=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """ % locals()) diff --git a/test/Deprecated/Options/import.py b/test/Deprecated/Options/import.py index a4d56b2..b93e6a2 100644 --- a/test/Deprecated/Options/import.py +++ b/test/Deprecated/Options/import.py @@ -48,7 +48,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", env.get('VARIABLE') +print("VARIABLE =", env.get('VARIABLE')) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py index 3f0ffdd..04dfd9b 100644 --- a/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py +++ b/test/Deprecated/SourceCode/BitKeeper/BitKeeper.py @@ -20,6 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -67,7 +68,7 @@ test.subdir('BK', 'import', ['import', 'sub']) # Test using BitKeeper to fetch from SCCS/s.file files. sccs = test.where_is('sccs') if not sccs: - print "Could not find SCCS, skipping sub-test of BitKeeper using SCCS files." + print("Could not find SCCS, skipping sub-test of BitKeeper using SCCS files.") else: test.subdir('work1', ['work1', 'SCCS'], @@ -167,9 +168,9 @@ sub/fff.in 1.1 -> 1.2: 1 lines 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." + print("Could not find RCS,\nskipping sub-test of BitKeeper using RCS files.") elif not ci: - print "Could not find the RCS ci command,\nskipping sub-test of BitKeeper using RCS files." + print("Could not find the RCS ci command,\nskipping sub-test of BitKeeper using RCS files.") else: test.subdir('work2', ['work2', 'RCS'], diff --git a/test/Deprecated/SourceCode/Subversion.py b/test/Deprecated/SourceCode/Subversion.py index 1e7c562..7ed4b15 100644 --- a/test/Deprecated/SourceCode/Subversion.py +++ b/test/Deprecated/SourceCode/Subversion.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -50,7 +51,7 @@ svnadmin = test.where_is('svnadmin') if not svn: test.skip_test("Could not find 'svnadmin'; skipping test(s).\n") -print "Short-circuiting this test until we support Subversion" +print("Short-circuiting this test until we support Subversion") test.pass_test() test.subdir('Subversion', 'import', ['import', 'sub'], 'work1', 'work2') diff --git a/test/Dir/Dir.py b/test/Dir/Dir.py index af0a10b..2e8204c 100644 --- a/test/Dir/Dir.py +++ b/test/Dir/Dir.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(FOO = 'fff', BAR = 'bbb') -print Dir('ddd') -print Dir('$FOO') -print Dir('${BAR}_$BAR') -print env.Dir('eee') -print env.Dir('$FOO') -print env.Dir('${BAR}_$BAR') +print(Dir('ddd')) +print(Dir('$FOO')) +print(Dir('${BAR}_$BAR')) +print(env.Dir('eee')) +print(env.Dir('$FOO')) +print(env.Dir('${BAR}_$BAR')) """) test.run(stdout = test.wrap_stdout(read_str = """\ diff --git a/test/Entry.py b/test/Entry.py index 3767cc5..3d3255d 100644 --- a/test/Entry.py +++ b/test/Entry.py @@ -36,12 +36,12 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(FOO = 'fff', BAR = 'bbb') -print Entry('ddd') -print Entry('$FOO') -print Entry('${BAR}_$BAR') -print env.Entry('eee') -print env.Entry('$FOO') -print env.Entry('${BAR}_$BAR') +print(Entry('ddd')) +print(Entry('$FOO')) +print(Entry('${BAR}_$BAR')) +print(env.Entry('eee')) +print(env.Entry('$FOO')) +print(env.Entry('${BAR}_$BAR')) """) test.run(stdout = test.wrap_stdout(read_str = """\ diff --git a/test/Environment.py b/test/Environment.py index 52b6488..6810979 100644 --- a/test/Environment.py +++ b/test/Environment.py @@ -42,8 +42,8 @@ assert Dir('.') == Dir('.').Dir('.') assert target == target.File('foo.out') e2 = env.Environment(XXX='$BAR', YYY='$BLAT') -print e2['XXX'] -print e2['YYY'] +print(e2['XXX']) +print(e2['YYY']) """ % locals()) test.write('build.py', """ diff --git a/test/Errors/Exception.py b/test/Errors/Exception.py index cc36035..30404fc 100644 --- a/test/Errors/Exception.py +++ b/test/Errors/Exception.py @@ -30,7 +30,7 @@ test = TestSCons.TestSCons(match = TestSCons.match_re_dotall) test.write('SConstruct', """\ def foo(env, target, source): - print str(target[0]) + print(str(target[0])) open(str(target[0]), 'wt').write('foo') def exit(env, target, source): diff --git a/test/ExecuteInvalidateCache.py b/test/ExecuteInvalidateCache.py index a22c5ea..6d8063e 100644 --- a/test/ExecuteInvalidateCache.py +++ b/test/ExecuteInvalidateCache.py @@ -40,9 +40,9 @@ subfn = os.path.join('sub', 'foo') test.write('SConstruct', """\ def exists(node): if node.exists(): - print str(node), "exists" + print(str(node), "exists") else: - print str(node), "does not exist" + print(str(node), "does not exist") Execute(Delete('abc')) n1 = File('abc') diff --git a/test/Exit.py b/test/Exit.py index 877a0b6..394ee2f 100644 --- a/test/Exit.py +++ b/test/Exit.py @@ -40,7 +40,7 @@ subdir_foo_in = os.path.join('subdir', 'foo.in') subdir_foo_out = os.path.join('subdir', 'foo.out') test.write('SConstruct', """\ -print "SConstruct, Exit()" +print("SConstruct, Exit()") Exit() """) @@ -51,7 +51,7 @@ SConstruct, Exit() test.write('SConstruct', """\ env = Environment() -print "SConstruct, env.Exit()" +print("SConstruct, env.Exit()") env.Exit() """) @@ -61,7 +61,7 @@ SConstruct, env.Exit() """) test.write('SConstruct', """\ -print "SConstruct" +print("SConstruct") Exit(7) """) @@ -71,12 +71,12 @@ SConstruct """) test.write('SConstruct', """\ -print "SConstruct" +print("SConstruct") SConscript('subdir/SConscript') """) test.write(['subdir', 'SConscript'], """\ -print "subdir/SConscript" +print("subdir/SConscript") Exit() """) @@ -87,7 +87,7 @@ subdir/SConscript """) test.write(['subdir', 'SConscript'], """\ -print "subdir/SConscript" +print("subdir/SConscript") Exit(17) """) diff --git a/test/File.py b/test/File.py index d919884..ec148b2 100644 --- a/test/File.py +++ b/test/File.py @@ -38,16 +38,16 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(FOO = 'fff', BAR = 'bbb') -print File('ddd') -print File('$FOO') -print File('${BAR}_$BAR') -print env.File('eee') -print env.File('$FOO') -print env.File('${BAR}_$BAR') +print(File('ddd')) +print(File('$FOO')) +print(File('${BAR}_$BAR')) +print(env.File('eee')) +print(env.File('$FOO')) +print(env.File('${BAR}_$BAR')) f1 = env.File('f1') -print f1 +print(f1) f2 = f1.File('f2') -print f2 +print(f2) """) expect = test.wrap_stdout(read_str = """\ diff --git a/test/FindFile.py b/test/FindFile.py index 5d198ac..e878172 100644 --- a/test/FindFile.py +++ b/test/FindFile.py @@ -40,13 +40,13 @@ test.write(['bar', 'baz', 'testfile2'], 'test 4\n') test.write('SConstruct', """ env = Environment(FILE = 'file', BAR = 'bar') file1 = FindFile('testfile1', [ 'foo', '.', 'bar', 'bar/baz' ]) -print open(str(file1), 'r').read() +print(open(str(file1), 'r').read()) file2 = env.FindFile('test${FILE}1', [ 'bar', 'foo', '.', 'bar/baz' ]) -print open(str(file2), 'r').read() +print(open(str(file2), 'r').read()) file3 = FindFile('testfile2', [ 'foo', '.', 'bar', 'bar/baz' ]) -print open(str(file3), 'r').read() +print(open(str(file3), 'r').read()) file4 = env.FindFile('testfile2', [ '$BAR/baz', 'foo', '.', 'bar' ]) -print open(str(file4), 'r').read() +print(open(str(file4), 'r').read()) """) expect = test.wrap_stdout(read_str = """test 1 diff --git a/test/Flatten.py b/test/Flatten.py index b41c4fe..fd9943d 100644 --- a/test/Flatten.py +++ b/test/Flatten.py @@ -44,15 +44,15 @@ def cat(env, source, target): env = Environment(BUILDERS={'Cat':Builder(action=cat)}) f1 = env.Cat('../file1.out', 'file1.in') f2 = env.Cat('../file2.out', ['file2a.in', 'file2b.in']) -print list(map(str, Flatten(['begin', f1, 'middle', f2, 'end']))) -print list(map(str, env.Flatten([f1, [['a', 'b'], 'c'], f2]))) +print(list(map(str, Flatten(['begin', f1, 'middle', f2, 'end'])))) +print(list(map(str, env.Flatten([f1, [['a', 'b'], 'c'], f2])))) SConscript('SConscript', "env") """) test.write(['work', 'SConscript'], """ Import("env") -print Flatten([1, [2, 3], 4]) -print env.Flatten([[[[1], 2], 3], 4]) +print(Flatten([1, [2, 3], 4])) +print(env.Flatten([[[[1], 2], 3], 4])) """) test.write('file1.in', "file1.in\n") diff --git a/test/Fortran/F77FLAGS.py b/test/Fortran/F77FLAGS.py index b708f9e..342adac 100644 --- a/test/Fortran/F77FLAGS.py +++ b/test/Fortran/F77FLAGS.py @@ -77,6 +77,9 @@ g77 = test.detect_tool(fc) if g77: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -87,7 +90,7 @@ os.system(" ".join(sys.argv[1:])) test.write('SConstruct', """ foo = Environment(F77 = '%(fc)s', tools = ['default', 'f77'], F77FILESUFFIXES = [".f"]) f77 = foo.Dictionary('F77') -bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77, F77FLAGS = '-Ix') +bar = foo.Clone(F77 = r'%(_python_)s wrapper.py ' + f77, F77FLAGS = '-I%(directory)s') foo.Program(target = 'foo', source = 'foo.f') bar.Program(target = 'bar', source = 'bar.f') """ % locals()) diff --git a/test/Fortran/FORTRANFLAGS.py b/test/Fortran/FORTRANFLAGS.py index 8c5e781..150000a 100644 --- a/test/Fortran/FORTRANFLAGS.py +++ b/test/Fortran/FORTRANFLAGS.py @@ -95,6 +95,9 @@ g77 = test.detect_tool(fc) if g77: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -105,7 +108,7 @@ os.system(" ".join(sys.argv[1:])) test.write('SConstruct', """ foo = Environment(FORTRAN = '%(fc)s') f77 = foo.Dictionary('FORTRAN') -bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77, FORTRANFLAGS = '-Ix') +bar = foo.Clone(FORTRAN = r'%(_python_)s wrapper.py ' + f77, FORTRANFLAGS = '-I%(directory)s') foo.Program(target = 'foo', source = 'foo.f') bar.Program(target = 'bar', source = 'bar.f') """ % locals()) diff --git a/test/Fortran/SHF77FLAGS.py b/test/Fortran/SHF77FLAGS.py index 644b827..79e46f3 100644 --- a/test/Fortran/SHF77FLAGS.py +++ b/test/Fortran/SHF77FLAGS.py @@ -75,6 +75,9 @@ g77 = test.detect_tool(fc) if g77: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -87,7 +90,7 @@ foo = Environment(SHF77 = '%(fc)s') shf77 = foo.Dictionary('SHF77') bar = foo.Clone(SHF77 = r'%(_python_)s wrapper.py ' + shf77, tools = ["default", 'f77'], F77FILESUFFIXES = [".f"]) -bar.Append(SHF77FLAGS = '-Ix') +bar.Append(SHF77FLAGS = '-I%(directory)s') foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') """ % locals()) diff --git a/test/Fortran/SHFORTRANFLAGS.py b/test/Fortran/SHFORTRANFLAGS.py index 11116f4..8e6f019 100644 --- a/test/Fortran/SHFORTRANFLAGS.py +++ b/test/Fortran/SHFORTRANFLAGS.py @@ -91,6 +91,9 @@ fortran = test.detect_tool(fc) if fortran: + directory = 'x' + test.subdir(directory) + test.write("wrapper.py", """import os import sys @@ -102,7 +105,7 @@ os.system(" ".join(sys.argv[1:])) foo = Environment(SHFORTRAN = '%(fc)s') shfortran = foo.Dictionary('SHFORTRAN') bar = foo.Clone(SHFORTRAN = r'%(_python_)s wrapper.py ' + shfortran) -bar.Append(SHFORTRANFLAGS = '-Ix') +bar.Append(SHFORTRANFLAGS = '-I%(directory)s') foo.SharedLibrary(target = 'foo/foo', source = 'foo.f') bar.SharedLibrary(target = 'bar/bar', source = 'bar.f') """ % locals()) diff --git a/test/GetBuildFailures/option-k.py b/test/GetBuildFailures/option-k.py index b4e8d54..0ff22e6 100644 --- a/test/GetBuildFailures/option-k.py +++ b/test/GetBuildFailures/option-k.py @@ -65,7 +65,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures for bf in sorted(GetBuildFailures(), key=lambda a: a.filename): - print "%%s failed: %%s" %% (bf.node, bf.errstr) + print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit atexit.register(print_build_failures) diff --git a/test/GetBuildFailures/parallel.py b/test/GetBuildFailures/parallel.py index b7576af..ee0e831 100644 --- a/test/GetBuildFailures/parallel.py +++ b/test/GetBuildFailures/parallel.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ Verify that a failed build action with -j works as expected. @@ -80,7 +81,7 @@ Command('f6', 'f6.in', r'@%(_python_)s mypass.py f5 - $TARGET $SOURCE') def print_build_failures(): from SCons.Script import GetBuildFailures for bf in sorted(GetBuildFailures(), key=lambda t: t.filename): - print "%%s failed: %%s" %% (bf.node, bf.errstr) + print("%%s failed: %%s" %% (bf.node, bf.errstr)) import atexit atexit.register(print_build_failures) @@ -95,15 +96,15 @@ test.run(arguments = '-Q -j 4 .', status = 2, stderr = None) -f4_error = "scons: *** [f4] Error 1\n" +f4_error = "scons: *** [f4] Error 1\n" f5_error = "scons: *** [f5] Error 1\n" error_45 = f4_error + f5_error error_54 = f5_error + f4_error if test.stderr() not in [error_45, error_54]: - print "Did not find the following output in list of expected strings:" - print test.stderr(), + print("Did not find the following output in list of expected strings:") + print(test.stderr(), end=' ') test.fail_test() # We jump through hoops above to try to make sure that the individual @@ -121,14 +122,14 @@ failed_45 = f4_failed + f5_failed failed_54 = f5_failed + f4_failed if test.stdout() not in [failed_45, failed_54]: - print "Did not find the following output in list of expected strings:" - print test.stdout(), + print("Did not find the following output in list of expected strings:") + print(test.stdout(), end=' ') test.fail_test() test.must_match(test.workpath('f3'), 'f3.in\n') test.must_not_exist(test.workpath('f4')) test.must_not_exist(test.workpath('f5')) -test.must_match(test.workpath('f6'), 'f6.in\n') +test.must_match(test.workpath('f6'), 'f6.in\n') diff --git a/test/GetBuildFailures/serial.py b/test/GetBuildFailures/serial.py index 9c56bb1..55a990f 100644 --- a/test/GetBuildFailures/serial.py +++ b/test/GetBuildFailures/serial.py @@ -82,8 +82,8 @@ Command('f08', 'f08.in', raiseExcAction(SCons.Errors.UserError("My User Error")) Command('f09', 'f09.in', returnExcAction(SCons.Errors.UserError("My User Error"))) Command('f10', 'f10.in', raiseExcAction(MyBuildError(errstr="My Build Error", status=7))) Command('f11', 'f11.in', returnExcAction(MyBuildError(errstr="My Build Error", status=7))) -Command('f12', 'f12.in', raiseExcAction(EnvironmentError(123, "My EnvironmentError", "f12"))) -Command('f13', 'f13.in', returnExcAction(EnvironmentError(123, "My EnvironmentError", "f13"))) +Command('f12', 'f12.in', raiseExcAction(OSError(123, "My EnvironmentError", "f12"))) +Command('f13', 'f13.in', returnExcAction(OSError(123, "My EnvironmentError", "f13"))) Command('f14', 'f14.in', raiseExcAction(SCons.Errors.InternalError("My InternalError"))) Command('f15', 'f15.in', returnExcAction(SCons.Errors.InternalError("My InternalError"))) @@ -91,9 +91,9 @@ def print_build_failures(): from SCons.Script import GetBuildFailures for bf in sorted(GetBuildFailures(), key=lambda t: str(t.node)): assert( isinstance(bf, SCons.Errors.BuildError) ) - print "BF: %%s failed (%%s): %%s" %% (bf.node, bf.status, bf.errstr) + print("BF: %%s failed (%%s): %%s" %% (bf.node, bf.status, bf.errstr)) if bf.command: - print "BF: %%s" %% " ".join(Flatten(bf.command)) + print("BF: %%s" %% " ".join(Flatten(bf.command))) import atexit atexit.register(print_build_failures) diff --git a/test/GetOption/help.py b/test/GetOption/help.py index e2eeef7..4f15fe6 100644 --- a/test/GetOption/help.py +++ b/test/GetOption/help.py @@ -34,9 +34,9 @@ test = TestSCons.TestSCons() test.write('SConstruct', """\ if GetOption('help'): - print "GetOption('help') set" + print("GetOption('help') set") else: - print "no help for you" + print("no help for you") """) test.run(arguments = '-q -Q', stdout = "no help for you\n") diff --git a/test/Glob/glob-libpath.py b/test/Glob/glob-libpath.py index b09aab9..0878090 100644 --- a/test/Glob/glob-libpath.py +++ b/test/Glob/glob-libpath.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -77,10 +78,10 @@ test.write(['src', 'util', 'util.cpp'], """int i=0; test.run(arguments = '-Q .') if not test.match_re_dotall(test.stdout(), r".*(-L|/LIBPATH:)build[/\\]util.*"): - print repr(test.stdout())+" should contain -Lbuild/util or /LIBPATH:build\\util" + print(repr(test.stdout())+" should contain -Lbuild/util or /LIBPATH:build\\util") test.fail_test() if test.match_re_dotall(test.stdout(), r".*(-L|/LIBPATH:)src[/\\]util.*"): - print repr(test.stdout())+" should not contain -Lsrc/util or /LIBPATH:src\\util" + print(repr(test.stdout())+" should not contain -Lsrc/util or /LIBPATH:src\\util") test.fail_test() test.pass_test() diff --git a/test/Install/Install.py b/test/Install/Install.py index adadfd9..d66660b 100644 --- a/test/Install/Install.py +++ b/test/Install/Install.py @@ -129,7 +129,7 @@ test.must_match(['work', 'f2.out'], "f2.in\n") # if a target can not be unlinked before building it: test.write(['work', 'f1.in'], "f1.in again again\n") -os.chmod(test.workpath('work', 'export'), 0555) +os.chmod(test.workpath('work', 'export'), 0o555) f = open(f1_out, 'rb') diff --git a/test/Interactive/version.py b/test/Interactive/version.py index 96ce51e..d0f362a 100644 --- a/test/Interactive/version.py +++ b/test/Interactive/version.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ @@ -72,7 +73,7 @@ expect2 = r"""scons>>> SCons by Steven Knight et al\.: stdout = test.stdout() + '\n' if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): - print repr(stdout) + print(repr(stdout)) test.fail_test() diff --git a/test/Java/multi-step.py b/test/Java/multi-step.py index 160c523..b43d641 100644 --- a/test/Java/multi-step.py +++ b/test/Java/multi-step.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -564,7 +565,7 @@ test.must_exist(['buildout', 'jni', 'SampleTest.java']) # it doesn't exist. p = test.workpath('buildout', 'jni', 'SampleTest.class') if not os.path.exists(p): - print 'Warning: %s does not exist' % p + print('Warning: %s does not exist' % p) test.up_to_date(arguments = '.') diff --git a/test/LINK/VersionedLib.py b/test/LINK/VersionedLib.py index 3f4a912..468e3e5 100644 --- a/test/LINK/VersionedLib.py +++ b/test/LINK/VersionedLib.py @@ -1,286 +1,288 @@ -#!/usr/bin/env python
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-import os
-import sys
-import TestSCons
-
-import SCons.Platform
-import SCons.Defaults
-
-env = SCons.Defaults.DefaultEnvironment()
-platform = SCons.Platform.platform_default()
-tool_list = SCons.Platform.DefaultToolList(platform, env)
-
-if 'gnulink' in tool_list:
- test_plan = [
- {
- 'libversion' : '2',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
- },
- {
- 'libversion' : '2.5',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
- },
- {
- 'libversion' : '2.5.4',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
- },
- {
- 'libversion' : '2.5.4.7.8',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
- },
- {
- 'libversion' : 'aabf114f',
- 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
- },
- {
- 'libversion' : '2.dfffa11',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
- },
- ]
-elif 'applelink' in tool_list:
- # All (?) the files we expect will get created in the current directory
- test_plan = [
- {
- 'libversion' : '2.5.4',
- 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ],
- 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ],
- 'symlinks' : [],
- },
- ]
-elif 'cyglink' in tool_list:
- test_plan = [
- {
- 'libversion' : '2',
- 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ],
- 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ],
- 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ],
- },
- {
- 'libversion' : '2.5',
- 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ],
- 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ],
- 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ],
- },
- {
- 'libversion' : '2.5.4',
- 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ],
- 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ],
- 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ],
- },
- {
- 'libversion' : '2.5.4.7.8',
- 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ],
- 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ],
- 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ],
- },
- {
- 'libversion' : 'aabf114f',
- 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ],
- 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ],
- 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ],
- },
- {
- 'libversion' : '2.dfffa11',
- 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ],
- 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ],
- 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ],
- },
- ]
-elif 'mslink' in tool_list:
- test_plan = [
- {
- 'libversion' : '2.5.4',
- 'files' : [ 'test.dll', 'test.lib', 'test.obj' ],
- 'instfiles' : [ 'test.dll', 'test.lib' ],
- 'symlinks' : [],
- },
- ]
-elif 'sunlink' in tool_list:
- test_plan = [
- {
- 'libversion' : '2',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2') ],
- },
- {
- 'libversion' : '2.5',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ],
- },
- {
- 'libversion' : '2.5.4',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ],
- },
- {
- 'libversion' : '2.5.4.7.8',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ],
- },
- {
- 'libversion' : 'aabf114f',
- 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ],
- },
- {
- 'libversion' : '2.dfffa11',
- 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ],
- 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ],
- 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ],
- },
- ]
-else:
- test_plan = [
- {
- 'libversion' : '2.5.4',
- 'files' : [ 'libtest.so', 'test.os' ],
- 'instfiles' : [ ],
- },
- ]
-
-test_c_src = """\
-#if _WIN32
-__declspec(dllexport)
-#endif
-int testlib(int n) { return n+1 ; }
-"""
-
-test_c_src2 = """\
-#if _WIN32
-__declspec(dllexport)
-#endif
-int testlib(int n) { return n+11 ; }
-"""
-
-testapp_c_src = """\
-#if _WIN32
-__declspec(dllimport)
-#endif
-int testlib(int n);
-#include <stdio.h>
-int main(int argc, char **argv)
-{
-int itest ;
-
-itest = testlib(2) ;
-printf("results: testlib(2) = %d\\n",itest) ;
-return 0 ;
-}
-"""
-
-for t in test_plan:
-
- test = TestSCons.TestSCons()
-
- libversion = t['libversion']
- files = t['files']
- symlinks = t['symlinks']
- instfiles = t['instfiles']
-
- test.write('SConstruct', """\
-import os
-env = Environment()
-objs = env.SharedObject('test.c')
-mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s')
-env.Program('testapp1.c', LIBS = mylib, LIBPATH='.')
-env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.')
-instnode = env.InstallVersionedLib("#/installtest",mylib)
-env.Default(instnode)
-
-# Extra test to ensure that InstallVersionedLib can be called from the DefaultEnvironment
-# Ensures orthogonality where InstallVersionedLib wasn't previously available: SCons gave NameError.
-instnode = InstallVersionedLib("defaultenv-installtest",mylib)
-Default(instnode)
-
-""" % libversion)
-
- test.write('test.c', test_c_src)
- test.write('testapp1.c', testapp_c_src)
- test.write('testapp2.c', testapp_c_src)
-
- test.run(arguments = ['--tree=all'])
-
- for f in files:
- test.must_exist([ f])
- for f in instfiles:
- test.must_exist(['installtest', f])
- test.must_exist(['defaultenv-installtest', f])
-
- wrong_symlinks = []
- for (linkname,expected) in symlinks:
- try:
- endpoint = os.readlink(linkname)
- except OSError, err:
- print "%s (expected symlink %r -> %r)" % (err, linkname, expected)
- wrong_symlinks.append(linkname)
- else:
- if endpoint != expected:
- print "Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname, endpoint, linkname, expected)
- wrong_symlinks.append(linkname)
-
- if wrong_symlinks:
- test.fail_test(wrong_symlinks)
-
- # modify test.c and make sure it can recompile when links already exist
- test.write('test.c', test_c_src2)
-
- test.run()
-
- test.run(arguments = ['-c'])
-
- for f in files:
- test.must_not_exist([ f])
-
- for f in instfiles:
- test.must_not_exist(['installtest', f])
- test.must_not_exist(['defaultenv-installtest', f])
-
-test.pass_test()
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
+#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +from __future__ import print_function + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import sys +import TestSCons + +import SCons.Platform +import SCons.Defaults + +env = SCons.Defaults.DefaultEnvironment() +platform = SCons.Platform.platform_default() +tool_list = SCons.Platform.DefaultToolList(platform, env) + +if 'gnulink' in tool_list: + test_plan = [ + { + 'libversion' : '2', + 'files' : [ 'libtest.so', 'libtest.so.2', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], + }, + { + 'libversion' : '2.5', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], + }, + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], + }, + { + 'libversion' : '2.5.4.7.8', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], + }, + { + 'libversion' : 'aabf114f', + 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], + }, + { + 'libversion' : '2.dfffa11', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], + }, + ] +elif 'applelink' in tool_list: + # All (?) the files we expect will get created in the current directory + test_plan = [ + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.dylib', 'libtest.2.5.4.dylib', 'test.os' ], + 'instfiles' : [ 'libtest.dylib', 'libtest.2.5.4.dylib' ], + 'symlinks' : [], + }, + ] +elif 'cyglink' in tool_list: + test_plan = [ + { + 'libversion' : '2', + 'files' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2.dll', 'libtest-2.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2.dll.a') ], + }, + { + 'libversion' : '2.5', + 'files' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-5.dll', 'libtest-2-5.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5.dll.a') ], + }, + { + 'libversion' : '2.5.4', + 'files' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-5-4.dll', 'libtest-2-5-4.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4.dll.a') ], + }, + { + 'libversion' : '2.5.4.7.8', + 'files' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-5-4-7-8.dll', 'libtest-2-5-4-7-8.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-5-4-7-8.dll.a') ], + }, + { + 'libversion' : 'aabf114f', + 'files' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-aabf114f.dll', 'libtest-aabf114f.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-aabf114f.dll.a') ], + }, + { + 'libversion' : '2.dfffa11', + 'files' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a', 'test.os' ], + 'instfiles' : [ 'cygtest-2-dfffa11.dll', 'libtest-2-dfffa11.dll.a', 'libtest.dll.a' ], + 'symlinks' : [ ('libtest.dll.a', 'libtest-2-dfffa11.dll.a') ], + }, + ] +elif 'mslink' in tool_list: + test_plan = [ + { + 'libversion' : '2.5.4', + 'files' : [ 'test.dll', 'test.lib', 'test.obj' ], + 'instfiles' : [ 'test.dll', 'test.lib' ], + 'symlinks' : [], + }, + ] +elif 'sunlink' in tool_list: + test_plan = [ + { + 'libversion' : '2', + 'files' : [ 'libtest.so', 'libtest.so.2', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2') ], + }, + { + 'libversion' : '2.5', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5'), ('libtest.so.2', 'libtest.so.2.5') ], + }, + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4'), ('libtest.so.2', 'libtest.so.2.5.4') ], + }, + { + 'libversion' : '2.5.4.7.8', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.5.4.7.8' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.5.4.7.8'), ('libtest.so.2', 'libtest.so.2.5.4.7.8') ], + }, + { + 'libversion' : 'aabf114f', + 'files' : [ 'libtest.so', 'libtest.so.aabf114f', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.aabf114f' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.aabf114f') ], + }, + { + 'libversion' : '2.dfffa11', + 'files' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11', 'so_test.os' ], + 'instfiles' : [ 'libtest.so', 'libtest.so.2', 'libtest.so.2.dfffa11' ], + 'symlinks' : [ ('libtest.so', 'libtest.so.2.dfffa11'), ('libtest.so.2', 'libtest.so.2.dfffa11') ], + }, + ] +else: + test_plan = [ + { + 'libversion' : '2.5.4', + 'files' : [ 'libtest.so', 'test.os' ], + 'instfiles' : [ ], + }, + ] + +test_c_src = """\ +#if _WIN32 +__declspec(dllexport) +#endif +int testlib(int n) { return n+1 ; } +""" + +test_c_src2 = """\ +#if _WIN32 +__declspec(dllexport) +#endif +int testlib(int n) { return n+11 ; } +""" + +testapp_c_src = """\ +#if _WIN32 +__declspec(dllimport) +#endif +int testlib(int n); +#include <stdio.h> +int main(int argc, char **argv) +{ +int itest ; + +itest = testlib(2) ; +printf("results: testlib(2) = %d\\n",itest) ; +return 0 ; +} +""" + +for t in test_plan: + + test = TestSCons.TestSCons() + + libversion = t['libversion'] + files = t['files'] + symlinks = t['symlinks'] + instfiles = t['instfiles'] + + test.write('SConstruct', """\ +import os +env = Environment() +objs = env.SharedObject('test.c') +mylib = env.SharedLibrary('test', objs, SHLIBVERSION = '%s') +env.Program('testapp1.c', LIBS = mylib, LIBPATH='.') +env.Program('testapp2.c', LIBS = ['test'], LIBPATH='.') +instnode = env.InstallVersionedLib("#/installtest",mylib) +env.Default(instnode) + +# Extra test to ensure that InstallVersionedLib can be called from the DefaultEnvironment +# Ensures orthogonality where InstallVersionedLib wasn't previously available: SCons gave NameError. +instnode = InstallVersionedLib("defaultenv-installtest",mylib) +Default(instnode) + +""" % libversion) + + test.write('test.c', test_c_src) + test.write('testapp1.c', testapp_c_src) + test.write('testapp2.c', testapp_c_src) + + test.run(arguments = ['--tree=all']) + + for f in files: + test.must_exist([ f]) + for f in instfiles: + test.must_exist(['installtest', f]) + test.must_exist(['defaultenv-installtest', f]) + + wrong_symlinks = [] + for (linkname,expected) in symlinks: + try: + endpoint = os.readlink(linkname) + except OSError as err: + print("%s (expected symlink %r -> %r)" % (err, linkname, expected)) + wrong_symlinks.append(linkname) + else: + if endpoint != expected: + print("Wrong symlink: %r -> %r (expected symlink: %r -> %r)" % (linkname, endpoint, linkname, expected)) + wrong_symlinks.append(linkname) + + if wrong_symlinks: + test.fail_test(wrong_symlinks) + + # modify test.c and make sure it can recompile when links already exist + test.write('test.c', test_c_src2) + + test.run() + + test.run(arguments = ['-c']) + + for f in files: + test.must_not_exist([ f]) + + for f in instfiles: + test.must_not_exist(['installtest', f]) + test.must_not_exist(['defaultenv-installtest', f]) + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/Libs/SharedLibraryIxes.py b/test/Libs/SharedLibraryIxes.py index 6924769..93d67ea 100644 --- a/test/Libs/SharedLibraryIxes.py +++ b/test/Libs/SharedLibraryIxes.py @@ -102,7 +102,7 @@ def nameInLib(source, lib, libname): # When using non-standard prefixes and suffixes, one has to # provide the full name of the library since scons can not know # which of the non-standard extension to use. - # + # # Note that this is not necessarily SHLIBPREFIX and # SHLIBSUFFIX. These are the ixes of the target library, not the # ixes of the library that we are linking against. @@ -130,7 +130,7 @@ def buildAndlinkAgainst(builder, target, source, method, lib, libname, **kw): # for the linker command line... if (isMingw or isCygwin) and len(lib) > 1: lib = lib[1:] - + # Apply the naming method to be tested and call the specified Builder. (source, LIBS) = method(source, lib, libname) #build = builder(target=target, source=source, LIBS=LIBS, **kw) @@ -153,8 +153,8 @@ def buildAndlinkAgainst(builder, target, source, method, lib, libname, **kw): (list(map(str,lib)), list(map(str, build[0].children())), method.__name__, libname, shlibsuffix) return build -def prog(i, - goomethod, goolibprefix, goolibsuffix, +def prog(i, + goomethod, goolibprefix, goolibsuffix, foomethod, foolibprefix, foolibsuffix): '''Build a program @@ -166,7 +166,7 @@ def prog(i, foo_name = foolibprefix+'foo'+str(i)+foolibsuffix prog_name = progprefix+'prog'+str(i)+progsuffix - print 'Prog: %d, %s, %s, %s' % (i, goo_name, foo_name, prog_name) + print('Prog: %d, %s, %s, %s' % (i, goo_name, foo_name, prog_name)) # On Windows, we have to link against the .lib file. if isWindows: @@ -179,7 +179,7 @@ def prog(i, goo_lib = env.SharedLibrary( goo_name, goo_obj, SHLIBSUFFIX=goolibsuffix) foo_lib = buildAndlinkAgainst( - env.SharedLibrary, foo_name, foo_obj, + env.SharedLibrary, foo_name, foo_obj, goomethod, goo_lib, goo_libname, SHLIBSUFFIX=foolibsuffix) prog = buildAndlinkAgainst(env.Program, prog_name, prog_obj, foomethod, foo_lib, foo_libname) @@ -199,8 +199,8 @@ for foolibprefix in prefixes: for goolibsuffix in suffixes: for goomethod in libmethods: tests.append( - (i, - goomethod, goolibprefix, goolibsuffix, + (i, + goomethod, goolibprefix, goolibsuffix, foomethod, foolibprefix, foolibsuffix)) i = i + 1 diff --git a/test/MSVC/batch-longlines.py b/test/MSVC/batch-longlines.py index ef7233b..c584aba 100644 --- a/test/MSVC/batch-longlines.py +++ b/test/MSVC/batch-longlines.py @@ -1,61 +1,61 @@ -#!/usr/bin/env python
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-"""
-Verify operation of Visual C/C++ batch builds with long lines.
-
-Only runs on Windows.
-"""
-
-import TestSCons
-
-test = TestSCons.TestSCons()
-
-test.skip_if_not_msvc()
-
-_python_ = TestSCons._python_
-
-for i in xrange(1,200):
- test.write('source-file-with-quite-a-long-name-maybe-unrealistic-but-who-cares-%05d.cxx'%i,
- '/* source file %d */\nint var%d;\n'%(i,i))
-
-test.write('SConstruct', """
-env = Environment(tools=['msvc', 'mslink'],
- MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH'))
-env.SharedLibrary('mylib', Glob('source*.cxx'))
-""" % locals())
-
-test.run(arguments = 'MSVC_BATCH=1 .')
-
-test.must_exist('mylib.dll')
-
-test.pass_test()
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
+#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +""" +Verify operation of Visual C/C++ batch builds with long lines. + +Only runs on Windows. +""" + +import TestSCons + +test = TestSCons.TestSCons() + +test.skip_if_not_msvc() + +_python_ = TestSCons._python_ + +for i in range(1,200): + test.write('source-file-with-quite-a-long-name-maybe-unrealistic-but-who-cares-%05d.cxx'%i, + '/* source file %d */\nint var%d;\n'%(i,i)) + +test.write('SConstruct', """ +env = Environment(tools=['msvc', 'mslink'], + MSVC_BATCH=ARGUMENTS.get('MSVC_BATCH')) +env.SharedLibrary('mylib', Glob('source*.cxx')) +""" % locals()) + +test.run(arguments = 'MSVC_BATCH=1 .') + +test.must_exist('mylib.dll') + +test.pass_test() + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index c68fb45..a70ed67 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -181,9 +182,9 @@ slow = time.time() - start # using precompiled headers should be faster limit = slow*0.90 if fast >= limit: - print "Using precompiled headers was not fast enough:" - print "slow.obj: %.3fs" % slow - print "fast.obj: %.3fs (expected less than %.3fs)" % (fast, limit) + print("Using precompiled headers was not fast enough:") + print("slow.obj: %.3fs" % slow) + print("fast.obj: %.3fs (expected less than %.3fs)" % (fast, limit)) test.fail_test() # Modifying resource.h should cause both the resource and precompiled header to be rebuilt: diff --git a/test/MSVC/query_vcbat.py b/test/MSVC/query_vcbat.py index 328345d..428fe56 100644 --- a/test/MSVC/query_vcbat.py +++ b/test/MSVC/query_vcbat.py @@ -49,7 +49,7 @@ DefaultEnvironment(tools = []) # print k, v #MergeMSVSBatFile(env, 9.0) #print env['ENV']['PATH'] -print query_versions() +print(query_versions()) """) test.run(stderr = None) diff --git a/test/MSVS/vs-10.0-exec.py b/test/MSVS/vs-10.0-exec.py index 86b4042..1a4b59a 100644 --- a/test/MSVS/vs-10.0-exec.py +++ b/test/MSVS/vs-10.0-exec.py @@ -55,7 +55,7 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +print("os.environ.update(%%s)" %% repr(env['ENV'])) """ % locals()) exec(test.stdout()) diff --git a/test/MSVS/vs-8.0-exec.py b/test/MSVS/vs-8.0-exec.py index cff7ca2..96c4c29 100644 --- a/test/MSVS/vs-8.0-exec.py +++ b/test/MSVS/vs-8.0-exec.py @@ -55,7 +55,7 @@ if not msvs_version in test.msvs_versions(): test.run(arguments = '-n -q -Q -f -', stdin = """\ env = Environment(tools = ['msvc'], MSVS_VERSION='%(msvs_version)s') -print "os.environ.update(%%s)" %% repr(env['ENV']) +print("os.environ.update(%%s)" %% repr(env['ENV'])) """ % locals()) exec(test.stdout()) diff --git a/test/Mkdir.py b/test/Mkdir.py index 4d309bb..8ace476 100644 --- a/test/Mkdir.py +++ b/test/Mkdir.py @@ -178,7 +178,7 @@ test.write(['work3', 'sub1', 'sub11', 'SConscript'], """\ #/sub1/sub11/SConscript------------------------- Import('env test1') test11 = test1 + '/test11' -print 'test11 = ' + test11 +print('test11 = ' + test11) env.Command(Dir(test11), '', Mkdir('$TARGET')) """) diff --git a/test/NodeOps.py b/test/NodeOps.py index 5062b72..1f856c3 100644 --- a/test/NodeOps.py +++ b/test/NodeOps.py @@ -43,7 +43,7 @@ _lib = TestSCons._lib _obj = TestSCons._obj dll_ = TestSCons.dll_ _dll = TestSCons._dll - + if os.name == 'posix': os.environ['LD_LIBRARY_PATH'] = '.' if sys.platform.find('irix') > -1: @@ -71,7 +71,7 @@ if %(_E)s: exists = [N.exists() for N in Nodes] real2 = [os.path.exists(str(N)) for N in Nodes] for N,D,R,E,F in zip(Nodes, derived, real1, exists, real2): - print '%%s: %%s %%s %%s %%s'%%(N,D,R,E,F) + print('%%s: %%s %%s %%s %%s'%%(N,D,R,E,F)) foo.SharedLibrary(target = 'foo', source = 'foo%(_obj)s') bar.SharedLibrary(target = 'bar', source = 'bar%(_obj)s') diff --git a/test/ParseConfig.py b/test/ParseConfig.py index 9bcc440..efb3a75 100644 --- a/test/ParseConfig.py +++ b/test/ParseConfig.py @@ -38,17 +38,17 @@ test_config3 = test.workpath('test-config3') # File node. # It used to be returned as the 'static_libs' output of ParseConfig. test.write(test_config1, """\ -print "-I/usr/include/fum -Ibar -X -arch i386" -print "-L/usr/fax -Lfoo -lxxx abc" +print("-I/usr/include/fum -Ibar -X -arch i386") +print("-L/usr/fax -Lfoo -lxxx abc") """) test.write(test_config2, """\ -print "-L foo -L lib_dir" +print("-L foo -L lib_dir") """) # This is like what wxWidgets does on OSX w/ Universal Binaries test.write(test_config3, """\ -print "-L foo -L lib_dir -isysroot /tmp -arch ppc -arch i386" +print("-L foo -L lib_dir -isysroot /tmp -arch ppc -arch i386") """) test.write('SConstruct1', """ @@ -56,10 +56,10 @@ env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '-pipe -Wall') env.ParseConfig([r'%(_python_)s', r"%(test_config1)s", "--libs --cflags"]) env.ParseConfig([r'%(_python_)s', r"%(test_config2)s", "--libs --cflags"]) -print env['CPPPATH'] -print env['LIBPATH'] -print [str(x) for x in env['LIBS']] -print env['CCFLAGS'] +print(env['CPPPATH']) +print(env['LIBPATH']) +print([str(x) for x in env['LIBS']]) +print(env['CCFLAGS']) """ % locals()) test.write('SConstruct2', """ @@ -68,10 +68,10 @@ env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], PYTHON = r'%(_python_)s') env.ParseConfig(r"$PYTHON %(test_config1)s --libs --cflags") env.ParseConfig(r"$PYTHON %(test_config2)s --libs --cflags") -print env['CPPPATH'] -print env['LIBPATH'] -print [str(x) for x in env['LIBS']] -print env['CCFLAGS'] +print(env['CPPPATH']) +print(env['LIBPATH']) +print([str(x) for x in env['LIBS']]) +print(env['CCFLAGS']) """ % locals()) test.write('SConstruct3', """ @@ -79,10 +79,10 @@ env = Environment(CPPPATH = [], LIBPATH = [], LIBS = [], CCFLAGS = '-pipe -Wall', PYTHON = r'%(_python_)s') env.ParseConfig(r"$PYTHON %(test_config3)s --libs --cflags") -print env['CPPPATH'] -print env['LIBPATH'] -print [str(x) for x in env['LIBS']] -print env['CCFLAGS'] +print(env['CPPPATH']) +print(env['LIBPATH']) +print([str(x) for x in env['LIBS']]) +print(env['CCFLAGS']) """ % locals()) good_stdout = """\ diff --git a/test/Platform.py b/test/Platform.py index 23068c4..924dbc7 100644 --- a/test/Platform.py +++ b/test/Platform.py @@ -31,27 +31,27 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment() Platform('cygwin')(env) -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) assert env['SHELL'] == 'sh' Platform('os2')(env) -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) env.Platform('posix') -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) Platform('win32')(env) -print "'%s'" % env['PROGSUFFIX'] +print("'%s'" % env['PROGSUFFIX']) SConscript('SConscript') """) test.write('SConscript', """ env = Environment() Platform('cygwin')(env) -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) Platform('os2')(env) -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) env.Platform('posix') -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) Platform('win32')(env) -print "'%s'" % env['LIBSUFFIX'] +print("'%s'" % env['LIBSUFFIX']) """) expect = test.wrap_stdout(read_str = """'.exe' diff --git a/test/QT/QTFLAGS.py b/test/QT/QTFLAGS.py index 008397a..f6aa00f 100644 --- a/test/QT/QTFLAGS.py +++ b/test/QT/QTFLAGS.py @@ -136,7 +136,7 @@ int main() { """) test.run(chdir = 'work1', arguments = "mytest" + _exe) - + test.must_exist(['work1', 'mmmmocFromH.cxx'], ['work1', 'mocmocFromCpp.inl'], ['work1', 'an_ui_file.cxx'], @@ -168,15 +168,15 @@ env1 = Environment(tools=['qt'], cpppath = env1.subst('$CPPPATH') if os.path.normpath(cpppath) != os.path.join(r'%(QTDIR)s', 'h64'): - print cpppath + print(cpppath) Exit(1) libpath = env1.subst('$LIBPATH') if os.path.normpath(libpath) != os.path.join(r'%(QTDIR)s', 'lib64'): - print libpath + print(libpath) Exit(2) qt_moc = env1.subst('$QT_MOC') if os.path.normpath(qt_moc) != os.path.join(r'%(QTDIR)s', 'bin64', 'moc'): - print qt_moc + print(qt_moc) Exit(3) env2 = Environment(tools=['default', 'qt'], diff --git a/test/QT/copied-env.py b/test/QT/copied-env.py index efa91be..3989143 100644 --- a/test/QT/copied-env.py +++ b/test/QT/copied-env.py @@ -20,6 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -70,8 +71,8 @@ moc_MyForm = [x for x in test.stdout().split('\n') if x.find('moc_MyForm') != -1 MYLIB_IMPL = [x for x in moc_MyForm if x.find('MYLIB_IMPL') != -1] if not MYLIB_IMPL: - print "Did not find MYLIB_IMPL on moc_MyForm compilation line:" - print test.stdout() + print("Did not find MYLIB_IMPL on moc_MyForm compilation line:") + print(test.stdout()) test.fail_test() test.pass_test() diff --git a/test/QT/manual.py b/test/QT/manual.py index d911fb3..1f140ae 100644 --- a/test/QT/manual.py +++ b/test/QT/manual.py @@ -58,7 +58,7 @@ env.Ignore( moc, moc ) sources.extend(env.Uic(['include/uic_fff.hpp', 'fff.cpp', 'fff.moc.cpp'], 'ui/fff.ui')[1:]) -print list(map(str,sources)) +print(list(map(str,sources))) env.Program(target='aaa', source=sources, CPPPATH=['$CPPPATH', './include'], @@ -68,7 +68,7 @@ env.Program(target='aaa', test.write('aaa.cpp', r""" #include "aaa.h" """) - + test.write(['include', 'aaa.h'], r""" #include "my_qobject.h" void aaa(void) Q_OBJECT; @@ -91,7 +91,7 @@ void ccc(void) test.write('ddd.cpp', r""" #include "ddd.h" """) - + test.write(['include', 'ddd.h'], r""" #include "my_qobject.h" void ddd(void) Q_OBJECT; diff --git a/test/QT/warnings.py b/test/QT/warnings.py index a861b24..a1cf221 100644 --- a/test/QT/warnings.py +++ b/test/QT/warnings.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -59,8 +60,8 @@ scons: warning: Generated moc file 'aaa.moc' is not included by 'aaa.cpp' """ + TestSCons.file_expr if not re.search(match12, test.stderr()): - print "Did not find expected regular expression in stderr:" - print test.stderr() + print("Did not find expected regular expression in stderr:") + print(test.stderr()) test.fail_test() os.environ['QTDIR'] = test.QT diff --git a/test/Repository/Default.py b/test/Repository/Default.py index 127c29a..44aecfb 100644 --- a/test/Repository/Default.py +++ b/test/Repository/Default.py @@ -46,7 +46,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) diff --git a/test/Repository/Local.py b/test/Repository/Local.py index 1b63345..ea03281 100644 --- a/test/Repository/Local.py +++ b/test/Repository/Local.py @@ -48,7 +48,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) @@ -65,7 +65,7 @@ SConscript('build/SConscript') test.write(['repository', 'src', 'SConscript'], r""" def bbb_copy(env, source, target): target = str(target[0]) - print 'bbb_copy()' + print('bbb_copy()') open(target, "wb").write(open('build/bbb.1', "rb").read()) Import("env") diff --git a/test/Repository/VariantDir.py b/test/Repository/VariantDir.py index ec723c8..0258ff5 100644 --- a/test/Repository/VariantDir.py +++ b/test/Repository/VariantDir.py @@ -48,7 +48,7 @@ test.write(['repository', 'src', 'SConscript'], r""" def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/Repository/option-c.py b/test/Repository/option-c.py index ea989c2..c06c7d8 100644 --- a/test/Repository/option-c.py +++ b/test/Repository/option-c.py @@ -65,7 +65,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) diff --git a/test/Repository/option-n.py b/test/Repository/option-n.py index 220baad..2a0ae5d 100644 --- a/test/Repository/option-n.py +++ b/test/Repository/option-n.py @@ -48,7 +48,7 @@ test.write(['repository', 'SConstruct'], r""" def copy(env, source, target): source = str(source[0]) target = str(target[0]) - print 'copy() < %s > %s' % (source, target) + print('copy() < %s > %s' % (source, target)) open(target, "wb").write(open(source, "rb").read()) Build = Builder(action=copy) diff --git a/test/Repository/targets.py b/test/Repository/targets.py index 62f4785..0fbc896 100644 --- a/test/Repository/targets.py +++ b/test/Repository/targets.py @@ -43,7 +43,7 @@ test.write(['repository', 'SConstruct'], """ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/SConscript/Return.py b/test/SConscript/Return.py index a810c7c..997de9d 100644 --- a/test/SConscript/Return.py +++ b/test/SConscript/Return.py @@ -39,50 +39,50 @@ x = SConscript('SConscript2') y, z = SConscript('SConscript3') a4, b4 = SConscript('SConscript4') foo, bar = SConscript('SConscript5') -print "x =", x -print "y =", y -print "z =", z -print "a4 =", a4 -print "b4 =", b4 -print "foo =", foo -print "bar =", bar +print ("x =", x) +print ("y =", y) +print ("z =", z) +print ("a4 =", a4) +print ("b4 =", b4) +print ("foo =", foo) +print ("bar =", bar) """) test.write('SConscript1', """\ -print "line 1" +print ("line 1") Return() -print "line 2" +print ("line 2") """) test.write('SConscript2', """\ -print "line 3" +print ("line 3") x = 7 Return('x') -print "line 4" +print ("line 4") """) test.write('SConscript3', """\ -print "line 5" +print ("line 5") y = 8 z = 9 Return('y z') -print "line 6" +print ("line 6") """) test.write('SConscript4', """\ a4 = 'aaa' b4 = 'bbb' -print "line 7" +print ("line 7") Return('a4', 'b4', stop=False) b4 = 'b-after' -print "line 8" +print ("line 8") """) test.write('SConscript5', """\ foo = 'foo' bar = 'bar' Return(["foo", "bar"]) -print "line 9" +print ("line 9") """) expect = """\ diff --git a/test/SConscript/SConscript.py b/test/SConscript/SConscript.py index c8453a7..d1e09ce 100644 --- a/test/SConscript/SConscript.py +++ b/test/SConscript/SConscript.py @@ -37,7 +37,7 @@ import foo assert foo.foo == 4 -print "SConstruct", os.getcwd() +print ("SConstruct", os.getcwd()) SConscript('SConscript') x1 = "SConstruct x1" @@ -85,11 +85,11 @@ SConscript('SConscript7') test.write('SConscript', """\ -# os should not be automajically imported: +# os should not be automatically imported: assert "os" not in globals() import os -print "SConscript " + os.getcwd() +print ("SConscript " + os.getcwd()) """) test.write('SConscript1', """ diff --git a/test/SConscript/env.py b/test/SConscript/env.py index 42963ff..a16866c 100644 --- a/test/SConscript/env.py +++ b/test/SConscript/env.py @@ -36,7 +36,7 @@ test.subdir('sub1', 'sub2') test.write("SConstruct", """\ env = Environment(SUB1='sub1', SUB2='sub2') -print "SConstruct" +print("SConstruct") x = 'xxx' y = 'yyy' env.Export(["x", "y"]) @@ -49,15 +49,15 @@ env.SConscript(['s3', 's4']) test.write(['sub1', 'SConscript'], """\ env = Environment() env.Import("x") -print "sub1/SConscript" -print "x =", x +print("sub1/SConscript") +print("x =", x) """) test.write(['sub2', 'SConscript'], """\ env = Environment() env.Import("y") -print "sub2/SConscript" -print "y =", y +print("sub2/SConscript") +print("y =", y) """) test.write('s1', "\n") diff --git a/test/SConscript/white-space.py b/test/SConscript/white-space.py index 06acea8..cc8f00e 100644 --- a/test/SConscript/white-space.py +++ b/test/SConscript/white-space.py @@ -38,7 +38,7 @@ SConscript('white space/SConscript') """) test.write(['white space', 'SConscript'], """\ -print "`white space/SConscript'" +print("`white space/SConscript'") """) expect = test.wrap_stdout(read_str = "`white space/SConscript'\n", diff --git a/test/SConsignFile/use-dbhash.py b/test/SConsignFile/use-dbhash.py index bf9868b..f70c8b0 100644 --- a/test/SConsignFile/use-dbhash.py +++ b/test/SConsignFile/use-dbhash.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dbhash + import dbm.bsd except ImportError: test.skip_test('No dbhash in this version of Python; skipping test.\n') diff --git a/test/SConsignFile/use-dbm.py b/test/SConsignFile/use-dbm.py index 75f088d..90983b3 100644 --- a/test/SConsignFile/use-dbm.py +++ b/test/SConsignFile/use-dbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dbm + import dbm.ndbm except ImportError: test.skip_test('No dbm in this version of Python; skipping test.\n') diff --git a/test/SConsignFile/use-dumbdbm.py b/test/SConsignFile/use-dumbdbm.py index 434435a..02a52da 100644 --- a/test/SConsignFile/use-dumbdbm.py +++ b/test/SConsignFile/use-dumbdbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import dumbdbm + import dbm.dumb except ImportError: test.skip_test('No dumbdbm in this version of Python; skipping test.\n') diff --git a/test/SConsignFile/use-gdbm.py b/test/SConsignFile/use-gdbm.py index 1eb3645..a7e4f59 100644 --- a/test/SConsignFile/use-gdbm.py +++ b/test/SConsignFile/use-gdbm.py @@ -35,7 +35,7 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() try: - import gdbm + import dbm.gnu except ImportError: test.skip_test('No gdbm in this version of Python; skipping test.\n') diff --git a/test/SConstruct.py b/test/SConstruct.py index 15e1c1b..9b2807f 100644 --- a/test/SConstruct.py +++ b/test/SConstruct.py @@ -41,7 +41,7 @@ wpath = test.workpath() test.write('sconstruct', """ import os -print "sconstruct", os.getcwd() +print("sconstruct", os.getcwd()) """) test.run(arguments = ".", @@ -51,7 +51,7 @@ test.run(arguments = ".", test.write('Sconstruct', """ import os -print "Sconstruct", os.getcwd() +print("Sconstruct", os.getcwd()) """) test.run(arguments = ".", @@ -60,7 +60,7 @@ test.run(arguments = ".", test.write('SConstruct', """ import os -print "SConstruct", os.getcwd() +print("SConstruct", os.getcwd()) """) test.run(arguments = ".", diff --git a/test/SHELL.py b/test/SHELL.py index 93ed0b1..faee27f 100644 --- a/test/SHELL.py +++ b/test/SHELL.py @@ -64,7 +64,7 @@ ofp.close() sys.exit(0) """ % locals()) -os.chmod(my_shell, 0755) +os.chmod(my_shell, 0o755) test.write('SConstruct', """\ env = Environment(SHELL = r'%(my_shell)s') diff --git a/test/SWIG/SWIG.py b/test/SWIG/SWIG.py index d53fa49..38bdc97 100644 --- a/test/SWIG/SWIG.py +++ b/test/SWIG/SWIG.py @@ -48,14 +48,14 @@ for opt, arg in opts: if opt == '-c': pass elif opt == '-o': out = arg elif opt == '-v' and arg == 'ersion': - print "" - print "SWIG Version 0.1.2" - print "" - print "Compiled with g++ [x86_64-pc-linux-gnu]" - print "" - print "Configured options: +pcre" - print "" - print "Please see http://www.swig.org for reporting bugs and further information" + print("") + print("SWIG Version 0.1.2") + print("") + print("Compiled with g++ [x86_64-pc-linux-gnu]") + print("") + print("Configured options: +pcre") + print("") + print("Please see http://www.swig.org for reporting bugs and further information") sys.exit(0) infile = open(args[0], 'rb') outfile = open(out, 'wb') @@ -68,7 +68,7 @@ sys.exit(0) test.write('SConstruct', """ env = Environment(tools=['default', 'swig'], SWIG = [r'%(python)s', 'myswig.py']) -print env.subst("Using SWIG $SWIGVERSION") +print(env.subst("Using SWIG $SWIGVERSION")) env.Program(target = 'test1', source = 'test1.i') env.CFile(target = 'test2', source = 'test2.i') env.Clone(SWIGFLAGS = '-c++').Program(target = 'test3', source = 'test3.i') diff --git a/test/Scanner/CrossLanguageNoExtension.py b/test/Scanner/CrossLanguageNoExtension.py index 5bf205f..0016ca5 100644 --- a/test/Scanner/CrossLanguageNoExtension.py +++ b/test/Scanner/CrossLanguageNoExtension.py @@ -45,11 +45,11 @@ def scan(node, env, scanpaths, arg): return includes def kfile_scan(node, env, scanpaths, arg): - print 'kscan: ' + str(node) + print('kscan: ' + str(node)) return scan(node, env, scanpaths, arg) def k2file_scan(node, env, scanpaths, arg): - print 'k2scan: ' + str(node) + print('k2scan: ' + str(node)) return scan(node, env, scanpaths, arg) kscan = Scanner(name = 'kfile', diff --git a/test/Scanner/empty-implicit.py b/test/Scanner/empty-implicit.py index 0323240..45fe952 100644 --- a/test/Scanner/empty-implicit.py +++ b/test/Scanner/empty-implicit.py @@ -37,7 +37,7 @@ test.write('SConstruct', r""" import os.path def scan(node, env, envkey, arg): - print 'XScanner: node =', os.path.split(str(node))[1] + print('XScanner: node =', os.path.split(str(node))[1]) return [] def exists_check(node, env): @@ -52,7 +52,7 @@ XScanner = Scanner(name = 'XScanner', def echo(env, target, source): t = os.path.split(str(target[0]))[1] s = os.path.split(str(source[0]))[1] - print 'create %s from %s' % (t, s) + print('create %s from %s' % (t, s)) open(t, 'wb').write(open(s, 'rb').read()) Echo = Builder(action = Action(echo, None), diff --git a/test/Scanner/generated.py b/test/Scanner/generated.py index b41c7c8..7246cbe 100644 --- a/test/Scanner/generated.py +++ b/test/Scanner/generated.py @@ -317,8 +317,8 @@ def write_out(file, dict): class CScannerCounter(object): def __init__(self, original_CScanner, *args, **kw): self.original_CScanner = original_CScanner - def __cmp__(self, *args, **kw): - return self.original_CScanner.__cmp__(*args, **kw) + def __eq__(self, *args, **kw): + return self.original_CScanner.__eq__(*args, **kw) def __hash__(self, *args, **kw): return self.original_CScanner.__hash__(*args, **kw) def __str__(self, *args, **kw): diff --git a/test/Scanner/scan-once.py b/test/Scanner/scan-once.py index d68f918..eac1f49 100644 --- a/test/Scanner/scan-once.py +++ b/test/Scanner/scan-once.py @@ -36,7 +36,7 @@ test.write('SConstruct', r""" import os.path def scan(node, env, envkey, arg): - print 'XScanner: node =', os.path.split(str(node))[1] + print('XScanner: node =', os.path.split(str(node))[1]) return [] def exists_check(node, env): @@ -51,7 +51,7 @@ XScanner = Scanner(name = 'XScanner', def echo(env, target, source): t = os.path.split(str(target[0]))[1] s = os.path.split(str(source[0]))[1] - print 'create %s from %s' % (t, s) + print('create %s from %s' % (t, s)) Echo = Builder(action = Action(echo, None), src_suffix = '.x', diff --git a/test/Scanner/unicode.py b/test/Scanner/unicode.py index 55e22bd..2737f7d 100644 --- a/test/Scanner/unicode.py +++ b/test/Scanner/unicode.py @@ -35,12 +35,12 @@ _python_ = TestSCons._python_ test = TestSCons.TestSCons() -try: - unicode -except NameError: - import sys - msg = "Unicode not supported by Python version %s; skipping test\n" - test.skip_test(msg % sys.version[:3]) +## try: +## unicode +## except NameError: +## import sys +## msg = "Unicode not supported by Python version %s; skipping test\n" +## test.skip_test(msg % sys.version[:3]) import codecs @@ -102,28 +102,28 @@ include utf16be.k foo.k 1 line 4 """) -contents = unicode("""\ +contents = (u"""\ ascii.k 1 line 1 include ascii.inc ascii.k 1 line 3 """) test.write('ascii.k', contents.encode('ascii')) -contents = unicode("""\ +contents = (u"""\ utf8.k 1 line 1 include utf8.inc utf8.k 1 line 3 """) test.write('utf8.k', codecs.BOM_UTF8 + contents.encode('utf-8')) -contents = unicode("""\ +contents = (u"""\ utf16le.k 1 line 1 include utf16le.inc utf16le.k 1 line 3 """) test.write('utf16le.k', codecs.BOM_UTF16_LE + contents.encode('utf-16-le')) -contents = unicode("""\ +contents = (u"""\ utf16be.k 1 line 1 include utf16be.inc utf16be.k 1 line 3 diff --git a/test/Split.py b/test/Split.py index e98e299..c0533fa 100644 --- a/test/Split.py +++ b/test/Split.py @@ -30,19 +30,19 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(BBB = 'bbb', CCC = 'ccc') -print Split('aaa') -print Split('aaa $BBB') -print env.Split('bbb $CCC') -print env.Split('$BBB ccc') -print Split(['ddd', 'eee']) +print(Split('aaa')) +print(Split('aaa $BBB')) +print(env.Split('bbb $CCC')) +print(env.Split('$BBB ccc')) +print(Split(['ddd', 'eee'])) SConscript('SConscript') """) test.write('SConscript', """ env = Environment(FFF='fff', JJJ='jjj') -print env.Split('${FFF}.f') -print Split('ggg hhh') -print env.Split(['iii', '$JJJ']) +print(env.Split('${FFF}.f')) +print(Split('ggg hhh')) +print(env.Split(['iii', '$JJJ'])) """) expect = """\ diff --git a/test/Subst/AllowSubstExceptions.py b/test/Subst/AllowSubstExceptions.py index 286f189..7f2a9aa 100644 --- a/test/Subst/AllowSubstExceptions.py +++ b/test/Subst/AllowSubstExceptions.py @@ -52,37 +52,37 @@ assert env.subst_list('${INDEX[999]}') == [[]] AllowSubstExceptions() try: env.subst('$NAME') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${NAME}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${INDEX[999]}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('$NAME') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${NAME}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${INDEX[999]}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst('${1/0}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") try: env.subst_list('${1/0}') -except SCons.Errors.UserError, e: print e +except SCons.Errors.UserError, e: print(e) else: raise Exception("did not catch expected SCons.Errors.UserError") AllowSubstExceptions(ZeroDivisionError) diff --git a/test/TARGETS.py b/test/TARGETS.py index 5b36c49..0ffc3b6 100644 --- a/test/TARGETS.py +++ b/test/TARGETS.py @@ -35,11 +35,11 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ -print COMMAND_LINE_TARGETS -print list(map(str, BUILD_TARGETS)) +print(COMMAND_LINE_TARGETS) +print(list(map(str, BUILD_TARGETS))) Default('.') -print COMMAND_LINE_TARGETS -print list(map(str, BUILD_TARGETS)) +print(COMMAND_LINE_TARGETS) +print(list(map(str, BUILD_TARGETS))) """) test.write('aaa', 'aaa\n') @@ -68,17 +68,17 @@ test.run(arguments = 'bbb ccc=xyz -n aaa', stdout = expect) test.write('SConstruct', """ env = Environment() -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) Default('aaa') -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) env.Default('bbb') -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) env.Default(None) -print list(map(str, DEFAULT_TARGETS)) -print list(map(str, BUILD_TARGETS)) +print(list(map(str, DEFAULT_TARGETS))) +print(list(map(str, BUILD_TARGETS))) env.Default('ccc') """) @@ -113,9 +113,9 @@ test.run(arguments = '.', stdout = expect) test.write('SConstruct', """\ -print list(map(str, BUILD_TARGETS)) +print(list(map(str, BUILD_TARGETS))) SConscript('SConscript') -print list(map(str, BUILD_TARGETS)) +print(list(map(str, BUILD_TARGETS))) """) test.write('SConscript', """\ diff --git a/test/TEMPFILEPREFIX.py b/test/TEMPFILEPREFIX.py index f9b3240..8e756af 100644 --- a/test/TEMPFILEPREFIX.py +++ b/test/TEMPFILEPREFIX.py @@ -45,7 +45,7 @@ print sys.argv echo_py = test.workpath('echo.py') st = os.stat(echo_py) -os.chmod(echo_py, st[stat.ST_MODE]|0111) +os.chmod(echo_py, st[stat.ST_MODE]|0o111) test.write('SConstruct', """ import os diff --git a/test/TEX/TEX.py b/test/TEX/TEX.py index 42c1903..e1d634f 100644 --- a/test/TEX/TEX.py +++ b/test/TEX/TEX.py @@ -20,6 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -176,14 +177,14 @@ Run \texttt{latex}, then \texttt{bibtex}, then \texttt{latex} twice again \cite{ reruns = [x for x in output_lines if x.find('latex -interaction=nonstopmode -recorder rerun.tex') != -1] if len(reruns) != 2: - print "Expected 2 latex calls, got %s:" % len(reruns) - print '\n'.join(reruns) + print("Expected 2 latex calls, got %s:" % len(reruns)) + print('\n'.join(reruns)) test.fail_test() bibtex = [x for x in output_lines if x.find('bibtex bibtex-test') != -1] if len(bibtex) != 1: - print "Expected 1 bibtex call, got %s:" % len(bibtex) - print '\n'.join(bibtex) + print("Expected 1 bibtex call, got %s:" % len(bibtex)) + print('\n'.join(bibtex)) test.fail_test() test.pass_test() diff --git a/test/Value.py b/test/Value.py index f3ad458..7abe758 100644 --- a/test/Value.py +++ b/test/Value.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -81,7 +82,7 @@ open(sys.argv[-1],'wb').write(" ".join(sys.argv[1:-2])) # to make sure there's no difference in behavior. for source_signature in ['MD5', 'timestamp-newer']: - print "Testing Value node with source signatures:", source_signature + print("Testing Value node with source signatures:", source_signature) test.write('SConstruct', SConstruct_content % locals()) diff --git a/test/Variables/BoolVariable.py b/test/Variables/BoolVariable.py index 365567e..d259984 100644 --- a/test/Variables/BoolVariable.py +++ b/test/Variables/BoolVariable.py @@ -57,8 +57,8 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/EnumVariable.py b/test/Variables/EnumVariable.py index c04b396..cf35b9b 100644 --- a/test/Variables/EnumVariable.py +++ b/test/Variables/EnumVariable.py @@ -66,9 +66,9 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['debug'] -print env['guilib'] -print env['some'] +print(env['debug']) +print(env['guilib']) +print(env['some']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/ListVariable.py b/test/Variables/ListVariable.py index e5be625..e463840 100644 --- a/test/Variables/ListVariable.py +++ b/test/Variables/ListVariable.py @@ -66,15 +66,18 @@ env = Environment(variables=opts) opts.Save(optsfile, env) Help(opts.GenerateHelpText(env)) -print env['shared'] -if 'ical' in env['shared']: print '1' -else: print '0' -for x in env['shared']: - print x, -print -print env.subst('$shared') +print(env['shared']) + +if 'ical' in env['shared']: + print('1') +else: + print('0') + +print(" ".join(env['shared'])) + +print(env.subst('$shared')) # Test subst_path() because it's used in $CPPDEFINES expansions. -print env.subst_path('$shared') +print(env.subst_path('$shared')) Default(env.Alias('dummy', None)) """) @@ -162,7 +165,7 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['gpib'] +print(env['gpib']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/PackageVariable.py b/test/Variables/PackageVariable.py index 322bc9b..b3fd10a 100644 --- a/test/Variables/PackageVariable.py +++ b/test/Variables/PackageVariable.py @@ -59,7 +59,7 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['x11'] +print(env['x11']) Default(env.Alias('dummy', None)) """) diff --git a/test/Variables/PathVariable.py b/test/Variables/PathVariable.py index bfe82ba..753aa11 100644 --- a/test/Variables/PathVariable.py +++ b/test/Variables/PathVariable.py @@ -64,9 +64,9 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['qtdir'] -print env['qt_libraries'] -print env.subst('$qt_libraries') +print(env['qtdir']) +print(env['qt_libraries']) +print(env.subst('$qt_libraries')) Default(env.Alias('dummy', None)) """ % (workpath, os.path.join('$qtdir', 'lib') )) @@ -132,7 +132,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -165,7 +165,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_file) @@ -211,7 +211,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) @@ -259,7 +259,7 @@ opts.AddVariables( env = Environment(variables=opts) -print env['X'] +print(env['X']) Default(env.Alias('dummy', None)) """ % default_subdir) diff --git a/test/Variables/Variables.py b/test/Variables/Variables.py index 454e32e..1c60635 100644 --- a/test/Variables/Variables.py +++ b/test/Variables/Variables.py @@ -30,8 +30,8 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment() -print env['CC'] -print " ".join(env['CCFLAGS']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) Default(env.Alias('dummy', None)) """) test.run() @@ -99,12 +99,12 @@ env = Environment(variables=opts, tools=['default', test_tool]) Help('Variables settable in custom.py or on the command line:\\n' + opts.GenerateHelpText(env)) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['CC'] -print " ".join(env['CCFLAGS']) -print env['VALIDATE'] -print env['valid_key'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['CC']) +print(" ".join(env['CCFLAGS'])) +print(env['VALIDATE']) +print(env['valid_key']) # unspecified variables should not be set: assert 'UNSPECIFIED' not in env @@ -220,8 +220,8 @@ opts.Add('UNSPECIFIED', env = Environment(variables = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) opts.Save('variables.saved', env) """) @@ -231,7 +231,7 @@ opts.Save('variables.saved', env) def checkSave(file, expected): gdict = {} ldict = {} - exec open(file, 'rU').read() in gdict, ldict + exec(open(file, 'rU').read(), gdict, ldict) assert expected == ldict, "%s\n...not equal to...\n%s" % (expected, ldict) # First test with no command line variables @@ -276,9 +276,9 @@ opts.Add('LISTOPTION_TEST', env = Environment(variables = opts) -print env['RELEASE_BUILD'] -print env['DEBUG_BUILD'] -print env['LISTOPTION_TEST'] +print(env['RELEASE_BUILD']) +print(env['DEBUG_BUILD']) +print(env['LISTOPTION_TEST']) opts.Save('variables.saved', env) """) diff --git a/test/Variables/chdir.py b/test/Variables/chdir.py index 621e166..2d097d5 100644 --- a/test/Variables/chdir.py +++ b/test/Variables/chdir.py @@ -46,7 +46,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", repr(env['VARIABLE']) +print("VARIABLE =", repr(env['VARIABLE'])) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/Variables/help.py b/test/Variables/help.py index f04f962..bee6011 100644 --- a/test/Variables/help.py +++ b/test/Variables/help.py @@ -81,8 +81,8 @@ opts.AddVariables( env = Environment(variables=opts) Help(opts.GenerateHelpText(env)) -print env['warnings'] -print env['profile'] +print(env['warnings']) +print(env['profile']) Default(env.Alias('dummy', None)) """ % locals()) diff --git a/test/Variables/import.py b/test/Variables/import.py index 7cdd274..2da670a 100644 --- a/test/Variables/import.py +++ b/test/Variables/import.py @@ -48,7 +48,7 @@ SConscript_contents = """\ Import("opts") env = Environment() opts.Update(env) -print "VARIABLE =", env.get('VARIABLE') +print("VARIABLE =", env.get('VARIABLE')) """ test.write(['bin', 'opts.cfg'], """\ diff --git a/test/WhereIs.py b/test/WhereIs.py index dc127b6..c765848 100644 --- a/test/WhereIs.py +++ b/test/WhereIs.py @@ -45,10 +45,10 @@ if sys.platform != 'win32': os.mkdir(sub2_xxx_exe) test.write(sub3_xxx_exe, "\n") -os.chmod(sub3_xxx_exe, 0777) +os.chmod(sub3_xxx_exe, 0o777) test.write(sub4_xxx_exe, "\n") -os.chmod(sub4_xxx_exe, 0777) +os.chmod(sub4_xxx_exe, 0o777) env_path = os.environ['PATH'] @@ -67,14 +67,14 @@ pathdirs_1243 = [ test.workpath('sub1'), test.write('SConstruct', """ SConscript('%s') env = Environment() -print WhereIs('xxx.exe') -print WhereIs('xxx.exe', %s) -print env.WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s, reject=%s) +print(WhereIs('xxx.exe')) +print(WhereIs('xxx.exe', %s)) +print(env.WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s, reject=%s)) env.Replace( XXXNAME='xxx.exe' ) -print env.WhereIs( '$XXXNAME', %s ) +print(env.WhereIs( '$XXXNAME', %s )) """ % (subdir_SConscript, repr(os.pathsep.join(pathdirs_1234)), repr(os.pathsep.join(pathdirs_1243)), @@ -87,11 +87,11 @@ print env.WhereIs( '$XXXNAME', %s ) test.write(subdir_SConscript, """ env = Environment() -print WhereIs('xxx.exe') -print WhereIs('xxx.exe', %s) -print env.WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) -print WhereIs('xxx.exe', %s) +print(WhereIs('xxx.exe')) +print(WhereIs('xxx.exe', %s)) +print(env.WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) +print(WhereIs('xxx.exe', %s)) """ % (repr(os.pathsep.join(pathdirs_1234)), repr(os.pathsep.join(pathdirs_1243)), repr(pathdirs_1234), diff --git a/test/Win32/bad-drive.py b/test/Win32/bad-drive.py index f2a55b8..67a287a 100644 --- a/test/Win32/bad-drive.py +++ b/test/Win32/bad-drive.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ This test verifies (on Windows systems) that we fail gracefully and @@ -50,15 +51,15 @@ for i in range(len(uppercase)-1, -1, -1): break if bad_drive is None: - print "All drive letters appear to be in use." - print "Cannot test SCons handling of invalid Windows drive letters." + print("All drive letters appear to be in use.") + print("Cannot test SCons handling of invalid Windows drive letters.") test.no_result(1); test.write('SConstruct', """ def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%%s) > %%s' %% (source, target) + print('cat(%%s) > %%s' %% (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/Win32/default-drive.py b/test/Win32/default-drive.py index f427a20..31253e4 100644 --- a/test/Win32/default-drive.py +++ b/test/Win32/default-drive.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function """ This test verifies (on Windows systems) that specifying an @@ -59,7 +60,7 @@ test.write(['src', 'file.in'], "src/file.in\n") build_file_out = test.workpath('build', 'file.out') -print os.path.splitdrive(build_file_out)[1] +print(os.path.splitdrive(build_file_out)[1]) test.run(chdir = 'src', arguments = os.path.splitdrive(build_file_out)[1]) diff --git a/test/Win32/mingw.py b/test/Win32/mingw.py index 6b23314..80067bc 100644 --- a/test/Win32/mingw.py +++ b/test/Win32/mingw.py @@ -47,7 +47,7 @@ from SCons.Tool.mingw import exists import sys env = Environment() if exists(env): - print 'mingw exists' + print('mingw exists') sys.exit(0) """) diff --git a/test/ZIP/ZIP.py b/test/ZIP/ZIP.py index af2450b..f2acad8 100644 --- a/test/ZIP/ZIP.py +++ b/test/ZIP/ZIP.py @@ -47,7 +47,7 @@ def zipfile_contains(zipfilename, names): for name in names: try: info=zf.getinfo(name) - except KeyError, e: # name not found + except KeyError as e: # name not found zf.close() return False return True diff --git a/test/ZIP/ZIPROOT.py b/test/ZIP/ZIPROOT.py index 96747a7..f3e4496 100644 --- a/test/ZIP/ZIPROOT.py +++ b/test/ZIP/ZIPROOT.py @@ -1,98 +1,98 @@ -#!/usr/bin/env python
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-import os
-import stat
-
-import TestSCons
-
-_python_ = TestSCons._python_
-
-test = TestSCons.TestSCons()
-
-import zipfile
-
-def zipfile_contains(zipfilename, names):
- """Returns True if zipfilename contains all the names, False otherwise."""
- zf=zipfile.ZipFile(zipfilename, 'r')
- if type(names)==type(''):
- names=[names]
- for name in names:
- try:
- info=zf.getinfo(name)
- except KeyError, e: # name not found
- zf.close()
- return False
- return True
-
-def zipfile_files(fname):
- """Returns all the filenames in zip file fname."""
- zf = zipfile.ZipFile(fname, 'r')
- return [x.filename for x in zf.infolist()]
-
-test.subdir('sub1')
-test.subdir(['sub1', 'sub2'])
-
-test.write('SConstruct', """
-env = Environment(tools = ['zip'])
-env.Zip(target = 'aaa.zip', source = ['sub1/file1'], ZIPROOT='sub1')
-env.Zip(target = 'bbb.zip', source = ['sub1/file2', 'sub1/sub2/file2'], ZIPROOT='sub1')
-""" % locals())
-
-test.write(['sub1', 'file1'], "file1\n")
-test.write(['sub1', 'file2'], "file2a\n")
-test.write(['sub1', 'sub2', 'file2'], "file2b\n")
-
-test.run(arguments = 'aaa.zip', stderr = None)
-
-test.must_exist('aaa.zip')
-
-# TEST: Zip file should contain 'file1', not 'sub1/file1', because of ZIPROOT.
-zf=zipfile.ZipFile('aaa.zip', 'r')
-test.fail_test(zf.testzip() is not None)
-zf.close()
-
-files=zipfile_files('aaa.zip')
-test.fail_test(zipfile_files('aaa.zip') != ['file1'],
- message='Zip file aaa.zip has wrong files: %s'%repr(files))
-
-###
-
-test.run(arguments = 'bbb.zip', stderr = None)
-
-test.must_exist('bbb.zip')
-
-# TEST: Zip file should contain 'sub2/file2', not 'sub1/sub2/file2', because of ZIPROOT.
-zf=zipfile.ZipFile('bbb.zip', 'r')
-test.fail_test(zf.testzip() is not None)
-zf.close()
-
-files=zipfile_files('bbb.zip')
-test.fail_test(zipfile_files('bbb.zip') != ['file2', 'sub2/file2'],
- message='Zip file bbb.zip has wrong files: %s'%repr(files))
-
-
-test.pass_test()
+#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import os +import stat + +import TestSCons + +_python_ = TestSCons._python_ + +test = TestSCons.TestSCons() + +import zipfile + +def zipfile_contains(zipfilename, names): + """Returns True if zipfilename contains all the names, False otherwise.""" + zf=zipfile.ZipFile(zipfilename, 'r') + if type(names)==type(''): + names=[names] + for name in names: + try: + info=zf.getinfo(name) + except KeyError as e: # name not found + zf.close() + return False + return True + +def zipfile_files(fname): + """Returns all the filenames in zip file fname.""" + zf = zipfile.ZipFile(fname, 'r') + return [x.filename for x in zf.infolist()] + +test.subdir('sub1') +test.subdir(['sub1', 'sub2']) + +test.write('SConstruct', """ +env = Environment(tools = ['zip']) +env.Zip(target = 'aaa.zip', source = ['sub1/file1'], ZIPROOT='sub1') +env.Zip(target = 'bbb.zip', source = ['sub1/file2', 'sub1/sub2/file2'], ZIPROOT='sub1') +""" % locals()) + +test.write(['sub1', 'file1'], "file1\n") +test.write(['sub1', 'file2'], "file2a\n") +test.write(['sub1', 'sub2', 'file2'], "file2b\n") + +test.run(arguments = 'aaa.zip', stderr = None) + +test.must_exist('aaa.zip') + +# TEST: Zip file should contain 'file1', not 'sub1/file1', because of ZIPROOT. +zf=zipfile.ZipFile('aaa.zip', 'r') +test.fail_test(zf.testzip() is not None) +zf.close() + +files=zipfile_files('aaa.zip') +test.fail_test(zipfile_files('aaa.zip') != ['file1'], + message='Zip file aaa.zip has wrong files: %s'%repr(files)) + +### + +test.run(arguments = 'bbb.zip', stderr = None) + +test.must_exist('bbb.zip') + +# TEST: Zip file should contain 'sub2/file2', not 'sub1/sub2/file2', because of ZIPROOT. +zf=zipfile.ZipFile('bbb.zip', 'r') +test.fail_test(zf.testzip() is not None) +zf.close() + +files=zipfile_files('bbb.zip') +test.fail_test(zipfile_files('bbb.zip') != ['file2', 'sub2/file2'], + message='Zip file bbb.zip has wrong files: %s'%repr(files)) + + +test.pass_test() diff --git a/test/_CPPINCFLAGS.py b/test/_CPPINCFLAGS.py index ccf5e79..c5096ba 100644 --- a/test/_CPPINCFLAGS.py +++ b/test/_CPPINCFLAGS.py @@ -39,9 +39,9 @@ env=Environment(CPPPATH=['tmp'], INCPREFIX='-I') d=Entry('foo.d') e=Entry('foo.e') f=File('foo.f') -print env.subst('$_CPPINCFLAGS', target=e, source=f) -print env.subst('$_CPPINCFLAGS', target=d, source=f) -print env.subst('$_CPPINCFLAGS', target=f, source=d) +print(env.subst('$_CPPINCFLAGS', target=e, source=f)) +print(env.subst('$_CPPINCFLAGS', target=d, source=f)) +print(env.subst('$_CPPINCFLAGS', target=f, source=d)) """) expect = """\ diff --git a/test/custom-concat.py b/test/custom-concat.py index 56c7f64..730e6cd 100644 --- a/test/custom-concat.py +++ b/test/custom-concat.py @@ -44,7 +44,7 @@ env1 = Environment(MYFLAGS=myflags, _concat = my_concat1, MYPREFIX='p', MYSUFFIX='s', STRIPPREFIX='xxx', STRIPSUFFIX='yyy', LIST=['a', 'xxxb', 'cyyy', 'd']) -print env1.subst('$MYFLAGS') +print(env1.subst('$MYFLAGS')) """) expect = test.wrap_stdout(read_str = "mypas1 mypbs1 mypcs1 mypds1\n", diff --git a/test/exitfns.py b/test/exitfns.py index f64969b..d1bda3a 100644 --- a/test/exitfns.py +++ b/test/exitfns.py @@ -32,11 +32,11 @@ sconstruct = """ from SCons.exitfuncs import * def x1(): - print "running x1" + print("running x1") def x2(n): - print "running x2(%s)" % repr(n) + print("running x2(%s)" % repr(n)) def x3(n, kwd=None): - print "running x3(%s, kwd=%s)" % (repr(n), repr(kwd)) + print("running x3(%s, kwd=%s)" % (repr(n), repr(kwd))) register(x3, "no kwd args") register(x1) diff --git a/test/gnutools.py b/test/gnutools.py index e1b7e42..b0ebc1c 100644 --- a/test/gnutools.py +++ b/test/gnutools.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -118,7 +119,7 @@ def testObject(test, obj, expect): line1 = contents.split('\n')[0] actual = ' '.join(line1.split()) if not expect == actual: - print "%s: %s != %s\n" % (obj, repr(expect), repr(actual)) + print("%s: %s != %s\n" % (obj, repr(expect), repr(actual))) test.fail_test() if sys.platform in ('win32', 'cygwin'): diff --git a/test/import.py b/test/import.py index ef5ee61..c23657a 100644 --- a/test/import.py +++ b/test/import.py @@ -63,7 +63,7 @@ platforms = [ for platform in platforms: test.write('SConstruct', """ -print "Platform %(platform)s" +print("Platform %(platform)s") env = Environment(platform = '%(platform)s') import SCons.Platform.%(platform)s x = SCons.Platform.%(platform)s.generate @@ -150,7 +150,7 @@ error_output = { # An SConstruct for importing Tool names that have illegal characters # for Python variable names. indirect_import = """\ -print "Tool %(tool)s (indirect)" +print("Tool %(tool)s (indirect)") env = Environment(tools = ['%(tool)s']) SCons = __import__('SCons.Tool.%(tool)s', globals(), locals(), []) @@ -161,7 +161,7 @@ m.generate(env) # An SConstruct for importing Tool names "normally." direct_import = """\ -print "Tool %(tool)s (direct)" +print("Tool %(tool)s (direct)") env = Environment(tools = ['%(tool)s']) import SCons.Tool.%(tool)s @@ -185,8 +185,8 @@ for tool in tools: matched = 1 break if not matched: - print "Failed importing '%s', stderr:" % tool - print stderr + print("Failed importing '%s', stderr:" % tool) + print(stderr) failures.append(tool) test.fail_test(len(failures)) diff --git a/test/long-lines/signature.py b/test/long-lines/signature.py index bc5d11a..ce38bec 100644 --- a/test/long-lines/signature.py +++ b/test/long-lines/signature.py @@ -51,7 +51,7 @@ fp.write('FILEFLAG=%s\\n' % args[2]) fp.write('TIMESTAMP=%s\\n' % args[3]) """) -os.chmod(build_py, 0755) +os.chmod(build_py, 0o755) test.write('SConstruct', """\ arg = 'a_long_ignored_argument' diff --git a/test/no-arguments.py b/test/no-arguments.py index e447ff6..953d827 100644 --- a/test/no-arguments.py +++ b/test/no-arguments.py @@ -40,7 +40,7 @@ test.write('SConstruct', r""" def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/option--C.py b/test/option--C.py index 27f4950..1df3c1a 100644 --- a/test/option--C.py +++ b/test/option--C.py @@ -51,18 +51,18 @@ test.subdir('sub', ['sub', 'dir']) test.write('SConstruct', """ import os -print "SConstruct", os.getcwd() +print("SConstruct", os.getcwd()) """) test.write(['sub', 'SConstruct'], """ import os -print GetBuildPath('..') +print(GetBuildPath('..')) """) test.write(['sub', 'dir', 'SConstruct'], """ import os env = Environment(FOO='foo', BAR='bar') -print env.GetBuildPath('../$FOO/$BAR') +print(env.GetBuildPath('../$FOO/$BAR')) """) test.run(arguments = '-C sub .', diff --git a/test/option--I.py b/test/option--I.py index d65349a..0ca262d 100644 --- a/test/option--I.py +++ b/test/option--I.py @@ -44,9 +44,9 @@ variable = "sub2/bar" test.write('SConstruct', """ import foo -print foo.variable +print(foo.variable) import bar -print bar.variable +print(bar.variable) """) test.run(arguments = '-I sub1 -I sub2 .', diff --git a/test/option--random.py b/test/option--random.py index a9b9b9d..357cf2e 100644 --- a/test/option--random.py +++ b/test/option--random.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -66,7 +67,7 @@ tries = 0 max_tries = 10 while test.stdout() == non_random_output: if tries >= max_tries: - print "--random generated the non-random output %s times!" % max_tries + print("--random generated the non-random output %s times!" % max_tries) test.fail_test() tries = tries + 1 test.run(arguments = '-n -Q --random') @@ -84,7 +85,7 @@ tries = 0 max_tries = 10 while test.stdout() == non_random_output: if tries >= max_tries: - print "--random generated the non-random output %s times!" % max_tries + print("--random generated the non-random output %s times!" % max_tries) test.fail_test() tries = tries + 1 test.run(arguments = '-n -Q --random') diff --git a/test/option-f.py b/test/option-f.py index 2a238d3..9fd1a57 100644 --- a/test/option-f.py +++ b/test/option-f.py @@ -36,17 +36,17 @@ subdir_BuildThis = os.path.join('subdir', 'Buildthis') test.write('SConscript', """ import os -print "SConscript " + os.getcwd() +print("SConscript " + os.getcwd()) """) test.write(subdir_BuildThis, """ import os -print "subdir/BuildThis", os.getcwd() +print("subdir/BuildThis", os.getcwd()) """) test.write('Build2', """ import os -print "Build2", os.getcwd() +print("Build2", os.getcwd()) """) wpath = test.workpath() @@ -85,7 +85,7 @@ test.run(arguments = '--sconstruct=%s .' % subdir_BuildThis, test.run(arguments = '-f - .', stdin = """ import os -print "STDIN " + os.getcwd() +print("STDIN " + os.getcwd()) """, stdout = test.wrap_stdout(read_str = 'STDIN %s\n' % wpath, build_str = "scons: `.' is up to date.\n")) diff --git a/test/option-v.py b/test/option-v.py index f3eb61c..4a67df0 100644 --- a/test/option-v.py +++ b/test/option-v.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -53,13 +54,13 @@ expect2 = r"""SCons by Steven Knight et al.: test.run(arguments = '-v') stdout = test.stdout() if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): - print stdout + print(stdout) test.fail_test() test.run(arguments = '--version') stdout = test.stdout() if not test.match_re(stdout, expect1) and not test.match_re(stdout, expect2): - print stdout + print(stdout) test.fail_test() test.pass_test() diff --git a/test/option/debug-count.py b/test/option/debug-count.py index 39c1222..b82a434 100644 --- a/test/option/debug-count.py +++ b/test/option/debug-count.py @@ -20,6 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -75,10 +76,10 @@ for args in ['-h --debug=count', '--debug=count']: missing = [o for o in objects if find_object_count(o, stdout) is None] if missing: - print "Missing the following object lines from '%s' output:" % args - print "\t", ' '.join(missing) - print "STDOUT ==========" - print stdout + print("Missing the following object lines from '%s' output:" % args) + print("\t", ' '.join(missing)) + print("STDOUT ==========") + print(stdout) test.fail_test(1) expect_warning = """ diff --git a/test/option/debug-multiple.py b/test/option/debug-multiple.py index f5bbdf0..f121a2c 100644 --- a/test/option/debug-multiple.py +++ b/test/option/debug-multiple.py @@ -21,6 +21,8 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ @@ -65,16 +67,16 @@ for args in ['--debug=prepare,count', '--debug=count,prepare']: missing = [o for o in objects if find_object_count(o, stdout) is None] if missing: - print "Missing the following object lines from '%s' output:" % args - print "\t", ' '.join(missing) - print "STDOUT ==========" - print stdout + print("Missing the following object lines from '%s' output:" % args) + print("\t", ' '.join(missing)) + print("STDOUT ==========") + print(stdout) test.fail_test(1) if 'Preparing target file.out...' not in stdout: - print "Missing 'Preparing' lines from '%s' output:" % args - print "STDOUT ==========" - print stdout + print("Missing 'Preparing' lines from '%s' output:" % args) + print("STDOUT ==========") + print(stdout) test.fail_test(1) test.pass_test() diff --git a/test/option/debug-time.py b/test/option/debug-time.py index 198d71d..7dd17fe 100644 --- a/test/option/debug-time.py +++ b/test/option/debug-time.py @@ -20,7 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -from __future__ import division +from __future__ import division, print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -164,7 +164,7 @@ outside of the 15%% tolerance. """ % locals()) if failures or warnings: - print '\n'.join([test.stdout()] + failures + warnings) + print('\n'.join([test.stdout()] + failures + warnings)) if failures: test.fail_test(1) @@ -172,7 +172,7 @@ test.run(arguments = "--debug=time . SLEEP=0") command_time = get_command_time(test.stdout()) if command_time != 0.0: - print "Up-to-date run received non-zero command time of %s" % command_time + print("Up-to-date run received non-zero command time of %s" % command_time) test.fail_test() @@ -201,14 +201,14 @@ outside of the 1%% tolerance. """ % locals()) if failures: - print '\n'.join([test.stdout()] + failures) + print('\n'.join([test.stdout()] + failures)) test.fail_test(1) test.run(arguments = "-j4 --debug=time . SLEEP=1") command_time = get_command_time(test.stdout()) if command_time != 0.0: - print "Up-to-date run received non-zero command time of %s" % command_time + print("Up-to-date run received non-zero command time of %s" % command_time) test.fail_test() diff --git a/test/option/help-options.py b/test/option/help-options.py index 45bbfa0..e14eff2 100644 --- a/test/option/help-options.py +++ b/test/option/help-options.py @@ -20,6 +20,7 @@ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +from __future__ import print_function __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" @@ -60,8 +61,8 @@ options = [x[-1] == ',' and x[:-1] or x for x in options] lowered = [x.lower() for x in options] ordered = sorted(lowered) if lowered != ordered: - print "lowered =", lowered - print "sorted =", ordered + print("lowered =", lowered) + print("sorted =", ordered) test.fail_test() test.pass_test() diff --git a/test/option/profile.py b/test/option/profile.py index 4d6caae..4d942cf 100644 --- a/test/option/profile.py +++ b/test/option/profile.py @@ -21,6 +21,7 @@ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import sys @@ -106,7 +107,7 @@ memory_lines = [l for l in lines if l.find(expect) != -1] test.fail_test(len(memory_lines) != 1) - + test.pass_test() diff --git a/test/overrides.py b/test/overrides.py index d706ab7..69d5207 100644 --- a/test/overrides.py +++ b/test/overrides.py @@ -35,9 +35,9 @@ _python_ = TestSCons._python_ test.write('SConstruct', """ env = Environment(CCFLAGS='-DFOO', LIBS=['a']) def build(target, source, env): - print "env['CC'] =", env['CC'] - print "env['CCFLAGS'] =", env['CCFLAGS'] - print "env['LIBS'] =", env['LIBS'] + print("env['CC'] =", env['CC']) + print("env['CCFLAGS'] =", env['CCFLAGS']) + print("env['LIBS'] =", env['LIBS']) builder = Builder(action=build, CC='buildcc', LIBS='buildlibs') env['BUILDERS']['Build'] = builder diff --git a/test/packaging/convenience-functions/image/SConstruct b/test/packaging/convenience-functions/image/SConstruct index 461961e..f35c3e3 100644 --- a/test/packaging/convenience-functions/image/SConstruct +++ b/test/packaging/convenience-functions/image/SConstruct @@ -1,3 +1,4 @@ +from __future__ import print_function env = Environment(tools=['default', 'packaging']) prog = env.Install( 'bin/', ["f1", "f2"] ) @@ -6,5 +7,5 @@ env.File( "f3" ) src_files = sorted(map(str, env.FindSourceFiles())) oth_files = sorted(map(str, env.FindInstalledFiles())) -print src_files -print oth_files +print(src_files) +print(oth_files) diff --git a/test/preserve-source.py b/test/preserve-source.py index 6e09073..b7eccd1 100644 --- a/test/preserve-source.py +++ b/test/preserve-source.py @@ -35,7 +35,7 @@ test.write('SConstruct', r""" def cat(env, source, target): target = str(target[0]) source = list(map(str, source)) - print 'cat(%s) > %s' % (source, target) + print('cat(%s) > %s' % (source, target)) f = open(target, "wb") for src in source: f.write(open(src, "rb").read()) diff --git a/test/scons-time/run/config/python.py b/test/scons-time/run/config/python.py index 6cf965b..57b732d 100644 --- a/test/scons-time/run/config/python.py +++ b/test/scons-time/run/config/python.py @@ -53,7 +53,7 @@ for arg in sys.argv[1:]: print 'my_python.py: %s' % profile """) -os.chmod(my_python_py, 0755) +os.chmod(my_python_py, 0o755) test.run(arguments = 'run -f config foo.tar.gz') diff --git a/test/scons-time/run/option/python.py b/test/scons-time/run/option/python.py index a28e23f..70feb70 100644 --- a/test/scons-time/run/option/python.py +++ b/test/scons-time/run/option/python.py @@ -49,7 +49,7 @@ for arg in sys.argv[1:]: sys.stdout.write('my_python.py: %s\\n' % profile) """) -os.chmod(my_python_py, 0755) +os.chmod(my_python_py, 0o755) test.run(arguments = 'run --python %s foo.tar.gz' % my_python_py) diff --git a/test/sconsign/nonwritable.py b/test/sconsign/nonwritable.py index 913dcf1..5ae55bb 100644 --- a/test/sconsign/nonwritable.py +++ b/test/sconsign/nonwritable.py @@ -78,7 +78,7 @@ test.write(['work1', 'foo.in'], "work1/foo.in\n") test.write(work1__sconsign_dblite, "") -os.chmod(work1__sconsign_dblite, 0444) +os.chmod(work1__sconsign_dblite, 0o444) test.run(chdir='work1', arguments='.') @@ -95,7 +95,7 @@ test.write(['work2', 'foo.in'], "work2/foo.in\n") pickle.dump({}, open(work2_sub1__sconsign, 'wb'), 1) pickle.dump({}, open(work2_sub2__sconsign, 'wb'), 1) -os.chmod(work2_sub1__sconsign, 0444) +os.chmod(work2_sub1__sconsign, 0o444) test.run(chdir='work2', arguments='.') diff --git a/test/sconsign/script/SConsignFile.py b/test/sconsign/script/SConsignFile.py index 74fb1f0..dc45cc1 100644 --- a/test/sconsign/script/SConsignFile.py +++ b/test/sconsign/script/SConsignFile.py @@ -86,8 +86,8 @@ output.write(input.read()) sys.exit(0) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) # Note: We don't use os.path.join() representations of the file names # in the expected output because paths in the .sconsign files are diff --git a/test/sconsign/script/Signatures.py b/test/sconsign/script/Signatures.py index cfd2a7f..5babe67 100644 --- a/test/sconsign/script/Signatures.py +++ b/test/sconsign/script/Signatures.py @@ -105,8 +105,8 @@ output.write(input.read()) sys.exit(0) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) test.write('SConstruct', """ SConsignFile(None) diff --git a/test/sconsign/script/no-SConsignFile.py b/test/sconsign/script/no-SConsignFile.py index 09ecfa2..4e9915b 100644 --- a/test/sconsign/script/no-SConsignFile.py +++ b/test/sconsign/script/no-SConsignFile.py @@ -94,8 +94,8 @@ output.write(input.read()) sys.exit(0) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) # Note: We don't use os.path.join() representations of the file names # in the expected output because paths in the .sconsign files are diff --git a/test/site_scons/basic.py b/test/site_scons/basic.py index 1868723..b3ae9f2 100644 --- a/test/site_scons/basic.py +++ b/test/site_scons/basic.py @@ -40,7 +40,7 @@ test.subdir('site_scons', ['site_scons', 'site_tools']) test.write(['site_scons', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in site_scons/site_init.py!" +print("Hi there, I am in site_scons/site_init.py!") """) test.write(['site_scons', 'site_tools', 'mytool.py'], """ @@ -54,7 +54,7 @@ def exists(env): test.write('SConstruct', """ e=Environment(tools=['default', 'mytool']) -print e.subst('My site tool is $MYTOOL') +print(e.subst('My site tool is $MYTOOL')) """) test.run(arguments = '-Q .', diff --git a/test/site_scons/no-site-dir.py b/test/site_scons/no-site-dir.py index d01d419..c31ec94 100644 --- a/test/site_scons/no-site-dir.py +++ b/test/site_scons/no-site-dir.py @@ -37,7 +37,7 @@ test.subdir('site_scons', ['site_scons', 'site_tools']) test.write(['site_scons', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in site_scons/site_init.py!" +print("Hi there, I am in site_scons/site_init.py!") """) test.write(['site_scons', 'site_tools', 'mytool.py'], """ @@ -68,7 +68,7 @@ test.run(arguments = '-Q --no-site-dir .', test.write('SConstruct', """ e=Environment() -print e.subst('no site: M4 is $M4, M4_MINE is $M4_MINE') +print(e.subst('no site: M4 is $M4, M4_MINE is $M4_MINE')) """) test.run(arguments = '-Q --no-site-dir .') diff --git a/test/site_scons/override.py b/test/site_scons/override.py index e33bb88..d65c09e 100644 --- a/test/site_scons/override.py +++ b/test/site_scons/override.py @@ -49,7 +49,7 @@ def exists(env): test.write('SConstruct', """ e=Environment(tools=['m4']) -print e.subst('M4 is $M4, M4_MINE is $M4_MINE') +print(e.subst('M4 is $M4, M4_MINE is $M4_MINE')) """) test.run(arguments = '-Q .', stdout = """M4 is my_m4, M4_MINE is 1 diff --git a/test/site_scons/site-dir.py b/test/site_scons/site-dir.py index 8e82e94..d60e7d9 100644 --- a/test/site_scons/site-dir.py +++ b/test/site_scons/site-dir.py @@ -38,7 +38,7 @@ test.subdir('site_scons', ['site_scons', 'site_tools']) test.write(['site_scons', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in site_scons/site_init.py!" +print("Hi there, I am in site_scons/site_init.py!") """) test.write(['site_scons', 'site_tools', 'mytool.py'], """ @@ -55,7 +55,7 @@ test.subdir('alt_site', ['alt_site', 'site_tools']) test.write(['alt_site', 'site_init.py'], """ from SCons.Script import * -print "Hi there, I am in alt_site/site_init.py!" +print("Hi there, I am in alt_site/site_init.py!") """) test.write('SConstruct', """ diff --git a/test/site_scons/site_init.py b/test/site_scons/site_init.py index 9f2e411..27768a9 100644 --- a/test/site_scons/site_init.py +++ b/test/site_scons/site_init.py @@ -51,17 +51,17 @@ import os.path import re special = [] -for x in globals().keys(): +for x in list(globals().keys()): if re.match("__[^_]+__", x): if x in ("__builtins__", "__package__",): # Ignore certain keywords, as they are known to be added by Python continue special.append(x) -print sorted(special) -print __doc__ -print os.path.realpath(__file__) -print __name__ +print(sorted(special)) +print(__doc__) +print(os.path.realpath(__file__)) +print(__name__) """) test.write('SConstruct', "\n") diff --git a/test/site_scons/sysdirs.py b/test/site_scons/sysdirs.py index f50485a..60b4f0b 100644 --- a/test/site_scons/sysdirs.py +++ b/test/site_scons/sysdirs.py @@ -1,71 +1,73 @@ -#!/usr/bin/env python
-#
-# __COPYRIGHT__
-#
-# Permission is hereby granted, free of charge, to any person obtaining
-# a copy of this software and associated documentation files (the
-# "Software"), to deal in the Software without restriction, including
-# without limitation the rights to use, copy, modify, merge, publish,
-# distribute, sublicense, and/or sell copies of the Software, and to
-# permit persons to whom the Software is furnished to do so, subject to
-# the following conditions:
-#
-# The above copyright notice and this permission notice shall be included
-# in all copies or substantial portions of the Software.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
-# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
-# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-#
-
-__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
-
-import TestSCons
-
-"""
-Verify site_scons system dirs are getting loaded.
-Uses an internal test fixture to get at the site_scons dirs.
-
-TODO: it would be great to test if it can actually load site_scons
-files from the system dirs, but the test harness can't put files in
-those dirs (which may not even exist on a build system).
-"""
-
-test = TestSCons.TestSCons()
-
-test.write('SConstruct', """
-import SCons.Script
-SCons.Script.Main.test_load_all_site_scons_dirs(Dir('.').get_internal_path())
-""")
-
-test.run(arguments = '-Q .')
-
-import SCons.Platform
-platform = SCons.Platform.platform_default()
-if platform in ('win32', 'cygwin'):
- dir_to_check_for='Application Data'
-elif platform in ('darwin'):
- dir_to_check_for='Library'
-else:
- dir_to_check_for='.scons'
-
-if 'Loading site dir' not in test.stdout():
- print test.stdout()
- test.fail_test()
-if dir_to_check_for not in test.stdout():
- print test.stdout()
- test.fail_test()
-
-test.pass_test()
-
-# end of file
-
-# Local Variables:
-# tab-width:4
-# indent-tabs-mode:nil
-# End:
-# vim: set expandtab tabstop=4 shiftwidth=4:
+#!/usr/bin/env python +# +# __COPYRIGHT__ +# +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of this software and associated documentation files (the +# "Software"), to deal in the Software without restriction, including +# without limitation the rights to use, copy, modify, merge, publish, +# distribute, sublicense, and/or sell copies of the Software, and to +# permit persons to whom the Software is furnished to do so, subject to +# the following conditions: +# +# The above copyright notice and this permission notice shall be included +# in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY +# KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +# + +from __future__ import print_function + +__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" + +import TestSCons + +""" +Verify site_scons system dirs are getting loaded. +Uses an internal test fixture to get at the site_scons dirs. + +TODO: it would be great to test if it can actually load site_scons +files from the system dirs, but the test harness can't put files in +those dirs (which may not even exist on a build system). +""" + +test = TestSCons.TestSCons() + +test.write('SConstruct', """ +import SCons.Script +SCons.Script.Main.test_load_all_site_scons_dirs(Dir('.').get_internal_path()) +""") + +test.run(arguments = '-Q .') + +import SCons.Platform +platform = SCons.Platform.platform_default() +if platform in ('win32', 'cygwin'): + dir_to_check_for='Application Data' +elif platform in ('darwin'): + dir_to_check_for='Library' +else: + dir_to_check_for='.scons' + +if 'Loading site dir' not in test.stdout(): + print(test.stdout()) + test.fail_test() +if dir_to_check_for not in test.stdout(): + print(test.stdout()) + test.fail_test() + +test.pass_test() + +# end of file + +# Local Variables: +# tab-width:4 +# indent-tabs-mode:nil +# End: +# vim: set expandtab tabstop=4 shiftwidth=4: diff --git a/test/spaces.py b/test/spaces.py index db1ae97..1309047 100644 --- a/test/spaces.py +++ b/test/spaces.py @@ -36,7 +36,7 @@ if sys.platform == 'win32': else: test.write('duplicate a file.sh', 'cp foo.in foo.out\n') copy = test.workpath('duplicate a file.sh') - os.chmod(test.workpath('duplicate a file.sh'), 0777) + os.chmod(test.workpath('duplicate a file.sh'), 0o777) test.write('SConstruct', r''' diff --git a/test/subdivide.py b/test/subdivide.py index 2978e08..44402c9 100644 --- a/test/subdivide.py +++ b/test/subdivide.py @@ -76,8 +76,8 @@ for s in sys.argv[2:]: ofp.write(open(s, 'rb').read()) """) -test.chmod(fake_cc_py, 0755) -test.chmod(fake_link_py, 0755) +test.chmod(fake_cc_py, 0o755) +test.chmod(fake_link_py, 0o755) test.write('SConstruct', """\ SConsignFile(None) diff --git a/test/tool_args.py b/test/tool_args.py index 692f6a5..b0f69ef 100644 --- a/test/tool_args.py +++ b/test/tool_args.py @@ -38,13 +38,13 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ # Test passing kw args to Tool constructor env1 = Environment(tools=[Tool('FooTool', toolpath=['.'], kw1='kw1val')]) -print "env1['TOOL_FOO'] =", env1.get('TOOL_FOO') -print "env1['kw1'] =", env1.get('kw1') +print("env1['TOOL_FOO'] =", env1.get('TOOL_FOO')) +print("env1['kw1'] =", env1.get('kw1')) # Test apply_tools taking a list of (name, kwargs_dict) env2 = Environment(tools=[('FooTool', {'kw2':'kw2val'})], toolpath=['.']) -print "env2['TOOL_FOO'] =", env2.get('TOOL_FOO') -print "env2['kw2'] =", env2.get('kw2') +print("env2['TOOL_FOO'] =", env2.get('TOOL_FOO')) +print("env2['kw2'] =", env2.get('kw2')) """) diff --git a/test/toolpath/basic.py b/test/toolpath/basic.py index e1e6f3c..509d4cb 100644 --- a/test/toolpath/basic.py +++ b/test/toolpath/basic.py @@ -33,63 +33,63 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ def foo(env): env['TOOL_FOO'] = 1 - + env1 = Environment(tools=[foo, 'bar'], toolpath=['tools']) -print "env1['TOOL_FOO'] =", env1.get('TOOL_FOO') -print "env1['TOOL_BAR'] =", env1.get('TOOL_BAR') +print("env1['TOOL_FOO'] =", env1.get('TOOL_FOO')) +print("env1['TOOL_BAR'] =", env1.get('TOOL_BAR')) # pick a built-in tool with pretty simple behavior env2 = Environment(tools=['SCCS']) -print "env2['SCCS'] =", env2.get('SCCS') -print "env2['TOOL_SCCS1'] =", env2.get('TOOL_SCCS1') -print "env2['TOOL_SCCS2'] =", env2.get('TOOL_SCCS2') +print("env2['SCCS'] =", env2.get('SCCS')) +print("env2['TOOL_SCCS1'] =", env2.get('TOOL_SCCS1')) +print("env2['TOOL_SCCS2'] =", env2.get('TOOL_SCCS2')) env3 = Environment(tools=['SCCS'], toolpath=['.']) -print "env3['SCCS'] =", env3.get('SCCS') -print "env3['TOOL_SCCS1'] =", env3.get('TOOL_SCCS1') -print "env3['TOOL_SCCS2'] =", env3.get('TOOL_SCCS2') +print("env3['SCCS'] =", env3.get('SCCS')) +print("env3['TOOL_SCCS1'] =", env3.get('TOOL_SCCS1')) +print("env3['TOOL_SCCS2'] =", env3.get('TOOL_SCCS2')) env4 = Environment(tools=['SCCS'], toolpath=['tools']) -print "env4['SCCS'] =", env4.get('SCCS') -print "env4['TOOL_SCCS1'] =", env4.get('TOOL_SCCS1') -print "env4['TOOL_SCCS2'] =", env4.get('TOOL_SCCS2') +print("env4['SCCS'] =", env4.get('SCCS')) +print("env4['TOOL_SCCS1'] =", env4.get('TOOL_SCCS1')) +print("env4['TOOL_SCCS2'] =", env4.get('TOOL_SCCS2')) env5 = Environment(tools=['SCCS'], toolpath=['tools', '.']) -print "env5['SCCS'] =", env5.get('SCCS') -print "env5['TOOL_SCCS1'] =", env5.get('TOOL_SCCS1') -print "env5['TOOL_SCCS2'] =", env5.get('TOOL_SCCS2') +print("env5['SCCS'] =", env5.get('SCCS')) +print("env5['TOOL_SCCS1'] =", env5.get('TOOL_SCCS1')) +print("env5['TOOL_SCCS2'] =", env5.get('TOOL_SCCS2')) env6 = Environment(tools=['SCCS'], toolpath=['.', 'tools']) -print "env6['SCCS'] =", env6.get('SCCS') -print "env6['TOOL_SCCS1'] =", env6.get('TOOL_SCCS1') -print "env6['TOOL_SCCS2'] =", env6.get('TOOL_SCCS2') +print("env6['SCCS'] =", env6.get('SCCS')) +print("env6['TOOL_SCCS1'] =", env6.get('TOOL_SCCS1')) +print("env6['TOOL_SCCS2'] =", env6.get('TOOL_SCCS2')) env7 = Environment(TOOLPATH="tools", tools=['SCCS'], toolpath=['$TOOLPATH']) -print "env7['SCCS'] =", env7.get('SCCS') -print "env7['TOOL_SCCS1'] =", env7.get('TOOL_SCCS1') -print "env7['TOOL_SCCS2'] =", env7.get('TOOL_SCCS2') +print("env7['SCCS'] =", env7.get('SCCS')) +print("env7['TOOL_SCCS1'] =", env7.get('TOOL_SCCS1')) +print("env7['TOOL_SCCS2'] =", env7.get('TOOL_SCCS2')) env8 = Environment(tools=[]) env8.Tool('SCCS', toolpath=['tools']) -print "env8['SCCS'] =", env8.get('SCCS') -print "env8['TOOL_SCCS1'] =", env8.get('TOOL_SCCS1') -print "env8['TOOL_SCCS2'] =", env8.get('TOOL_SCCS2') +print("env8['SCCS'] =", env8.get('SCCS')) +print("env8['TOOL_SCCS1'] =", env8.get('TOOL_SCCS1')) +print("env8['TOOL_SCCS2'] =", env8.get('TOOL_SCCS2')) env9 = Environment(tools=[]) Tool('SCCS', toolpath=['tools'])(env9) -print "env9['SCCS'] =", env9.get('SCCS') -print "env9['TOOL_SCCS1'] =", env9.get('TOOL_SCCS1') -print "env9['TOOL_SCCS2'] =", env9.get('TOOL_SCCS2') +print("env9['SCCS'] =", env9.get('SCCS')) +print("env9['TOOL_SCCS1'] =", env9.get('TOOL_SCCS1')) +print("env9['TOOL_SCCS2'] =", env9.get('TOOL_SCCS2')) env0 = Environment(TOOLPATH='tools', tools=[]) env0.Tool('SCCS', toolpath=['$TOOLPATH']) -print "env0['SCCS'] =", env0.get('SCCS') -print "env0['TOOL_SCCS1'] =", env0.get('TOOL_SCCS1') -print "env0['TOOL_SCCS2'] =", env0.get('TOOL_SCCS2') +print("env0['SCCS'] =", env0.get('SCCS')) +print("env0['TOOL_SCCS1'] =", env0.get('TOOL_SCCS1')) +print("env0['TOOL_SCCS2'] =", env0.get('TOOL_SCCS2')) base = Environment(tools=[], toolpath=['tools']) derived = base.Clone(tools=['bar']) -print "derived['TOOL_BAR'] =", derived.get('TOOL_BAR') +print("derived['TOOL_BAR'] =", derived.get('TOOL_BAR')) """) test.write('SCCS.py', r"""\ |