Fix tests on systems where 'ar' prints warnings about creating archives. (Kevin...
authorstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 13 Jul 2004 08:06:06 +0000 (08:06 +0000)
committerstevenknight <stevenknight@fdb21ef1-2011-0410-befe-b5e4ea1792b1>
Tue, 13 Jul 2004 08:06:06 +0000 (08:06 +0000)
git-svn-id: http://scons.tigris.org/svn/scons/trunk@1005 fdb21ef1-2011-0410-befe-b5e4ea1792b1

20 files changed:
etc/TestSCons.py
src/CHANGES.txt
test/AR.py
test/ARFLAGS.py
test/CPPPATH.py
test/HeaderGen.py
test/HeaderInstall.py
test/LIBPATH.py
test/LIBPREFIXES.py
test/LIBS.py
test/LIBSUFFIXES.py
test/Library.py
test/QT.py
test/QTFLAGS.py
test/RANLIB.py
test/RANLIBFLAGS.py
test/Repository/StaticLibrary.py
test/SharedLibrary.py
test/long-lines.py
test/scan-once.py

index 8cba239dc35d7178763c1c9c486528c98b983ecc..737f8a28e6dfde6d7ea2fe38b8e49b6d17255e6c 100644 (file)
@@ -208,3 +208,14 @@ class TestSCons(TestCommon):
         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?)*'
index 6694df2d38fc8f3e01a03fd16bfddb3f74f2fa91..ab32ceffe96b1ce207a8fb092ec4da94c73fc315 100644 (file)
@@ -162,8 +162,12 @@ RELEASE 0.96 - XXX
 
   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.
index f077c72cd3f8a8639ff609868f3e4fccccb41c45..f27aeb06ad6a8536b0567b42560af74075642b13 100644 (file)
@@ -32,7 +32,7 @@ import TestSCons
 python = TestSCons.python
 _exe = TestSCons._exe
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.write("wrapper.py",
 """import os
@@ -82,11 +82,11 @@ main(int argc, char *argv[])
 """)
 
 
-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")
 
index a9dc5728c858d45f5bd5ffa0343f3e237564f8af..15ce994b24de7cb10f7abd7a628e449681ef5c68 100644 (file)
@@ -32,7 +32,7 @@ import TestSCons
 python = TestSCons.python
 _exe   = TestSCons._exe
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.write("wrapper.py",
 """import os
@@ -82,11 +82,11 @@ main(int argc, char *argv[])
 """)
 
 
-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")
 
index 1f93bf5d5a505246a38222e00216e85c26e31516..d3185c023ddebba6c5c8f279085515b5d0eb20d7 100644 (file)
@@ -36,7 +36,7 @@ variant_prog = os.path.join('variant', 'prog' + _exe)
 
 args = prog + ' ' + subdir_prog + ' ' + variant_prog
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.subdir('include', 'subdir', ['subdir', 'include'], 'inc2')
 
@@ -203,6 +203,6 @@ env.Library('foo', source = 'empty.c')
 test.write('empty.c', """
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 test.pass_test()
index 9a3a6ab0ffa566e232b1fa45587c716c3dff8b11..44dd3ced29ead6dd45f4c3bd367da7bd49e85ac3 100644 (file)
 __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):
@@ -50,8 +51,34 @@ env.Command('gen.cpp', [],
             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()
index cccf4d6b737563eae520b1f346679468a6311acc..ae4213fcfb55fcca9b7872af86630932842943d3 100644 (file)
@@ -31,7 +31,7 @@ import os.path
 
 import TestSCons
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.subdir('work1', ['work1', 'dist'])
 
@@ -64,7 +64,7 @@ test.write(['work1', 'dist', 'h3.h'], """\
 int foo = 3;
 """)
 
-test.run(chdir = 'work1', arguments = ".")
+test.run(chdir = 'work1', arguments = ".", stderr=TestSCons.noisy_ar)
 
 test.up_to_date(chdir = 'work1', arguments = ".")
 
index d691af20582bf699f38b70647387a60bd542803f..9f5bbfd341cc0e7b7cc2ae1601f462a0771f63e3 100644 (file)
@@ -33,7 +33,7 @@ _exe = TestSCons._exe
 _dll = TestSCons._dll
 dll_ = TestSCons.dll_
     
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.subdir('lib1', 'lib2')
 
@@ -86,7 +86,7 @@ main(int argc, char *argv[])
 }
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 test.run(program = prog1,
          stdout = "f1.c\nprog.c\n")
@@ -107,7 +107,7 @@ f1(void)
 }
 """)
 
-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))
@@ -138,7 +138,7 @@ f1(void)
 }
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 test.run(program = prog1,
          stdout = "f1.c 2\nprog.c\n")
 
@@ -154,6 +154,6 @@ env = Environment(LIBPATH = '')
 env.Library('foo', source = 'empty.c')
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 test.pass_test()
index abd212023f2181ccb031456a6393142f2fedfbc1..7abf0d4827f067ff7caba0192dd5d0b6200395bf 100644 (file)
@@ -33,7 +33,7 @@ if sys.platform == 'win32':
 else:
     _lib = '.a'
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.write('SConstruct', """
 env = Environment(LIBPREFIX = 'xxx-',
@@ -62,7 +62,7 @@ main(int argc, char *argv[])
 }
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 test.fail_test(not os.path.exists(test.workpath('xxx-foo' + _lib)))
 
index c91e38d185121bf54bf65710d892de7bb54219c5..07f1746ec4c315139ae92d74c3808479e9efa1f6 100644 (file)
@@ -34,7 +34,7 @@ else:
     _exe = ''
     bar_lib = 'libbar.a'
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.subdir('sub1', 'sub2')
 
@@ -145,11 +145,11 @@ SConscript('sub1/SConscript', 'env')
 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')
 
@@ -174,8 +174,8 @@ void baz()
 }
 """)
 
-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')
 
@@ -251,7 +251,7 @@ int DisplayMessage2 (void)
 }
 """)
 
-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')
index 19a092f0d6f7aea7412841e8fe1a9d3ef4b3234a..4e0073e0e982af98c9f3fe82dda68e7edee6db5f 100644 (file)
@@ -33,7 +33,7 @@ if sys.platform == 'win32':
 else:
     lib_ = 'lib'
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.write('SConstruct', """
 env = Environment(LIBSUFFIX = '.xxx',
@@ -62,7 +62,7 @@ main(int argc, char *argv[])
 }
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 test.fail_test(not os.path.exists(test.workpath(lib_ + 'foo.xxx')))
 
index f22172c31fffad8c3679e6cde3b3e719b71199a4..2b0810f8d2f5d30e194df8dd2e8fcc811777c64b 100644 (file)
@@ -26,7 +26,7 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import TestSCons
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.write('SConstruct', """
 env = Environment(LIBS = [ 'foo1', 'libfoo2' ],
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
 }
 """)
 
-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")
@@ -150,7 +150,7 @@ int main() {
 }
 """)
 
-test.run()
+test.run(stderr=TestSCons.noisy_ar)
 test.run(program = test.workpath('uses-nrd'),
          stdout = "nrd\n")
 
index 6b378c463176ae1ab2416d44ea457b39a377fa01..c5f32fb54f634d83e5b17ac8318e0e3ee69cfe4e 100644 (file)
@@ -43,7 +43,7 @@ dll_ = TestSCons.dll_
 _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'] )
 
@@ -126,7 +126,8 @@ env = Environment()
 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'
@@ -310,7 +311,7 @@ void useit() {
 }
 """)
 
-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"
@@ -322,7 +323,8 @@ test.not_up_to_date(chdir='work3', options = '-n', arguments = moc)
 
 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) )
index 867dbfb79d5cd3754f760caabe3301f2eff3a1f5..3563d378fb4de52c56fbe9b58797596c20b8faa0 100644 (file)
@@ -34,7 +34,7 @@ import os.path
 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'] )
 
@@ -116,7 +116,8 @@ env = Environment()
 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'
index cb8f1dbbd5da050c2f28c68569bb2f62dccac621..5de4a09ae596a920292f3ef98c58377046e4883a 100644 (file)
@@ -34,7 +34,7 @@ python = TestSCons.python
 
 _exe = TestSCons._exe
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 ranlib = test.detect('RANLIB', 'ranlib')
 
@@ -89,11 +89,11 @@ main(int argc, char *argv[])
 """)
 
 
-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")
 
index 07da92e4a260358446e63044d8ebefb962449f73..64c6847b08de81eb138c46c7e2638a06725b9ab5 100644 (file)
@@ -32,7 +32,7 @@ import TestSCons
 python = TestSCons.python
 _exe   = TestSCons._exe
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 ranlib = test.detect('RANLIB', 'ranlib')
 
@@ -86,11 +86,11 @@ main(int argc, char *argv[])
 """)
 
 
-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")
 
index 00c5eb59cd33b374a32f83dbaa4dae08cda91354..2dd8f88b63e68b5b47c107ef59f71f2f72b84b5b 100644 (file)
@@ -37,7 +37,7 @@ else:
 
 
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 #
 test.subdir('repository', 'work1', 'work2', 'work3')
@@ -100,7 +100,8 @@ main(int argc, char *argv[])
 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
@@ -123,7 +124,8 @@ bbb(void)
 }
 """)
 
-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
@@ -141,7 +143,8 @@ test.up_to_date(chdir = 'work1', options = opts, arguments = ".")
 #
 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
@@ -169,7 +172,8 @@ bbb(void)
 }
 """)
 
-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
index 6ad278dc8ef444e093254adb0f5cdf3e1f8e7079..d4eb7303f7b1a2785b2f77af51abe6022b9e1169 100644 (file)
@@ -31,7 +31,7 @@ import sys
 import TestCmd
 import TestSCons
 
-test = TestSCons.TestSCons(match=TestCmd.match_re)
+test = TestSCons.TestSCons(match=TestCmd.match_re_dotall)
 
 test.write('SConstruct', """
 import sys
@@ -191,7 +191,7 @@ main(int argc, char *argv[])
 }
 """)
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 if os.name == 'posix':
     os.environ['LD_LIBRARY_PATH'] = '.'
@@ -213,7 +213,7 @@ scons: \*\*\* Source file: foo\..* is static and is not compatible with shared t
 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
index 9d385048ca2b0d2d90fa935c383c93b80f6e7934..5216429ca22835bfd349c1a6db83899b01989729 100644 (file)
@@ -30,7 +30,7 @@ import string
 import sys
 import TestSCons
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 if sys.platform == 'win32':
     lib_static_lib = 'static.lib'
@@ -103,7 +103,7 @@ main(int argc, char *argv[])
 """)
 
 
-test.run(arguments = '.')
+test.run(arguments = '.', stderr=TestSCons.noisy_ar)
 
 test.up_to_date(arguments = '.')
 
index 606590b2d69efa8a6172e90580c880543f1c9267..57a8d36e0ed89b2e68bdd91b69cf041cc01b6bdd 100644 (file)
@@ -43,7 +43,7 @@ import sys
 import TestCmd
 import TestSCons
 
-test = TestSCons.TestSCons()
+test = TestSCons.TestSCons(match=TestSCons.match_re_dotall)
 
 test.subdir('simple',
             'SLF',
@@ -474,7 +474,7 @@ XScanner: node = file3.x
 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