Skip to content

Commit

Permalink
Set anycpu arch for non dotnet test sources (#1233)
Browse files Browse the repository at this point in the history
* Set anycpu arch for non dotnet test sources
  • Loading branch information
smadala authored and codito committed Oct 27, 2017
1 parent e5588e1 commit 0e18b2f
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
17 changes: 13 additions & 4 deletions src/vstest.console/CommandLine/InferHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ public Architecture AutoDetectArchitecture(List<string> sources, IDictionary<str
}
else
{
//TODO what to do for js, appx and others? Using default for now.
arch = Constants.DefaultPlatform;
// Set AnyCPU for non dotnet test sources (js, py and other). Otherwise warning will
// show up if there is mismatch with user provided platform.
arch = Architecture.AnyCPU;
}
sourcePlatforms[source]=(Architecture)arch;

Expand Down Expand Up @@ -78,10 +79,18 @@ public Architecture AutoDetectArchitecture(List<string> sources, IDictionary<str
{
EqtTrace.Error("Failed to determine platform: {0}, using default: {1}", ex, architecture);
}

if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("Determined platform for all sources: {0}", architecture);
}

return architecture;
}

/// <inheritdoc />
/// <summary>
/// Determines Framework from sources.
/// </summary>
public Framework AutoDetectFramework(List<string> sources, IDictionary<string, Framework> sourceFrameworkVersions)
{
Framework framework = Framework.DefaultFramework;
Expand All @@ -107,7 +116,7 @@ public Framework AutoDetectFramework(List<string> sources, IDictionary<string, F

if (EqtTrace.IsInfoEnabled)
{
EqtTrace.Info("Determined framework: {0}", framework);
EqtTrace.Info("Determined framework for all sources: {0}", framework);
}

return framework;
Expand Down
7 changes: 7 additions & 0 deletions test/vstest.console.UnitTests/CommandLine/InferHelperTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,13 @@ public void AutoDetectArchitectureShouldReturnCorrectDefaultArchForNotDotNetAsse
this.mockAssemblyHelper.Verify(ah => ah.GetArchitecture(It.IsAny<string>()), Times.Never);
}

[TestMethod]
public void AutoDetectArchitectureShouldSetAnyCpuArchForNotDotNetAssembly()
{
inferHelper.AutoDetectArchitecture(new List<string>() { "NotDotNetAssebly.appx" }, sourceArchitectures);
Assert.AreEqual(Architecture.AnyCPU, sourceArchitectures["NotDotNetAssebly.appx"]);
}

[TestMethod]
public void AutoDetectArchitectureShouldReturnDefaultArchForAllAnyCpuAssemblies()
{
Expand Down

0 comments on commit 0e18b2f

Please sign in to comment.