From 868d09c5718e34f682614059f49d0eb4e3a5f777 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 12:55:01 +0100 Subject: [PATCH 1/7] add new architecture for process mapping, return Default instead of throw --- src/Microsoft.TestPlatform.ObjectModel/Architecture.cs | 1 + .../PublicAPI/PublicAPI.Shipped.txt | 3 ++- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs b/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs index 58de3ae0ed..839137de10 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Architecture.cs @@ -11,4 +11,5 @@ public enum Architecture ARM, AnyCPU, ARM64, + S390x } \ No newline at end of file diff --git a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt index 3eace443ef..687a5c1b0f 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt +++ b/src/Microsoft.TestPlatform.ObjectModel/PublicAPI/PublicAPI.Shipped.txt @@ -106,6 +106,7 @@ Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.TestPlatformFormatExcept Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.TestPlatformFormatException.TestPlatformFormatException(string message, string filterValue) -> void Microsoft.VisualStudio.TestPlatform.ObjectModel.Adapter.TestPlatformFormatException.TestPlatformFormatException(string message, System.Exception innerException) -> void Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture +Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture.S390x = 6 -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture.ARM64 = 5 -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture.AnyCPU = 4 -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture.ARM = 3 -> Microsoft.VisualStudio.TestPlatform.ObjectModel.Architecture @@ -887,4 +888,4 @@ Microsoft.VisualStudio.TestPlatform.ObjectModel.InvokedDataCollector.HasAttachme Microsoft.VisualStudio.TestPlatform.ObjectModel.InvokedDataCollector.Uri.get -> System.Uri override Microsoft.VisualStudio.TestPlatform.ObjectModel.InvokedDataCollector.Equals(object obj) -> bool override Microsoft.VisualStudio.TestPlatform.ObjectModel.InvokedDataCollector.GetHashCode() -> int -override Microsoft.VisualStudio.TestPlatform.ObjectModel.InvokedDataCollector.ToString() -> string \ No newline at end of file +override Microsoft.VisualStudio.TestPlatform.ObjectModel.InvokedDataCollector.ToString() -> string diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index dcac5c548b..320050126c 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -664,11 +664,13 @@ static Architecture TranslateToArchitecture(PlatformArchitecture targetArchitect return Architecture.ARM; case PlatformArchitecture.ARM64: return Architecture.ARM64; + case PlatformArchitecture.S390x: + return Architecture.S390x; default: break; } - throw new TestPlatformException($"Invalid target architecture '{targetArchitecture}'"); + return Architecture.Default; } #endif } From 34932c021ec0dfc8be696c75f87fda03a20274d0 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 15:29:53 +0100 Subject: [PATCH 2/7] fix unit tests --- .../Processors/PlatformArgumentProcessorTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs b/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs index 317a7ff91b..a19983ac04 100644 --- a/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs +++ b/test/vstest.console.UnitTests/Processors/PlatformArgumentProcessorTests.cs @@ -86,7 +86,7 @@ public void InitializeShouldThrowIfArgumentIsNotAnArchitecture() { ExceptionUtilities.ThrowsException( () => _executor.Initialize("foo"), - "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64.", + "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64, S390x.", "foo"); } @@ -95,7 +95,7 @@ public void InitializeShouldThrowIfArgumentIsNotASupportedArchitecture() { ExceptionUtilities.ThrowsException( () => _executor.Initialize("AnyCPU"), - "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64.", + "Invalid platform type: {0}. Valid platform types are X86, X64, ARM, ARM64, S390x.", "AnyCPU"); } From 789ad9b7f6a6b0d4a487ea0d274a416726bb3ae4 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 15:38:15 +0100 Subject: [PATCH 3/7] improve logs --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 320050126c..ef61e0549a 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -624,7 +624,7 @@ private bool UpdateRunSettingsIfRequired( // We want to find 64-bit SDK because it is more likely to be installed. defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86; #endif - EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture}"); + EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}"); } settingsUpdated |= UpdatePlatform( From 33a9ce0ad8193ebb924bdb84a70cc343d39e8d00 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 15:41:06 +0100 Subject: [PATCH 4/7] add comment --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index ef61e0549a..3f5c31f2a7 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -670,6 +670,8 @@ static Architecture TranslateToArchitecture(PlatformArchitecture targetArchitect break; } + // We prefer to not throw in case of unhandled architecture but return Default, + // it should be handled in correct way by the callers. return Architecture.Default; } #endif From 23d66e2d8574a753f7bf3f1d1d7d728d324286ac Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 15:44:19 +0100 Subject: [PATCH 5/7] fix comment --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 3f5c31f2a7..9ec799eb99 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -671,7 +671,7 @@ static Architecture TranslateToArchitecture(PlatformArchitecture targetArchitect } // We prefer to not throw in case of unhandled architecture but return Default, - // it should be handled in correct way by the callers. + // it should be handled in a correct way by the callers. return Architecture.Default; } #endif From 00c47b16d54e690cb4bdbac0554682f9c305bd25 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 16:00:15 +0100 Subject: [PATCH 6/7] Update src/vstest.console/TestPlatformHelpers/TestRequestManager.cs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Amaury Levé --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 9ec799eb99..0d5a0a8aa8 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -624,7 +624,7 @@ private bool UpdateRunSettingsIfRequired( // We want to find 64-bit SDK because it is more likely to be installed. defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86; #endif - EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture} Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}"); + EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture}, Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}."); } settingsUpdated |= UpdatePlatform( From 183e7210d861c40a4ef661c9224c0ca5dd7be485 Mon Sep 17 00:00:00 2001 From: Marco Rossignoli Date: Fri, 28 Jan 2022 16:07:00 +0100 Subject: [PATCH 7/7] log in case of unhandled architecture --- src/vstest.console/TestPlatformHelpers/TestRequestManager.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs index 0d5a0a8aa8..a1df9a5964 100644 --- a/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs +++ b/src/vstest.console/TestPlatformHelpers/TestRequestManager.cs @@ -624,7 +624,7 @@ private bool UpdateRunSettingsIfRequired( // We want to find 64-bit SDK because it is more likely to be installed. defaultArchitecture = Environment.Is64BitOperatingSystem ? Architecture.X64 : Architecture.X86; #endif - EqtTrace.Verbose($"Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture}, Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}."); + EqtTrace.Verbose($"TestRequestManager.UpdateRunSettingsIfRequired: Default architecture: {defaultArchitecture} IsDefaultTargetArchitecture: {RunSettingsHelper.Instance.IsDefaultTargetArchitecture}, Current process architecture: {_processHelper.GetCurrentProcessArchitecture()}."); } settingsUpdated |= UpdatePlatform( @@ -667,6 +667,7 @@ static Architecture TranslateToArchitecture(PlatformArchitecture targetArchitect case PlatformArchitecture.S390x: return Architecture.S390x; default: + EqtTrace.Error($"TestRequestManager.TranslateToArchitecture: Unhandled architecture '{targetArchitecture}'."); break; }