From 9f8906fdacb1fd8f86acdeeefbc00f37d8e0e746 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Mon, 29 Feb 2016 22:09:38 -0800 Subject: [PATCH] Update dotnet projectmodel tests --- .../src/EmptyLibrary/project-update.json | 2 +- .../DthTestProjects/src/EmptyLibrary/project.json | 2 +- .../src/FailReleaseProject/project.json | 2 +- .../project.json | 0 scripts/dotnet-cli-build/TestTargets.cs | 12 ++++++++---- .../FileFormatException.cs | 2 +- test/dotnet-projectmodel-server.Tests/DthTests.cs | 10 ++++++---- 7 files changed, 18 insertions(+), 12 deletions(-) rename TestAssets/ProjectModelServer/{DthTestProjects/src/BrokenProjectFileSample => IncorrectProjectJson}/project.json (100%) diff --git a/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project-update.json b/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project-update.json index 9aaa9064d..ebe3e29af 100644 --- a/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project-update.json +++ b/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project-update.json @@ -3,7 +3,7 @@ "frameworks": { "dnxcore50": { "dependencies":{ - "System.Runtime": "4.0.21-beta-*", + "NETStandard.Library": "1.0.0-rc2-23811", "System.Console": "4.0.0-beta-*" } } diff --git a/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project.json b/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project.json index 6e615135d..d3ff05ba2 100644 --- a/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project.json +++ b/TestAssets/ProjectModelServer/DthTestProjects/src/EmptyLibrary/project.json @@ -4,7 +4,7 @@ "frameworks": { "dnxcore50": { "dependencies":{ - "System.Runtime": "4.0.21-*" + "NETStandard.Library": "1.0.0-rc2-23811" } } } diff --git a/TestAssets/ProjectModelServer/DthTestProjects/src/FailReleaseProject/project.json b/TestAssets/ProjectModelServer/DthTestProjects/src/FailReleaseProject/project.json index 60da6b421..ac54eee2f 100644 --- a/TestAssets/ProjectModelServer/DthTestProjects/src/FailReleaseProject/project.json +++ b/TestAssets/ProjectModelServer/DthTestProjects/src/FailReleaseProject/project.json @@ -2,7 +2,7 @@ "frameworks": { "dnxcore50": { "dependencies": { - "System.Runtime": "4.0.21-*" + "NETStandard.Library": "1.0.0-rc2-23811" } } }, diff --git a/TestAssets/ProjectModelServer/DthTestProjects/src/BrokenProjectFileSample/project.json b/TestAssets/ProjectModelServer/IncorrectProjectJson/project.json similarity index 100% rename from TestAssets/ProjectModelServer/DthTestProjects/src/BrokenProjectFileSample/project.json rename to TestAssets/ProjectModelServer/IncorrectProjectJson/project.json diff --git a/scripts/dotnet-cli-build/TestTargets.cs b/scripts/dotnet-cli-build/TestTargets.cs index 0036c397d..f02c700d0 100644 --- a/scripts/dotnet-cli-build/TestTargets.cs +++ b/scripts/dotnet-cli-build/TestTargets.cs @@ -73,14 +73,18 @@ namespace Microsoft.DotNet.Cli.Build CleanNuGetTempCache(); var dotnet = DotNetCli.Stage2; + dotnet.Restore("--fallbacksource", Dirs.TestPackages) .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "TestProjects")) .Execute().EnsureSuccessful(); - + // 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, "TestAssets", "ProjectModelServer")) - .CaptureStdErr() - .CaptureStdOut() + dotnet.Restore() + .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthTestProjects")) + .Execute(); + + dotnet.Restore() + .WorkingDirectory(Path.Combine(c.BuildContext.BuildDirectory, "TestAssets", "ProjectModelServer", "DthUpdateSearchPathSample")) .Execute(); return c.Success(); diff --git a/src/Microsoft.DotNet.ProjectModel/FileFormatException.cs b/src/Microsoft.DotNet.ProjectModel/FileFormatException.cs index 4d723677a..0e9c5d11f 100644 --- a/src/Microsoft.DotNet.ProjectModel/FileFormatException.cs +++ b/src/Microsoft.DotNet.ProjectModel/FileFormatException.cs @@ -24,7 +24,7 @@ namespace Microsoft.DotNet.ProjectModel public override string ToString() { - return $"{Path}({Line},{Column}): Error: {base.ToString()}"; + return string.Format("{0}({1},{2}): {3}", Path, Line, Column, base.Message); } internal static FileFormatException Create(Exception exception, string filePath) diff --git a/test/dotnet-projectmodel-server.Tests/DthTests.cs b/test/dotnet-projectmodel-server.Tests/DthTests.cs index 61d6faa79..07d7ddf49 100644 --- a/test/dotnet-projectmodel-server.Tests/DthTests.cs +++ b/test/dotnet-projectmodel-server.Tests/DthTests.cs @@ -4,12 +4,10 @@ using System; using System.IO; using System.Linq; -using Microsoft.DotNet.ProjectModel.Graph; using Microsoft.DotNet.TestFramework; using Microsoft.DotNet.Tools.Test.Utilities; using Microsoft.Extensions.Logging; using Microsoft.Extensions.PlatformAbstractions; -using Microsoft.DotNet.TestFramework; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using Xunit; @@ -291,17 +289,21 @@ namespace Microsoft.DotNet.ProjectModel.Server.Tests [Fact] public void InvalidProjectJson() { + var testAssetsPath = Path.Combine(RepoRoot, "TestAssets", "ProjectModelServer"); + var assetsManager = new TestAssetsManager(testAssetsPath); + var testSource = assetsManager.CreateTestInstance("IncorrectProjectJson").TestRoot; + using (var server = new DthTestServer(_loggerFactory)) using (var client = new DthTestClient(server)) { client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "EmptyLibrary")); - client.Initialize(Path.Combine(_testAssetsManager.AssetsRoot, "BrokenProjectFileSample")); + client.Initialize(testSource); // Error for invalid project.json var messages = client.DrainAllMessages(); messages.Single(msg => msg.MessageType == MessageTypes.Error) .Payload.AsJObject() - .AssertProperty("Path", v => v.Contains("BrokenProjectFileSample")); + .AssertProperty("Path", v => v.Contains("IncorrectProjectJson")); // Successfully initialize the other project messages.Single(msg => msg.MessageType == MessageTypes.ProjectInformation)