self.match_func = match_re_dotall
apply(self.run, [], kw)
self.match_func = old_match_func
+
+# In some environments, $AR will generate a warning message to stderr
+# if the library doesn't previously exist and is being created. One
+# way to fix this is to tell AR to be quiet (sometimes the 'c' flag),
+# but this is difficult to do in a platform-/implementation-specific
+# method. Instead, we will use the following as a stderr match for
+# tests that use AR so that we will view zero or more "ar: creating
+# <file>" messages to be successful executions of the test (see
+# test/AR.py for sample usage).
+
+noisy_ar=r'(ar: creating \S+\n?)*'
From Kevin Quick:
+ - Handling SCons exceptions according to Pythonic standards.
+
- Fix test/chained-build.py on systems that execute within one second.
+ - Fix tests on systems where 'ar' warns about archive creation.
+
From Anthony Roach:
- Fix use of the --implicit-cache option with timestamp signatures.
python = TestSCons.python
_exe = TestSCons._exe
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.write("wrapper.py",
"""import os
""")
-test.run(arguments = 'f' + _exe)
+test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
-test.run(arguments = 'b' + _exe)
+test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
python = TestSCons.python
_exe = TestSCons._exe
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.write("wrapper.py",
"""import os
""")
-test.run(arguments = 'f' + _exe)
+test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
-test.run(arguments = 'b' + _exe)
+test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
args = prog + ' ' + subdir_prog + ' ' + variant_prog
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
test.write('empty.c', """
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.pass_test()
__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
"""
-Test that dependencies in generated header files get re-scanned correctly.
+Test that dependencies in generated header files get re-scanned correctly
+and that generated header files don't cause circular dependencies.
"""
import TestSCons
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.write('SConstruct', """\
def writeFile(target, contents):
lambda env,target,source: writeFile(target, '#include "gen.h"\\n'))
""")
-test.run()
+test.run(stderr=TestSCons.noisy_ar)
test.up_to_date(arguments = '.')
+test.write('SConstruct', """\
+env = Environment()
+
+def gen_a_h(target, source, env):
+ t = open(str(target[0]), 'wb')
+ s = open(str(source[0]), 'rb')
+ s.readline()
+ t.write(s.readline()[:-1] + ';\\n')
+
+MakeHeader = Builder(action = gen_a_h)
+env_no_scan = env.Copy(SCANNERS=[], BUILDERS={'MakeHeader' : MakeHeader})
+env_no_scan.MakeHeader('a.h', 'a.c')
+
+env.StaticObject('a.c')
+""")
+
+test.write('a.c', """\
+#include "a.h"
+void a(void)
+{
+ ;
+}
+""")
+
+test.run()
+
test.pass_test()
import TestSCons
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir('work1', ['work1', 'dist'])
int foo = 3;
""")
-test.run(chdir = 'work1', arguments = ".")
+test.run(chdir = 'work1', arguments = ".", stderr=TestSCons.noisy_ar)
test.up_to_date(chdir = 'work1', arguments = ".")
_dll = TestSCons._dll
dll_ = TestSCons.dll_
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir('lib1', 'lib2')
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.run(program = prog1,
stdout = "f1.c\nprog.c\n")
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.run(program = prog1,
stdout = "f1.c 1\nprog.c\n")
test.fail_test(oldtime2 == os.path.getmtime(prog2))
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.run(program = prog1,
stdout = "f1.c 2\nprog.c\n")
env.Library('foo', source = 'empty.c')
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.pass_test()
else:
_lib = '.a'
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.write('SConstruct', """
env = Environment(LIBPREFIX = 'xxx-',
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.fail_test(not os.path.exists(test.workpath('xxx-foo' + _lib)))
_exe = ''
bar_lib = 'libbar.a'
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir('sub1', 'sub2')
SConscript('sub2/SConscript', 'env')
""")
-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.\n'
-test.fail_test(not test.stderr() in ['', sw])
+test.run(arguments = '.', stderr='(%s|%s'%(sw, TestSCons.noisy_ar[1:]))
+#test.fail_test(not test.stderr() in ['', sw])
test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c\n')
}
""")
-test.run(arguments = '.', stderr=None)
-test.fail_test(not test.stderr() in ['', sw])
+test.run(arguments = '.', stderr='(%s|%s'%(sw, TestSCons.noisy_ar[1:]))
+#test.fail_test(not test.stderr() in ['', sw, TestSCons.noisy_ar])
test.run(program=foo1_exe, stdout='sub1/bar.c\nsub1/baz.c 2\n')
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.run(program=blender_exe,
stdout='src/component1/message.c\nsrc/component2/hello.c\n')
else:
lib_ = 'lib'
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.write('SConstruct', """
env = Environment(LIBSUFFIX = '.xxx',
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.fail_test(not os.path.exists(test.workpath(lib_ + 'foo.xxx')))
import TestSCons
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.write('SConstruct', """
env = Environment(LIBS = [ 'foo1', 'libfoo2' ],
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.run(program = test.workpath('prog'),
stdout = "f1.c\nf2a.c\nf2b.c\nf2c.c\nf3a.c\nf3b.c\nf3c.cpp\nprog.c\n")
}
""")
-test.run()
+test.run(stderr=TestSCons.noisy_ar)
test.run(program = test.workpath('uses-nrd'),
stdout = "nrd\n")
_dll = TestSCons._dll
_shobj = TestSCons._shobj
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'] )
env.StaticLibrary( 'myqt', 'my_qobject.cpp' )
""")
-test.run(chdir=test.workpath('qt','lib'), arguments = '.')
+test.run(chdir=test.workpath('qt','lib'), arguments = '.',
+ stderr=TestSCons.noisy_ar)
QT = test.workpath('qt')
QT_LIB = 'myqt'
}
""")
-test.run(chdir='work3', arguments = lib_aaa)
+test.run(chdir='work3', arguments = lib_aaa, stderr=TestSCons.noisy_ar)
test.up_to_date(chdir='work3', options = '-n', arguments = lib_aaa)
test.write(['work3', 'aaa.cpp'], r"""
#include "my_qobject.h"
test.run(chdir='work3',
arguments = "build_dir=1 " +
- test.workpath('work3', 'build', lib_aaa) )
+ test.workpath('work3', 'build', lib_aaa),
+ stderr=TestSCons.noisy_ar )
test.run(chdir='work3',
arguments = "build_dir=1 chdir=1 " +
test.workpath('work3', 'build', lib_aaa) )
python = TestSCons.python
_exe = TestSCons._exe
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir( 'qt', ['qt', 'bin'], ['qt', 'include'], ['qt', 'lib'] )
env.StaticLibrary( 'myqt', 'my_qobject.cpp' )
""")
-test.run(chdir=test.workpath('qt','lib'), arguments = '.')
+test.run(chdir=test.workpath('qt','lib'), arguments = '.',
+ stderr=TestSCons.noisy_ar)
QT = test.workpath('qt')
QT_LIB = 'myqt'
_exe = TestSCons._exe
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
ranlib = test.detect('RANLIB', 'ranlib')
""")
-test.run(arguments = 'f' + _exe)
+test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
-test.run(arguments = 'b' + _exe)
+test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
python = TestSCons.python
_exe = TestSCons._exe
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
ranlib = test.detect('RANLIB', 'ranlib')
""")
-test.run(arguments = 'f' + _exe)
+test.run(arguments = 'f' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(os.path.exists(test.workpath('wrapper.out')))
-test.run(arguments = 'b' + _exe)
+test.run(arguments = 'b' + _exe, stderr=TestSCons.noisy_ar)
test.fail_test(test.read('wrapper.out') != "wrapper.py\n")
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
#
test.subdir('repository', 'work1', 'work2', 'work3')
test.writable('repository', 0)
#
-test.run(chdir = 'work1', options = opts, arguments = ".")
+test.run(chdir = 'work1', options = opts, arguments = ".",
+ stderr=TestSCons.noisy_ar)
test.run(program = work1_foo, stdout =
"""repository/aaa.c
}
""")
-test.run(chdir = 'work1', options = opts, arguments = ".")
+test.run(chdir = 'work1', options = opts, arguments = ".",
+ stderr=TestSCons.noisy_ar)
test.run(program = work1_foo, stdout =
"""repository/aaa.c
#
test.writable('repository', 1)
-test.run(chdir = 'repository', options = opts, arguments = ".")
+test.run(chdir = 'repository', options = opts, arguments = ".",
+ stderr=TestSCons.noisy_ar)
test.run(program = repository_foo, stdout =
"""repository/aaa.c
}
""")
-test.run(chdir = 'work2', options = opts, arguments = ".")
+test.run(chdir = 'work2', options = opts, arguments = ".",
+ stderr=TestSCons.noisy_ar)
test.run(program = work2_foo, stdout =
"""repository/aaa.c
import TestCmd
import TestSCons
-test = TestSCons.TestSCons(match=TestCmd.match_re)
+test = TestSCons.TestSCons(match=TestCmd.match_re_dotall)
test.write('SConstruct', """
import sys
}
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
if os.name == 'posix':
os.environ['LD_LIBRARY_PATH'] = '.'
scons: \*\*\* Source file: foo\..* is static and is not compatible with shared target: .*
''')
-test.run(arguments = '-f SConstructFoo2')
+test.run(arguments = '-f SConstructFoo2', stderr=TestSCons.noisy_ar)
if sys.platform == 'win32':
# Make sure we don't insert a .def source file (when
import sys
import TestSCons
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
if sys.platform == 'win32':
lib_static_lib = 'static.lib'
""")
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
test.up_to_date(arguments = '.')
import TestCmd
import TestSCons
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
test.subdir('simple',
'SLF',
create file4.x from file3.x
"""))
-test.run(arguments = 'SLF')
+test.run(arguments = 'SLF', stderr=TestSCons.noisy_ar)
# XXX Note that the generated .h files still get scanned twice,
# once before they're generated and once after. That's the