Rebase with the latest sources and fix the tests.

This commit is contained in:
Sridhar Periyasamy 2016-02-16 11:26:40 -08:00
parent ab455e6bb9
commit 9ec8556d24
7 changed files with 37 additions and 13 deletions

View file

@ -56,6 +56,13 @@ namespace Microsoft.DotNet.Cli.Build
[Target]
public static BuildTargetResult BuildTestPrerequisites(BuildTargetContext c)
{
BuildTestAssetPackages(c);
BuildTestAssetProjects(c);
return c.Success();
}
public static void BuildTestAssetPackages(BuildTargetContext c)
{
var dotnet = DotNetCli.Stage2;
@ -71,8 +78,24 @@ namespace Microsoft.DotNet.Cli.Build
.Execute()
.EnsureSuccessful();
}
}
return c.Success();
public static void BuildTestAssetProjects(BuildTargetContext c)
{
var dotnet = DotNetCli.Stage2;
string testProjectsRoot = Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects");
List<string> exclusionList = new List<string> { Path.Combine(testProjectsRoot, "CompileFail", "project.json") };
var projects = Directory.GetFiles(testProjectsRoot, "project.json", SearchOption.AllDirectories)
.Where(p => !exclusionList.Any(e => e.Contains(p)));
foreach (var project in projects)
{
c.Info($"Building: {project}");
dotnet.Build("--framework", "dnxcore50")
.WorkingDirectory(Path.GetDirectoryName(project))
.Execute()
.EnsureSuccessful();
}
}
[Target]

View file

@ -18,7 +18,7 @@ namespace Microsoft.DotNet.TestFramework
get; private set;
}
public TestAssetsManager(string assetsRoot, bool skipRestore = true, bool skipBuild = true)
public TestAssetsManager(string assetsRoot, bool doRestore = false, bool doBuild = false)
{
if (!Directory.Exists(assetsRoot))
{
@ -27,12 +27,12 @@ namespace Microsoft.DotNet.TestFramework
AssetsRoot = assetsRoot;
if (!skipRestore)
if (doRestore)
{
Restore();
}
if (!skipBuild)
if (doBuild)
{
Build();
}

View file

@ -62,11 +62,13 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
[Fact]
public void TestNoDependencyFlag()
{
var dependencies = new[] { "L11", "L12", "L21", "L22" };
var testInstance = TestAssetsManager.CreateTestInstance("TestProjectToProjectDependencies")
.WithLockFiles()
.WithBuildArtifacts();
TestProjectRoot = testInstance.TestRoot;
// first clean build; all projects required compilation
var result1 = BuildProject();
AssertRebuilt(result1, _projects);
var dependencies = new[] { "L11", "L12", "L21", "L22" };
// modify the source code of a leaf dependency
TouchSourcesOfProject("L22");

View file

@ -61,7 +61,7 @@ namespace Microsoft.DotNet.Tools.Builder.Tests
protected CommandResult BuildProject(bool noDependencies = false, bool noIncremental = false, bool expectBuildFailure = false)
{
var mainProjectFile = GetProjectFile(MainProject);
return BuildProject(mainProjectFile, noIncremental, expectBuildFailure);
return BuildProject(mainProjectFile, noDependencies, noIncremental, expectBuildFailure);
}
protected CommandResult BuildProject(string projectFile, bool noDependencies = false, bool noIncremental = false, bool expectBuildFailure = false)

View file

@ -24,7 +24,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
public GivenACompilationDriverController()
{
_projectJson =
Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", "TestApp", "project.json");
Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects", "TestAppWithLibrary", "TestApp", "project.json");
_managedCompilerMock = new Mock<ICompiler>();
_managedCompilerMock.Setup(c => c
.Compile(It.IsAny<ProjectContext>(), It.IsAny<CompilerCommandApp>()))

View file

@ -156,6 +156,7 @@ namespace Microsoft.DotNet.Tools.Compiler.Tests
AppContext.BaseDirectory,
"TestAssets",
"TestProjects",
"TestAppWithLibrary",
"TestApp");
public static string OutputPath = Path.Combine(

View file

@ -24,9 +24,7 @@
},
"content": [
"../../TestAssets/TestProjects/TestLibrary/*",
"../../TestAssets/TestProjects/TestApp/*",
"../../TestAssets/TestProjects/global.json"
"../../TestAssets/TestProjects/TestAppWithLibrary/**/*"
],
"testRunner": "xunit"