python = TestCmd.python_executable
-if string.find(sys.platform, 'irix') != -1:
+if sys.platform == 'win32':
+ _exe = '.exe'
+ _obj = '.obj'
+ _shobj = '.obj'
+ _dll = '.dll'
+ lib_ = ''
+ fortran_lib = 'g2c'
+elif sys.platform == 'cygwin':
+ _exe = '.exe'
+ _obj = '.o'
+ _shobj = '.os'
+ _dll = '.dll'
+ lib_ = ''
+ fortran_lib = 'g2c'
+elif string.find(sys.platform, 'irix') != -1:
+ _exe = ''
+ _obj = '.o'
+ _shobj = '.o'
+ _dll = '.so'
+ lib_ = 'lib'
fortran_lib = 'ftn'
else:
+ _exe = ''
+ _obj = '.o'
+ _shobj = '.os'
+ _dll = '.so'
+ lib_ = 'lib'
fortran_lib = 'g2c'
class TestFailed(Exception):
# The variable reference substitutes to nothing.
return ''
+ def __cmp__(self, other):
+ return cmp(self.__dict__, other.__dict__)
+
class FunctionAction(ActionBase):
"""Class for Python function actions."""
assert c == "act.py: 'three' 'four'\n", c
cmd5 = r'%s %s %s $TARGET XYZZY' % (python, act_py, outfile)
+
+ act = SCons.Action.CommandAction(cmd5)
+ env5 = Environment()
+ if scons_env.has_key('ENV'):
+ env5['ENV'] = scons_env['ENV']
+ PATH = scons_env['ENV'].get('PATH', '')
+ else:
+ env5['ENV'] = {}
+ PATH = ''
+
+ env5['ENV']['XYZZY'] = 'xyzzy'
+ r = act(target = 'out5', source = [], env = env5)
act = SCons.Action.CommandAction(cmd5)
r = act(target = 'out5',
source = [],
- env = env.Copy(ENV = {'XYZZY' : 'xyzzy'}))
+ env = env.Copy(ENV = {'XYZZY' : 'xyzzy',
+ 'PATH' : PATH}))
assert r == 0
c = test.read(outfile, 'r')
assert c == "act.py: 'out5' 'XYZZY'\nact.py: 'xyzzy'\n", c
# as "file not found" errors
expect_nonexistent = 1
expect_nonexecutable = 1
+ elif sys.platform == 'cygwin':
+ expect_nonexistent = 127
+ expect_nonexecutable = 127
else:
expect_nonexistent = 127
expect_nonexecutable = 126
s2 = s2 + "}\n"
return s1 + s2
+def diff_dict(d1, d2):
+ s1 = "d1 = {\n"
+ s2 = "d2 = {\n"
+ d = {}
+ for k in d1.keys() + d2.keys():
+ d[k] = None
+ keys = d.keys()
+ keys.sort()
+ for k in keys:
+ if d1.has_key(k):
+ if d2.has_key(k):
+ if d1[k] != d2[k]:
+ s1 = s1 + " " + repr(k) + " : " + repr(d1[k]) + "\n"
+ s2 = s2 + " " + repr(k) + " : " + repr(d2[k]) + "\n"
+ else:
+ s1 = s1 + " " + repr(k) + " : " + repr(d1[k]) + "\n"
+ elif env2.has_key(k):
+ s2 = s2 + " " + repr(k) + " : " + repr(d2[k]) + "\n"
+ s1 = s1 + "}\n"
+ s2 = s2 + "}\n"
+ return s1 + s2
+
called_it = {}
built_it = {}
def test_Append(self):
"""Test appending to construction variables in an Environment
"""
+
+ b1 = Environment()['BUILDERS']
+ b2 = Environment()['BUILDERS']
+ assert b1 == b2, diff_dict(b1, b2)
+
import UserList
UL = UserList.UserList
env1 = Environment(AAA = 'a', BBB = 'b', CCC = 'c', DDD = 'd',
if platform == 'os2':
gs = 'gsos2'
-elif platform == 'cygwin' or platform == 'win32':
+elif platform == 'win32':
gs = 'gswin32c'
else:
gs = 'gs'
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
while args:
a = args[0]
args = args[1:]
- if a[0] != '/':
+ if not a[0] in "/-":
if not inf:
inf = a
continue
if a[:3] == '/Fo': out = a[3:]
+ if a == '-o':
+ out = args[0]
+ args = args[1:]
infile = open(inf, 'rb')
outfile = open(out, 'wb')
for l in infile.readlines():
python = TestSCons.python
test = TestSCons.TestSCons()
+_exe = TestSCons._exe
if sys.platform == 'win32':
- _exe = '.exe'
-
o = ' -x'
o_c = ' -x'
else:
- _exe = ''
-
o = ' -x'
o_c = ' -x -c'
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
- _obj = '.obj'
- _shobj = '.obj'
-else:
- _exe = ''
- _obj = '.o'
- if string.find(sys.platform, 'irix') > -1:
- _shobj = '.o'
- else:
- _shobj = '.os'
+_exe = TestSCons._exe
+_obj = TestSCons._obj
+_shobj = TestSCons._shobj
test = TestSCons.TestSCons()
import sys
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
test.write('SConstruct', """
import os
Bld = Builder(action = r"%s build.py $TARGET $SOURCES")
-env1 = Environment(ENV = {'X' : 'env1'}, BUILDERS = { 'Bld' : Bld })
-env2 = Environment(ENV = {'X' : 'env2'}, BUILDERS = { 'Bld' : Bld })
+env1 = Environment(BUILDERS = { 'Bld' : Bld })
+env2 = Environment(BUILDERS = { 'Bld' : Bld })
+env1['ENV']['X'] = 'env1'
+env2['ENV']['X'] = 'env2'
env1.Bld(target = 'env1.out', source = 'input')
env2.Bld(target = 'env2.out', source = 'input')
""" % python)
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
python = TestSCons.python
test = TestSCons.TestSCons()
-
+_exe = TestSCons._exe
if sys.platform == 'win32':
- _exe = '.exe'
-
test.write('mylink.py', r"""
import string
import sys
else:
- _exe = ''
-
test.write('mylink.py', r"""
import getopt
import sys
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import os.path
import time
-if sys.platform == 'win32':
- _exe = '.exe'
- _dll = '.dll'
- lib_ = ''
-else:
- _exe = ''
- _dll = '.so'
- lib_ = 'lib'
+_exe = TestSCons._exe
+_dll = TestSCons._dll
+lib_ = TestSCons.lib_
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import sys
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
f1 = 'f1' + _exe
f2 = 'f2' + _exe
import time
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
python = TestSCons.python
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- _obj = '.obj'
-else:
- if string.find(sys.platform, 'irix') > -1:
- _obj = '.o'
- else:
- _obj = '.os'
+_obj = TestSCons._shobj
test = TestSCons.TestSCons()
import sys
import TestSCons
-if sys.platform == 'win32':
- _lib = '.dll'
-else:
- _lib = '.so'
+_lib = TestSCons._dll
test = TestSCons.TestSCons()
import sys
import TestSCons
-if sys.platform == 'win32':
- lib_ = ''
-else:
- lib_ = 'lib'
+lib_ = TestSCons.lib_
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
+lib_ = TestSCons.lib_
+_shlib = TestSCons._dll
-if sys.platform == 'win32':
- lib_ = ''
- _shlib='.dll'
-else:
- lib_ = 'lib'
- _shlib='.so'
-
test = TestSCons.TestSCons()
test.write("wrapper.py",
import TestSCons
python = TestSCons.python
-
-if sys.platform == 'win32':
- lib_ = ''
- _shlib = '.dll'
-else:
- lib_ = 'lib'
- _shlib = '.so'
+lib_ = TestSCons.lib_
+_shlib = TestSCons._dll
test = TestSCons.TestSCons()
import TestSCons
python = TestSCons.python
+_exe = TestSCons._exe
if sys.platform == 'win32':
- _exe = '.exe'
compiler = 'msvc'
linker = 'mslink'
else:
- _exe = ''
compiler = 'gcc'
linker = 'gnulink'
import TestSCons
python = TestSCons.python
+_exe = TestSCons._exe
if sys.platform == 'win32':
- _exe = '.exe'
compiler = 'msvc'
linker = 'mslink'
else:
- _exe = ''
compiler = 'gcc'
linker = 'gnulink'
test = TestSCons.TestSCons()
-if sys.platform in ['win32', 'cygwin']:
+if sys.platform == 'win32':
lib_static_lib = 'static.lib'
lib_shared_dll ='shared.dll'
arflag_init = '/LIBPATH:' + test.workpath()
arflag = ' /LIBPATH:' + test.workpath()
linkflag_init = '/LIBPATH:' + test.workpath()
linkflag = ' /LIBPATH:' + test.workpath()
+elif sys.platform == 'cygwin':
+ lib_static_lib = 'libstatic.a'
+ lib_shared_dll ='shared.dll'
+ arflag_init = 'r'
+ arflag = 'o'
+ linkflag_init = '-L' + test.workpath()
+ linkflag = ' -L' + test.workpath()
else:
lib_shared_dll = 'libshared.so'
lib_static_lib = 'libstatic.a'
import TestSCons
import string
-if sys.platform == 'win32':
- _exe = '.exe'
- _obj = '.obj'
-else:
- _exe = ''
- _obj = '.o'
+_exe = TestSCons._exe
+_obj = TestSCons._obj
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
import sys
import TestSCons
-if sys.platform == 'win32':
- _exe = '.exe'
-else:
- _exe = ''
+_exe = TestSCons._exe
test = TestSCons.TestSCons()
test = TestSCons.TestSCons()
-file_names = [
+attempt_file_names = [
'File with spaces',
'File"with"double"quotes',
"File'with'single'quotes",
"Combination '\"\n\\;<>?|*\t&"
]
-if os.name == 'nt':
- # Windows only supports spaces.
- file_names = file_names[0:1]
-
test.write("cat.py", """\
import sys
open(sys.argv[1], 'wb').write(open(sys.argv[2], 'rb').read())
""")
-for fn in file_names:
- test.write(fn + '.in', fn + '\n')
+file_names = []
+for fn in attempt_file_names:
+ try:
+ test.write(fn + '.in', fn + '\n')
+ file_names.append(fn)
+ except IOError:
+ # if the Python interpreter can't handle it, don't bother
+ # testing to see if SCons can
+ pass
def buildFileStr(fn):
return "env.Build(source=r\"\"\"%s.in\"\"\", target=r\"\"\"%s.out\"\"\")" % ( fn, fn )