dirkbaechle avatar dirkbaechle committed c2bf08a

- moved check for an installed MSVC toolchain into its own function in TestSCons

Comments (0)

Files changed (15)

QMTest/TestSCons.py

     
         return libs
 
+    def skip_if_not_msvc(self, check_platform=True):
+        """ Check whether we are on a Windows platform and skip the
+            test if not. This check can be omitted by setting
+            check_platform to False.
+            Then, for a win32 platform, additionally check
+            whether we have a MSVC toolchain installed
+            in the system, and skip the test if none can be
+            found (=MinGW is the only compiler available).
+        """
+        if check_platform:
+            if sys.platform != 'win32':
+                msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
+                self.skip_test(msg)
+                return
+        
+        try:
+            import SCons.Tool.MSCommon as msc
+            if not msc.msvc_exists():
+                msg = "No MSVC toolchain found...skipping test\n"
+                self.skip_test(msg)
+        except:
+            pass
 
     def checkLogAndStdout(self, checks, results, cached,
                           logfile, sconf_dir, sconstruct,
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import os
-import sys
 
 import TestSCons
 
 test = TestSCons.TestSCons(match = TestSCons.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 #####
 # Test the basics

test/MSVC/PCH-source.py

 Issue 2505:  http://scons.tigris.org/issues/show_bug.cgi?id=2505
 """
 
-import sys
-
 import TestSCons
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.write('SConstruct', """\
 env = Environment(tools=['msvc', 'mslink'])

test/MSVC/PCHSTOP-errors.py

 """
 
 import re
-import sys
 
 import TestSCons
 
 test = TestSCons.TestSCons(match = TestSCons.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
-
+test.skip_if_not_msvc()
 
 SConstruct_path = test.workpath('SConstruct')
 

test/MSVC/TARGET_ARCH.py

 """
 
 import TestSCons
-import sys
 
 _python_ = TestSCons._python_
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.write('SConstruct', """
 env_64 = Environment(tools=['default', 'msvc'],

test/MSVC/batch-longlines.py

 Only runs on Windows.
 """
 
-import sys
 import TestSCons
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 _python_ = TestSCons._python_
 

test/MSVC/embed-manifest.py

 Verify that manifest files get embedded correctly in EXEs and DLLs
 """
 
-import sys
-
 import TestSCons
 
 _exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.write('SConstruct', """\
 env=Environment(WINDOWS_EMBED_MANIFEST=True)

test/MSVC/hierarchical.py

 Verify use of Visual Studio with a hierarchical build.
 """
 
-import sys
-
 import TestSCons
 
 test = TestSCons.TestSCons(match = TestSCons.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
-
+test.skip_if_not_msvc()
 
 test.subdir('src', 'build', 'out')
 

test/MSVC/msvc.py

 of a precompiled header with the $CCFLAGS variable.
 """
 
-import sys
 import time
 
 import TestSCons
 
 test = TestSCons.TestSCons(match = TestSCons.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 #####
 # Test the basics

test/MSVC/multiple-pdb.py

 list(s).
 """
 
-import sys
-
 import TestSCons
 
 _exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.write('SConstruct', """\
 env = Environment(PDB = '${TARGET.base}.pdb')

test/MSVC/pch-spaces-subdir.py

 Verify PCH works if variant dir has spaces in its name
 """
 
-import sys
 import time
 
 import TestSCons
 
 test = TestSCons.TestSCons(match = TestSCons.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.write('Main.cpp', """\
 #include "Precompiled.h"

test/MSVC/pdb-VariantDir-path.py

 Verify that .pdb files get put in a variant_dir correctly.
 """
 
-import sys
-
 import TestSCons
 
 _exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.subdir('src')
 

test/MSVC/pdb-manifest.py

 Verify that .pdb files work correctly in conjunction with manifest files.
 """
 
-import sys
-
 import TestSCons
 
 _exe = TestSCons._exe
 
 test = TestSCons.TestSCons()
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.write('SConstruct', """\
 env = Environment()

test/MSVC/query_vcbat.py

 
 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
-import sys
-
 import TestSCons
 
 test = TestSCons.TestSCons(match = TestSCons.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping Visual C/C++ test on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 #####
 # Test the basics

test/Win32/win32pathmadness.py

 __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
 
 import TestSCons
-import sys
 import TestCmd
 import os.path
 
 test = TestSCons.TestSCons(match=TestCmd.match_re)
 
-if sys.platform != 'win32':
-    msg = "Skipping Windows path tests on non-Windows platform '%s'\n" % sys.platform
-    test.skip_test(msg)
-
-import SCons.Tool.MSCommon as msc
-if not msc.msvc_exists():
-    msg = "No MSVC toolchain found...skipping test'\n"
-    test.skip_test(msg)
+test.skip_if_not_msvc()
 
 test.subdir('src', 'build', 'include', 'src2')
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.