-
Notifications
You must be signed in to change notification settings - Fork 325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C++ UWP Reflection based discovery #1336
Changes from 5 commits
eeedadc
4a40e8c
e235f59
06754c9
e1314d5
c75d0f8
5b95e63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System.IO; | ||
|
||
/// <summary> | ||
/// File Abstraction | ||
/// </summary> | ||
public static class PlatformPath | ||
{ | ||
/// <summary> | ||
/// Checks if give file exists on disk | ||
/// </summary> | ||
/// <param name="filePath">input filePath</param> | ||
/// <param name="fileName">output fileName</param> | ||
public static void TryGetFileName(string filePath, out string fileName) | ||
{ | ||
try | ||
{ | ||
fileName = Path.GetFileName(filePath); | ||
} | ||
catch | ||
{ | ||
fileName = filePath; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System.IO; | ||
|
||
/// <summary> | ||
/// File Abstraction | ||
/// </summary> | ||
public static class PlatformPath | ||
{ | ||
/// <summary> | ||
/// Checks if give file exists on disk | ||
/// </summary> | ||
/// <param name="filePath">input filePath</param> | ||
/// <param name="fileName">output fileName</param> | ||
public static void TryGetFileName(string filePath, out string fileName) | ||
{ | ||
throw new FileNotFoundException(); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.PlatformAbstractions | ||
{ | ||
using System.IO; | ||
|
||
/// <summary> | ||
/// File Abstraction | ||
/// </summary> | ||
public static class PlatformPath | ||
{ | ||
/// <summary> | ||
/// Checks if give file exists on disk | ||
/// </summary> | ||
/// <param name="filePath">input filePath</param> | ||
/// <param name="fileName">output fileName</param> | ||
public static void TryGetFileName(string filePath, out string fileName) | ||
{ | ||
try | ||
{ | ||
fileName = Path.GetFileName(filePath); | ||
} | ||
catch | ||
{ | ||
fileName = filePath; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) Microsoft Corporation. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider | ||
{ | ||
using System.IO; | ||
using System.Xml.Linq; | ||
|
||
/// <summary> Wrapper for an appxmanifest file. </summary> | ||
internal static class AppxManifestFile | ||
{ | ||
/// <summary> Gets the app's exe name. </summary> | ||
/// <param name="filePath"> | ||
/// AppxManifest filePath | ||
/// </param> | ||
/// <returns>ExecutableName</returns> | ||
public static string GetApplicationExecutableName(string filePath) | ||
{ | ||
if (File.Exists(filePath)) | ||
{ | ||
var doc = XDocument.Load(filePath); | ||
var ns = doc.Root.Name.Namespace; | ||
|
||
return doc.Element(ns + "Package"). | ||
Element(ns + "Applications"). | ||
Element(ns + "Application"). | ||
Attribute("Executable").Value; | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,11 +13,13 @@ namespace Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Hosting | |
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using System.Xml.Linq; | ||
using Microsoft.TestPlatform.TestHostProvider.Hosting; | ||
using Microsoft.TestPlatform.TestHostProvider.Resources; | ||
using Microsoft.VisualStudio.TestPlatform.CoreUtilities.Extensions; | ||
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers; | ||
using Microsoft.VisualStudio.TestPlatform.CrossPlatEngine.Helpers.Interfaces; | ||
using Microsoft.VisualStudio.TestPlatform.DesktopTestHostRuntimeProvider; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Client.Interfaces; | ||
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Host; | ||
|
@@ -203,7 +205,21 @@ public IEnumerable<string> GetTestPlatformExtensions(IEnumerable<string> sources | |
/// <inheritdoc/> | ||
public IEnumerable<string> GetTestSources(IEnumerable<string> sources) | ||
{ | ||
// We do not have scenario where full CLR tests are deployed to remote machine, so no need to udpate sources | ||
// We are doing this specifically for UWP, should we extract it out to some other utility? | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Absolutely. This code takes us back couple of years, albeit the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm thinking of moving this to UWP provider, & invoke it via reflection so it always owns the ownership of giving us the correct exe, but that would still mean Desktop Provider would need to understand what all packages types it can support, however it need not understand the logic to extract sources from that package. Thoughts? |
||
// Why? Lets say if we have to do same for someother source extension, would we just add another if check? | ||
var uwpSources = sources.Where(source => source.EndsWith(".appxrecipe", StringComparison.OrdinalIgnoreCase)); | ||
|
||
if (uwpSources.Any()) | ||
{ | ||
List<string> actualSources = new List<string>(); | ||
foreach (var uwpSource in uwpSources) | ||
{ | ||
actualSources.Add(Path.Combine(Path.GetDirectoryName(uwpSource), this.GetUwpSources(uwpSource))); | ||
} | ||
|
||
return actualSources; | ||
} | ||
|
||
return sources; | ||
} | ||
|
||
|
@@ -380,5 +396,23 @@ private bool LaunchHost(TestProcessStartInfo testHostStartInfo, CancellationToke | |
this.OnHostLaunched(new HostProviderEventArgs("Test Runtime launched", 0, this.testHostProcess.Id)); | ||
return this.testHostProcess != null; | ||
} | ||
|
||
private string GetUwpSources(string uwpSource) | ||
{ | ||
var doc = XDocument.Load(uwpSource); | ||
var ns = doc.Root.Name.Namespace; | ||
|
||
string appxManifestPath = doc.Element(ns + "Project"). | ||
Element(ns + "ItemGroup"). | ||
Element(ns + "AppXManifest"). | ||
Attribute("Include").Value; | ||
|
||
if (!Path.IsPathRooted(appxManifestPath)) | ||
{ | ||
appxManifestPath = Path.Combine(Path.GetDirectoryName(uwpSource), appxManifestPath); | ||
} | ||
|
||
return AppxManifestFile.GetApplicationExecutableName(appxManifestPath); | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Package xmlns="http://schemas.microsoft.com/appx/manifest/foundation/windows10" xmlns:mp="http://schemas.microsoft.com/appx/2014/phone/manifest" xmlns:uap="http://schemas.microsoft.com/appx/manifest/uap/windows10" IgnorableNamespaces="uap mp build" xmlns:build="http://schemas.microsoft.com/developer/appx/2015/build"> | ||
<!-- | ||
THIS PACKAGE MANIFEST FILE IS GENERATED BY THE BUILD PROCESS. | ||
|
||
Changes to this file will be lost when it is regenerated. To correct errors in this file, edit the source .appxmanifest file. | ||
|
||
For more information on package manifest files, see http://go.microsoft.com/fwlink/?LinkID=241727 | ||
--> | ||
<Identity Name="e7a3d303-9783-498c-9285-7474e1e66396" Publisher="CN=maban" Version="1.0.0.0" ProcessorArchitecture="x86" /> | ||
<mp:PhoneIdentity PhoneProductId="e7a3d303-9783-498c-9285-7474e1e66396" PhonePublisherId="00000000-0000-0000-0000-000000000000" /> | ||
<Properties> | ||
<DisplayName>UnitTestApp8</DisplayName> | ||
<PublisherDisplayName>maban</PublisherDisplayName> | ||
<Logo>Assets\StoreLogo.png</Logo> | ||
</Properties> | ||
<Dependencies> | ||
<TargetDeviceFamily Name="Windows.Universal" MinVersion="10.0.10586.0" MaxVersionTested="10.0.16299.0" /> | ||
<PackageDependency Name="Microsoft.VCLibs.140.00" MinVersion="14.0.25426.0" Publisher="CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US" /> | ||
</Dependencies> | ||
<Resources> | ||
<Resource Language="EN-US" /> | ||
</Resources> | ||
<Applications> | ||
<Application Id="vstest.executionengine.universal.App" Executable="UnitTestApp8.exe" EntryPoint="UnitTestApp8.App"> | ||
<uap:VisualElements DisplayName="UnitTestApp8" Square150x150Logo="Assets\Square150x150Logo.png" Square44x44Logo="Assets\Square44x44Logo.png" Description="UnitTestApp8" BackgroundColor="transparent"> | ||
<uap:DefaultTile Wide310x150Logo="Assets\Wide310x150Logo.png" /> | ||
<uap:SplashScreen Image="Assets\SplashScreen.png" /> | ||
</uap:VisualElements> | ||
</Application> | ||
</Applications> | ||
<Capabilities> | ||
<Capability Name="internetClientServer" /> | ||
</Capabilities> | ||
<Extensions> | ||
<Extension Category="windows.activatableClass.inProcessServer"> | ||
<InProcessServer> | ||
<Path>CLRHost.dll</Path> | ||
<ActivatableClass ActivatableClassId="Microsoft.VisualStudio.TestPlatform.TestExecutor.WinRTCore.UnitTestClient" ThreadingModel="both" /> | ||
</InProcessServer> | ||
</Extension> | ||
<Extension Category="windows.activatableClass.inProcessServer"> | ||
<InProcessServer> | ||
<Path>CppUnitTestFramework_Executor_WindowsPhone.dll</Path> | ||
<ActivatableClass ActivatableClassId="CppUnitTestFramework_Executor_WindowsPhone.CppTestCase" ThreadingModel="both" /> | ||
<ActivatableClass ActivatableClassId="CppUnitTestFramework_Executor_WindowsPhone.TestResult" ThreadingModel="both" /> | ||
<ActivatableClass ActivatableClassId="CppUnitTestFramework_Executor_WindowsPhone.CTestRunner" ThreadingModel="both" /> | ||
</InProcessServer> | ||
</Extension> | ||
<Extension Category="windows.activatableClass.inProcessServer"> | ||
<InProcessServer> | ||
<Path>vstest_executionengine_platformbridge.dll</Path> | ||
<ActivatableClass ActivatableClassId="vstest_executionengine_platformbridge.MessageTransmitter" ThreadingModel="both" /> | ||
<ActivatableClass ActivatableClassId="vstest_executionengine_platformbridge.ServiceMain" ThreadingModel="both" /> | ||
<ActivatableClass ActivatableClassId="vstest_executionengine_platformbridge.NativeMethods" ThreadingModel="both" /> | ||
</InProcessServer> | ||
</Extension> | ||
</Extensions> | ||
<build:Metadata> | ||
<build:Item Name="cl.exe" Version="19.13.26009.0 built by: VCTOOLSREL" /> | ||
<build:Item Name="VisualStudio" Version="15.0" /> | ||
<build:Item Name="VisualStudioEdition" Value="Microsoft Visual Studio Enterprise 2017" /> | ||
<build:Item Name="OperatingSystem" Version="10.0.16299.15 (WinBuild.160101.0800)" /> | ||
<build:Item Name="Microsoft.Build.AppxPackage.dll" Version="15.0.27215.3002" /> | ||
<build:Item Name="ProjectGUID" Value="{f0aa89fc-5ffc-4a0b-819b-0bae6b341260}" /> | ||
<build:Item Name="ilc.exe" Version="1.4.24211.00 built by: PROJECTNGDR2" /> | ||
<build:Item Name="OptimizingToolset" Value="ilc.exe" /> | ||
<build:Item Name="UseDotNetNativeSharedAssemblyFrameworkPackage" Value="True" /> | ||
<build:Item Name="UniversalGenericsOptOut" Value="false" /> | ||
<build:Item Name="Microsoft.Windows.UI.Xaml.Build.Tasks.dll" Version="15.0.27215.3002" /> | ||
<build:Item Name="CppUnitTestFramework.Universal" Version="15.0" /> | ||
<build:Item Name="TestPlatform.Universal" Version="15.0" /> | ||
<build:Item Name="MakePri.exe" Version="10.0.16299.15 (WinBuild.160101.0800)" /> | ||
</build:Metadata> | ||
</Package> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have the code there itself. remove this.