Fix run behaviour when only single target exists

This commit is contained in:
Pavel Krymets 2016-02-19 15:12:04 -08:00
parent f81ba05a7c
commit 6ca22e4a56
15 changed files with 197 additions and 7 deletions

View file

@ -0,0 +1,54 @@
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.IO;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
namespace Microsoft.DotNet.Tools.Compiler.Tests
{
public class CompilerTests : TestBase
{
private static const string RunTestsBase = "RunTestsApps";
[WindowsOnlyFact]
public void RunsSingleTarget()
{
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppDesktopClr"))
.WithLockFiles()
.WithBuildArtifacts();
new RunCommand(testInstance.TestRoot).Execute().Should().Pass();
}
public void RunsDefaultWhenPresent()
{
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppMultiTarget"))
.WithLockFiles()
.WithBuildArtifacts();
new RunCommand(testInstance.TestRoot).Execute().Should().Pass();
}
public void FailsWithMultipleTargetAndNoDefault()
{
TestInstance instance = TestAssetsManager.CreateTestInstance(RunTestsBase, "TestAppMultiTargetNoCoreClr")
.WithLockFiles()
.WithBuildArtifacts();
new RunCommand(testInstance.TestRoot).Execute().Should().Fail();
}
private void CopyProjectToTempDir(string projectDir, TempDirectory tempDir)
{
// copy all the files to temp dir
foreach (var file in Directory.EnumerateFiles(projectDir))
{
tempDir.CopyFile(file);
}
}
private string GetProjectPath(TempDirectory projectDir)
{
return Path.Combine(projectDir.Path, "project.json");
}
}
}