Integrate ProjectModel server tests
This commit is contained in:
parent
b5de686ba4
commit
f7e4714dc5
20 changed files with 28 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"NETStandard.Library": "1.0.0-rc2-23811",
|
"NETStandard.Library": "1.0.0-rc2-23811",
|
||||||
"EmptyLibrary": ""
|
"EmptyLibrary": "1.0.0-*"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnxcore50": { }
|
"dnxcore50": { }
|
|
@ -1,4 +1,5 @@
|
||||||
{
|
{
|
||||||
|
"version": "1.0.0-*",
|
||||||
"dependencies": { },
|
"dependencies": { },
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnxcore50": {
|
"dnxcore50": {
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"EmptyLibrary": ""
|
"EmptyLibrary": "1.0.0-*"
|
||||||
},
|
},
|
||||||
"frameworks": {
|
"frameworks": {
|
||||||
"dnx451": { }
|
"dnx451": { }
|
|
@ -28,6 +28,7 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
"dotnet-compile.UnitTests",
|
"dotnet-compile.UnitTests",
|
||||||
"dotnet-build.Tests",
|
"dotnet-build.Tests",
|
||||||
"dotnet-pack.Tests",
|
"dotnet-pack.Tests",
|
||||||
|
"dotnet-projectmodel-server.Tests",
|
||||||
"dotnet-resgen.Tests",
|
"dotnet-resgen.Tests",
|
||||||
"dotnet-run.Tests",
|
"dotnet-run.Tests",
|
||||||
"Microsoft.DotNet.Cli.Utils.Tests",
|
"Microsoft.DotNet.Cli.Utils.Tests",
|
||||||
|
@ -76,8 +77,11 @@ namespace Microsoft.DotNet.Cli.Build
|
||||||
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
|
.WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects"))
|
||||||
.Execute().EnsureSuccessful();
|
.Execute().EnsureSuccessful();
|
||||||
|
|
||||||
// The 'testapp' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
|
// The 'ProjectModelServer' directory contains intentionally-unresolved dependencies, so don't check for success. Also, suppress the output
|
||||||
dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "testapp")).CaptureStdErr().CaptureStdOut().Execute();
|
dotnet.Restore().WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer"))
|
||||||
|
.CaptureStdErr()
|
||||||
|
.CaptureStdOut()
|
||||||
|
.Execute();
|
||||||
|
|
||||||
return c.Success();
|
return c.Success();
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,6 @@ using System.Net;
|
||||||
using System.Net.Sockets;
|
using System.Net.Sockets;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.Extensions.Logging;
|
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
|
||||||
|
@ -34,6 +33,9 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
|
|
||||||
public DthTestClient(DthTestServer server)
|
public DthTestClient(DthTestServer server)
|
||||||
{
|
{
|
||||||
|
// Avoid Socket exception 10006 on Linux
|
||||||
|
Thread.Sleep(100);
|
||||||
|
|
||||||
_socket = new Socket(AddressFamily.InterNetwork,
|
_socket = new Socket(AddressFamily.InterNetwork,
|
||||||
SocketType.Stream,
|
SocketType.Stream,
|
||||||
ProtocolType.Tcp);
|
ProtocolType.Tcp);
|
||||||
|
|
|
@ -5,6 +5,8 @@ using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.DotNet.ProjectModel.Server.Tests.Helpers;
|
using Microsoft.DotNet.ProjectModel.Server.Tests.Helpers;
|
||||||
|
using Microsoft.DotNet.Tools.Test.Utilities;
|
||||||
|
using Microsoft.Extensions.PlatformAbstractions;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
using Xunit;
|
using Xunit;
|
||||||
|
@ -92,6 +94,12 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests
|
||||||
string expectedUnresolvedDependency,
|
string expectedUnresolvedDependency,
|
||||||
string expectedUnresolvedType)
|
string expectedUnresolvedType)
|
||||||
{
|
{
|
||||||
|
if (PlatformServices.Default.Runtime.OperatingSystemPlatform == Platform.Linux)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Test is skipped on Linux");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var projectPath = _testHelper.FindSampleProject(testProjectName);
|
var projectPath = _testHelper.FindSampleProject(testProjectName);
|
||||||
Assert.NotNull(projectPath);
|
Assert.NotNull(projectPath);
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests.Helpers
|
||||||
public class TestHelper
|
public class TestHelper
|
||||||
{
|
{
|
||||||
private readonly string _tempPath;
|
private readonly string _tempPath;
|
||||||
|
private readonly string _testProjectsDir;
|
||||||
|
|
||||||
public TestHelper()
|
public TestHelper()
|
||||||
{
|
{
|
||||||
|
@ -28,8 +29,8 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests.Helpers
|
||||||
}
|
}
|
||||||
|
|
||||||
_tempPath = CreateTempFolder();
|
_tempPath = CreateTempFolder();
|
||||||
var dthTestProjectsFolder = Path.Combine(FindRoot(), "testapp", "DthTestProjects");
|
_testProjectsDir = Path.Combine(AppContext.BaseDirectory, "TestAssets", "ProjectModelServer");
|
||||||
CopyFiles(dthTestProjectsFolder, _tempPath);
|
CopyFiles(_testProjectsDir, _tempPath);
|
||||||
|
|
||||||
var logger = LoggerFactory.CreateLogger<TestHelper>();
|
var logger = LoggerFactory.CreateLogger<TestHelper>();
|
||||||
logger.LogInformation($"Test projects are copied to {_tempPath}");
|
logger.LogInformation($"Test projects are copied to {_tempPath}");
|
||||||
|
@ -39,7 +40,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests.Helpers
|
||||||
|
|
||||||
public string FindSampleProject(string name)
|
public string FindSampleProject(string name)
|
||||||
{
|
{
|
||||||
var result = Path.Combine(_tempPath, "src", name);
|
var result = Path.Combine(_tempPath, "DthTestProjects", "src", name);
|
||||||
if (Directory.Exists(result))
|
if (Directory.Exists(result))
|
||||||
{
|
{
|
||||||
return result;
|
return result;
|
||||||
|
@ -52,7 +53,7 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests.Helpers
|
||||||
|
|
||||||
public string CreateSampleProject(string name)
|
public string CreateSampleProject(string name)
|
||||||
{
|
{
|
||||||
var source = Path.Combine(FindRoot(), "test", name);
|
var source = Path.Combine(AppContext.BaseDirectory, "TestAssets", "ProjectModelServer");
|
||||||
if (!Directory.Exists(source))
|
if (!Directory.Exists(source))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
|
@ -82,26 +83,6 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests.Helpers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string FindRoot()
|
|
||||||
{
|
|
||||||
var solutionName = "Microsoft.DotNet.Cli.sln";
|
|
||||||
var root = new DirectoryInfo(Directory.GetCurrentDirectory());
|
|
||||||
|
|
||||||
while (root != null && root.GetFiles(solutionName).Length == 0)
|
|
||||||
{
|
|
||||||
root = Directory.GetParent(root.FullName);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (root != null)
|
|
||||||
{
|
|
||||||
return root.FullName;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string CreateTempFolder()
|
private static string CreateTempFolder()
|
||||||
{
|
{
|
||||||
var result = Path.GetTempFileName();
|
var result = Path.GetTempFileName();
|
||||||
|
|
|
@ -11,5 +11,8 @@
|
||||||
"imports": "portable-net45+win8"
|
"imports": "portable-net45+win8"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"content": [
|
||||||
|
"../../TestAssets/ProjectModelServer/**"
|
||||||
|
],
|
||||||
"testRunner": "xunit"
|
"testRunner": "xunit"
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue