summaryrefslogtreecommitdiffstats
path: root/test/import.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/import.py')
-rw-r--r--test/import.py106
1 files changed, 53 insertions, 53 deletions
diff --git a/test/import.py b/test/import.py
index bb070ab..92797df 100644
--- a/test/import.py
+++ b/test/import.py
@@ -29,6 +29,9 @@ Verify that we can import and use the contents of Platform and Tool
modules directly.
"""
+import re
+import sys
+
import TestSCons
test = TestSCons.TestSCons()
@@ -49,10 +52,10 @@ platforms = [
for platform in platforms:
test.write('SConstruct', """
-env = Environment(platform = '%s')
-import SCons.Platform.%s
-x = SCons.Platform.%s.generate
-""" % (platform, platform, platform))
+env = Environment(platform = '%(platform)s')
+import SCons.Platform.%(platform)s
+x = SCons.Platform.%(platform)s.generate
+""" % locals())
test.run()
tools = [
@@ -139,46 +142,33 @@ tools = [
'zip',
]
-# Intel no compiler warning..
-intel_no_compiler_fmt = """
-scons: warning: Failed to find Intel compiler for version='None', abi='%(abi)s'
-File "%(SConstruct_path)s", line 1, in ?
-"""
-
-abi = 'ia32'
-intel_no_compiler_32_warning = intel_no_compiler_fmt % locals()
+if sys.platform == 'win32':
+ tools.extend([
+ '386asm',
+ 'linkloc',
+ ])
-abi = 'x86_64'
-intel_no_compiler_64_warning = intel_no_compiler_fmt % locals()
+# Intel no compiler warning..
+intel_no_compiler_warning = """
+scons: warning: Failed to find Intel compiler for version='None', abi='[^']*'
+""" + TestSCons.file_expr
# Intel no top dir warning.
-intel_no_top_dir_fmt = """
-scons: warning: Can't find Intel compiler top dir for version='None', abi='%(abi)s'
-File "%(SConstruct_path)s", line 1, in ?
-""" % locals()
-
-abi = 'ia32'
-intel_no_top_dir_32_warning = intel_no_top_dir_fmt % locals()
-
-abi = 'x86_64'
-intel_no_top_dir_64_warning = intel_no_top_dir_fmt % locals()
+intel_no_top_dir_warning = """
+scons: warning: Can't find Intel compiler top dir for version='None', abi='[^']*'
+""" + TestSCons.file_expr
# Intel no license directory warning
-intel_license_warning = """
+intel_license_warning = re.escape("""
scons: warning: Intel license dir was not found. Tried using the INTEL_LICENSE_FILE environment variable (), the registry () and the default path (C:\Program Files\Common Files\Intel\Licenses). Using the default path as a last resort.
-File "%(SConstruct_path)s", line 1, in ?
-""" % locals()
+""") + TestSCons.file_expr
intel_warnings = [
- intel_license_warning,
- intel_no_compiler_32_warning,
- intel_no_compiler_32_warning + intel_license_warning,
- intel_no_compiler_64_warning,
- intel_no_compiler_64_warning + intel_license_warning,
- intel_no_top_dir_32_warning,
- intel_no_top_dir_32_warning + intel_license_warning,
- intel_no_top_dir_64_warning,
- intel_no_top_dir_64_warning + intel_license_warning,
+ re.compile(intel_license_warning),
+ re.compile(intel_no_compiler_warning),
+ re.compile(intel_no_compiler_warning + intel_license_warning),
+ re.compile(intel_no_top_dir_warning),
+ re.compile(intel_no_top_dir_warning + intel_license_warning),
]
moc = test.where_is('moc')
@@ -189,50 +179,60 @@ if moc:
qt_err = """
scons: warning: Could not detect qt, using moc executable as a hint (QTDIR=%(qtdir)s)
-File "%(SConstruct_path)s", line 1, in ?
""" % locals()
else:
qt_err = """
scons: warning: Could not detect qt, using empty QTDIR
-File "%(SConstruct_path)s", line 1, in ?
-""" % locals()
+"""
+
+qt_warnings = [ re.compile(qt_err + TestSCons.file_expr) ]
error_output = {
'icl' : intel_warnings,
'intelc' : intel_warnings,
- 'qt' : [qt_err],
+ 'qt' : qt_warnings,
}
# An SConstruct for importing Tool names that have illegal characters
# for Python variable names.
indirect_import = """\
-env = Environment(tools = ['%s'])
-SCons = __import__('SCons.Tool.%s', globals(), locals(), [])
-m = getattr(SCons.Tool, '%s')
-x = m.generate
+env = Environment(tools = ['%(tool)s'])
+
+SCons = __import__('SCons.Tool.%(tool)s', globals(), locals(), [])
+m = getattr(SCons.Tool, '%(tool)s')
+env = Environment()
+m.generate(env)
"""
# An SConstruct for importing Tool names "normally."
direct_import = """\
-env = Environment(tools = ['%s'])
-import SCons.Tool.%s
-x = SCons.Tool.%s.generate
+env = Environment(tools = ['%(tool)s'])
+
+import SCons.Tool.%(tool)s
+env = Environment()
+SCons.Tool.%(tool)s.generate(env)
"""
failures = []
for tool in tools:
if tool[0] in '0123456789' or '+' in tool:
- test.write('SConstruct', indirect_import % (tool, tool, tool))
+ test.write('SConstruct', indirect_import % locals())
else:
- test.write('SConstruct', direct_import % (tool, tool, tool))
+ test.write('SConstruct', direct_import % locals())
test.run(stderr=None)
stderr = test.stderr()
- if not stderr in [''] + error_output.get(tool, []):
- print "Failed importing '%s', stderr:" % tool
- print stderr
- failures.append(tool)
+ if stderr:
+ matched = None
+ for expression in error_output.get(tool, []):
+ if expression.match(stderr):
+ matched = 1
+ break
+ if not matched:
+ print "Failed importing '%s', stderr:" % tool
+ print stderr
+ failures.append(tool)
test.fail_test(len(failures))