[WIP] Removes *3 verbs, making msbuild the driver (#4456)
Removes *3 verbs, making msbuild the driver
This commit is contained in:
parent
55c59d621e
commit
6fcbefa4f7
746 changed files with 4256 additions and 32434 deletions
118
test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs
Normal file
118
test/dotnet-run.Tests/GivenDotnetRunRunsCsProj.cs
Normal file
|
@ -0,0 +1,118 @@
|
|||
// 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.IO;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Cli.Run.Tests
|
||||
{
|
||||
public class GivenDotnetRunBuildsCsproj : TestBase
|
||||
{
|
||||
[Fact]
|
||||
public void ItCanRunAMSBuildProject()
|
||||
{
|
||||
var testAppName = "MSBuildTestApp";
|
||||
var testInstance = TestAssetsManager
|
||||
.CreateTestInstance(testAppName);
|
||||
|
||||
var testProjectDirectory = testInstance.TestRoot;
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute("/p:SkipInvalidConfigurations=true")
|
||||
.Should().Pass();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItBuildsTheProjectBeforeRunning()
|
||||
{
|
||||
var testAppName = "MSBuildTestApp";
|
||||
var testInstance = TestAssetsManager
|
||||
.CreateTestInstance(testAppName);
|
||||
|
||||
var testProjectDirectory = testInstance.TestRoot;
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute("/p:SkipInvalidConfigurations=true")
|
||||
.Should().Pass();
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItCanRunAMSBuildProjectWhenSpecifyingAFramework()
|
||||
{
|
||||
var testAppName = "MSBuildTestApp";
|
||||
var testInstance = TestAssetsManager
|
||||
.CreateTestInstance(testAppName);
|
||||
|
||||
var testProjectDirectory = testInstance.TestRoot;
|
||||
|
||||
new RestoreCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.Execute("/p:SkipInvalidConfigurations=true")
|
||||
.Should().Pass();
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(testProjectDirectory)
|
||||
.ExecuteWithCapturedOutput("--framework netcoreapp1.0")
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_runs_portable_apps_from_a_different_path_after_building()
|
||||
{
|
||||
var testInstance = TestAssets.Get("MSBuildTestApp")
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles();
|
||||
|
||||
new BuildCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.Execute()
|
||||
.Should().Pass();
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(testInstance.Root)
|
||||
.ExecuteWithCapturedOutput($"--no-build")
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void It_runs_portable_apps_from_a_different_path_without_building()
|
||||
{
|
||||
var testAppName = "MSBuildTestApp";
|
||||
var testInstance = TestAssets.Get(testAppName)
|
||||
.CreateInstance()
|
||||
.WithSourceFiles()
|
||||
.WithRestoreFiles();
|
||||
|
||||
var projectFile = testInstance.Root.GetFile(testAppName + ".csproj");
|
||||
|
||||
new RunCommand()
|
||||
.WithWorkingDirectory(testInstance.Root.Parent)
|
||||
.ExecuteWithCapturedOutput($"--project {projectFile.FullName}")
|
||||
.Should().Pass()
|
||||
.And.HaveStdOutContaining("Hello World!");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,192 +0,0 @@
|
|||
// 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.TestFramework;
|
||||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Xunit;
|
||||
|
||||
namespace Microsoft.DotNet.Tools.Run.Tests
|
||||
{
|
||||
public class RunTests : TestBase
|
||||
{
|
||||
private const string PortableAppsTestBase = "PortableTests";
|
||||
private const string RunTestsBase = "RunTestsApps";
|
||||
|
||||
[WindowsOnlyFact]
|
||||
public void RunsSingleTarget()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppFullClr"))
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot).ExecuteWithCapturedOutput().Should().Pass().And.HaveStdOutContaining("NET451, ARGS: 0");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RunsDefaultWhenPresent()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppMultiTarget"))
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void FailsWithMultipleTargetAndNoDefault()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(RunTestsBase, "TestAppMultiTargetNoCoreClr"))
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot).ExecuteWithCapturedOutput().Should().Fail();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItRunsPortableApps()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(PortableAppsTestBase, "PortableApp"))
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact(Skip = "https://github.com/dotnet/cli/issues/1940")]
|
||||
public void ItRunsPortableAppsWithNative()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(PortableAppsTestBase, "PortableAppWithNative"))
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItRunsStandaloneApps()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance(Path.Combine(PortableAppsTestBase, "StandaloneApp"))
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot).Execute().Should().Pass();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItRunsWithLocalProjectJsonArg()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppSimple")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand("project.json")
|
||||
.WithWorkingDirectory(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("Hello World!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItRunsAppsThatOutputUnicodeCharacters()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithUnicodéPath")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining("Hélló Wórld!");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItPassesArgumentsToTheApp()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput("one --two -three")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
JoinWithNewlines(
|
||||
"Hello World!",
|
||||
"I was passed 3 args:",
|
||||
"arg: [one]",
|
||||
"arg: [--two]",
|
||||
"arg: [-three]"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItPassesAllArgsAfterUnexpectedArg()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput("Hello -f")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
JoinWithNewlines(
|
||||
"Hello World!",
|
||||
"I was passed 2 args:",
|
||||
"arg: [Hello]",
|
||||
"arg: [-f]"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItHandlesArgSeparatorCorrectly()
|
||||
{
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppWithArgs")
|
||||
.WithLockFiles()
|
||||
.WithBuildArtifacts();
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput("-- one two")
|
||||
.Should()
|
||||
.Pass()
|
||||
.And
|
||||
.HaveStdOutContaining(
|
||||
JoinWithNewlines(
|
||||
"Hello World!",
|
||||
"I was passed 2 args:",
|
||||
"arg: [one]",
|
||||
"arg: [two]"));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItHandlesUnrestoredProjectFileCorrectly()
|
||||
{
|
||||
// NOTE: we don't say "WithLockFiles", so the project is "unrestored"
|
||||
TestInstance instance = TestAssetsManager.CreateTestInstance("TestAppSimple");
|
||||
|
||||
new RunCommand(instance.TestRoot)
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("NU1009")
|
||||
.And
|
||||
.HaveStdErrContaining("dotnet restore");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ItHandlesUnknownProjectFileCorrectly()
|
||||
{
|
||||
new RunCommand("bad path")
|
||||
.ExecuteWithCapturedOutput()
|
||||
.Should()
|
||||
.Fail()
|
||||
.And
|
||||
.HaveStdErrContaining("DOTNET1017")
|
||||
.And
|
||||
.HaveStdErrContaining("bad path");
|
||||
}
|
||||
|
||||
private static string JoinWithNewlines(params string[] values)
|
||||
{
|
||||
return string.Join(Environment.NewLine, values);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0.24720" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.24720</VisualStudioVersion>
|
||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>35e3c2dc-9b38-4ec5-8dd7-c32458dc485f</ProjectGuid>
|
||||
<RootNamespace>dotnet-run.Tests</RootNamespace>
|
||||
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
|
||||
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<SchemaVersion>2.0</SchemaVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||
</Project>
|
|
@ -9,9 +9,6 @@
|
|||
"Microsoft.DotNet.Tools.Tests.Utilities": {
|
||||
"target": "project"
|
||||
},
|
||||
"Microsoft.DotNet.Cli.Utils": {
|
||||
"target": "project"
|
||||
},
|
||||
"xunit": "2.2.0-beta3-build3330",
|
||||
"dotnet-test-xunit": "1.0.0-rc2-350904-49"
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue