From 7f95557d20c331f7ab4fa0e33f9ee06ac0db8039 Mon Sep 17 00:00:00 2001 From: Alex Earl Date: Wed, 7 Dec 2016 16:02:14 -0700 Subject: [PATCH] Fix more tests on Linux (#1552) * Fix more tests on Linux * Namespace on windows --- .../Languages/IronPython/27/Lib/ntpath.py | 2 +- .../Tests/modules/misc/system_namespaces.py | 35 +++-- .../Tests/modules/system_related/sys_test.py | 2 +- Makefile | 14 +- Test/IronPython.tests | 1 + Util/IronPython/Lib/iptest/process_util.py | 147 ------------------ 6 files changed, 30 insertions(+), 171 deletions(-) delete mode 100644 Util/IronPython/Lib/iptest/process_util.py diff --git a/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/ntpath.py b/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/ntpath.py index 0b85b0b9be..1bb37143ed 100644 --- a/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/ntpath.py +++ b/External.LCA_RESTRICTED/Languages/IronPython/27/Lib/ntpath.py @@ -332,7 +332,7 @@ def expandvars(path): return path import string varchars = string.ascii_letters + string.digits + '_-' - if isinstance(path, _unicode): + if sys.platform != 'cli' and isinstance(path, _unicode): encoding = sys.getfilesystemencoding() def getenv(var): return os.environ[var.encode(encoding)].decode(encoding) diff --git a/Languages/IronPython/Tests/modules/misc/system_namespaces.py b/Languages/IronPython/Tests/modules/misc/system_namespaces.py index c81a5ac2ab..aa4c0c4fea 100644 --- a/Languages/IronPython/Tests/modules/misc/system_namespaces.py +++ b/Languages/IronPython/Tests/modules/misc/system_namespaces.py @@ -18,7 +18,7 @@ ''' #--IMPORTS--------------------------------------------------------------------- -from iptest.assert_util import skiptest, is_cli, run_test +from iptest.assert_util import skiptest, is_cli, run_test, is_posix skiptest("win32", "silverlight") skiptest("netstandard") # references are different in netstandard @@ -27,7 +27,10 @@ clr.AddReference("System.Configuration.Install") clr.AddReference("System.Data") clr.AddReference("System.Data.OracleClient") -clr.AddReference("System.Data.SqlXml") +if is_posix: + clr.AddReference("System.Data.SqlClient") +else: + clr.AddReference("System.Data.SqlXml") clr.AddReference("System.Deployment") clr.AddReference("System.Design") clr.AddReference("System.DirectoryServices") @@ -47,7 +50,7 @@ clr.AddReference("System.Web.RegularExpressions") clr.AddReference("System.Web.Services") clr.AddReference("System.Windows.Forms") -clr.AddReference("System.XML") +clr.AddReference("System.Xml") from System import * from System.CodeDom import * @@ -74,8 +77,9 @@ from System.Data.Sql import * from System.Data.SqlClient import * from System.Data.SqlTypes import * -from System.Deployment.Application import * -from System.Deployment.Internal import * +if not is_posix: + from System.Deployment.Application import * + from System.Deployment.Internal import * from System.Diagnostics import * from System.Diagnostics.CodeAnalysis import * from System.Diagnostics.Design import * @@ -102,8 +106,7 @@ from System.Media import * from System.Messaging import * from System.Messaging.Design import * -#http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=25806 -#from System.Net import * +from System.Net import * from System.Net.Cache import * from System.Net.Configuration import * from System.Net.Mail import * @@ -168,9 +171,10 @@ from System.Web.Hosting import * from System.Web.Mail import * from System.Web.Management import * -from System.Web.Mobile import * +if not is_posix: + from System.Web.Mobile import * + from System.Web.RegularExpressions import * from System.Web.Profile import * -from System.Web.RegularExpressions import * from System.Web.Security import * from System.Web.Services import * from System.Web.Services.Configuration import * @@ -181,14 +185,15 @@ from System.Web.UI import * from System.Web.UI.Adapters import * from System.Web.UI.Design import * -from System.Web.UI.Design.MobileControls import * -from System.Web.UI.Design.MobileControls.Converters import * +if not is_posix: + from System.Web.UI.Design.MobileControls import * + from System.Web.UI.Design.MobileControls.Converters import * + from System.Web.UI.MobileControls import * + from System.Web.UI.MobileControls.Adapters import * + from System.Web.UI.MobileControls.Adapters.XhtmlAdapters import * + from System.Web.UI.Design.WebControls.WebParts import * from System.Web.UI.Design.WebControls import * -from System.Web.UI.Design.WebControls.WebParts import * from System.Web.UI.HtmlControls import * -from System.Web.UI.MobileControls import * -from System.Web.UI.MobileControls.Adapters import * -from System.Web.UI.MobileControls.Adapters.XhtmlAdapters import * from System.Web.UI.WebControls import * from System.Web.UI.WebControls.Adapters import * from System.Web.UI.WebControls.WebParts import * diff --git a/Languages/IronPython/Tests/modules/system_related/sys_test.py b/Languages/IronPython/Tests/modules/system_related/sys_test.py index e2e498678b..17c7c08568 100644 --- a/Languages/IronPython/Tests/modules/system_related/sys_test.py +++ b/Languages/IronPython/Tests/modules/system_related/sys_test.py @@ -361,7 +361,7 @@ def test_version(): # 2.7.5 (IronPython 2.7.5 (2.7.5.0) on .NET 4.0.30319.18444 (32-bit)) # 2.7.6a0 (IronPython 2.7.6a0 DEBUG (2.7.6.0) on .NET 4.0.30319.18444 (32-bit)) # 2.7.6 (IronPython 2.7.6.3 (2.7.6.3) on .NET 4.0.30319.42000 (32-bit)) - regex = "^\d\.\d\.\d((RC\d+ )|(a\d+ )|(b\d+ )|( ))\(IronPython \d\.\d(\.\d)?(\.\d)?((RC\d+ )|(a\d+ )|(b\d+ )|( ))?((DEBUG )|()|(\d?))\(\d\.\d\.\d{1,8}\.\d{1,8}\) on \.NET \d(\.\d{1,5}){3} \(32-bit\)\)$" + regex = "^\d\.\d\.\d((RC\d+ )|(a\d+ )|(b\d+ )|( ))\(IronPython \d\.\d(\.\d)?(\.\d)?((RC\d+ )|(a\d+ )|(b\d+ )|( ))?((DEBUG )|()|(\d?))\(\d\.\d\.\d{1,8}\.\d{1,8}\) on ((\.NET)|(Mono)) \d(\.\d{1,5}){3} \(((32)|(64))-bit\)\)$" Assert(re.match(regex, sys.version, re.IGNORECASE) != None) def test_winver(): diff --git a/Makefile b/Makefile index bfe057e2e6..42c704c22b 100644 --- a/Makefile +++ b/Makefile @@ -3,22 +3,22 @@ all: ironpython ironpython: - xbuild Build.proj /t:Build "/p:Mono=true;BaseConfiguration=Debug" + xbuild Build.proj /t:Build "/p:Mono=true;BaseConfiguration=Debug" /verbosity:minimal /nologo ironpython-release: - xbuild Build.proj /t:Build "/p:Mono=true;BaseConfiguration=Release" + xbuild Build.proj /t:Build "/p:Mono=true;BaseConfiguration=Release" /verbosity:minimal /nologo testrunner: - xbuild Test/ClrAssembly/ClrAssembly.csproj /t:Rebuild /p:Configuration=Debug - xbuild Test/TestRunner/TestRunner.sln /p:Configuration=Debug + xbuild Test/ClrAssembly/ClrAssembly.csproj /t:Rebuild /p:Configuration=Debug /verbosity:minimal /nologo + xbuild Test/TestRunner/TestRunner.sln /p:Configuration=Debug /verbosity:minimal /nologo rm -rf bin/Debug/DLLs/PresentationFramework.dll \ bin/Debug/DLLs/IronPython.Wpf.dll \ bin/Debug/DLLs/WindowsBase.dll \ bin/Debug/DLLs/System.Xaml.dll testrunner-release: - xbuild Test/ClrAssembly/ClrAssembly.csproj /t:Rebuild /p:Configuration=Release - xbuild Test/TestRunner/TestRunner.sln /p:Configuration=Release + xbuild Test/ClrAssembly/ClrAssembly.csproj /t:Rebuild /p:Configuration=Release /verbosity:minimal /nologo + xbuild Test/TestRunner/TestRunner.sln /p:Configuration=Release /verbosity:minimal /nologo rm -rf bin/Release/DLLs/PresentationFramework.dll \ bin/Release/DLLs/IronPython.Wpf.dll \ bin/Release/DLLs/WindowsBase.dll \ @@ -47,7 +47,7 @@ test-ipy-disabled-release: ironpython-release testrunner-release Test/IronPython.tests /binpath:bin/Release /all /runlong /rundisabled package-release: - xbuild Build.proj /t:Package "/p:Mono=true;BaseConfiguration=Release" /nologo + xbuild Build.proj /t:Package "/p:Mono=true;BaseConfiguration=Release" /verbosity:minimal /nologo clean: xbuild Build.proj /t:Clean /p:Mono=true /verbosity:minimal /nologo diff --git a/Test/IronPython.tests b/Test/IronPython.tests index c2f64703bc..e17b11fa1e 100644 --- a/Test/IronPython.tests +++ b/Test/IronPython.tests @@ -4251,6 +4251,7 @@ 600000 true false + '$(OS)' != 'Unix' false false %DLR_ROOT%\External.LCA_RESTRICTED\Languages\IronPython\27\Lib diff --git a/Util/IronPython/Lib/iptest/process_util.py b/Util/IronPython/Lib/iptest/process_util.py deleted file mode 100644 index 73df66ef64..0000000000 --- a/Util/IronPython/Lib/iptest/process_util.py +++ /dev/null @@ -1,147 +0,0 @@ -##################################################################################### -# -# Copyright (c) Microsoft Corporation. All rights reserved. -# -# This source code is subject to terms and conditions of the Microsoft Public License. A -# copy of the license can be found in the License.html file at the root of this distribution. If -# you cannot locate the Microsoft Public License, please send an email to -# ironpy@microsoft.com. By using this source code in any fashion, you are agreeing to be bound -# by the terms of the Microsoft Public License. -# -# You must not remove this notice, or any other, from this software. -# -# -##################################################################################### - -## BE PLATFORM NETURAL - -import nt -import sys -from assert_util import testpath, is_cli - -one_arg_params = ("-X:Optimize", "-W", "-c", "-X:MaxRecursion", "-X:AssembliesDir") - -def launch(executable, *params): - l = [ executable ] + list(params) - return nt.spawnv(0, executable, l) - -def launch_ironpython(pyfile, *args): - t = (pyfile, ) - for arg in args: t += (arg, ) - return launch(testpath.ipython_executable, *t) - -def launch_cpython(pyfile, *args): - t = (pyfile, ) - for arg in args: t += (arg, ) - return launch(testpath.cpython_executable, *t) - -def launch_ironpython_with_extensions(pyfile, extensions, args): - t = tuple(extensions) - t += (pyfile, ) - for arg in args: t += (arg, ) - return launch(testpath.ipython_executable, *t) - -def _get_ip_testmode(): - import System - lastConsumesNext = False - switches = [] - for param in System.Environment.GetCommandLineArgs(): - if param.startswith('-T:') or param.startswith('-O:'): - continue - if param.startswith("-"): - switches.append(param) - if param in one_arg_params: - lastConsumesNext = True - else: - if lastConsumesNext: - switches.append(param) - lastConsumesNext = False - return switches - -def launch_ironpython_changing_extensions(test, add=[], remove=[], additionalScriptParams=()): - final = _get_ip_testmode() - for param in add: - if param not in final: final.append(param) - - for param in remove: - if param in final: - pos = final.index(param) - if pos != -1: - if param in one_arg_params: - del final[pos:pos+2] - else : - del final[pos] - - params = [sys.executable] - params.extend(final) - params.append(test) - params.extend(additionalScriptParams) - - print "Starting process: %s" % params - - return nt.spawnv(0, sys.executable, params) - -def run_tool(cmd, args=""): - import System - process = System.Diagnostics.Process() - process.StartInfo.FileName = cmd - process.StartInfo.Arguments = args - process.StartInfo.CreateNoWindow = True - process.StartInfo.UseShellExecute = False - process.StartInfo.RedirectStandardInput = False - process.StartInfo.RedirectStandardOutput = False - process.StartInfo.RedirectStandardError = False - process.Start() - process.WaitForExit() - return process.ExitCode - -def has_csc(): - try: run_csc("/?") - except WindowsError: return False - else: return True - -def has_vbc(): - try: run_vbc("/?") - except WindowsError: return False - else: return True - -def has_ilasm(): - try: run_ilasm("/?") - except WindowsError: return False - else: return True - -def run_tlbimp(pathToTypeLib, outputName=None): - if outputName: - return run_tool("tlbimp.exe", pathToTypeLib+" /out:"+outputName) - else: - return run_tool("tlbimp.exe", pathToTypeLib) - -def run_register_com_component(pathToDll): - return run_tool("regsvr32.exe", "/s "+pathToDll) - -def run_unregister_com_component(pathToDll): - return run_tool("regsvr32.exe", "/s /u "+pathToDll) - -def run_csc(args): - import file_util - return run_tool(file_util.path_combine(get_clr_dir(),"csc.exe"), args) - -def run_vbc(args): - import file_util - return run_tool(file_util.path_combine(get_clr_dir(),"vbc.exe"), args) - -def run_ilasm(args): - import file_util - return run_tool(file_util.path_combine(get_clr_dir(),"ilasm.exe"), args) - -def number_of_process(arg): - return len([x for x in nt.popen('tasklist.exe').readlines() if x.lower().startswith(arg.lower()) ]) - -def kill_process(arg): - return run_tool("taskkill.exe", '/F /IM %s' % arg) - -def get_clr_dir(): - import clr - from System import Type - from System.IO import Path - return Path.GetDirectoryName(Type.GetType('System.Int32').Assembly.Location)