From 239a4bf92af5eb85ab9322610f46d0f6798f4d4b Mon Sep 17 00:00:00 2001 From: Dirk Baechle Date: Sat, 22 Dec 2012 12:41:34 +0100 Subject: - moved check for an installed MSVC toolchain into its own function in TestSCons --- QMTest/TestSCons.py | 22 ++++++++++++++++++++++ test/IDL/midl.py | 10 +--------- test/MSVC/PCH-source.py | 11 +---------- test/MSVC/PCHSTOP-errors.py | 11 +---------- test/MSVC/TARGET_ARCH.py | 10 +--------- test/MSVC/batch-longlines.py | 10 +--------- test/MSVC/embed-manifest.py | 11 +---------- test/MSVC/hierarchical.py | 12 +----------- test/MSVC/msvc.py | 10 +--------- test/MSVC/multiple-pdb.py | 11 +---------- test/MSVC/pch-spaces-subdir.py | 10 +--------- test/MSVC/pdb-VariantDir-path.py | 11 +---------- test/MSVC/pdb-manifest.py | 11 +---------- test/MSVC/query_vcbat.py | 11 +---------- test/Win32/win32pathmadness.py | 10 +--------- 15 files changed, 36 insertions(+), 135 deletions(-) diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index ea18757..b015637 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -976,6 +976,28 @@ SConscript( sconscript ) 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, diff --git a/test/IDL/midl.py b/test/IDL/midl.py index 0322483..7ada153 100644 --- a/test/IDL/midl.py +++ b/test/IDL/midl.py @@ -25,20 +25,12 @@ __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 diff --git a/test/MSVC/PCH-source.py b/test/MSVC/PCH-source.py index c3c0f2e..6015fec 100644 --- a/test/MSVC/PCH-source.py +++ b/test/MSVC/PCH-source.py @@ -31,20 +31,11 @@ up in both the env.PCH() and the env.Program() source list. 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']) diff --git a/test/MSVC/PCHSTOP-errors.py b/test/MSVC/PCHSTOP-errors.py index d3ffc70..aa14a3f 100644 --- a/test/MSVC/PCHSTOP-errors.py +++ b/test/MSVC/PCHSTOP-errors.py @@ -29,21 +29,12 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" """ 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') diff --git a/test/MSVC/TARGET_ARCH.py b/test/MSVC/TARGET_ARCH.py index 8b1c39d..1df28d0 100644 --- a/test/MSVC/TARGET_ARCH.py +++ b/test/MSVC/TARGET_ARCH.py @@ -29,20 +29,12 @@ Test the ability to configure the $TARGET_ARCH construction variable. """ 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'], diff --git a/test/MSVC/batch-longlines.py b/test/MSVC/batch-longlines.py index a5786fa..ef7233b 100644 --- a/test/MSVC/batch-longlines.py +++ b/test/MSVC/batch-longlines.py @@ -30,19 +30,11 @@ Verify operation of Visual C/C++ batch builds with long lines. 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_ diff --git a/test/MSVC/embed-manifest.py b/test/MSVC/embed-manifest.py index 286c2c7..13f1def 100644 --- a/test/MSVC/embed-manifest.py +++ b/test/MSVC/embed-manifest.py @@ -28,8 +28,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Verify that manifest files get embedded correctly in EXEs and DLLs """ -import sys - import TestSCons _exe = TestSCons._exe @@ -38,14 +36,7 @@ _lib = TestSCons._lib 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) diff --git a/test/MSVC/hierarchical.py b/test/MSVC/hierarchical.py index 72e5813..0b19483 100644 --- a/test/MSVC/hierarchical.py +++ b/test/MSVC/hierarchical.py @@ -28,21 +28,11 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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') diff --git a/test/MSVC/msvc.py b/test/MSVC/msvc.py index d98ffbe..c68fb45 100644 --- a/test/MSVC/msvc.py +++ b/test/MSVC/msvc.py @@ -29,21 +29,13 @@ Verify basic invocation of Microsoft Visual C/C++, including use 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 diff --git a/test/MSVC/multiple-pdb.py b/test/MSVC/multiple-pdb.py index 8e86639..78805e3 100644 --- a/test/MSVC/multiple-pdb.py +++ b/test/MSVC/multiple-pdb.py @@ -33,22 +33,13 @@ $TARGET variable (and implicitly $SOURCE), using the original specified 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') diff --git a/test/MSVC/pch-spaces-subdir.py b/test/MSVC/pch-spaces-subdir.py index 2b66a55..3a65b44 100644 --- a/test/MSVC/pch-spaces-subdir.py +++ b/test/MSVC/pch-spaces-subdir.py @@ -28,21 +28,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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" diff --git a/test/MSVC/pdb-VariantDir-path.py b/test/MSVC/pdb-VariantDir-path.py index 899208e..838487c 100644 --- a/test/MSVC/pdb-VariantDir-path.py +++ b/test/MSVC/pdb-VariantDir-path.py @@ -28,22 +28,13 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" 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') diff --git a/test/MSVC/pdb-manifest.py b/test/MSVC/pdb-manifest.py index 46189ac..e06fe0c 100644 --- a/test/MSVC/pdb-manifest.py +++ b/test/MSVC/pdb-manifest.py @@ -28,8 +28,6 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" Verify that .pdb files work correctly in conjunction with manifest files. """ -import sys - import TestSCons _exe = TestSCons._exe @@ -38,14 +36,7 @@ _lib = TestSCons._lib 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() diff --git a/test/MSVC/query_vcbat.py b/test/MSVC/query_vcbat.py index f07f780..328345d 100644 --- a/test/MSVC/query_vcbat.py +++ b/test/MSVC/query_vcbat.py @@ -23,20 +23,11 @@ __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 diff --git a/test/Win32/win32pathmadness.py b/test/Win32/win32pathmadness.py index fe6373d..925a323 100644 --- a/test/Win32/win32pathmadness.py +++ b/test/Win32/win32pathmadness.py @@ -31,20 +31,12 @@ inconsistent about which case is used for the drive letter. __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') -- cgit v0.12