Merge pull request #2226 from dotnet/pakrym/no-trim-refs
Do not trim refs
This commit is contained in:
commit
87ee62c282
31 changed files with 455 additions and 108 deletions
|
@ -42,6 +42,7 @@ pushd "$Stage2Dir"
|
|||
|
||||
try {
|
||||
.\dotnet restore `
|
||||
--infer-runtimes `
|
||||
$testDir `
|
||||
-f https://www.myget.org/F/dotnet-buildtools/api/v3/index.json | Out-Host
|
||||
|
||||
|
|
|
@ -103,7 +103,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
string.Equals("on", val, StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
|
||||
protected void TestExecutable(string outputDir,
|
||||
protected CommandResult TestExecutable(string outputDir,
|
||||
string executableName,
|
||||
string expectedOutput)
|
||||
{
|
||||
|
@ -123,9 +123,13 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
var result = executableCommand.ExecuteWithCapturedOutput(string.Join(" ", args));
|
||||
|
||||
result.Should().HaveStdOut(expectedOutput);
|
||||
if (!string.IsNullOrEmpty(expectedOutput))
|
||||
{
|
||||
result.Should().HaveStdOut(expectedOutput);
|
||||
}
|
||||
result.Should().NotHaveStdErr();
|
||||
result.Should().Pass();
|
||||
return result;
|
||||
}
|
||||
|
||||
protected void TestOutputExecutable(
|
||||
|
|
|
@ -0,0 +1,133 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using FluentAssertions;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.Extensions.DependencyModel
|
||||
{
|
||||
public class FunctionalTests : TestBase
|
||||
{
|
||||
private readonly string _testProjectsRoot;
|
||||
|
||||
public FunctionalTests()
|
||||
{
|
||||
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("TestApp", true)]
|
||||
[InlineData("TestAppPortable", true)]
|
||||
[InlineData("TestAppDeps", false)]
|
||||
[InlineData("TestAppPortableDeps", false)]
|
||||
public void RunTest(string appname, bool checkCompilation)
|
||||
{
|
||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", appname);
|
||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||
|
||||
var runCommand = new RunCommand(testProject);
|
||||
var result = runCommand.ExecuteWithCapturedOutput();
|
||||
result.Should().Pass();
|
||||
ValidateRuntimeLibrarites(result, appname);
|
||||
if (checkCompilation)
|
||||
{
|
||||
ValidateCompilationLibraries(result, appname);
|
||||
}
|
||||
}
|
||||
|
||||
[Theory]
|
||||
[InlineData("TestApp", false, true)]
|
||||
[InlineData("TestAppPortable", true, true)]
|
||||
[InlineData("TestAppDeps", false, false)]
|
||||
[InlineData("TestAppPortableDeps", true, false)]
|
||||
public void PublishTest(string appname, bool portable, bool checkCompilation)
|
||||
{
|
||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", appname);
|
||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||
|
||||
var publishCommand = new PublishCommand(testProject);
|
||||
publishCommand.Execute().Should().Pass();
|
||||
|
||||
var exeName = portable ? publishCommand.GetPortableOutputName() : publishCommand.GetOutputExecutable();
|
||||
|
||||
var result = TestExecutable(publishCommand.GetOutputDirectory(portable).FullName, exeName, string.Empty);
|
||||
ValidateRuntimeLibrarites(result, appname);
|
||||
if (checkCompilation)
|
||||
{
|
||||
ValidateCompilationLibraries(result, appname);
|
||||
}
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void RunTestFullClr()
|
||||
{
|
||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppFullClr");
|
||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||
|
||||
var runCommand = new RunCommand(testProject);
|
||||
var result = runCommand.ExecuteWithCapturedOutput();
|
||||
result.Should().Pass();
|
||||
ValidateRuntimeLibraritesFullClr(result, "TestAppFullClr");
|
||||
ValidateCompilationLibrariesFullClr(result, "TestAppFullClr");
|
||||
}
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void PublishTestFullClr()
|
||||
{
|
||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppFullClr");
|
||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||
|
||||
var publishCommand = new PublishCommand(testProject);
|
||||
publishCommand.Execute().Should().Pass();
|
||||
|
||||
var result = TestExecutable(publishCommand.GetOutputDirectory().FullName, publishCommand.GetOutputExecutable(), string.Empty);
|
||||
ValidateRuntimeLibraritesFullClr(result, "TestAppFullClr");
|
||||
ValidateCompilationLibrariesFullClr(result, "TestAppFullClr");
|
||||
}
|
||||
|
||||
private void ValidateRuntimeLibraritesFullClr(CommandResult result, string appname)
|
||||
{
|
||||
// entry assembly
|
||||
result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}");
|
||||
// project dependency
|
||||
result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator");
|
||||
}
|
||||
|
||||
private void ValidateCompilationLibrariesFullClr(CommandResult result, string appname)
|
||||
{
|
||||
// entry assembly
|
||||
result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.exe");
|
||||
// project dependency
|
||||
result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll");
|
||||
// system assembly
|
||||
result.Should().HaveStdOutContaining("Compilation mscorlib:mscorlib.dll");
|
||||
}
|
||||
|
||||
|
||||
private void ValidateRuntimeLibrarites(CommandResult result, string appname)
|
||||
{
|
||||
// entry assembly
|
||||
result.Should().HaveStdOutContaining($"Runtime {appname}:{appname}");
|
||||
// project dependency
|
||||
result.Should().HaveStdOutContaining("Runtime DependencyContextValidator:DependencyContextValidator");
|
||||
// system assembly
|
||||
result.Should().HaveStdOutContaining("Runtime System.Linq:System.Linq");
|
||||
}
|
||||
|
||||
private void ValidateCompilationLibraries(CommandResult result, string appname)
|
||||
{
|
||||
// entry assembly
|
||||
result.Should().HaveStdOutContaining($"Compilation {appname}:{appname}.dll");
|
||||
// project dependency
|
||||
result.Should().HaveStdOutContaining("Compilation DependencyContextValidator:DependencyContextValidator.dll");
|
||||
// system assembly
|
||||
result.Should().HaveStdOutContaining("Compilation System.Linq:System.Linq.dll");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -9,6 +9,9 @@
|
|||
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project"
|
||||
},
|
||||
"FluentAssertions": "4.0.0",
|
||||
"moq.netcore": "4.4.0-beta8",
|
||||
"xunit": "2.1.0",
|
||||
|
|
|
@ -147,26 +147,6 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
|
|||
result.StdOut.Should().Contain("MyNamespace.Util");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EmbeddedDependencyContextIsValidOnBuild()
|
||||
{
|
||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestApp");
|
||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||
|
||||
var runCommand = new RunCommand(testProject);
|
||||
runCommand.Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void DepsDependencyContextIsValidOnBuild()
|
||||
{
|
||||
var testProjectPath = Path.Combine(RepoRoot, "TestAssets", "TestProjects", "DependencyContextValidator", "TestAppDeps");
|
||||
var testProject = Path.Combine(testProjectPath, "project.json");
|
||||
|
||||
var runCommand = new RunCommand(testProject);
|
||||
runCommand.Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void CanSetOutputAssemblyNameForLibraries()
|
||||
{
|
||||
|
|
|
@ -81,6 +81,24 @@ namespace Microsoft.DotNet.Tools.Publish.Tests
|
|||
publishDir.Should().NotHaveFile("PortableAppWithNative.runtimeconfig.dev.json");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RefsPublishTest()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("PortableTests")
|
||||
.WithLockFiles();
|
||||
|
||||
var publishCommand = new PublishCommand(Path.Combine(instance.TestRoot, "PortableAppCompilationContext"));
|
||||
publishCommand.Execute().Should().Pass();
|
||||
|
||||
publishCommand.GetOutputDirectory(true).Should().HaveFile("PortableAppCompilationContext.dll");
|
||||
|
||||
var refsDirectory = new DirectoryInfo(Path.Combine(publishCommand.GetOutputDirectory(true).FullName, "refs"));
|
||||
// Should have compilation time assemblies
|
||||
refsDirectory.Should().HaveFile("System.IO.dll");
|
||||
// Libraries in which lib==ref should be deduped
|
||||
refsDirectory.Should().NotHaveFile("PortableAppCompilationContext.dll");
|
||||
}
|
||||
|
||||
private DirectoryInfo Publish(TestInstance testInstance)
|
||||
{
|
||||
var publishCommand = new PublishCommand(Path.Combine(testInstance.TestRoot, "PortableAppWithNative"));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue