diff --git a/scripts/build.ps1 b/scripts/build.ps1 index 502f443153..26bbe02b7f 100644 --- a/scripts/build.ps1 +++ b/scripts/build.ps1 @@ -61,8 +61,8 @@ $env:DOTNET_SKIP_FIRST_TIME_EXPERIENCE = 1 # Dotnet build doesn't support --packages yet. See https://github.com/dotnet/cli/issues/2712 $env:NUGET_PACKAGES = $env:TP_PACKAGES_DIR $env:NUGET_EXE_Version = "3.4.3" -$env:DOTNET_CLI_VERSION = "LATEST" -$env:DOTNET_RUNTIME_VERSION = "LATEST" +$env:DOTNET_CLI_VERSION = "2.1.0-preview1-007372" +# $env:DOTNET_RUNTIME_VERSION = "LATEST" $env:VSWHERE_VERSION = "2.0.2" $env:MSBUILD_VERSION = "15.0" diff --git a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs index d933f3aefe..395f937052 100644 --- a/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.Common/DataCollection/DataCollectionManager.cs @@ -537,9 +537,9 @@ private Dictionary GetEnvironmentVari var dataCollectorEnvironmentVariable = new Dictionary(StringComparer.OrdinalIgnoreCase); foreach (var dataCollectorInfo in this.RunDataCollectors.Values) { - dataCollectorInfo.SetTestExecutionEnvironmentVariables(); try { + dataCollectorInfo.SetTestExecutionEnvironmentVariables(); this.AddCollectorEnvironmentVariables(dataCollectorInfo, dataCollectorEnvironmentVariable); } catch (Exception ex) diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs index baac2470d5..e4b5d7186a 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/Client/ProxyExecutionManagerWithDataCollection.cs @@ -26,7 +26,7 @@ internal class ProxyExecutionManagerWithDataCollection : ProxyExecutionManager /// /// Initializes a new instance of the class. /// - /// + /// /// Test request sender instance. /// /// @@ -44,6 +44,7 @@ public ProxyExecutionManagerWithDataCollection(IRequestData requestData, ITestRe this.ProxyDataCollectionManager = proxyDataCollectionManager; this.DataCollectionRunEventsHandler = new DataCollectionRunEventsHandler(); this.requestData = requestData; + this.dataCollectionEnvironmentVariables = new Dictionary(); } /// diff --git a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs index 9fc0ac15c0..687066c8ce 100644 --- a/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs +++ b/src/Microsoft.TestPlatform.CrossPlatEngine/DataCollection/ProxyDataCollectionManager.cs @@ -149,7 +149,7 @@ public DataCollectionParameters BeforeTestRunStart( ITestMessageEventHandler runEventsHandler) { var areTestCaseLevelEventsRequired = false; - IDictionary environmentVariables = null; + IDictionary environmentVariables = new Dictionary(); var dataCollectionEventsPort = 0; this.InvokeDataCollectionServiceAction( diff --git a/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs b/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs index d207641584..54f176beac 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs @@ -556,19 +556,11 @@ internal static class DiaSourceObject public static IDiaDataSource GetDiaSourceObject() { - var currentDirectory = new ProcessHelper().GetCurrentProcessLocation(); + var nativeDllDirectory = new ProcessHelper().GetNativeDllDirectory(); - IntPtr modHandle = IntPtr.Zero; - if (IntPtr.Size == 8) - { - modHandle = LoadLibraryEx(Path.Combine(currentDirectory, "x64\\msdia140.dll"), IntPtr.Zero, 0); - } - else - { - modHandle = LoadLibraryEx(Path.Combine(currentDirectory, "x86\\msdia140.dll"), IntPtr.Zero, 0); - } + IntPtr modHandle = LoadLibraryEx(Path.Combine(nativeDllDirectory, "msdia140.dll"), IntPtr.Zero, 0); - if(modHandle == IntPtr.Zero) + if (modHandle == IntPtr.Zero) { throw new COMException(string.Format(Resources.Resources.FailedToLoadMsDia)); } diff --git a/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs b/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs index 55c631c32e..786af5c29a 100644 --- a/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs +++ b/src/Microsoft.TestPlatform.ObjectModel/TestCase.cs @@ -18,13 +18,12 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel [DataContract] public sealed class TestCase : TestObject { -#if TODO /// /// LocalExtensionData which can be used by Adapter developers for local transfer of extended properties. /// Note that this data is available only for in-Proc execution, and may not be available for OutProc executors /// - private Object m_localExtensionData; -#endif + private Object localExtensionData; + private Guid defaultId = Guid.Empty; private Guid id; private string displayName; @@ -70,17 +69,15 @@ public TestCase(string fullyQualifiedName, Uri executorUri, string source) #region Properties -#if TODO /// /// LocalExtensionData which can be used by Adapter developers for local transfer of extended properties. /// Note that this data is available only for in-Proc execution, and may not be available for OutProc executors /// public Object LocalExtensionData { - get { return m_localExtensionData; } - set { m_localExtensionData = value; } + get { return localExtensionData; } + set { localExtensionData = value; } } -#endif /// /// Gets or sets the id of the test case. diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs index e463046c8e..eca17c7099 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/Interfaces/System/IProcessHelper.cs @@ -41,6 +41,18 @@ public interface IProcessHelper /// Location of test engine. string GetTestEngineDirectory(); + /// + /// Gets the location of native dll's, depending on current process architecture.. + /// + /// Location of native dll's + string GetNativeDllDirectory(); + + /// + /// Gets current process architecture + /// + /// Process Architecture + PlatformArchitecture GetCurrentProcessArchitecture(); + /// /// Gets the process id of test engine. /// diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs index aa147a1aad..ec924ed47b 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/common/System/ProcessHelper.cs @@ -16,6 +16,8 @@ namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions /// public partial class ProcessHelper : IProcessHelper { + private static readonly string ARM = "arm"; + /// public object LaunchProcess(string processPath, string arguments, string workingDirectory, IDictionary envVariables, Action errorCallback, Action exitCallBack) { @@ -162,5 +164,28 @@ public int GetProcessId(object process) var proc = process as Process; return proc?.Id ?? -1; } + + /// + public PlatformArchitecture GetCurrentProcessArchitecture() + { + if (IntPtr.Size == 8) + { + return PlatformArchitecture.X64; + } + + return PlatformArchitecture.X86; + } + + /// + public string GetNativeDllDirectory() + { + var osArchitecture = new PlatformEnvironment().Architecture; + if (osArchitecture == PlatformArchitecture.ARM || osArchitecture == PlatformArchitecture.ARM64) + { + return Path.Combine(this.GetCurrentProcessLocation(), this.GetCurrentProcessArchitecture().ToString().ToLower(), ARM); + } + + return Path.Combine(this.GetCurrentProcessLocation(), this.GetCurrentProcessArchitecture().ToString().ToLower()); + } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard1.0/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard1.0/System/ProcessHelper.cs index 6cd58c1706..7cd2ca470c 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard1.0/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/netstandard1.0/System/ProcessHelper.cs @@ -78,5 +78,17 @@ public int GetProcessId(object process) { throw new NotImplementedException(); } + + /// + public string GetNativeDllDirectory() + { + throw new NotImplementedException(); + } + + /// + public PlatformArchitecture GetCurrentProcessArchitecture() + { + throw new NotImplementedException(); + } } } diff --git a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs index 1661246052..69525fa74a 100644 --- a/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs +++ b/src/Microsoft.TestPlatform.PlatformAbstractions/uap10.0/System/ProcessHelper.cs @@ -77,5 +77,23 @@ public int GetProcessId(object process) { return -1; } + + /// + public PlatformArchitecture GetCurrentProcessArchitecture() + { + if (IntPtr.Size == 8) + { + return PlatformArchitecture.X64; + } + + return PlatformArchitecture.X86; + } + + /// + public string GetNativeDllDirectory() + { + // For UWP the native dll's are to be kept in same directory + return this.GetCurrentProcessLocation(); + } } } diff --git a/src/package/VSIXProject/testplatform.config b/src/package/VSIXProject/testplatform.config index 0ab8787965..4d391b6d12 100644 --- a/src/package/VSIXProject/testplatform.config +++ b/src/package/VSIXProject/testplatform.config @@ -3,7 +3,7 @@ - + diff --git a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs index a2526df5ca..ba778d8021 100644 --- a/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs +++ b/test/Microsoft.TestPlatform.CrossPlatEngine.UnitTests/DataCollection/ProxyDataCollectionManagerTests.cs @@ -136,9 +136,9 @@ public void BeforeTestRunStartsShouldInvokeRunEventsHandlerIfExceptionIsThrown() var result = this.proxyDataCollectionManager.BeforeTestRunStart(true, true, mockRunEventsHandler.Object); mockRunEventsHandler.Verify(eh => eh.HandleLogMessage(TestMessageLevel.Error, "Exception of type 'System.Exception' was thrown."), Times.Once); - Assert.AreEqual(result.EnvironmentVariables, null); - Assert.AreEqual(result.AreTestCaseLevelEventsRequired, false); - Assert.AreEqual(result.DataCollectionEventsPort, 0); + Assert.AreEqual(0, result.EnvironmentVariables.Count); + Assert.AreEqual(false, result.AreTestCaseLevelEventsRequired); + Assert.AreEqual(0, result.DataCollectionEventsPort); } [TestMethod] diff --git a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs index 70630bf9af..4923d4898a 100644 --- a/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs +++ b/test/Microsoft.TestPlatform.ObjectModel.UnitTests/TestCaseTests.cs @@ -53,6 +53,14 @@ public void TestCaseIdShouldReturnIdSetExplicitlyEvenIfNameOrSourceInfoChanges() Assert.AreEqual(testGuid, testCase.Id); } + [TestMethod] + public void TestCaseLocalExtensionDataIsPubliclySettableGettableProperty() + { + var dummyData = "foo"; + this.testCase.LocalExtensionData = dummyData; + Assert.AreEqual("foo", this.testCase.LocalExtensionData); + } + #region GetSetPropertyValue Tests [TestMethod] diff --git a/test/datacollector.UnitTests/DataCollectionManagerTests.cs b/test/datacollector.UnitTests/DataCollectionManagerTests.cs index 9c9963323f..94d5bf01ee 100644 --- a/test/datacollector.UnitTests/DataCollectionManagerTests.cs +++ b/test/datacollector.UnitTests/DataCollectionManagerTests.cs @@ -157,6 +157,17 @@ public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfInitializat this.mockMessageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once); } + [TestMethod] + public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfSetEnvironmentVariableFails() + { + this.mockDataCollector.As().Setup(x => x.GetTestExecutionEnvironmentVariables()).Throws(); + + this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings); + + Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count); + this.mockMessageSink.Verify(x => x.SendMessage(It.IsAny()), Times.Once); + } + [TestMethod] public void InitializeDataCollectorsShouldReturnFirstEnvironmentVariableIfMoreThanOneVariablesWithSameKeyIsSpecified() {