Added fix for TeX includes with same name as subdirs.
[scons.git] / test / import.py
index 7debffc3d3c31da8f6dddfb3e340486afd7e7274..ff15e16c63c1c2e318445e002fddbb1642e08bab 100644 (file)
@@ -29,13 +29,24 @@ Verify that we can import and use the contents of Platform and Tool
 modules directly.
 """
 
+import os
 import re
 import sys
 
-import TestSCons
+# must do this here, since TestSCons will chdir
+tooldir = os.path.join(os.getcwd(), 'src', 'engine', 'SCons', 'Tool')
 
+import TestSCons
 test = TestSCons.TestSCons()
 
+# Before executing the any of the platform or tool modules, add some
+# null entries to the environment $PATH variable to make sure there's
+# no code that tries to index elements from the list before making sure
+# they're non-null.
+# (This was a problem in checkpoint release 0.97.d020070809.)
+os.environ['PATH'] = os.pathsep + os.environ['PATH'] + \
+                     os.pathsep + os.pathsep + '/no/such/dir' + os.pathsep
+
 SConstruct_path = test.workpath('SConstruct')
 
 platforms = [
@@ -59,89 +70,23 @@ x = SCons.Platform.%(platform)s.generate
 """ % locals())
     test.run()
 
-tools = [
-    # Can't import '386asm' everywhere due to Windows registry dependency.
-    'aixc++',
-    'aixcc',
-    'aixf77',
-    'aixlink',
-    'applelink',
-    'ar',
-    'as',
-    'bcc32',
-    'BitKeeper',
-    'c++',
-    'cc',
-    'cvf',
-    'CVS',
-    'default',
-    'dmd',
-    'dvi',
-    'dvipdf',
-    'dvips',
-    'f77',
-    'f90',
-    'f95',
-    'fortran',
-    'g++',
-    'g77',
-    'gas',
-    'gcc',
-    'gnulink',
-    'gs',
-    'hpc++',
-    'hpcc',
-    'hplink',
-    'icc',
-    'icl',
-    'ifort',
-    'ifl',
-    'ilink',
-    'ilink32',
-    'intelc',
-    'jar',
-    'javac',
-    'javah',
-    'latex',
-    'lex',
-    'link',
-    # Can't import 'linkloc' everywhere due to Windows registry dependency.
-    'm4',
-    'masm',
-    'midl',
-    'mingw',
-    'mslib',
-    'mslink',
-    'msvc',
-    'msvs',
-    'mwcc',
-    'mwld',
-    'nasm',
-    'pdf',
-    'pdflatex',
-    'pdftex',
-    'Perforce',
-    'qt',
-    'RCS',
-    'rmic',
-    'rpcgen',
-    'SCCS',
-    'sgiar',
-    'sgic++',
-    'sgicc',
-    'sgilink',
-    'Subversion',
-    'sunar',
-    'sunc++',
-    'suncc',
-    'sunlink',
-    'swig',
-    'tar',
-    'tex',
-    'tlib',
-    'yacc',
-    'zip',
-]
+ignore = ('__init__.py',
+        # Can't import these everywhere due to Windows registry dependency.
+        '386asm.py', 'linkloc.py',
+        # Directory of common stuff for MSVC and MSVS
+        'MSCommon',
+        # Sun pkgchk and pkginfo common stuff
+        'sun_pkg.py',
+        )
+tools = []
+for name in os.listdir(tooldir):
+    if name in ignore: continue
+    if name[-3:] == '.py':
+        if name[-8:] not in ('Tests.py', 'ommon.py'):
+            tools.append(name[:-3])
+    elif os.path.exists(os.path.join(tooldir,name,'__init__.py')):
+        tools.append(name)
+tools.sort()    # why not?
 
 #if sys.platform == 'win32':
 # Just comment out (for now?) due to registry dependency.
@@ -179,8 +124,8 @@ if moc:
 
     qtdir = os.path.dirname(os.path.dirname(moc))
 
-    qt_err = """
-scons: warning: Could not detect qt, using moc executable as a hint (QTDIR=%(qtdir)s)
+    qt_err = r"""
+scons: warning: Could not detect qt, using moc executable as a hint \(QTDIR=%(qtdir)s\)
 """ % locals()
 
 else:
@@ -216,12 +161,13 @@ env = Environment(tools = ['%(tool)s'])
 
 import SCons.Tool.%(tool)s
 env = Environment()
+SCons.Tool.%(tool)s.exists(env)
 SCons.Tool.%(tool)s.generate(env)
 """
 
 failures = []
 for tool in tools:
-    if tool[0] in '0123456789' or '+' in tool:
+    if tool[0] in '0123456789' or '+' in tool or tool in ('as',):
         test.write('SConstruct', indirect_import % locals())
     else:
         test.write('SConstruct', direct_import % locals())
@@ -241,3 +187,9 @@ for tool in tools:
 test.fail_test(len(failures))
 
 test.pass_test()
+
+# Local Variables:
+# tab-width:4
+# indent-tabs-mode:nil
+# End:
+# vim: set expandtab tabstop=4 shiftwidth=4: