Merge branch 'PackagedCommands' of https://github.com/eerhardt/cli into eerhardt-PackagedCommands

This commit is contained in:
Piotr Puszkiewicz 2016-02-16 21:02:56 -08:00
commit d9b54cecac
12 changed files with 139 additions and 1 deletions

View file

@ -54,6 +54,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-projectmodel-server.
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.DotNet.Files", "src\Microsoft.DotNet.Files\Microsoft.DotNet.Files.xproj", "{D521DD9F-0614-4929-93B4-D8FA5682C174}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet.Tests", "test\dotnet.Tests\dotnet.Tests.xproj", "{CB710268-4A82-48E4-9531-FAF1C8F78F4B}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scripts", "scripts", "{88278B81-7649-45DC-8A6A-D3A645C5AFC3}"
EndProject
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "dotnet-cli-build", "scripts\dotnet-cli-build\dotnet-cli-build.xproj", "{D7B9695D-23EB-4EA8-B8AB-707A0092E1D5}"
@ -390,6 +392,22 @@ Global
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Debug|x64.ActiveCfg = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Debug|x64.Build.0 = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.MinSizeRel|Any CPU.ActiveCfg = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.MinSizeRel|Any CPU.Build.0 = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.MinSizeRel|x64.ActiveCfg = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.MinSizeRel|x64.Build.0 = Debug|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Release|Any CPU.Build.0 = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Release|x64.ActiveCfg = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.Release|x64.Build.0 = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.RelWithDebInfo|Any CPU.ActiveCfg = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.RelWithDebInfo|Any CPU.Build.0 = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.RelWithDebInfo|x64.ActiveCfg = Release|Any CPU
{CB710268-4A82-48E4-9531-FAF1C8F78F4B}.RelWithDebInfo|x64.Build.0 = Release|Any CPU
{920B71D8-62DA-4F5E-8A26-926C113F1D97}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{920B71D8-62DA-4F5E-8A26-926C113F1D97}.Debug|Any CPU.Build.0 = Debug|Any CPU
{920B71D8-62DA-4F5E-8A26-926C113F1D97}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -525,6 +543,7 @@ Global
{386D412C-003C-47B1-8258-0E35865CB7C4} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{11C77123-E4DA-499F-8900-80C88C2C69F2} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{D521DD9F-0614-4929-93B4-D8FA5682C174} = {ED2FE3E2-F7E7-4389-8231-B65123F2076F}
{CB710268-4A82-48E4-9531-FAF1C8F78F4B} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}
{D7B9695D-23EB-4EA8-B8AB-707A0092E1D5} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{49BEB486-AB5A-4416-91EA-8CD34ABB0C9D} = {88278B81-7649-45DC-8A6A-D3A645C5AFC3}
{920B71D8-62DA-4F5E-8A26-926C113F1D97} = {17735A9D-BFD9-4585-A7CB-3208CA6EA8A7}

View file

@ -22,6 +22,7 @@ namespace Microsoft.DotNet.Cli.Build
public static readonly string[] TestProjects = new[]
{
"EndToEnd",
"dotnet.Tests",
"dotnet-publish.Tests",
"dotnet-compile.Tests",
"dotnet-compile.UnitTests",

View file

@ -6,7 +6,6 @@ using System;
using System.Diagnostics;
using System.IO;
namespace Microsoft.DotNet.Tools.Test.Utilities
{
public class TestCommand

View file

@ -0,0 +1,71 @@
// 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.Cli.Utils;
using Microsoft.DotNet.Tools.Test.Utilities;
using Xunit;
namespace Microsoft.DotNet.Tests
{
public class PackagedCommandTests : TestBase
{
private readonly string _testProjectsRoot;
public PackagedCommandTests()
{
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
}
[Theory]
[InlineData("AppWithDirectAndToolDependency")]
[InlineData("AppWithDirectDependency")]
[InlineData("AppWithToolDependency")]
public void TestPackagedCommandDependency(string appName)
{
string appDirectory = Path.Combine(_testProjectsRoot, appName);
new BuildCommand(Path.Combine(appDirectory, "project.json"))
.Execute()
.Should()
.Pass();
var currentDirectory = Directory.GetCurrentDirectory();
Directory.SetCurrentDirectory(appDirectory);
try
{
CommandResult result = new HelloCommand().ExecuteWithCapturedOutput();
result.Should().HaveStdOut("Hello" + Environment.NewLine);
result.Should().NotHaveStdErr();
result.Should().Pass();
}
finally
{
Directory.SetCurrentDirectory(currentDirectory);
}
}
class HelloCommand : TestCommand
{
public HelloCommand()
: base("dotnet")
{
}
public override CommandResult Execute(string args = "")
{
args = $"hello {args}";
return base.Execute(args);
}
public override CommandResult ExecuteWithCapturedOutput(string args = "")
{
args = $"hello {args}";
return base.ExecuteWithCapturedOutput(args);
}
}
}
}

View file

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0.23107" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0.23107</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.Props" Condition="'$(VSToolsPath)' != ''" />
<PropertyGroup Label="Globals">
<ProjectGuid>cb710268-4a82-48e4-9531-faf1c8f78f4b</ProjectGuid>
<RootNamespace>Microsoft.DotNet.Tests</RootNamespace>
<BaseIntermediateOutputPath Condition="'$(BaseIntermediateOutputPath)'=='' ">..\..\artifacts\obj\$(MSBuildProjectName)</BaseIntermediateOutputPath>
<OutputPath Condition="'$(OutputPath)'=='' ">..\..\artifacts\bin\$(MSBuildProjectName)\</OutputPath>
</PropertyGroup>
<PropertyGroup>
<SchemaVersion>2.0</SchemaVersion>
</PropertyGroup>
<Import Project="$(VSToolsPath)\DNX\Microsoft.DNX.targets" Condition="'$(VSToolsPath)' != ''" />
</Project>

View file

@ -0,0 +1,30 @@
{
"version": "1.0.0-*",
"dependencies": {
"NETStandard.Library": "1.0.0-rc2-23810",
"Microsoft.DotNet.Tools.Tests.Utilities": { "target": "project" },
"Microsoft.DotNet.Cli.Utils": {
"target": "project",
"type": "build"
},
"xunit": "2.1.0",
"dotnet-test-xunit": "1.0.0-dev-48273-16"
},
"frameworks": {
"dnxcore50": {
"imports": "portable-net45+win8"
}
},
"content": [
"../../TestAssets/TestProjects/AppWithDirectAndToolDependency/**/*",
"../../TestAssets/TestProjects/AppWithDirectDependency/**/*",
"../../TestAssets/TestProjects/AppWithToolDependency/**/*"
],
"testRunner": "xunit"
}