Skip to content

Commit

Permalink
Integration test for publish filter profile
Browse files Browse the repository at this point in the history
  • Loading branch information
ramarag committed Jan 19, 2017
1 parent 3dd8b84 commit 7d6e836
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<PackageReference Include="Newtonsoft.Json">
<Version>9.0.1</Version>
</PackageReference>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Microsoft.NET.TestFramework.Commands;
using Xunit;
using static Microsoft.NET.TestFramework.Commands.MSBuildTest;
using Microsoft.DotNet.InternalAbstractions;
using System.Runtime.InteropServices;

namespace Microsoft.NET.Publish.Tests
Expand Down Expand Up @@ -109,5 +110,116 @@ public void It_publishes_projects_targeting_netcoreapp11_with_p2p_targeting_netc
.Should()
.Pass();
}

[Fact]
public void It_publishes_projects_with_simple_dependencies_with_filter_profile()
{
TestAsset simpleDependenciesAsset = _testAssetsManager
.CopyTestAsset("SimpleDependencies")
.WithSource()
.Restore();

string filterProjDir = _testAssetsManager.GetAndValidateTestProjectDirectory("NewtonsoftFilterProfile");
string filterProjFile = Path.Combine(filterProjDir, "NewtonsoftFilterProfile.csproj");

PublishCommand publishCommand = new PublishCommand(Stage0MSBuild, simpleDependenciesAsset.TestRoot);
publishCommand
.Execute($"/p:FilterProjFile={filterProjFile}")
.Should()
.Pass();

DirectoryInfo publishDirectory = publishCommand.GetOutputDirectory();

publishDirectory.Should().OnlyHaveFiles(new[] {
"SimpleDependencies.dll",
"SimpleDependencies.pdb",
"SimpleDependencies.deps.json",
"SimpleDependencies.runtimeconfig.json",
"System.Collections.NonGeneric.dll"
});
//TODO: Enable testing the run once dotnet host has the notion of looking up shared packages
// string appPath = publishCommand.GetPublishedAppPath("SimpleDependencies");

// Command runAppCommand = Command.Create(
// RepoInfo.DotNetHostPath,
// new[] { appPath, "one", "two" });

// string expectedOutput =
//@"{
// ""one"": ""one"",
// ""two"": ""two""
//}";

// runAppCommand
// .CaptureStdOut()
// .Execute()
// .Should()
// .Pass()
// .And
// .HaveStdOutContaining(expectedOutput);
}

[Fact]
public void It_publishes_projects_with_filter_and_rid()
{
var rid = RuntimeEnvironment.GetRuntimeIdentifier();
TestAsset simpleDependenciesAsset = _testAssetsManager
.CopyTestAsset("SimpleDependencies")
.WithSource()
.Restore("", $"/p:RuntimeIdentifier={rid}");

string filterProjDir = _testAssetsManager.GetAndValidateTestProjectDirectory("NewtonsoftFilterProfile");
string filterProjFile = Path.Combine(filterProjDir, "NewtonsoftFilterProfile.csproj");


PublishCommand publishCommand = new PublishCommand(Stage0MSBuild, simpleDependenciesAsset.TestRoot);
publishCommand
.Execute($"/p:RuntimeIdentifier={rid}", $"/p:FilterProjFile={filterProjFile}")
.Should()
.Pass();

DirectoryInfo publishDirectory = publishCommand.GetOutputDirectory(runtimeIdentifier: rid);

string libPrefix = "";
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
libPrefix = "lib";
}
publishDirectory.Should().HaveFiles(new[] {
"SimpleDependencies.dll",
"SimpleDependencies.pdb",
"SimpleDependencies.deps.json",
"SimpleDependencies.runtimeconfig.json",
"System.Collections.NonGeneric.dll",
$"{libPrefix}coreclr{Constants.DynamicLibSuffix}"

});

publishDirectory.Should().NotHaveFiles(new[] {
"Newtonsoft.Json.dll",
"System.Runtime.Serialization.Primitives.dll"
});

//TODO: Enable testing the run once dotnet host has the notion of looking up shared packages
// string appPath = publishCommand.GetPublishedAppPath("SimpleDependencies");

// Command runAppCommand = Command.Create(
// RepoInfo.DotNetHostPath,
// new[] { appPath, "one", "two" });

// string expectedOutput =
//@"{
// ""one"": ""one"",
// ""two"": ""two""
//}";

// runAppCommand
// .CaptureStdOut()
// .Execute()
// .Should()
// .Pass()
// .And
// .HaveStdOutContaining(expectedOutput);
}
}
}
2 changes: 1 addition & 1 deletion test/Microsoft.NET.TestFramework/TestAssetsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public TestAsset CreateTestProject(
return testAsset;
}

private string GetAndValidateTestProjectDirectory(string testProjectName)
public string GetAndValidateTestProjectDirectory(string testProjectName)
{
string testProjectDirectory = Path.Combine(ProjectsRoot, testProjectName);

Expand Down

0 comments on commit 7d6e836

Please sign in to comment.