diff options
-rw-r--r-- | src/engine/SCons/Defaults.py | 4 | ||||
-rw-r--r-- | test/CC.py | 25 | ||||
-rw-r--r-- | test/CCFLAGS.py | 4 | ||||
-rw-r--r-- | test/CPPPATH.py | 34 | ||||
-rw-r--r-- | test/ENV.py | 50 | ||||
-rw-r--r-- | test/LIBPATH.py | 6 | ||||
-rw-r--r-- | test/LINK.py | 29 | ||||
-rw-r--r-- | test/LINKFLAGS.py | 29 | ||||
-rw-r--r-- | test/Library.py | 2 | ||||
-rw-r--r-- | test/Object.py | 10 | ||||
-rw-r--r-- | test/Program-j.py | 29 | ||||
-rw-r--r-- | test/Program.py | 73 |
12 files changed, 163 insertions, 132 deletions
diff --git a/src/engine/SCons/Defaults.py b/src/engine/SCons/Defaults.py index be750e4..ba1b9e9 100644 --- a/src/engine/SCons/Defaults.py +++ b/src/engine/SCons/Defaults.py @@ -114,7 +114,7 @@ elif os.name == 'nt': 'CXXFLAGS' : '$CCFLAGS', 'CXXCOM' : '$CXX $CXXFLAGS $_INCFLAGS /c $SOURCES /Fo$TARGET', 'LINK' : 'link', - 'LINKFLAGS' : '', + 'LINKFLAGS' : '/nologo', 'LINKCOM' : '$LINK $LINKFLAGS /OUT:$TARGET $_LIBDIRFLAGS $_LIBFLAGS $SOURCES', 'AR' : 'lib', 'ARFLAGS' : '/nologo', @@ -127,7 +127,7 @@ elif os.name == 'nt': 'PROGSUFFIX' : '.exe', 'LIBPREFIX' : '', 'LIBSUFFIX' : '.lib', - 'LIBDIRPREFIX' : '/LIBPATH', + 'LIBDIRPREFIX' : '/LIBPATH:', 'LIBDIRSUFFIX' : '', 'LIBLINKPREFIX' : '', 'LIBLINKSUFFIX' : '$LIBSUFFIX', @@ -25,24 +25,31 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os +import string import sys import TestSCons python = sys.executable +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + test = TestSCons.TestSCons() -test.write("ccwrapper.py", +test.write("wrapper.py", """import os import string import sys -open('%s', 'wb').write("ccwrapper.py\\n") -os.system(string.join(["cc"] + sys.argv[1:], " ")) -""" % test.workpath('ccwrapper.out')) +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ foo = Environment() -bar = Environment(CC = r'%s ccwrapper.py') +cc = foo.Dictionary('CC') +bar = Environment(CC = r'%s wrapper.py ' + cc) foo.Program(target = 'foo', source = 'foo.c') bar.Program(target = 'bar', source = 'bar.c') """ % python) @@ -68,12 +75,12 @@ main(int argc, char *argv[]) """) -test.run(arguments = 'foo') +test.run(arguments = 'foo' + _exe) -test.fail_test(os.path.exists(test.workpath('ccwrapper.out'))) +test.fail_test(os.path.exists(test.workpath('wrapper.out'))) -test.run(arguments = 'bar') +test.run(arguments = 'bar' + _exe) -test.fail_test(test.read('ccwrapper.out') != "ccwrapper.py\n") +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.pass_test() diff --git a/test/CCFLAGS.py b/test/CCFLAGS.py index 3c9e716..098b5cb 100644 --- a/test/CCFLAGS.py +++ b/test/CCFLAGS.py @@ -69,12 +69,12 @@ test.run(program = test.workpath('foo'), stdout = "prog.c: FOO\n") test.run(program = test.workpath('bar'), stdout = "prog.c: BAR\n") test.write('SConstruct', """ -bar = Environment(CCFLAGS = '-DBAR') +bar = Environment(CCFLAGS = '%s') bar.Object(target = 'foo%s', source = 'prog.c') bar.Object(target = 'bar%s', source = 'prog.c') bar.Program(target = 'foo', source = 'foo%s') bar.Program(target = 'bar', source = 'bar%s') -""" % (_obj, _obj, _obj, _obj)) +""" % (barflags, _obj, _obj, _obj, _obj)) test.run(arguments = '.') diff --git a/test/CPPPATH.py b/test/CPPPATH.py index 345603b..30b0c22 100644 --- a/test/CPPPATH.py +++ b/test/CPPPATH.py @@ -24,8 +24,16 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys import TestSCons +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + +prog = 'prog' + _exe + test = TestSCons.TestSCons() test.write('foo.c', @@ -43,13 +51,13 @@ int main(void) test.subdir('include') test.write('include/foo.h', -""" +r""" #define FOO_STRING "foo.h 1\n" #include "bar.h" """) test.write('include/bar.h', -""" +r""" #define BAR_STRING "bar.h 1\n" """) @@ -58,38 +66,38 @@ env = Environment(CPPPATH = ['include']) env.Program(target='prog', source='foo.c') """) -test.run(arguments = 'prog') +test.run(arguments = prog) -test.run(program = test.workpath('prog'), +test.run(program = test.workpath(prog), stdout = "foo.h 1\nbar.h 1\n") -test.up_to_date(arguments = 'prog') +test.up_to_date(arguments = prog) test.unlink('include/foo.h') test.write('include/foo.h', -""" +r""" #define FOO_STRING "foo.h 2\n" #include "bar.h" """) -test.run(arguments = 'prog') +test.run(arguments = prog) -test.run(program = test.workpath('prog'), +test.run(program = test.workpath(prog), stdout = "foo.h 2\nbar.h 1\n") -test.up_to_date(arguments = 'prog') +test.up_to_date(arguments = prog) test.unlink('include/bar.h') test.write('include/bar.h', -""" +r""" #define BAR_STRING "bar.h 2\n" """) -test.run(arguments = 'prog') +test.run(arguments = prog) -test.run(program = test.workpath('prog'), +test.run(program = test.workpath(prog), stdout = "foo.h 2\nbar.h 2\n") -test.up_to_date(arguments = 'prog') +test.up_to_date(arguments = prog) test.pass_test() diff --git a/test/ENV.py b/test/ENV.py index 50032df..24fb572 100644 --- a/test/ENV.py +++ b/test/ENV.py @@ -24,56 +24,38 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import os +import sys import TestSCons -test = TestSCons.TestSCons() +python = sys.executable -test.subdir('bin1', 'bin2') +test = TestSCons.TestSCons() -bin1 = test.workpath('bin1') -bin2 = test.workpath('bin2') bin1_build_py = test.workpath('bin1', 'build.py') bin2_build_py = test.workpath('bin2', 'build.py') test.write('SConstruct', """ import os -bin1_path = r'%s' + os.pathsep + os.environ['PATH'] -bin2_path = r'%s' + os.pathsep + os.environ['PATH'] -Bld = Builder(name = 'Bld', action = "build.py $TARGET $SOURCES") -bin1 = Environment(ENV = {'PATH' : bin1_path}, BUILDERS = [Bld]) -bin2 = Environment(ENV = {'PATH' : bin2_path}, BUILDERS = [Bld]) -bin1.Bld(target = 'bin1.out', source = 'input') -bin2.Bld(target = 'bin2.out', source = 'input') -""" % (bin1, bin2)) - -test.write(bin1_build_py, -"""#!/usr/bin/env python -import sys -contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') -file.write("bin1/build.py\\n") -file.write(contents) -file.close() -""") -os.chmod(bin1_build_py, 0755) - -test.write(bin2_build_py, -"""#!/usr/bin/env python +Bld = Builder(name = 'Bld', action = "%s build.py $TARGET $SOURCES") +env1 = Environment(ENV = {'X' : 'env1'}, BUILDERS = [Bld]) +env2 = Environment(ENV = {'X' : 'env2'}, BUILDERS = [Bld]) +env1.Bld(target = 'env1.out', source = 'input') +env2.Bld(target = 'env2.out', source = 'input') +""" % python) + +test.write('build.py', +r"""#!/usr/bin/env python +import os import sys contents = open(sys.argv[2], 'rb').read() -file = open(sys.argv[1], 'wb') -file.write("bin2/build.py\\n") -file.write(contents) -file.close() +open(sys.argv[1], 'wb').write("build.py %s\n%s" % (os.environ['X'], contents)) """) -os.chmod(bin2_build_py, 0755) test.write('input', "input file\n") test.run(arguments = '.') -test.fail_test(test.read('bin1.out') != "bin1/build.py\ninput file\n") -test.fail_test(test.read('bin2.out') != "bin2/build.py\ninput file\n") +test.fail_test(test.read('env1.out') != "build.py env1\ninput file\n") +test.fail_test(test.read('env2.out') != "build.py env2\ninput file\n") test.pass_test() diff --git a/test/LIBPATH.py b/test/LIBPATH.py index 2efd236..7d5a7cc 100644 --- a/test/LIBPATH.py +++ b/test/LIBPATH.py @@ -35,7 +35,7 @@ env.Program(target = 'prog', source = 'prog.c') env.Library(target = './libs/foo1', source = 'f1.c') """) -test.write('f1.c', """ +test.write('f1.c', r""" void f1(void) { @@ -43,7 +43,7 @@ f1(void) } """) -test.write('prog.c', """ +test.write('prog.c', r""" void f1(void); int main(int argc, char *argv[]) @@ -55,7 +55,7 @@ main(int argc, char *argv[]) } """) -test.run(arguments = 'prog') +test.run(arguments = '.') test.run(program = test.workpath('prog'), stdout = "f1.c\nprog.c\n") diff --git a/test/LINK.py b/test/LINK.py index 6b99976..3a8ab33 100644 --- a/test/LINK.py +++ b/test/LINK.py @@ -25,29 +25,36 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os +import string import sys import TestSCons python = sys.executable +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + test = TestSCons.TestSCons() -test.write("ccwrapper.py", +test.write("wrapper.py", """import os import string import sys -open('%s', 'wb').write("ccwrapper.py\\n") -os.system(string.join(["cc"] + sys.argv[1:], " ")) -""" % test.workpath('ccwrapper.out')) +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ foo = Environment() -bar = Environment(LINK = r'%s ccwrapper.py') +link = foo.Dictionary('LINK') +bar = Environment(LINK = r'%s wrapper.py ' + link) foo.Program(target = 'foo', source = 'foo.c') bar.Program(target = 'bar', source = 'bar.c') """ % python) -test.write('foo.c', """ +test.write('foo.c', r""" int main(int argc, char *argv[]) { @@ -57,7 +64,7 @@ main(int argc, char *argv[]) } """) -test.write('bar.c', """ +test.write('bar.c', r""" int main(int argc, char *argv[]) { @@ -68,12 +75,12 @@ main(int argc, char *argv[]) """) -test.run(arguments = 'foo') +test.run(arguments = 'foo' + _exe) -test.fail_test(os.path.exists(test.workpath('ccwrapper.out'))) +test.fail_test(os.path.exists(test.workpath('wrapper.out'))) -test.run(arguments = 'bar') +test.run(arguments = 'bar' + _exe) -test.fail_test(test.read('ccwrapper.out') != "ccwrapper.py\n") +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.pass_test() diff --git a/test/LINKFLAGS.py b/test/LINKFLAGS.py index ff4ee88..3b6e735 100644 --- a/test/LINKFLAGS.py +++ b/test/LINKFLAGS.py @@ -25,29 +25,36 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" import os +import string import sys import TestSCons python = sys.executable +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + test = TestSCons.TestSCons() -test.write("ccwrapper.py", +test.write("wrapper.py", """import os import string import sys -open('%s', 'wb').write("ccwrapper.py\\n") -os.system(string.join(["cc"] + sys.argv[1:], " ")) -""" % test.workpath('ccwrapper.out')) +open('%s', 'wb').write("wrapper.py\\n") +os.system(string.join(sys.argv[1:], " ")) +""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\')) test.write('SConstruct', """ foo = Environment() -bar = Environment(LINK = '', LINKFLAGS = r'%s ccwrapper.py') +link = foo.Dictionary('LINK') +bar = Environment(LINK = '', LINKFLAGS = r'%s wrapper.py ' + link) foo.Program(target = 'foo', source = 'foo.c') bar.Program(target = 'bar', source = 'bar.c') """ % python) -test.write('foo.c', """ +test.write('foo.c', r""" int main(int argc, char *argv[]) { @@ -57,7 +64,7 @@ main(int argc, char *argv[]) } """) -test.write('bar.c', """ +test.write('bar.c', r""" int main(int argc, char *argv[]) { @@ -68,12 +75,12 @@ main(int argc, char *argv[]) """) -test.run(arguments = 'foo') +test.run(arguments = 'foo' + _exe) -test.fail_test(os.path.exists(test.workpath('ccwrapper.out'))) +test.fail_test(os.path.exists(test.workpath('wrapper.out'))) -test.run(arguments = 'bar') +test.run(arguments = 'bar' + _exe) -test.fail_test(test.read('ccwrapper.out') != "ccwrapper.py\n") +test.fail_test(test.read('wrapper.out') != "wrapper.py\n") test.pass_test() diff --git a/test/Library.py b/test/Library.py index 12f98f0..d3a412d 100644 --- a/test/Library.py +++ b/test/Library.py @@ -30,7 +30,7 @@ test = TestSCons.TestSCons() test.write('SConstruct', """ env = Environment(LIBS = [ 'foo1', 'foo2', 'foo3' ], - LIBPATH = [ './' ]) + LIBPATH = [ '.' ]) env.Library(target = 'foo1', source = 'f1.c') env.Library(target = 'foo2', source = 'f2a.c f2b.c f2c.c') env.Library(target = 'foo3', source = ['f3a.c', 'f3b.c', 'f3c.c']) diff --git a/test/Object.py b/test/Object.py index ebbdf0f..93a0b94 100644 --- a/test/Object.py +++ b/test/Object.py @@ -44,7 +44,7 @@ env.Program(target = 'prog2', source = [f1, f2, f3, 'prog.cpp']) env.Program(target = 'prog3', source = ['f1%s', f2, 'f3%s', 'prog.cpp']) """ % (_obj, _obj, _obj, _obj, _obj)) -test.write('f1.c', """ +test.write('f1.c', r""" void f1(void) { @@ -52,7 +52,7 @@ f1(void) } """) -test.write('f2.cpp', """ +test.write('f2.cpp', r""" #include <stdio.h> void @@ -62,7 +62,7 @@ f2(void) } """) -test.write('f3.c', """ +test.write('f3.c', r""" void f3(void) { @@ -70,7 +70,7 @@ f3(void) } """) -test.write('prog.cpp', """ +test.write('prog.cpp', r""" #include <stdio.h> extern "C" void f1(void); @@ -90,7 +90,7 @@ main(int argc, char *argv[]) stdout = "f1.c\nf2.c\nf3.c\nprog.c\n" -test.run(arguments = 'prog1 prog2 prog3') +test.run(arguments = '.') test.run(program = test.workpath('prog1'), stdout = stdout) diff --git a/test/Program-j.py b/test/Program-j.py index 6b86127..231fff8 100644 --- a/test/Program-j.py +++ b/test/Program-j.py @@ -24,8 +24,19 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys import TestSCons +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' + +f1 = 'f1' + _exe +f2 = 'f2' + _exe +f3 = 'f3' + _exe +f4 = 'f4' + _exe + test = TestSCons.TestSCons() test.write('SConstruct', """ @@ -36,49 +47,49 @@ env.Program(target = 'f3', source = 'f3.c') env.Program(target = 'f4', source = 'f4.c') """) -test.write('f1.c', """ +test.write('f1.c', r""" int main(int argc, char *argv[]) { argv[argc++] = "--"; - printf(\"f1.c\n\"); + printf("f1.c\n"); exit (0); } """) -test.write('f2.c', """ +test.write('f2.c', r""" int main(int argc, char *argv[]) { argv[argc++] = "--"; - printf(\"f2.c\n\"); + printf("f2.c\n"); exit (0); } """) -test.write('f3.c', """ +test.write('f3.c', r""" int main(int argc, char *argv[]) { argv[argc++] = "--"; - printf(\"f3.c\n\"); + printf("f3.c\n"); exit (0); } """) -test.write('f4.c', """ +test.write('f4.c', r""" int main(int argc, char *argv[]) { argv[argc++] = "--"; - printf(\"f4.c\n\"); + printf("f4.c\n"); exit (0); } """) -test.run(arguments = '-j 3 f1 f2 f3 f4') +test.run(arguments = '-j 3 %s %s %s %s' % (f1, f2, f3, f4)) test.run(program = test.workpath('f1'), stdout = "f1.c\n") diff --git a/test/Program.py b/test/Program.py index a32c48e..7d1a3fd 100644 --- a/test/Program.py +++ b/test/Program.py @@ -24,14 +24,23 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" -import TestSCons import os.path +import sys import time +import TestSCons -#XXX Future: be able to interpolate +if sys.platform == 'win32': + _exe = '.exe' +else: + _exe = '' test = TestSCons.TestSCons() +foo1 = test.workpath('foo1' + _exe) +foo2 = test.workpath('foo2' + _exe) +foo3 = test.workpath('foo3' + _exe) +foo_args = 'foo1%s foo2%s foo3%s' % (_exe, _exe, _exe) + test.write('SConstruct', """ env = Environment() env.Program(target = 'foo1', source = 'f1.c') @@ -111,9 +120,9 @@ main(int argc, char *argv[]) test.run(arguments = '.') -test.run(program = test.workpath('foo1'), stdout = "f1.c\n") -test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") -test.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c\nf3c.c\n") +test.run(program = foo1, stdout = "f1.c\n") +test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n") +test.run(program = foo3, stdout = "f3a.c\nf3b.c\nf3c.c\n") test.up_to_date(arguments = '.') @@ -137,24 +146,24 @@ f3b(void) test.run(arguments = '.') -test.run(program = test.workpath('foo1'), stdout = "f1.c X\n") -test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") -test.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c X\nf3c.c\n") +test.run(program = foo1, stdout = "f1.c X\n") +test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n") +test.run(program = foo3, stdout = "f3a.c\nf3b.c X\nf3c.c\n") test.up_to_date(arguments = '.') # make sure the programs didn't get rebuilt, because nothing changed: -oldtime1 = os.path.getmtime(test.workpath('foo1')) -oldtime2 = os.path.getmtime(test.workpath('foo2')) -oldtime3 = os.path.getmtime(test.workpath('foo3')) +oldtime1 = os.path.getmtime(foo1) +oldtime2 = os.path.getmtime(foo2) +oldtime3 = os.path.getmtime(foo3) time.sleep(2) # introduce a small delay, to make the test valid -test.run(arguments = 'foo1 foo2 foo3') +test.run(arguments = foo_args) -test.fail_test(not (oldtime1 == os.path.getmtime(test.workpath('foo1')))) -test.fail_test(not (oldtime2 == os.path.getmtime(test.workpath('foo2')))) -test.fail_test(not (oldtime3 == os.path.getmtime(test.workpath('foo3')))) +test.fail_test(oldtime1 != os.path.getmtime(foo1)) +test.fail_test(oldtime2 != os.path.getmtime(foo2)) +test.fail_test(oldtime3 != os.path.getmtime(foo3)) test.write('f1.c', r""" int @@ -174,13 +183,13 @@ f3b(void) } """) -test.run(arguments = 'foo1 foo2 foo3') +test.run(arguments = foo_args) -test.run(program = test.workpath('foo1'), stdout = "f1.c Y\n") -test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") -test.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c Y\nf3c.c\n") +test.run(program = foo1, stdout = "f1.c Y\n") +test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n") +test.run(program = foo3, stdout = "f3a.c\nf3b.c Y\nf3c.c\n") -test.up_to_date(arguments = 'foo1 foo2 foo3') +test.up_to_date(arguments = foo_args) test.write('f1.c', r""" int @@ -200,25 +209,25 @@ f3b(void) } """) -test.run(arguments = 'foo1 foo2 foo3') +test.run(arguments = foo_args) -test.run(program = test.workpath('foo1'), stdout = "f1.c Z\n") -test.run(program = test.workpath('foo2'), stdout = "f2a.c\nf2b.c\nf2c.c\n") -test.run(program = test.workpath('foo3'), stdout = "f3a.c\nf3b.c Z\nf3c.c\n") +test.run(program = foo1, stdout = "f1.c Z\n") +test.run(program = foo2, stdout = "f2a.c\nf2b.c\nf2c.c\n") +test.run(program = foo3, stdout = "f3a.c\nf3b.c Z\nf3c.c\n") -test.up_to_date(arguments = 'foo1 foo2 foo3') +test.up_to_date(arguments = foo_args) # make sure the programs didn't get rebuilt, because nothing changed: -oldtime1 = os.path.getmtime(test.workpath('foo1')) -oldtime2 = os.path.getmtime(test.workpath('foo2')) -oldtime3 = os.path.getmtime(test.workpath('foo3')) +oldtime1 = os.path.getmtime(foo1) +oldtime2 = os.path.getmtime(foo2) +oldtime3 = os.path.getmtime(foo3) time.sleep(2) # introduce a small delay, to make the test valid -test.run(arguments = 'foo1 foo2 foo3') +test.run(arguments = foo_args) -test.fail_test(not (oldtime1 == os.path.getmtime(test.workpath('foo1')))) -test.fail_test(not (oldtime2 == os.path.getmtime(test.workpath('foo2')))) -test.fail_test(not (oldtime3 == os.path.getmtime(test.workpath('foo3')))) +test.fail_test(not (oldtime1 == os.path.getmtime(foo1))) +test.fail_test(not (oldtime2 == os.path.getmtime(foo2))) +test.fail_test(not (oldtime3 == os.path.getmtime(foo3))) test.pass_test() |