diff options
author | William Deegan <bill@baddogconsulting.com> | 2016-05-08 23:27:44 (GMT) |
---|---|---|
committer | William Deegan <bill@baddogconsulting.com> | 2016-05-08 23:27:44 (GMT) |
commit | d86a8cf1f8e5aadca9bcd6b7481ab15eccc0530d (patch) | |
tree | 521ddb1071569fa90100e11d7f03af13d5689aaf /QMTest | |
parent | 98bb69c7c9e13ea57ae7e6e8db4740a4dd43ed16 (diff) | |
parent | 6a37189174372c9c98c63ada58ab4352adf650e8 (diff) | |
download | SCons-d86a8cf1f8e5aadca9bcd6b7481ab15eccc0530d.zip SCons-d86a8cf1f8e5aadca9bcd6b7481ab15eccc0530d.tar.gz SCons-d86a8cf1f8e5aadca9bcd6b7481ab15eccc0530d.tar.bz2 |
merged
Diffstat (limited to 'QMTest')
-rw-r--r-- | QMTest/TestCmd.py | 21 | ||||
-rw-r--r-- | QMTest/TestCmdTests.py | 12 | ||||
-rw-r--r-- | QMTest/TestCommon.py | 58 | ||||
-rw-r--r-- | QMTest/TestSCons.py | 28 | ||||
-rw-r--r-- | QMTest/TestSConsMSVS.py | 110 |
5 files changed, 166 insertions, 63 deletions
diff --git a/QMTest/TestCmd.py b/QMTest/TestCmd.py index e6b128b..f8c4e69 100644 --- a/QMTest/TestCmd.py +++ b/QMTest/TestCmd.py @@ -287,8 +287,6 @@ version. # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. from __future__ import division, print_function -from SCons.compat.six import PY3 - __author__ = "Steven Knight <knight at baldmt dot com>" __revision__ = "TestCmd.py 1.3.D001 2010/06/03 12:58:27 knight" __version__ = "1.3" @@ -319,20 +317,6 @@ except ImportError: exec('from UserList import UserList') exec('from UserString import UserString') -try: - # pre-2.7 doesn't have the memoryview() built-in - memoryview -except NameError: - class memoryview: - def __init__(self, obj): - # wrapping buffer in () keeps the fixer from changing it - self.obj = (buffer)(obj) - def __getitem__(self, indx): - if isinstance(indx, slice): - return self.obj[indx.start:indx.stop] - else: - return self.obj[indx] - __all__ = [ 'diff_re', 'fail_test', @@ -488,7 +472,8 @@ def match_re(lines = None, res = None): """ """ if not is_List(lines): - lines = lines.split("\n") + # CRs mess up matching (Windows) so split carefully + lines = re.split('\r?\n', lines) if not is_List(res): res = res.split("\n") if len(lines) != len(res): @@ -1743,8 +1728,6 @@ class TestCmd(object): exist. The I/O mode for the file may be specified; it must begin with a 'w'. The default is 'wb' (binary write). """ - if PY3: - content = re.sub(r'print (.+)', r'print(\1)', content) file = self.canonicalize(file) if mode[0] != 'w': raise ValueError("mode must begin with 'w'") diff --git a/QMTest/TestCmdTests.py b/QMTest/TestCmdTests.py index a2e7022..cd62d9f 100644 --- a/QMTest/TestCmdTests.py +++ b/QMTest/TestCmdTests.py @@ -19,8 +19,6 @@ AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. """ -from SCons.compat.six import PY3 - __author__ = "Steven Knight <knight at baldmt dot com>" __revision__ = "TestCmdTests.py 1.3.D001 2010/06/03 12:58:27 knight" @@ -28,19 +26,13 @@ import os import shutil import signal import stat -if PY3: - from io import StringIO -else: - from StringIO import StringIO +from StringIO import StringIO import sys import tempfile import time import types import unittest -if PY3: - from collections import UserList -else: - from UserList import UserList +from UserList import UserList # Strip the current directory so we get the right TestCmd.py module. diff --git a/QMTest/TestCommon.py b/QMTest/TestCommon.py index f1a7407..f878636 100644 --- a/QMTest/TestCommon.py +++ b/QMTest/TestCommon.py @@ -36,6 +36,8 @@ provided by the TestCommon class: test.must_contain('file', 'required text\n') + test.must_contain_all(output, input, ['title', find]) + test.must_contain_all_lines(output, lines, ['title', find]) test.must_contain_any_line(output, lines, ['title', find]) @@ -90,6 +92,7 @@ The TestCommon module also provides the following variables # PARTICULAR PURPOSE. THE CODE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, # AND THERE IS NO OBLIGATION WHATSOEVER TO PROVIDE MAINTENANCE, # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. + from __future__ import print_function __author__ = "Steven Knight <knight at baldmt dot com>" @@ -122,31 +125,6 @@ __all__.extend([ 'TestCommon', 'dll_suffix', ]) -try: - sorted -except NameError: - # Pre-2.4 Python has no sorted() function. - # - # The pre-2.4 Python list.sort() method does not support - # list.sort(key=) nor list.sort(reverse=) keyword arguments, so - # we must implement the functionality of those keyword arguments - # by hand instead of passing them to list.sort(). - def sorted(iterable, cmp=None, key=None, reverse=False): - if key is not None: - result = [(key(x), x) for x in iterable] - else: - result = iterable[:] - if cmp is None: - # Pre-2.3 Python does not support list.sort(None). - result.sort() - else: - result.sort(cmp) - if key is not None: - result = [t1 for t0,t1 in result] - if reverse: - result.reverse() - return result - # Variables that describe the prefixes and suffixes on this system. if sys.platform == 'win32': exe_suffix = '.exe' @@ -306,6 +284,36 @@ class TestCommon(TestCmd): print(file_contents) self.fail_test(not contains) + def must_contain_all(self, output, input, title=None, find=None): + """Ensures that the specified output string (first argument) + contains all of the specified input as a block (second argument). + + An optional third argument can be used to describe the type + of output being searched, and only shows up in failure output. + + An optional fourth argument can be used to supply a different + function, of the form "find(line, output), to use when searching + for lines in the output. + """ + if find is None: + def find(o, i): + try: + return o.index(i) + except ValueError: + return None + + if is_List(output): + output = os.newline.join(output) + + if find(output, input) is None: + if title is None: + title = 'output' + print('Missing expected input from {}:'.format(title)) + print(input) + print(self.banner(title + ' ')) + print(output) + self.fail_test() + def must_contain_all_lines(self, output, lines, title=None, find=None): """Ensures that the specified output string (first argument) contains all of the specified lines (second argument). diff --git a/QMTest/TestSCons.py b/QMTest/TestSCons.py index 3fe07c3..88d0e9c 100644 --- a/QMTest/TestSCons.py +++ b/QMTest/TestSCons.py @@ -34,9 +34,9 @@ from TestCmd import PIPE # here provides some independent verification that what we packaged # conforms to what we expect. -default_version = '2.3.1.alpha.yyyymmdd' +default_version = '2.5.0' -python_version_unsupported = (2, 3, 0) +python_version_unsupported = (2, 6, 0) python_version_deprecated = (2, 7, 0) # In the checked-in source, the value of SConsVersion in the following @@ -201,6 +201,7 @@ class TestSCons(TestCommon): """ scons_version = SConsVersion + javac_is_gcj = False def __init__(self, **kw): """Initialize an SCons testing object. @@ -693,7 +694,7 @@ class TestSCons(TestCommon): else: jni_dirs = ['/System/Library/Frameworks/JavaVM.framework/Versions/%s*/Headers/jni.h'%version] jni_dirs.extend(['/usr/lib/jvm/java-*-sun-%s*/include/jni.h'%version, - '/usr/lib/jvm/java-%s*-openjdk/include/jni.h'%version, + '/usr/lib/jvm/java-%s*-openjdk*/include/jni.h'%version, '/usr/java/jdk%s*/include/jni.h'%version]) dirs = self.paths(jni_dirs) if not dirs: @@ -714,6 +715,9 @@ class TestSCons(TestCommon): home = '/System/Library/Frameworks/JavaVM.framework/Home' else: home = '/System/Library/Frameworks/JavaVM.framework/Versions/%s/Home' % version + if not os.path.exists(home): + # This works on OSX 10.10 + home = '/System/Library/Frameworks/JavaVM.framework/Versions/Current/' else: jar = self.java_where_jar(version) home = os.path.normpath('%s/..'%jar) @@ -765,8 +769,13 @@ class TestSCons(TestCommon): m = re.search(r'javac (\d\.\d)', self.stderr()) if m: version = m.group(1) + self.javac_is_gcj = False + elif self.stderr().find('gcj'): + version='1.2' + self.javac_is_gcj = True else: version = None + self.javac_is_gcj = False return where_javac, version def java_where_javah(self, version=None): @@ -789,6 +798,7 @@ class TestSCons(TestCommon): self.skip_test("Could not find Java rmic, skipping non-simulated test(s).\n") return where_rmic + def java_get_class_files(self, dir): result = [] for dirpath, dirnames, filenames in os.walk(dir): @@ -926,7 +936,7 @@ if ARGUMENTS.get('variant_dir', 0): else: builddir = 'build' VariantDir(builddir, '.', duplicate=dup) - print builddir, dup + print(builddir, dup) sconscript = Dir(builddir).File('SConscript') else: sconscript = File('SConscript') @@ -1139,12 +1149,12 @@ except AttributeError: try: import distutils.sysconfig exec_prefix = distutils.sysconfig.EXEC_PREFIX - print distutils.sysconfig.get_python_inc() - print os.path.join(exec_prefix, 'libs') + print(distutils.sysconfig.get_python_inc()) + print(os.path.join(exec_prefix, 'libs')) except: - print os.path.join(sys.prefix, 'include', py_ver) - print os.path.join(sys.prefix, 'lib', py_ver, 'config') -print py_ver + print(os.path.join(sys.prefix, 'include', py_ver) + print(os.path.join(sys.prefix, 'lib', py_ver, 'config')) +print(py_ver) """) return [python] + self.stdout().strip().split('\n') diff --git a/QMTest/TestSConsMSVS.py b/QMTest/TestSConsMSVS.py index 478438a..7459af0 100644 --- a/QMTest/TestSConsMSVS.py +++ b/QMTest/TestSConsMSVS.py @@ -514,6 +514,26 @@ Global EndGlobal """ +expected_slnfile_14_0 = """\ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 14 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Test.vcxproj", "Test.vcxproj", "{39A97E1F-1A52-8954-A0B1-A10A8487545E}" +EndProject +Global +<SCC_SLN_INFO> +\tGlobalSection(SolutionConfigurationPlatforms) = preSolution +\t\tRelease|Win32 = Release|Win32 +\tEndGlobalSection +\tGlobalSection(ProjectConfigurationPlatforms) = postSolution +\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.ActiveCfg = Release|Win32 +\t\t{39A97E1F-1A52-8954-A0B1-A10A8487545E}.Release|Win32.Build.0 = Release|Win32 +\tEndGlobalSection +\tGlobalSection(SolutionProperties) = preSolution +\t\tHideSolutionNode = FALSE +\tEndGlobalSection +EndGlobal +""" + expected_vcprojfile_8_0 = """\ <?xml version="1.0" encoding="Windows-1252"?> <VisualStudioProject @@ -709,6 +729,7 @@ expected_vcprojfile_10_0 = """\ \t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> \t\t<ConfigurationType>Makefile</ConfigurationType> \t\t<UseOfMfc>false</UseOfMfc> +\t\t<PlatformToolset>v100</PlatformToolset> \t</PropertyGroup> \t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> \t<ImportGroup Label="ExtensionSettings"> @@ -773,6 +794,72 @@ expected_vcprojfile_11_0 = """\ \t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> \t\t<ConfigurationType>Makefile</ConfigurationType> \t\t<UseOfMfc>false</UseOfMfc> +\t\t<PlatformToolset>v110</PlatformToolset> +\t</PropertyGroup> +\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> +\t<ImportGroup Label="ExtensionSettings"> +\t</ImportGroup> +\t<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets"> +\t\t<Import Project="$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" /> +\t</ImportGroup> +\t<PropertyGroup Label="UserMacros" /> +\t<PropertyGroup> +\t<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion> +\t\t<NMakeBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeBuildCommandLine> +\t\t<NMakeReBuildCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct "Test.exe"</NMakeReBuildCommandLine> +\t\t<NMakeCleanCommandLine Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">echo Starting SCons && "<PYTHON>" -c "<SCONS_SCRIPT_MAIN_XML>" -C "<WORKPATH>" -f SConstruct -c "Test.exe"</NMakeCleanCommandLine> +\t\t<NMakeOutput Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Test.exe</NMakeOutput> +\t\t<NMakePreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">DEF1;DEF2;DEF3=1234</NMakePreprocessorDefinitions> +\t\t<NMakeIncludeSearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">inc1;inc2</NMakeIncludeSearchPath> +\t\t<NMakeForcedIncludes Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedIncludes)</NMakeForcedIncludes> +\t\t<NMakeAssemblySearchPath Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeAssemblySearchPath)</NMakeAssemblySearchPath> +\t\t<NMakeForcedUsingAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(NMakeForcedUsingAssemblies)</NMakeForcedUsingAssemblies> +\t</PropertyGroup> +\t<ItemGroup> +\t\t<ClInclude Include="sdk_dir\sdk.h" /> +\t</ItemGroup> +\t<ItemGroup> +\t\t<ClInclude Include="test.h" /> +\t</ItemGroup> +\t<ItemGroup> +\t\t<None Include="readme.txt" /> +\t</ItemGroup> +\t<ItemGroup> +\t\t<None Include="test.rc" /> +\t</ItemGroup> +\t<ItemGroup> +\t\t<ClCompile Include="test1.cpp" /> +\t\t<ClCompile Include="test2.cpp" /> +\t</ItemGroup> +\t<ItemGroup> +\t\t<None Include="SConstruct" /> +\t</ItemGroup> +\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.targets" /> +\t<ImportGroup Label="ExtensionTargets"> +\t</ImportGroup> +</Project> +""" + +expected_vcprojfile_14_0 = """\ +<?xml version="1.0" encoding="utf-8"?> +<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> +\t<ItemGroup Label="ProjectConfigurations"> +\t\t<ProjectConfiguration Include="Release|Win32"> +\t\t\t<Configuration>Release</Configuration> +\t\t\t<Platform>Win32</Platform> +\t\t</ProjectConfiguration> +\t</ItemGroup> +\t<PropertyGroup Label="Globals"> +\t\t<ProjectGuid>{39A97E1F-1A52-8954-A0B1-A10A8487545E}</ProjectGuid> +<SCC_VCPROJ_INFO> +\t\t<RootNamespace>Test</RootNamespace> +\t\t<Keyword>MakeFileProj</Keyword> +\t</PropertyGroup> +\t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> +\t<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> +\t\t<ConfigurationType>Makefile</ConfigurationType> +\t\t<UseOfMfc>false</UseOfMfc> +\t\t<PlatformToolset>v140</PlatformToolset> \t</PropertyGroup> \t<Import Project="$(VCTargetsPath)\\Microsoft.Cpp.props" /> \t<ImportGroup Label="ExtensionSettings"> @@ -910,6 +997,29 @@ env.MSVSProject(target = 'Test.vcxproj', variant = 'Release') """ +SConscript_contents_14_0 = """\ +env=Environment(platform='win32', tools=['msvs'], MSVS_VERSION='14.0', + CPPDEFINES=['DEF1', 'DEF2',('DEF3','1234')], + CPPPATH=['inc1', 'inc2'], + HOST_ARCH='%(HOST_ARCH)s') + +testsrc = ['test1.cpp', 'test2.cpp'] +testincs = ['sdk_dir\sdk.h'] +testlocalincs = ['test.h'] +testresources = ['test.rc'] +testmisc = ['readme.txt'] + +env.MSVSProject(target = 'Test.vcxproj', + slnguid = '{SLNGUID}', + srcs = testsrc, + incs = testincs, + localincs = testlocalincs, + resources = testresources, + misc = testmisc, + buildtarget = 'Test.exe', + variant = 'Release') +""" + class TestSConsMSVS(TestSCons): """Subclass for testing MSVS-specific portions of SCons.""" |