2016-02-10 19:16:23 +00:00
|
|
|
|
// 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;
|
2016-04-06 22:29:10 +00:00
|
|
|
|
using System.Collections.Generic;
|
2016-02-10 19:16:23 +00:00
|
|
|
|
using System.IO;
|
2016-04-28 23:30:32 +00:00
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
using FluentAssertions;
|
2016-02-10 19:16:23 +00:00
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
2016-04-28 23:30:32 +00:00
|
|
|
|
using Microsoft.DotNet.InternalAbstractions;
|
2016-02-10 19:16:23 +00:00
|
|
|
|
using Xunit;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Tests
|
|
|
|
|
{
|
|
|
|
|
public class PackagedCommandTests : TestBase
|
|
|
|
|
{
|
|
|
|
|
private readonly string _testProjectsRoot;
|
2016-03-28 23:54:06 +00:00
|
|
|
|
private readonly string _desktopTestProjectsRoot;
|
2016-02-10 19:16:23 +00:00
|
|
|
|
|
2016-05-08 21:20:34 +00:00
|
|
|
|
public static IEnumerable<object[]> DependencyToolArguments
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
|
|
|
|
var projectOutputPath = $"AppWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\{rid}\\dotnet-desktop-and-portable.exe";
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
new object[] { ".NETCoreApp,Version=v1.0", "CoreFX", "lib\\netcoreapp1.0\\dotnet-desktop-and-portable.dll", true },
|
|
|
|
|
new object[] { ".NETFramework,Version=v4.5.1", "NetFX", projectOutputPath, true }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static IEnumerable<object[]> LibraryDependencyToolArguments
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
var rid = RuntimeEnvironmentRidExtensions.GetLegacyRestoreRuntimeIdentifier();
|
|
|
|
|
var projectOutputPath = $"LibraryWithDirectDependencyDesktopAndPortable\\bin\\Debug\\net451\\dotnet-desktop-and-portable.exe";
|
|
|
|
|
return new[]
|
|
|
|
|
{
|
|
|
|
|
new object[] { ".NETStandard,Version=v1.5", "CoreFX", "lib\\netstandard1.5\\dotnet-desktop-and-portable.dll", true },
|
|
|
|
|
new object[] { ".NETFramework,Version=v4.5.1", "NetFX", projectOutputPath, true }
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-10 19:16:23 +00:00
|
|
|
|
public PackagedCommandTests()
|
|
|
|
|
{
|
|
|
|
|
_testProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "TestProjects");
|
2016-03-28 23:54:06 +00:00
|
|
|
|
_desktopTestProjectsRoot = Path.Combine(AppContext.BaseDirectory, "TestAssets", "DesktopTestProjects");
|
2016-02-10 19:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Theory]
|
|
|
|
|
[InlineData("AppWithDirectAndToolDependency")]
|
|
|
|
|
[InlineData("AppWithToolDependency")]
|
2016-03-03 23:31:04 +00:00
|
|
|
|
public void TestProjectToolIsAvailableThroughDriver(string appName)
|
2016-02-10 19:16:23 +00:00
|
|
|
|
{
|
2016-03-03 23:31:04 +00:00
|
|
|
|
var appDirectory = Path.Combine(_testProjectsRoot, appName);
|
2016-02-10 19:16:23 +00:00
|
|
|
|
|
|
|
|
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
2016-03-28 10:18:13 +00:00
|
|
|
|
CommandResult result = new PortableCommand { WorkingDirectory = appDirectory }
|
|
|
|
|
.ExecuteWithCapturedOutput();
|
2016-02-10 19:16:23 +00:00
|
|
|
|
|
2016-05-08 21:20:34 +00:00
|
|
|
|
result.Should().HaveStdOutContaining("Hello Portable World!" + Environment.NewLine);
|
2016-03-28 10:18:13 +00:00
|
|
|
|
result.Should().NotHaveStdErr();
|
|
|
|
|
result.Should().Pass();
|
2016-02-10 19:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-04-20 23:05:53 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void CanInvokeToolWhosePackageNameIsDifferentFromDllName()
|
|
|
|
|
{
|
|
|
|
|
var appDirectory = Path.Combine(_testProjectsRoot, "AppWithDependencyOnToolWithOutputName");
|
|
|
|
|
|
|
|
|
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
CommandResult result = new GenericCommand("tool-with-output-name") { WorkingDirectory = appDirectory }
|
|
|
|
|
.ExecuteWithCapturedOutput();
|
|
|
|
|
|
|
|
|
|
result.Should().HaveStdOutContaining("Tool with output name!");
|
|
|
|
|
result.Should().NotHaveStdErr();
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Fact]
|
|
|
|
|
public void CanInvokeToolFromDirectDependenciesIfPackageNameDifferentFromToolName()
|
|
|
|
|
{
|
|
|
|
|
var appDirectory = Path.Combine(_testProjectsRoot, "AppWithDirectDependencyWithOutputName");
|
|
|
|
|
const string framework = ".NETCoreApp,Version=v1.0";
|
|
|
|
|
|
|
|
|
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
|
|
|
|
.ExecuteWithCapturedOutput("tool-with-output-name", framework, string.Empty);
|
|
|
|
|
|
2016-04-28 23:30:32 +00:00
|
|
|
|
result.Should().HaveStdOutContaining("Tool with output name!");
|
|
|
|
|
result.Should().NotHaveStdErr();
|
|
|
|
|
result.Should().Pass();
|
2016-04-20 23:05:53 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-03-28 08:35:25 +00:00
|
|
|
|
// need conditional theories so we can skip on non-Windows
|
2016-03-28 08:15:09 +00:00
|
|
|
|
[Theory]
|
2016-04-06 22:29:10 +00:00
|
|
|
|
[MemberData("DependencyToolArguments")]
|
2016-05-08 21:20:34 +00:00
|
|
|
|
public void TestFrameworkSpecificDependencyToolsCanBeInvoked(string framework, string args, string expectedDependencyToolPath, bool windowsOnly)
|
2016-03-28 08:15:09 +00:00
|
|
|
|
{
|
2016-05-08 21:20:34 +00:00
|
|
|
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
|
2016-03-28 08:35:25 +00:00
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-04-08 22:33:32 +00:00
|
|
|
|
|
2016-03-28 23:54:06 +00:00
|
|
|
|
var appDirectory = Path.Combine(_desktopTestProjectsRoot, "AppWithDirectDependencyDesktopAndPortable");
|
2016-03-28 08:15:09 +00:00
|
|
|
|
|
|
|
|
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
2016-03-28 10:18:13 +00:00
|
|
|
|
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
2016-04-20 23:05:53 +00:00
|
|
|
|
.ExecuteWithCapturedOutput("desktop-and-portable", framework, args);
|
2016-03-28 08:15:09 +00:00
|
|
|
|
|
2016-04-28 23:30:32 +00:00
|
|
|
|
result.Should().HaveStdOutContaining(framework);
|
|
|
|
|
result.Should().HaveStdOutContaining(args);
|
|
|
|
|
result.Should().HaveStdOutContaining(expectedDependencyToolPath);
|
|
|
|
|
result.Should().NotHaveStdErr();
|
|
|
|
|
result.Should().Pass();
|
2016-03-28 08:15:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2016-05-08 21:20:34 +00:00
|
|
|
|
[Theory]
|
|
|
|
|
[MemberData("LibraryDependencyToolArguments")]
|
|
|
|
|
public void TestFrameworkSpecificLibraryDependencyToolsCannotBeInvoked(string framework, string args, string expectedDependencyToolPath, bool windowsOnly)
|
|
|
|
|
{
|
|
|
|
|
if (!RuntimeInformation.IsOSPlatform(OSPlatform.Windows) && windowsOnly)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var appDirectory = Path.Combine(_desktopTestProjectsRoot, "LibraryWithDirectDependencyDesktopAndPortable");
|
|
|
|
|
|
|
|
|
|
new BuildCommand(Path.Combine(appDirectory, "project.json"))
|
|
|
|
|
.Execute()
|
|
|
|
|
.Should()
|
|
|
|
|
.Pass();
|
|
|
|
|
|
|
|
|
|
CommandResult result = new DependencyToolInvokerCommand { WorkingDirectory = appDirectory }
|
|
|
|
|
.ExecuteWithCapturedOutput("desktop-and-portable", framework, args);
|
|
|
|
|
|
|
|
|
|
result.Should().HaveStdOutContaining("Command not found");
|
|
|
|
|
result.Should().Fail();
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-08 22:33:32 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void ToolsCanAccessDependencyContextProperly()
|
|
|
|
|
{
|
|
|
|
|
var appDirectory = Path.Combine(_testProjectsRoot, "DependencyContextFromTool");
|
|
|
|
|
|
|
|
|
|
CommandResult result = new DependencyContextTestCommand() { WorkingDirectory = appDirectory }
|
|
|
|
|
.Execute(Path.Combine(appDirectory, "project.json"));
|
|
|
|
|
|
|
|
|
|
result.Should().Pass();
|
|
|
|
|
}
|
|
|
|
|
|
2016-03-03 23:31:04 +00:00
|
|
|
|
[Fact]
|
|
|
|
|
public void TestProjectDependencyIsNotAvailableThroughDriver()
|
|
|
|
|
{
|
|
|
|
|
var appName = "AppWithDirectDependency";
|
|
|
|
|
var 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();
|
|
|
|
|
|
2016-04-29 20:46:16 +00:00
|
|
|
|
result.StdErr.Should().Contain("No executable found matching command");
|
Extract dotnet-compile-fsc into a standalone command
Add basic Tests for dotnet-compile-fsc
Package Targets execute before TestTargets. Use Generated Nuget Packages in TestTargets. Generate Nuget packages on all platforms, and in C#
Fix bug in dotnet-restore, change fsharp new template, add support for native assets in DependencyContextCsvReader
copy fsc.exe to temp directory instead of package cache
fix rebase error
fix issue
fixes
fixes
fix
temporarily disable debian package e2e testing
fixes
bump fsc version
update fsc version
fix rebase errors
WIP update fsc tool
WIP, rebased and working again, need to solve issues with System.CommandLine
Working state for packaged, command, fsc.exe bugging out with dlopen(, 1): no suitable image found.
execute fsc like a unpublished standalone app
fixup after rebase
working? internet is out
working
cleanup
More cleanup, and run the debian package tests during the Test phase of the build.
update FSharp Test Projects NetStandard Library Version
Update Version Suffix when packing TestPackages. This will enable packing with the right dependency versions on Windows.
update dotnet-test version
Undo the reordering of the build
fix test package project pathsj
ignore net451 build failures for test packages which we need to build on non-windows
update dependency of desktop test app
add dotnetcli feed to nuget config for fsharp dotnet new
update deps after rebase
update dependency of dotnet-compile-fsc
pass args before commandPath when using muxer for tools
adjust testpackage cleaning not to clean packages which are also generated as part of the product from the nuget cache.
undo
Pass projectJson to pack instead of using WorkingDirectory
fix path separators using depsjsoncommandresolver on windows, fix building only specific frameworks for testpackages on non-windows.
PR Feedback
rebase
overwrite fsc runtimeconfig
2016-03-12 00:41:00 +00:00
|
|
|
|
result.Should().Fail();
|
2016-03-03 23:31:04 +00:00
|
|
|
|
}
|
|
|
|
|
finally
|
|
|
|
|
{
|
|
|
|
|
Directory.SetCurrentDirectory(currentDirectory);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-10 19:16:23 +00:00
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-17 18:43:17 +00:00
|
|
|
|
|
|
|
|
|
class PortableCommand : TestCommand
|
|
|
|
|
{
|
|
|
|
|
public PortableCommand()
|
|
|
|
|
: base("dotnet")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult Execute(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"portable {args}";
|
|
|
|
|
return base.Execute(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"portable {args}";
|
|
|
|
|
return base.ExecuteWithCapturedOutput(args);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-03-28 08:15:09 +00:00
|
|
|
|
|
2016-04-20 23:05:53 +00:00
|
|
|
|
class GenericCommand : TestCommand
|
|
|
|
|
{
|
|
|
|
|
private readonly string _commandName;
|
|
|
|
|
|
|
|
|
|
public GenericCommand(string commandName)
|
|
|
|
|
: base("dotnet")
|
|
|
|
|
{
|
|
|
|
|
_commandName = commandName;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult Execute(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"{_commandName} {args}";
|
|
|
|
|
return base.Execute(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult ExecuteWithCapturedOutput(string args = "")
|
|
|
|
|
{
|
|
|
|
|
args = $"{_commandName} {args}";
|
|
|
|
|
return base.ExecuteWithCapturedOutput(args);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-04-08 22:33:32 +00:00
|
|
|
|
class DependencyContextTestCommand : TestCommand
|
|
|
|
|
{
|
|
|
|
|
public DependencyContextTestCommand()
|
|
|
|
|
: base("dotnet")
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult Execute(string path)
|
|
|
|
|
{
|
|
|
|
|
var args = $"dependency-context-test {path}";
|
|
|
|
|
return base.Execute(args);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override CommandResult ExecuteWithCapturedOutput(string path)
|
|
|
|
|
{
|
|
|
|
|
var args = $"dependency-context-test {path}";
|
|
|
|
|
return base.ExecuteWithCapturedOutput(args);
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-02-10 19:16:23 +00:00
|
|
|
|
}
|
|
|
|
|
}
|