python = TestCmd.python_executable
+if string.find(sys.platform, 'irix') != -1:
+ fortran_lib = 'ftn'
+else:
+ fortran_lib = 'g2c'
+
class TestFailed(Exception):
def __init__(self, args=None):
self.args = args
- Using MSVC long command-line linking when running Cygwin.
+ - Portability fixes for a lot of tests.
+
From Allen Bierbaum:
- Pass an Environment to the Options validator method, and
if string.find(sys.platform, 'irix') != -1:
fortran_runtime = 'ftn'
+
+ # f77 does NOT work on cruncher
+ test.no_result()
else:
fortran_runtime = 'g2c'
else:
_exe = ''
_obj = '.o'
- _shobj = '.os'
+ if string.find(sys.platform, 'irix') > -1:
+ _shobj = '.o'
+ else:
+ _shobj = '.os'
test = TestSCons.TestSCons()
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(DVIPDFFLAGS = '-N')
+import os
+ENV = {'PATH' : os.environ['PATH']}
+foo = Environment(DVIPDFFLAGS = '-N', ENV = ENV)
dvipdf = foo.Dictionary('DVIPDF')
-bar = Environment(DVIPDF = r'%s wrapper.py ' + dvipdf)
+bar = Environment(DVIPDF = r'%s wrapper.py ' + dvipdf, ENV = ENV)
foo.PDF(target = 'foo.pdf',
source = foo.DVI(target = 'foo.dvi', source = 'foo.tex'))
bar.PDF(target = 'bar.pdf',
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment()
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV)
dvips = foo.Dictionary('DVIPS')
-bar = Environment(DVIPS = r'%s wrapper.py ' + dvips)
+bar = Environment(ENV = ENV, DVIPS = r'%s wrapper.py ' + dvips)
foo.PostScript(target = 'foo.ps', source = 'foo.tex')
bar.PostScript(target = 'bar1', source = 'bar1.tex')
bar.PostScript(target = 'bar2', source = 'bar2.ltx')
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(DVIPSFLAGS = '-N')
+import os
+ENV = {'PATH' : os.environ['PATH']}
+foo = Environment(ENV = ENV, DVIPSFLAGS = '-N')
dvips = foo.Dictionary('DVIPS')
-bar = Environment(DVIPS = r'%s wrapper.py ' + dvips)
+bar = Environment(ENV = ENV,DVIPS = r'%s wrapper.py ' + dvips)
foo.PostScript(target = 'foo.ps', source = 'foo.tex')
bar.PostScript(target = 'bar1', source = 'bar1.tex')
bar.PostScript(target = 'bar2', source = 'bar2.ltx')
test.write('SConstruct', """
env = Environment(LINK = r'%s mylink.py',
+ LINKFLAGS = [],
F77 = r'%s myg77.py')
env.Program(target = 'test1', source = 'test1.f')
env.Program(target = 'test2', source = 'test2.for')
g77 = test.where_is('g77')
+FTN_LIB = TestSCons.fortran_lib
if g77:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(LIBS = r'%s')
f77 = foo.Dictionary('F77')
bar = foo.Copy(F77 = r'%s wrapper.py ' + f77)
foo.Program(target = 'foo', source = 'foo.f')
bar.Program(target = 'bar', source = 'bar.f')
-""" % python)
+""" % (FTN_LIB, python))
test.write('foo.f', r"""
PROGRAM FOO
test.write('SConstruct', """
env = Environment(LINK = r'%s mylink.py',
+ LINKFLAGS = [],
F77 = r'%s myg77.py', F77FLAGS = '-x')
env.Program(target = 'test1', source = 'test1.f')
env.Program(target = 'test2', source = 'test2.for')
g77 = test.where_is('g77')
+FTN_LIB = TestSCons.fortran_lib
if g77:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(LIBS = r'%s')
f77 = foo.Dictionary('F77')
bar = foo.Copy(F77 = r'%s wrapper.py ' + f77, F77FLAGS = '-Ix')
foo.Program(target = 'foo', source = 'foo.f')
bar.Program(target = 'bar', source = 'bar.f')
-""" % python)
+""" % (FTN_LIB, python))
test.write('foo.f', r"""
PROGRAM FOO
else:
_exe = ''
+FTN_LIB = TestSCons.fortran_lib
+
prog = 'prog' + _exe
subdir_prog = os.path.join('subdir', 'prog' + _exe)
variant_prog = os.path.join('variant', 'prog' + _exe)
test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
test.write('SConstruct', """
-env = Environment(F77PATH = ['$FOO'], LIBS = 'g2c', FOO='include')
+env = Environment(F77PATH = ['$FOO'], LIBS = r'%s', FOO='include')
obj = env.Object(target='foobar/prog', source='subdir/prog.f')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
BuildDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77PATH=[include], LIBS = 'g2c')
+env = Environment(F77PATH=[include], LIBS = r'%s')
SConscript('variant/SConscript', "env")
-""")
+""" % (FTN_LIB, FTN_LIB))
test.write(['subdir', 'SConscript'],
"""
# Change F77PATH and make sure we don't rebuild because of it.
test.write('SConstruct', """
-env = Environment(F77PATH = Split('inc2 include'), LIBS = 'g2c')
+env = Environment(F77PATH = Split('inc2 include'), LIBS = r'%s')
obj = env.Object(target='foobar/prog', source='subdir/prog.f')
env.Program(target='prog', source=obj)
SConscript('subdir/SConscript', "env")
BuildDir('variant', 'subdir', 0)
include = Dir('include')
-env = Environment(F77PATH=['inc2', include], LIBS = 'g2c')
+env = Environment(F77PATH=['inc2', include], LIBS = r'%s')
SConscript('variant/SConscript', "env")
-""")
+""" % (FTN_LIB, FTN_LIB))
test.up_to_date(arguments = args)
# Check that a null-string F77PATH doesn't blow up.
test.write('SConstruct', """
-env = Environment(F77PATH = '', LIBS = 'g2c')
-env.Library('foo', source = '')
-""")
+env = Environment(F77PATH = '', LIBS = r'%s')
+env.Library('foo', source = 'empty.f')
+""" % FTN_LIB)
+
+test.write('empty.f', '')
test.run(arguments = '.')
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """\
-foo = Environment()
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV)
foo.Append(GSFLAGS = ' -q')
foo.PDF(target = 'foo.pdf', source = 'foo.ps')
""")
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment()
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV)
latex = foo.Dictionary('LATEX')
-bar = Environment(LATEX = r'%s wrapper.py ' + latex)
+bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex)
foo.DVI(target = 'foo.dvi', source = 'foo.ltx')
bar.DVI(target = 'bar', source = 'bar.latex')
""" % python)
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LATEXFLAGS = '--output-comment Commentary')
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV, LATEXFLAGS = '--output-comment Commentary')
latex = foo.Dictionary('LATEX')
-bar = Environment(LATEX = r'%s wrapper.py ' + latex)
+bar = Environment(ENV = ENV, LATEX = r'%s wrapper.py ' + latex)
foo.DVI(target = 'foo.dvi', source = 'foo.ltx')
bar.DVI(target = 'bar', source = 'bar.latex')
""" % python)
test()
{
f1();
+ return 0;
}
""")
test.up_to_date(arguments = '.')
+# We need at least one file for some implementations of the Library
+# builder, notably the SGI one.
+test.write('empty.c', '')
+
# Check that a null-string LIBPATH doesn't blow up.
test.write('SConstruct', """
env = Environment(LIBPATH = '')
-env.Library('foo', source = '')
+env.Library('foo', source = 'empty.c')
""")
test.run(arguments = '.')
SConscript('sub2/SConscript', 'env')
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=None)
+
+# on IRIX, ld32 prints out a warning saying that libbaz.a isn't used
+sw = 'ld32: WARNING 84 : ./libbaz.a is not used for resolving any symbol.'
+test.fail_test(not test.stderr() in ['', sw])
test.run(program=foo_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=None)
+test.fail_test(not test.stderr() in ['', sw])
test.run(program=foo_exe, stdout='sub1/bar.c\nsub1/baz.c 2\n')
test.pass_test()
-
-
-
""")
test.write('f3c.c', r"""
+void
f3c(void)
{
printf("f3c.c\n");
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment()
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV)
pdflatex = foo.Dictionary('PDFLATEX')
-bar = Environment(PDFLATEX = r'%s wrapper.py ' + pdflatex)
+bar = Environment(ENV = ENV, PDFLATEX = r'%s wrapper.py ' + pdflatex)
foo.PDF(target = 'foo.pdf', source = 'foo.ltx')
bar.PDF(target = 'bar', source = 'bar.latex')
""" % python)
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(PDFLATEXFLAGS = '--output-comment Commentary')
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV, PDFLATEXFLAGS = '--output-comment Commentary')
pdflatex = foo.Dictionary('PDFLATEX')
-bar = Environment(PDFLATEX = r'%s wrapper.py ' + pdflatex)
+bar = Environment(ENV = ENV, PDFLATEX = r'%s wrapper.py ' + pdflatex)
foo.PDF(target = 'foo.pdf', source = 'foo.ltx')
bar.PDF(target = 'bar', source = 'bar.latex')
""" % python)
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment()
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV)
pdftex = foo.Dictionary('PDFTEX')
-bar = Environment(PDFTEX = r'%s wrapper.py ' + pdftex)
+bar = Environment(ENV = ENV, PDFTEX = r'%s wrapper.py ' + pdftex)
foo.PDF(target = 'foo.pdf', source = 'foo.tex')
bar.PDF(target = 'bar', source = 'bar.tex')
""" % python)
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(PDFTEXFLAGS = '--output-comment Commentary')
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV, PDFTEXFLAGS = '--output-comment Commentary')
pdftex = foo.Dictionary('PDFTEX')
-bar = Environment(PDFTEX = r'%s wrapper.py ' + pdftex)
+bar = Environment(ENV = ENV, PDFTEX = r'%s wrapper.py ' + pdftex)
foo.PDF(target = 'foo.pdf', source = 'foo.tex')
bar.PDF(target = 'bar', source = 'bar.tex')
""" % python)
test.no_result(os.path.exists(test.workpath('work1', 'sub', 'fff.in')))
test.write(['work1', 'SConstruct'], """
+import os
+ENV = {'PATH' : os.environ['PATH']}
def cat(env, source, target):
target = str(target[0])
source = map(str, source)
for src in source:
f.write(open(src, "rb").read())
f.close()
-env = Environment(BUILDERS={'Cat':Builder(action=cat)},
+env = Environment(ENV=ENV,
+ BUILDERS={'Cat':Builder(action=cat)},
RCS_COFLAGS='-q')
env.Cat('aaa.out', 'aaa.in')
env.Cat('bbb.out', 'bbb.in')
test.no_result(os.path.exists(test.workpath('work2', 'sub', 'ccc.in')))
test.write(['work2', 'SConstruct'], """
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
def cat(env, source, target):
target = str(target[0])
source = map(str, source)
f.write(open(src, "rb").read())
f.close()
_default_env['RCS_COFLAGS'] = '-l'
-env = Environment(BUILDERS={'Cat':Builder(action=cat)})
+env = Environment(ENV=ENV, BUILDERS={'Cat':Builder(action=cat)})
env.Cat('aaa.out', 'aaa.in')
env.Cat('bbb.out', 'bbb.in')
env.Cat('ccc.out', 'ccc.in')
import sys
import TestSCons
import os
+import string
if sys.platform == 'win32':
fooflags = '/nologo -DFOO'
fooflags = '-DFOO'
barflags = '-DBAR'
+test = TestSCons.TestSCons()
+
if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
-
-test = TestSCons.TestSCons()
+if string.find(sys.platform, 'irix') > -1:
+ os.environ['LD_LIBRARYN32_PATH'] = '.'
test.write('SConstruct', """
foo = Environment(SHCCFLAGS = '%s', WIN32_INSERT_DEF=1)
import sys
import TestSCons
import os
+import string
if sys.platform == 'win32':
_obj = '.obj'
if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
+if string.find(sys.platform, 'irix') > -1:
+ os.environ['LD_LIBRARYN32_PATH'] = '.'
test = TestSCons.TestSCons()
if sys.platform == 'win32':
_obj = '.obj'
else:
- _obj = '.os'
+ if string.find(sys.platform, 'irix') > -1:
+ _obj = '.o'
+ else:
+ _obj = '.os'
test = TestSCons.TestSCons()
if sys.platform == 'win32':
_obj = '.obj'
else:
- _obj = '.os'
+ if string.find(sys.platform, 'irix') > -1:
+ _obj = '.o'
+ else:
+ _obj = '.os'
test = TestSCons.TestSCons()
g77 = test.where_is('g77')
+FTN_LIB = TestSCons.fortran_lib
if g77:
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(LIBS = 'g2c')
+foo = Environment(LIBS = r'%s')
shf77 = foo.Dictionary('SHF77')
bar = foo.Copy(SHF77 = r'%s wrapper.py ' + shf77, SHF77FLAGS = '-Ix')
foo.SharedLibrary(target = 'foo/foo', source = 'foo.f')
bar.SharedLibrary(target = 'bar/bar', source = 'bar.f')
-""" % python)
+""" % (FTN_LIB, python))
test.write('foo.f', r"""
PROGRAM FOO
if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
+if string.find(sys.platform, 'irix') != -1:
+ os.environ['LD_LIBRARYN32_PATH'] = '.'
test.run(program = test.workpath('prog'),
stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.c\nprog.c\n")
-if sys.platform == 'win32':
+if sys.platform == 'win32' or string.find(sys.platform, 'irix') != -1:
test.run(arguments = '-f SConstructFoo')
else:
test.run(arguments = '-f SConstructFoo', status=2, stderr='''
if opt == '-f': out = arg
def process(outfile, name):
if os.path.isdir(name):
- for entry in os.listdir(name):
+ list = os.listdir(name)
+ list.sort()
+ for entry in list:
process(outfile, os.path.join(name, entry))
else:
outfile.write(open(name, 'rb').read())
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment()
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV)
tex = foo.Dictionary('TEX')
-bar = Environment(TEX = r'%s wrapper.py ' + tex)
+bar = Environment(ENV = ENV, TEX = r'%s wrapper.py ' + tex)
foo.DVI(target = 'foo.dvi', source = 'foo.tex')
bar.DVI(target = 'bar', source = 'bar.tex')
""" % python)
""" % string.replace(test.workpath('wrapper.out'), '\\', '\\\\'))
test.write('SConstruct', """
-foo = Environment(TEXFLAGS = '--output-comment Commentary')
+import os
+ENV = { 'PATH' : os.environ['PATH'] }
+foo = Environment(ENV = ENV, TEXFLAGS = '--output-comment Commentary')
tex = foo.Dictionary('TEX')
-bar = Environment(TEX = r'%s wrapper.py ' + tex)
+bar = Environment(ENV = ENV, TEX = r'%s wrapper.py ' + tex)
foo.DVI(target = 'foo.dvi', source = 'foo.tex')
bar.DVI(target = 'bar', source = 'bar.tex')
""" % python)
import sys
def process(outfile, name):
if os.path.isdir(name):
- for entry in os.listdir(name):
+ list = os.listdir(name)
+ list.sort()
+ for entry in list:
process(outfile, os.path.join(name, entry))
else:
outfile.write(open(name, 'rb').read())
import os
import TestSCons
+python = TestSCons.python
+
test = TestSCons.TestSCons()
test.write('cat.py', r"""
test.write('SConstruct', r"""
env = Environment()
env.Command(target='foo1', source='bar1',
- action='python cat.py $SOURCES > $TARGET')
+ action= '%s cat.py $SOURCES > $TARGET')
env.Command(target='foo2', source='bar2',
- action='python cat.py < $SOURCES > $TARGET')
+ action= '%s cat.py < $SOURCES > $TARGET')
env.Command(target='foo3', source='bar3',
- action='python cat.py $SOURCES | python cat.py > $TARGET')
-""")
+ action='%s cat.py $SOURCES | %s cat.py > $TARGET')
+""" % (python, python, python, python))
test.write('bar1', 'bar1\r\n')
test.write('bar2', 'bar2\r\n')
import TestSCons
import os.path
+python = TestSCons.python
+
test = TestSCons.TestSCons()
test.subdir('subdir')
""")
test.write('SConstruct', """
-B = Builder(action = "python build.py $TARGETS $SOURCES")
+B = Builder(action = "%s build.py $TARGETS $SOURCES")
env = Environment(BUILDERS = { 'B' : B })
env.B(target = 'subdir/f1.out', source = 'subdir/f1.in')
env.B(target = 'subdir/f2.out', source = 'subdir/f2.in')
env.B(target = 'subdir/f3.out', source = 'subdir/f3.in')
env.B(target = 'subdir/f4.out', source = 'subdir/f4.in')
-""")
+""" % python)
test.write(['subdir', 'f1.in'], "f1.in\n")
test.write(['subdir', 'f2.in'], "f2.in\n")