Skip to content

Commit

Permalink
Insertion 20171031 (#1250)
Browse files Browse the repository at this point in the history
* Object Model Api fix (#1231)

* Adding the missing property LocalExtensionData in TestCase

* Fixed the test.

* Do not crash data collector if a extension initialize fails. (#1230)

* Do not crash data collector if a extension initialize fails.

* Add unit tests for the scenario.

* Use TPv2 as default for .NET 3.5. (#1232)

* Loading native dll's correctly for UWP release mode (#1234)

* Loading native dll's correctly for UWP release mode

* nit's

* decouple process bitness with OS Architecture

* HardCoded version of CLI to 2.1.0-preview1-007372 (#1238)

HardCoded version of CLI to 2.1.0-preview1-007372 as the latest version has some issues.

Reverted to old version of CLI because of dotnet/cli#7921

* Get OSArchitecture from Platform Abstraction to check for ARM Processor (#1242)

* GetOsArchitecture from Platform Abstraction to check for ARM

* making sure path is always small
  • Loading branch information
smadala authored Oct 31, 2017
1 parent ddf8a32 commit 71cbcd0
Show file tree
Hide file tree
Showing 14 changed files with 103 additions and 27 deletions.
4 changes: 2 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -537,9 +537,9 @@ private Dictionary<string, DataCollectionEnvironmentVariable> GetEnvironmentVari
var dataCollectorEnvironmentVariable = new Dictionary<string, DataCollectionEnvironmentVariable>(StringComparer.OrdinalIgnoreCase);
foreach (var dataCollectorInfo in this.RunDataCollectors.Values)
{
dataCollectorInfo.SetTestExecutionEnvironmentVariables();
try
{
dataCollectorInfo.SetTestExecutionEnvironmentVariables();
this.AddCollectorEnvironmentVariables(dataCollectorInfo, dataCollectorEnvironmentVariable);
}
catch (Exception ex)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal class ProxyExecutionManagerWithDataCollection : ProxyExecutionManager
/// <summary>
/// Initializes a new instance of the <see cref="ProxyExecutionManagerWithDataCollection"/> class.
/// </summary>
/// <param name="testRequestSender">
/// <param name="requestSender">
/// Test request sender instance.
/// </param>
/// <param name="testHostManager">
Expand All @@ -44,6 +44,7 @@ public ProxyExecutionManagerWithDataCollection(IRequestData requestData, ITestRe
this.ProxyDataCollectionManager = proxyDataCollectionManager;
this.DataCollectionRunEventsHandler = new DataCollectionRunEventsHandler();
this.requestData = requestData;
this.dataCollectionEnvironmentVariables = new Dictionary<string, string>();
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ public DataCollectionParameters BeforeTestRunStart(
ITestMessageEventHandler runEventsHandler)
{
var areTestCaseLevelEventsRequired = false;
IDictionary<string, string> environmentVariables = null;
IDictionary<string, string> environmentVariables = new Dictionary<string, string>();

var dataCollectionEventsPort = 0;
this.InvokeDataCollectionServiceAction(
Expand Down
14 changes: 3 additions & 11 deletions src/Microsoft.TestPlatform.ObjectModel/Navigation/NativeMethods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
Expand Down
11 changes: 4 additions & 7 deletions src/Microsoft.TestPlatform.ObjectModel/TestCase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,12 @@ namespace Microsoft.VisualStudio.TestPlatform.ObjectModel
[DataContract]
public sealed class TestCase : TestObject
{
#if TODO
/// <summary>
/// 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
/// </summary>
private Object m_localExtensionData;
#endif
private Object localExtensionData;

private Guid defaultId = Guid.Empty;
private Guid id;
private string displayName;
Expand Down Expand Up @@ -70,17 +69,15 @@ public TestCase(string fullyQualifiedName, Uri executorUri, string source)

#region Properties

#if TODO
/// <summary>
/// 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
/// </summary>
public Object LocalExtensionData
{
get { return m_localExtensionData; }
set { m_localExtensionData = value; }
get { return localExtensionData; }
set { localExtensionData = value; }
}
#endif

/// <summary>
/// Gets or sets the id of the test case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ public interface IProcessHelper
/// <returns>Location of test engine.</returns>
string GetTestEngineDirectory();

/// <summary>
/// Gets the location of native dll's, depending on current process architecture..
/// </summary>
/// <returns>Location of native dll's</returns>
string GetNativeDllDirectory();

/// <summary>
/// Gets current process architecture
/// </summary>
/// <returns>Process Architecture</returns>
PlatformArchitecture GetCurrentProcessArchitecture();

/// <summary>
/// Gets the process id of test engine.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions
/// </summary>
public partial class ProcessHelper : IProcessHelper
{
private static readonly string ARM = "arm";

/// <inheritdoc/>
public object LaunchProcess(string processPath, string arguments, string workingDirectory, IDictionary<string, string> envVariables, Action<object, string> errorCallback, Action<object> exitCallBack)
{
Expand Down Expand Up @@ -162,5 +164,28 @@ public int GetProcessId(object process)
var proc = process as Process;
return proc?.Id ?? -1;
}

/// <inheritdoc/>
public PlatformArchitecture GetCurrentProcessArchitecture()
{
if (IntPtr.Size == 8)
{
return PlatformArchitecture.X64;
}

return PlatformArchitecture.X86;
}

/// <inheritdoc/>
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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,5 +78,17 @@ public int GetProcessId(object process)
{
throw new NotImplementedException();
}

/// <inheritdoc/>
public string GetNativeDllDirectory()
{
throw new NotImplementedException();
}

/// <inheritdoc/>
public PlatformArchitecture GetCurrentProcessArchitecture()
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,23 @@ public int GetProcessId(object process)
{
return -1;
}

/// <inheritdoc/>
public PlatformArchitecture GetCurrentProcessArchitecture()
{
if (IntPtr.Size == 8)
{
return PlatformArchitecture.X64;
}

return PlatformArchitecture.X86;
}

/// <inheritdoc/>
public string GetNativeDllDirectory()
{
// For UWP the native dll's are to be kept in same directory
return this.GetCurrentProcessLocation();
}
}
}
2 changes: 1 addition & 1 deletion src/package/VSIXProject/testplatform.config
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<configuration>
<appSettings>
<!-- Setting feature.net35 to "true" will execute full clr tests targeting framework <=v3.5 through TPV2. -->
<add key="feature.net35" value="false" />
<add key="feature.net35" value="true" />
<!-- Setting feature.net40 to "true" will execute full clr tests targeting framework >=4.0 through TPV2. -->
<add key="feature.net40" value="true" />
<!-- Setting feature.datacollector to "true"" will execute data collection (code coverage, etc.) through TPV2. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
11 changes: 11 additions & 0 deletions test/datacollector.UnitTests/DataCollectionManagerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,17 @@ public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfInitializat
this.mockMessageSink.Verify(x => x.SendMessage(It.IsAny<DataCollectionMessageEventArgs>()), Times.Once);
}

[TestMethod]
public void InitializeDataCollectorsShouldLogExceptionToMessageSinkIfSetEnvironmentVariableFails()
{
this.mockDataCollector.As<ITestExecutionEnvironmentSpecifier>().Setup(x => x.GetTestExecutionEnvironmentVariables()).Throws<Exception>();

this.dataCollectionManager.InitializeDataCollectors(this.dataCollectorSettings);

Assert.AreEqual(0, this.dataCollectionManager.RunDataCollectors.Count);
this.mockMessageSink.Verify(x => x.SendMessage(It.IsAny<DataCollectionMessageEventArgs>()), Times.Once);
}

[TestMethod]
public void InitializeDataCollectorsShouldReturnFirstEnvironmentVariableIfMoreThanOneVariablesWithSameKeyIsSpecified()
{
Expand Down

0 comments on commit 71cbcd0

Please sign in to comment.