Use Corehost instead of CoreRun, refactor tests for individual commands
This commit is contained in:
parent
5c31655317
commit
8db6b797d2
4 changed files with 118 additions and 65 deletions
|
@ -32,7 +32,8 @@ popd
|
||||||
|
|
||||||
# Run the app and check the exit code
|
# Run the app and check the exit code
|
||||||
pushd "$RepoRoot\artifacts\$Rid\e2etest"
|
pushd "$RepoRoot\artifacts\$Rid\e2etest"
|
||||||
& "CoreRun.exe" "xunit.console.netcore.exe" "E2E.dll" -xml ..\..\e2etest.xml
|
mv E2E.exe corehost.exe
|
||||||
|
& "corehost.exe" "xunit.console.netcore.exe" "E2E.dll" -xml ..\..\e2etest.xml
|
||||||
if (!$?) {
|
if (!$?) {
|
||||||
Write-Host "E2E Test Failure"
|
Write-Host "E2E Test Failure"
|
||||||
popd
|
popd
|
||||||
|
|
|
@ -23,5 +23,6 @@ dotnet publish --framework dnxcore50 --runtime "$RID" --output "$REPOROOT/artifa
|
||||||
|
|
||||||
# set -e will abort if the exit code of this is non-zero
|
# set -e will abort if the exit code of this is non-zero
|
||||||
pushd "$REPOROOT/artifacts/$RID/e2etest"
|
pushd "$REPOROOT/artifacts/$RID/e2etest"
|
||||||
./corerun xunit.console.netcore.exe E2E.dll
|
mv ./E2E ./corehost
|
||||||
|
./corehost xunit.console.netcore.exe E2E.dll
|
||||||
popd
|
popd
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
using Microsoft.DotNet.Cli.Utils;
|
using Microsoft.DotNet.Cli.Utils;
|
||||||
using Microsoft.Extensions.ProjectModel;
|
using Microsoft.Extensions.ProjectModel;
|
||||||
|
@ -11,59 +12,119 @@ namespace ConsoleApplication
|
||||||
{
|
{
|
||||||
public class E2ETest
|
public class E2ETest
|
||||||
{
|
{
|
||||||
private static readonly string EXPECTED_OUTPUT = "Hello World!";
|
private static readonly string EXPECTED_OUTPUT = "Hello World!" + Environment.NewLine;
|
||||||
private static readonly string TEST_PROJECT_NAME = "hellotest";
|
private static readonly string TESTDIR_NAME = "hellotest";
|
||||||
private static readonly string OUTPUT_FOLDER_NAME = "testbin";
|
private static readonly string OUTPUTDIR_NAME = "testbin";
|
||||||
|
|
||||||
|
private static string RootPath { get; set; }
|
||||||
|
private string TestDirectory { get; set; }
|
||||||
|
private string OutputDirectory { get; set; }
|
||||||
|
private string Rid { get; set; }
|
||||||
|
|
||||||
public static void Main()
|
public static void Main()
|
||||||
{
|
{
|
||||||
Console.WriteLine("Dummy Entrypoint.");
|
Console.WriteLine("Dummy Entrypoint.");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Fact]
|
public E2ETest()
|
||||||
public static void TestE2E()
|
|
||||||
{
|
{
|
||||||
// Setup Paths
|
if (RootPath == null)
|
||||||
var rootPath = GetRootPath();
|
{
|
||||||
var testDir = Path.Combine(rootPath, TEST_PROJECT_NAME);
|
RootPath = Directory.GetCurrentDirectory();
|
||||||
var outputDir = Path.Combine(testDir, OUTPUT_FOLDER_NAME);
|
}
|
||||||
|
|
||||||
// Setup RID
|
TestDirectory = Path.Combine(RootPath, TESTDIR_NAME);
|
||||||
var rid = RuntimeIdentifier.Current;
|
OutputDirectory = Path.Combine(RootPath, OUTPUTDIR_NAME);
|
||||||
|
|
||||||
// Create Test Directory and cd there
|
Rid = RuntimeIdentifier.Current;
|
||||||
CleanOrCreateDirectory(testDir);
|
|
||||||
Directory.SetCurrentDirectory(TEST_PROJECT_NAME);
|
|
||||||
|
|
||||||
// Base Set of Commands
|
|
||||||
TestRunCommand("dotnet", "init");
|
|
||||||
|
|
||||||
TestRunCommand("dotnet", "restore");
|
|
||||||
TestRunCommand("dotnet", "run");
|
|
||||||
|
|
||||||
// Compile
|
|
||||||
TestRunCommand("dotnet", $"compile -o {outputDir}");
|
|
||||||
TestOutputExecutable(outputDir);
|
|
||||||
|
|
||||||
// Native Compilation
|
|
||||||
CleanOrCreateDirectory(outputDir);
|
|
||||||
TestRunCommand("dotnet", $"compile --native -o {outputDir}");
|
|
||||||
TestOutputExecutable(outputDir);
|
|
||||||
|
|
||||||
// Native Compilation w/ CPP backend
|
|
||||||
CleanOrCreateDirectory(outputDir);
|
|
||||||
TestRunCommand("dotnet", $"compile --native --cpp -o {outputDir}");
|
|
||||||
TestOutputExecutable(outputDir);
|
|
||||||
|
|
||||||
// Publish
|
|
||||||
CleanOrCreateDirectory(outputDir);
|
|
||||||
TestRunCommand("dotnet", $"publish --framework dnxcore50 --runtime {rid} -o {outputDir}");
|
|
||||||
TestOutputExecutable(outputDir);
|
|
||||||
|
|
||||||
TestRunCommand("dotnet", "pack");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TestRunCommand(string command, string args)
|
[Fact]
|
||||||
|
public void TestDotnetCompile()
|
||||||
|
{
|
||||||
|
TestSetup();
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", $"compile -o {OutputDirectory}");
|
||||||
|
TestOutputExecutable(OutputDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestDotnetCompileNativeRyuJit()
|
||||||
|
{
|
||||||
|
// Skip this test on mac
|
||||||
|
if(SkipForOS(OSPlatform.OSX, "https://github.com/dotnet/cli/issues/246"))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
TestSetup();
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", $"compile --native -o {OutputDirectory}");
|
||||||
|
|
||||||
|
var nativeOut = Path.Combine(OutputDirectory, "native");
|
||||||
|
TestOutputExecutable(nativeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestDotnetCompileNativeCpp()
|
||||||
|
{
|
||||||
|
TestSetup();
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", $"compile --native --cpp -o {OutputDirectory}");
|
||||||
|
|
||||||
|
var nativeOut = Path.Combine(OutputDirectory, "native");
|
||||||
|
TestOutputExecutable(nativeOut);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestDotnetRun()
|
||||||
|
{
|
||||||
|
TestSetup();
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", $"run");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact(Skip="https://github.com/dotnet/cli/issues/333")]
|
||||||
|
public void TestDotnetPack()
|
||||||
|
{
|
||||||
|
TestSetup();
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", $"pack");
|
||||||
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestDotnetPublish()
|
||||||
|
{
|
||||||
|
TestSetup();
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", $"publish --framework dnxcore50 --runtime {Rid} -o {OutputDirectory}");
|
||||||
|
TestOutputExecutable(OutputDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestSetup()
|
||||||
|
{
|
||||||
|
Directory.SetCurrentDirectory(RootPath);
|
||||||
|
|
||||||
|
CleanOrCreateDirectory(TestDirectory);
|
||||||
|
CleanOrCreateDirectory(OutputDirectory);
|
||||||
|
|
||||||
|
Directory.SetCurrentDirectory(TestDirectory);
|
||||||
|
|
||||||
|
TestRunCommand("dotnet", "init");
|
||||||
|
TestRunCommand("dotnet", "restore");
|
||||||
|
}
|
||||||
|
|
||||||
|
private bool SkipForOS(OSPlatform os, string reason)
|
||||||
|
{
|
||||||
|
if (RuntimeInformation.IsOSPlatform(os))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Skipping Test for reason: " + reason);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TestRunCommand(string command, string args)
|
||||||
{
|
{
|
||||||
var result = Command.Create(command, args)
|
var result = Command.Create(command, args)
|
||||||
.ForwardStdErr()
|
.ForwardStdErr()
|
||||||
|
@ -73,9 +134,9 @@ namespace ConsoleApplication
|
||||||
Assert.Equal(0, result.ExitCode);
|
Assert.Equal(0, result.ExitCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TestOutputExecutable(string outputDir)
|
private void TestOutputExecutable(string outputDir)
|
||||||
{
|
{
|
||||||
var executableName = TEST_PROJECT_NAME + Constants.ExeSuffix;
|
var executableName = TESTDIR_NAME + Constants.ExeSuffix;
|
||||||
|
|
||||||
var executablePath = Path.Combine(outputDir, executableName);
|
var executablePath = Path.Combine(outputDir, executableName);
|
||||||
|
|
||||||
|
@ -85,19 +146,10 @@ namespace ConsoleApplication
|
||||||
.Execute();
|
.Execute();
|
||||||
|
|
||||||
var outText = result.StdOut;
|
var outText = result.StdOut;
|
||||||
|
Assert.Equal(EXPECTED_OUTPUT, outText);
|
||||||
var expectedText = EXPECTED_OUTPUT + Environment.NewLine;
|
|
||||||
Assert.Equal(expectedText, outText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string GetRootPath()
|
private void CleanOrCreateDirectory(string path)
|
||||||
{
|
|
||||||
var cwd = Directory.GetCurrentDirectory();
|
|
||||||
|
|
||||||
return cwd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void CleanOrCreateDirectory(string path)
|
|
||||||
{
|
{
|
||||||
if (Directory.Exists(path))
|
if (Directory.Exists(path))
|
||||||
{
|
{
|
||||||
|
|
|
@ -6,21 +6,20 @@
|
||||||
|
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"Microsoft.NETCore.Platforms":"1.0.1-beta-*",
|
"Microsoft.NETCore.Platforms":"1.0.1-beta-*",
|
||||||
"Microsoft.NETCore.TestHost": "1.0.0-beta-*",
|
|
||||||
"Microsoft.NETCore.Runtime": "1.0.1-beta-*",
|
"Microsoft.NETCore.Runtime": "1.0.1-beta-*",
|
||||||
"Microsoft.NETCore.Console": "1.0.0-beta-*",
|
|
||||||
"System.IO": "4.0.11-beta-*",
|
|
||||||
"System.Console": "4.0.0-beta-*",
|
"System.Console": "4.0.0-beta-*",
|
||||||
"System.Runtime": "4.0.21-beta-*",
|
"System.Runtime": "4.0.21-beta-*",
|
||||||
|
"System.AppContext": "4.0.1-beta-*",
|
||||||
|
|
||||||
"xunit": "2.1.0",
|
"xunit": "2.1.0",
|
||||||
|
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
||||||
|
"xunit.runner.utility": "2.1.0",
|
||||||
|
|
||||||
|
"Microsoft.DotNet.ProjectModel": { "target": "project" },
|
||||||
"Microsoft.DotNet.Cli.Utils": {
|
"Microsoft.DotNet.Cli.Utils": {
|
||||||
"type": "build",
|
"type": "build",
|
||||||
"version": "1.0.0-*"
|
"version": "1.0.0-*"
|
||||||
},
|
},
|
||||||
"System.AppContext": "4.0.1-beta-*",
|
|
||||||
"xunit.console.netcore": "1.0.2-prerelease-00101",
|
|
||||||
"xunit.runner.utility": "2.1.0",
|
|
||||||
"Microsoft.DotNet.ProjectModel": { "target": "project" }
|
|
||||||
},
|
},
|
||||||
|
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
|
|
Loading…
Reference in a new issue