update project templates for portable app
also fix dotnet run
This commit is contained in:
parent
11e218d341
commit
cc00d9d839
10 changed files with 95 additions and 45 deletions
|
@ -8,11 +8,13 @@ using System.Runtime.InteropServices;
|
|||
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||
using Microsoft.Extensions.PlatformAbstractions;
|
||||
using Xunit;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace Microsoft.DotNet.Tests.EndToEnd
|
||||
{
|
||||
public class EndToEndTest : TestBase
|
||||
{
|
||||
private static readonly string NetStandardTfm = "netstandard1.5";
|
||||
private static readonly string s_expectedOutput = "Hello World!" + Environment.NewLine;
|
||||
private static readonly string s_testdirName = "e2etestroot";
|
||||
private static readonly string s_outputdirName = "test space/bin";
|
||||
|
@ -42,20 +44,20 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
[Fact]
|
||||
public void TestDotnetBuild()
|
||||
{
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: DefaultFramework);
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: NetStandardTfm);
|
||||
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void TestDotnetIncrementalBuild()
|
||||
{
|
||||
// first build
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: DefaultFramework);
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, framework: NetStandardTfm);
|
||||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
|
||||
|
||||
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
|
||||
var latestWriteTimeFirstBuild = GetLastWriteTimeUtcOfDirectoryFiles(
|
||||
|
@ -63,7 +65,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
|
||||
// second build; should get skipped (incremental because no inputs changed)
|
||||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeUtcSecondBuild = GetLastWriteTimeUtcOfDirectoryFiles(
|
||||
binariesOutputDirectory);
|
||||
|
@ -73,14 +75,14 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
|
||||
// third build; should get compiled because the source file got touched
|
||||
buildCommand.Execute().Should().Pass();
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
TestOutputExecutable(OutputDirectory, buildCommand.GetPortableOutputName(), s_expectedOutput);
|
||||
|
||||
var latestWriteTimeUtcThirdBuild = GetLastWriteTimeUtcOfDirectoryFiles(
|
||||
binariesOutputDirectory);
|
||||
Assert.NotEqual(latestWriteTimeUtcSecondBuild, latestWriteTimeUtcThirdBuild);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Native compilation isn't shipping in 1.0 and we're moving it out anyway")]
|
||||
public void TestDotnetBuildNativeRyuJit()
|
||||
{
|
||||
if (!IsNativeCompilationSupported())
|
||||
|
@ -88,14 +90,14 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
return;
|
||||
}
|
||||
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, framework: DefaultFramework);
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, framework: NetStandardTfm);
|
||||
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
||||
TestNativeOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Native compilation isn't shipping in 1.0 and we're moving it out anyway")]
|
||||
public void TestDotnetBuildNativeCpp()
|
||||
{
|
||||
if (!IsNativeCompilationSupported())
|
||||
|
@ -103,14 +105,14 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
return;
|
||||
}
|
||||
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true, framework: DefaultFramework);
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true, framework: NetStandardTfm);
|
||||
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
||||
TestNativeOutputExecutable(OutputDirectory, buildCommand.GetOutputExecutableName(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[Fact(Skip = "Native compilation isn't shipping in 1.0 and we're moving it out anyway")]
|
||||
public void TestDotnetCompileNativeCppIncremental()
|
||||
{
|
||||
if (!IsNativeCompilationSupported())
|
||||
|
@ -119,7 +121,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
}
|
||||
|
||||
// first build
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true, framework: DefaultFramework);
|
||||
var buildCommand = new BuildCommand(TestProject, output: OutputDirectory, native: true, nativeCppMode: true, framework: NetStandardTfm);
|
||||
var binariesOutputDirectory = GetCompilationOutputPath(OutputDirectory, false);
|
||||
|
||||
buildCommand.Execute().Should().Pass();
|
||||
|
@ -163,7 +165,7 @@ namespace Microsoft.DotNet.Tests.EndToEnd
|
|||
var publishCommand = new PublishCommand(TestProject, output: OutputDirectory);
|
||||
publishCommand.Execute().Should().Pass();
|
||||
|
||||
TestExecutable(OutputDirectory, publishCommand.GetOutputExecutable(), s_expectedOutput);
|
||||
TestExecutable(OutputDirectory, publishCommand.GetPortableOutputName(), s_expectedOutput);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
|
@ -254,6 +254,11 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return base.ExecuteWithCapturedOutput(args);
|
||||
}
|
||||
|
||||
public string GetPortableOutputName()
|
||||
{
|
||||
return $"{_project.Name}.dll";
|
||||
}
|
||||
|
||||
public string GetOutputExecutableName()
|
||||
{
|
||||
var result = _project.Name;
|
||||
|
|
|
@ -74,6 +74,11 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return new DirectoryInfo(output);
|
||||
}
|
||||
|
||||
public string GetPortableOutputName()
|
||||
{
|
||||
return $"{_project.Name}.dll";
|
||||
}
|
||||
|
||||
public string GetOutputExecutable()
|
||||
{
|
||||
var result = _project.Name;
|
||||
|
|
|
@ -23,11 +23,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
public virtual CommandResult Execute(string args = "")
|
||||
{
|
||||
var commandPath = _command;
|
||||
if (!Path.IsPathRooted(_command))
|
||||
{
|
||||
_command = Env.GetCommandPath(_command) ??
|
||||
Env.GetCommandPathFromRootPath(AppContext.BaseDirectory, _command);
|
||||
}
|
||||
ResolveCommand(ref commandPath, ref args);
|
||||
|
||||
Console.WriteLine($"Executing - {_command} {args}");
|
||||
|
||||
|
@ -44,9 +40,11 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
{
|
||||
Console.WriteLine($"Executing (Captured Output) - {_command} {args}");
|
||||
|
||||
var commandPath = Env.GetCommandPath(_command, ".exe", ".cmd", "") ??
|
||||
Env.GetCommandPathFromRootPath(AppContext.BaseDirectory, _command, ".exe", ".cmd", "");
|
||||
|
||||
var command = _command;
|
||||
ResolveCommand(ref command, ref args);
|
||||
var commandPath = Env.GetCommandPath(command, ".exe", ".cmd", "") ??
|
||||
Env.GetCommandPathFromRootPath(AppContext.BaseDirectory, command, ".exe", ".cmd", "");
|
||||
|
||||
var stdOut = new StreamForwarder();
|
||||
var stdErr = new StreamForwarder();
|
||||
|
||||
|
@ -56,6 +54,26 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
return RunProcess(commandPath, args, stdOut, stdErr);
|
||||
}
|
||||
|
||||
private void ResolveCommand(ref string executable, ref string args)
|
||||
{
|
||||
if (executable.EndsWith(".dll", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var newArgs = ArgumentEscaper.EscapeSingleArg(executable);
|
||||
if (!string.IsNullOrEmpty(args))
|
||||
{
|
||||
newArgs += " " + args;
|
||||
}
|
||||
args = newArgs;
|
||||
executable = "corehost";
|
||||
}
|
||||
|
||||
if (!Path.IsPathRooted(executable))
|
||||
{
|
||||
executable = Env.GetCommandPath(executable) ??
|
||||
Env.GetCommandPathFromRootPath(AppContext.BaseDirectory, executable);
|
||||
}
|
||||
}
|
||||
|
||||
private CommandResult RunProcess(string executable, string args, StreamForwarder stdOut, StreamForwarder stdErr)
|
||||
{
|
||||
var psi = new ProcessStartInfo
|
||||
|
@ -88,8 +106,8 @@ namespace Microsoft.DotNet.Tools.Test.Utilities
|
|||
|
||||
var result = new CommandResult(
|
||||
process.StartInfo,
|
||||
process.ExitCode,
|
||||
stdOut.CapturedOutput,
|
||||
process.ExitCode,
|
||||
stdOut.CapturedOutput,
|
||||
stdErr.CapturedOutput);
|
||||
|
||||
return result;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue