summaryrefslogtreecommitdiffstats
path: root/QMTest
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2008-09-23 16:15:40 (GMT)
committerSteven Knight <knight@baldmt.com>2008-09-23 16:15:40 (GMT)
commit4b764a46532db32edcbbc7a611294a57a02f5693 (patch)
treef620e13a07710c9cd136d38ce78491e16baeb273 /QMTest
parent379fee93166e2740f09dd5c7e4479a6a1947f842 (diff)
downloadSCons-4b764a46532db32edcbbc7a611294a57a02f5693.zip
SCons-4b764a46532db32edcbbc7a611294a57a02f5693.tar.gz
SCons-4b764a46532db32edcbbc7a611294a57a02f5693.tar.bz2
Refactor Visual Studio testing logic into a separate TestSConsMSVS
subclass, in its own module.
Diffstat (limited to 'QMTest')
-rw-r--r--QMTest/TestSCons.py100
-rw-r--r--QMTest/TestSConsMSVS.py128
2 files changed, 128 insertions, 100 deletions
diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py
index 2ef393c..c5180d8 100644
--- a/QMTest/TestSCons.py
+++ b/QMTest/TestSCons.py
@@ -720,106 +720,6 @@ Export("env dup")
SConscript( sconscript )
""" % (self.QT, self.QT_LIB, self.QT_MOC, self.QT_UIC))
- def msvs_versions(self):
- if not hasattr(self, '_msvs_versions'):
-
- # Determine the SCons version and the versions of the MSVS
- # environments installed on the test machine.
- #
- # We do this by executing SCons with an SConstruct file
- # (piped on stdin) that spits out Python assignments that
- # we can just exec(). We construct the SCons.__"version"__
- # string in the input here so that the SCons build itself
- # doesn't fill it in when packaging SCons.
- input = """\
-import SCons
-print "self._scons_version =", repr(SCons.__%s__)
-env = Environment();
-print "self._msvs_versions =", str(env['MSVS']['VERSIONS'])
-""" % 'version'
-
- self.run(arguments = '-n -q -Q -f -', stdin = input)
- exec(self.stdout())
-
- return self._msvs_versions
-
- def vcproj_sys_path(self, fname):
- """
- """
- orig = 'sys.path = [ join(sys'
-
- enginepath = repr(os.path.join(self._cwd, '..', 'engine'))
- replace = 'sys.path = [ %s, join(sys' % enginepath
-
- contents = self.read(fname)
- contents = string.replace(contents, orig, replace)
- self.write(fname, contents)
-
- def msvs_substitute(self, input, msvs_ver,
- subdir=None, sconscript=None,
- python=None,
- project_guid=None):
- if not hasattr(self, '_msvs_versions'):
- self.msvs_versions()
-
- if subdir:
- workpath = self.workpath(subdir)
- else:
- workpath = self.workpath()
-
- if sconscript is None:
- sconscript = self.workpath('SConstruct')
-
- if python is None:
- python = sys.executable
-
- if project_guid is None:
- project_guid = "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
-
- if os.environ.has_key('SCONS_LIB_DIR'):
- exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % os.environ['SCONS_LIB_DIR']
- else:
- exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self._scons_version, self._scons_version)
- exec_script_main_xml = string.replace(exec_script_main, "'", "&apos;")
-
- result = string.replace(input, r'<WORKPATH>', workpath)
- result = string.replace(result, r'<PYTHON>', python)
- result = string.replace(result, r'<SCONSCRIPT>', sconscript)
- result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
- result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
- result = string.replace(result, r'<PROJECT_GUID>', project_guid)
- return result
-
- def get_msvs_executable(self, version):
- """Returns a full path to the executable (MSDEV or devenv)
- for the specified version of Visual Studio.
- """
- common_msdev98_bin_msdev_com = ['Common', 'MSDev98', 'Bin', 'MSDEV.COM']
- common7_ide_devenv_com = ['Common7', 'IDE', 'devenv.com']
- common7_ide_vcexpress_exe = ['Common7', 'IDE', 'VCExpress.exe']
- sub_paths = {
- '6.0' : [
- common_msdev98_bin_msdev_com,
- ],
- '7.0' : [
- common7_ide_devenv_com,
- ],
- '7.1' : [
- common7_ide_devenv_com,
- ],
- '8.0' : [
- common7_ide_devenv_com,
- common7_ide_vcexpress_exe,
- ],
- }
- from SCons.Tool.msvs import get_msvs_install_dirs
- vs_path = get_msvs_install_dirs(version)['VSINSTALLDIR']
- for sp in sub_paths[version]:
- p = apply(os.path.join, [vs_path] + sp)
- if os.path.exists(p):
- return p
- return apply(os.path.join, [vs_path] + sub_paths[version][0])
-
NCR = 0 # non-cached rebuild
CR = 1 # cached rebuild (up to date)
diff --git a/QMTest/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py
new file mode 100644
index 0000000..4bdc546
--- /dev/null
+++ b/QMTest/TestSConsMSVS.py
@@ -0,0 +1,128 @@
+"""
+TestSConsMSVS.py: a testing framework for the SCons software construction
+tool.
+
+A TestSConsMSVS environment object is created via the usual invocation:
+
+ test = TestSConsMSVS()
+
+TestSConsMSVS is a subsclass of TestSCons, which is in turn a subclass
+of TestCommon, which is in turn is a subclass of TestCmd), and hence
+has available all of the methods and attributes from those classes,
+as well as any overridden or additional methods or attributes defined
+in this subclass.
+"""
+
+# __COPYRIGHT__
+
+__revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__"
+
+import os
+import string
+import sys
+
+from TestSCons import *
+from TestSCons import __all__
+
+class TestSConsMSVS(TestSCons):
+ """Subclass for testing MSVS-specific portions of SCons."""
+
+ def msvs_versions(self):
+ if not hasattr(self, '_msvs_versions'):
+
+ # Determine the SCons version and the versions of the MSVS
+ # environments installed on the test machine.
+ #
+ # We do this by executing SCons with an SConstruct file
+ # (piped on stdin) that spits out Python assignments that
+ # we can just exec(). We construct the SCons.__"version"__
+ # string in the input here so that the SCons build itself
+ # doesn't fill it in when packaging SCons.
+ input = """\
+import SCons
+print "self._scons_version =", repr(SCons.__%s__)
+env = Environment();
+print "self._msvs_versions =", str(env['MSVS']['VERSIONS'])
+""" % 'version'
+
+ self.run(arguments = '-n -q -Q -f -', stdin = input)
+ exec(self.stdout())
+
+ return self._msvs_versions
+
+ def vcproj_sys_path(self, fname):
+ """
+ """
+ orig = 'sys.path = [ join(sys'
+
+ enginepath = repr(os.path.join(self._cwd, '..', 'engine'))
+ replace = 'sys.path = [ %s, join(sys' % enginepath
+
+ contents = self.read(fname)
+ contents = string.replace(contents, orig, replace)
+ self.write(fname, contents)
+
+ def msvs_substitute(self, input, msvs_ver,
+ subdir=None, sconscript=None,
+ python=None,
+ project_guid=None):
+ if not hasattr(self, '_msvs_versions'):
+ self.msvs_versions()
+
+ if subdir:
+ workpath = self.workpath(subdir)
+ else:
+ workpath = self.workpath()
+
+ if sconscript is None:
+ sconscript = self.workpath('SConstruct')
+
+ if python is None:
+ python = sys.executable
+
+ if project_guid is None:
+ project_guid = "{E5466E26-0003-F18B-8F8A-BCD76C86388D}"
+
+ if os.environ.has_key('SCONS_LIB_DIR'):
+ exec_script_main = "from os.path import join; import sys; sys.path = [ r'%s' ] + sys.path; import SCons.Script; SCons.Script.main()" % os.environ['SCONS_LIB_DIR']
+ else:
+ exec_script_main = "from os.path import join; import sys; sys.path = [ join(sys.prefix, 'Lib', 'site-packages', 'scons-%s'), join(sys.prefix, 'scons-%s'), join(sys.prefix, 'Lib', 'site-packages', 'scons'), join(sys.prefix, 'scons') ] + sys.path; import SCons.Script; SCons.Script.main()" % (self._scons_version, self._scons_version)
+ exec_script_main_xml = string.replace(exec_script_main, "'", "&apos;")
+
+ result = string.replace(input, r'<WORKPATH>', workpath)
+ result = string.replace(result, r'<PYTHON>', python)
+ result = string.replace(result, r'<SCONSCRIPT>', sconscript)
+ result = string.replace(result, r'<SCONS_SCRIPT_MAIN>', exec_script_main)
+ result = string.replace(result, r'<SCONS_SCRIPT_MAIN_XML>', exec_script_main_xml)
+ result = string.replace(result, r'<PROJECT_GUID>', project_guid)
+ return result
+
+ def get_msvs_executable(self, version):
+ """Returns a full path to the executable (MSDEV or devenv)
+ for the specified version of Visual Studio.
+ """
+ common_msdev98_bin_msdev_com = ['Common', 'MSDev98', 'Bin', 'MSDEV.COM']
+ common7_ide_devenv_com = ['Common7', 'IDE', 'devenv.com']
+ common7_ide_vcexpress_exe = ['Common7', 'IDE', 'VCExpress.exe']
+ sub_paths = {
+ '6.0' : [
+ common_msdev98_bin_msdev_com,
+ ],
+ '7.0' : [
+ common7_ide_devenv_com,
+ ],
+ '7.1' : [
+ common7_ide_devenv_com,
+ ],
+ '8.0' : [
+ common7_ide_devenv_com,
+ common7_ide_vcexpress_exe,
+ ],
+ }
+ from SCons.Tool.msvs import get_msvs_install_dirs
+ vs_path = get_msvs_install_dirs(version)['VSINSTALLDIR']
+ for sp in sub_paths[version]:
+ p = apply(os.path.join, [vs_path] + sp)
+ if os.path.exists(p):
+ return p
+ return apply(os.path.join, [vs_path] + sub_paths[version][0])