Refactor 'publish' and 'build' tests to use the TestFramework
This commit is contained in:
parent
b239c548a4
commit
9695fbfeda
12 changed files with 267 additions and 180 deletions
|
@ -8,6 +8,7 @@ using System.Linq;
|
|||
using Microsoft.DotNet.Cli.Utils;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Builder.Tests
|
||||
{
|
||||
|
@ -15,26 +16,35 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
{
|
||||
private string[] _projects = new[] { "L0", "L11", "L12", "L21", "L22" };
|
||||
|
||||
public ProjectToProjectDependenciesIncrementalTest() : base(
|
||||
Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", "TestProjectToProjectDependencies"),
|
||||
"L0",
|
||||
"L0 L11 L12 L22 L21 L12 L22 " + Environment.NewLine)
|
||||
private string MainProjectExe
|
||||
{
|
||||
get
|
||||
{
|
||||
return MainProject + (RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? ".exe" : "");
|
||||
}
|
||||
}
|
||||
|
||||
public ProjectToProjectDependenciesIncrementalTest()
|
||||
{
|
||||
MainProject = "L0";
|
||||
ExpectedOutput = "L0 L11 L12 L22 L21 L12 L22 " + Environment.NewLine;
|
||||
|
||||
}
|
||||
|
||||
[Theory,
|
||||
InlineData("L0", new[] { "L0" }),
|
||||
InlineData("L11", new[] { "L0", "L11" }),
|
||||
InlineData("L12", new[] { "L0", "L11", "L12" }),
|
||||
InlineData("L22", new[] { "L0", "L11", "L12", "L22" }),
|
||||
InlineData("L21", new[] { "L0", "L11", "L21" })
|
||||
InlineData("1", "L0", new[] { "L0" }),
|
||||
InlineData("2", "L11", new[] { "L0", "L11" }),
|
||||
InlineData("3", "L12", new[] { "L0", "L11", "L12" }),
|
||||
InlineData("4", "L22", new[] { "L0", "L11", "L12", "L22" }),
|
||||
InlineData("5", "L21", new[] { "L0", "L11", "L21" })
|
||||
]
|
||||
public void TestIncrementalBuildOfDependencyGraph(string projectToTouch, string[] expectedRebuiltProjects)
|
||||
public void TestIncrementalBuildOfDependencyGraph(string testIdentifer, string projectToTouch, string[] expectedRebuiltProjects)
|
||||
{
|
||||
var testInstance = TestAssetsManager.CreateTestInstance("TestProjectToProjectDependencies", identifier: testIdentifer)
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
|
||||
// first clean build; all projects required compilation
|
||||
var result1 = BuildProject();
|
||||
AssertRebuilt(result1, _projects);
|
||||
TestProjectRoot = testInstance.TestRoot;
|
||||
|
||||
// second build; nothing changed; no project required compilation
|
||||
var result2 = BuildProject();
|
||||
|
@ -71,7 +81,25 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
|
|||
|
||||
protected override string GetProjectDirectory(string projectName)
|
||||
{
|
||||
return Path.Combine(TempProjectRoot.Path, "src", projectName);
|
||||
return Path.Combine(TestProjectRoot, "src", projectName);
|
||||
}
|
||||
|
||||
protected override string GetOutputDir()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
protected override string GetOutputExePath()
|
||||
{
|
||||
var outputExe = Directory.GetFiles(TestProjectRoot, MainProjectExe, SearchOption.AllDirectories)
|
||||
.FirstOrDefault();
|
||||
|
||||
if (string.IsNullOrEmpty(outputExe))
|
||||
{
|
||||
throw new FileNotFoundException($"Unable to find {outputExe} in {TestProjectRoot} or its subdirectories");
|
||||
}
|
||||
|
||||
return Path.GetDirectoryName(outputExe);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue