Commits

Anonymous committed 86aa2f1

More NT portability in the tests.

  • Participants
  • Parent commits 9b8f484

Comments (0)

Files changed (12)

File src/engine/SCons/Defaults.py

         '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',
         'PROGSUFFIX' : '.exe',
         'LIBPREFIX'  : '',
         'LIBSUFFIX'  : '.lib',
-        'LIBDIRPREFIX'          : '/LIBPATH',
+        'LIBDIRPREFIX'          : '/LIBPATH:',
         'LIBDIRSUFFIX'          : '',
         'LIBLINKPREFIX'         : '',
         'LIBLINKSUFFIX'         : '$LIBSUFFIX',
 __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)
 """)
 
 
-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()

File test/CCFLAGS.py

 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 = '.')
 

File test/CPPPATH.py

 
 __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',
 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"
 """)
 
 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()
 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import os
+import sys
 import TestSCons
 
+python = sys.executable
+
 test = TestSCons.TestSCons()
 
-test.subdir('bin1', 'bin2')
-
-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))
+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(bin1_build_py,
-"""#!/usr/bin/env 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("bin1/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(bin1_build_py, 0755)
-
-test.write(bin2_build_py,
-"""#!/usr/bin/env python
-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()
-""")
-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()

File test/LIBPATH.py

 env.Library(target = './libs/foo1', source = 'f1.c')
 """)
 
-test.write('f1.c', """
+test.write('f1.c', r"""
 void
 f1(void)
 {
 }
 """)
 
-test.write('prog.c', """
+test.write('prog.c', r"""
 void f1(void);
 int
 main(int argc, char *argv[])
 }
 """)
 
-test.run(arguments = 'prog')
+test.run(arguments = '.')
 
 test.run(program = test.workpath('prog'),
          stdout = "f1.c\nprog.c\n")

File test/LINK.py

 __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[])
 {
 }
 """)
 
-test.write('bar.c', """
+test.write('bar.c', r"""
 int
 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()

File test/LINKFLAGS.py

 __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[])
 {
 }
 """)
 
-test.write('bar.c', """
+test.write('bar.c', r"""
 int
 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()

File test/Library.py

 
 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'])

File test/Object.py

 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)
 {
 }
 """)
 
-test.write('f2.cpp', """
+test.write('f2.cpp', r"""
 #include <stdio.h>
 
 void
 }
 """)
 
-test.write('f3.c', """
+test.write('f3.c', r"""
 void
 f3(void)
 {
 }
 """)
 
-test.write('prog.cpp', """
+test.write('prog.cpp', r"""
 #include <stdio.h>
 
 extern "C" void f1(void);
 
 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)
 

File test/Program-j.py

 
 __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', """
 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")
 

File test/Program.py

 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
+import os.path
+import sys
+import time
 import TestSCons
-import os.path
-import time
 
-#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')
 
 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 = '.')
 
 
 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
 }
 """)
 
-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
 }
 """)
 
-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()