From a66546d8fb658fb66bd6bf72bb5e20ec12e21679 Mon Sep 17 00:00:00 2001 From: piotrp Date: Sun, 24 Jan 2016 01:04:39 -0800 Subject: [PATCH] Maintain test artifacts Improved test diagnostics Providing diagnostics about failed process. Workaround for https://github.com/NuGet/Home/issues/1977 get past crossgen errors! --- build.cmd | 3 ++ scripts/common/_common.ps1 | 4 ++- src/Microsoft.DotNet.Cli.Utils/Command.cs | 1 + .../CommandResult.cs | 6 +++- .../appdep/project.json | 2 +- .../Program.cs | 7 ++++- .../CSharp_Console/project.json | 2 +- src/Microsoft.DotNet.Tools.New/project.json | 2 +- .../project.json | 2 +- .../ArgumentForwardingTests/project.json | 8 +++-- .../Reflector/project.json | 8 +++-- .../project.json | 1 - .../Assertions/CommandResultAssertions.cs | 28 ++++++++++++------ .../Commands/TestCommand.cs | 1 + .../TempFileSystem/TempRoot.cs | 29 ++++++++++++------- .../project.json | 8 +---- .../TestLibraryWithRunner/project.json | 4 +-- .../src/L0/project.json | 2 +- .../src/L11/project.json | 2 +- .../src/L12/project.json | 2 +- .../src/L21/project.json | 2 +- .../src/L22/project.json | 2 +- .../src/EmptyConsoleApp/project.json | 2 +- tools/MultiProjectValidator/project.json | 2 +- 24 files changed, 81 insertions(+), 49 deletions(-) diff --git a/build.cmd b/build.cmd index 15cdc5999..9b72ee74b 100644 --- a/build.cmd +++ b/build.cmd @@ -3,4 +3,7 @@ REM Copyright (c) .NET Foundation and contributors. All rights reserved. REM Licensed under the MIT license. See LICENSE file in the project root for full license information. +REM Crossgen Workaround +set ComPlus_ReadyToRun=0 + powershell -NoProfile -NoLogo -Command "%~dp0scripts\build\build.ps1 %*; exit $LastExitCode;" diff --git a/scripts/common/_common.ps1 b/scripts/common/_common.ps1 index 4f591e5f2..7176ae246 100644 --- a/scripts/common/_common.ps1 +++ b/scripts/common/_common.ps1 @@ -7,7 +7,7 @@ $Rid = "win7-x64" $Tfm = "dnxcore50" -$RepoRoot = Convert-Path "$PSScriptRoot\..\.." +$RepoRoot = Resolve-Path "$PSScriptRoot\..\.." $OutputDir = "$RepoRoot\artifacts\$Rid" $DnxDir = "$OutputDir\dnx" $DnxRoot = "$DnxDir\bin" @@ -19,6 +19,8 @@ $HostDir = "$OutputDir\corehost" $PackageDir = "$RepoRoot\artifacts\packages\dnvm" $env:ReleaseSuffix = "beta" $env:Channel = "$env:ReleaseSuffix" +$env:TEST_ROOT = "$OutputDir\tests" +$env:TEST_ARTIFACTS = "$env:TEST_ROOT\artifacts" # Set reasonable defaults for unset variables setEnvIfDefault "DOTNET_INSTALL_DIR" "$(Convert-Path "$PSScriptRoot\..")\.dotnet_stage0\win7-x64" diff --git a/src/Microsoft.DotNet.Cli.Utils/Command.cs b/src/Microsoft.DotNet.Cli.Utils/Command.cs index 45e9bbebe..8f75721c7 100644 --- a/src/Microsoft.DotNet.Cli.Utils/Command.cs +++ b/src/Microsoft.DotNet.Cli.Utils/Command.cs @@ -103,6 +103,7 @@ namespace Microsoft.DotNet.Cli.Utils #endif return new CommandResult( + this._process.StartInfo, exitCode, _stdOut.GetCapturedOutput(), _stdErr.GetCapturedOutput()); diff --git a/src/Microsoft.DotNet.Cli.Utils/CommandResult.cs b/src/Microsoft.DotNet.Cli.Utils/CommandResult.cs index 778d72316..9b7af5bde 100644 --- a/src/Microsoft.DotNet.Cli.Utils/CommandResult.cs +++ b/src/Microsoft.DotNet.Cli.Utils/CommandResult.cs @@ -1,18 +1,22 @@ // 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.Diagnostics; + namespace Microsoft.DotNet.Cli.Utils { public struct CommandResult { public static readonly CommandResult Empty = new CommandResult(); + public ProcessStartInfo StartInfo { get; } public int ExitCode { get; } public string StdOut { get; } public string StdErr { get; } - public CommandResult(int exitCode, string stdOut, string stdErr) + public CommandResult(ProcessStartInfo startInfo, int exitCode, string stdOut, string stdErr) { + StartInfo = startInfo; ExitCode = exitCode; StdOut = stdOut; StdErr = stdErr; diff --git a/src/Microsoft.DotNet.Tools.Compiler.Native/appdep/project.json b/src/Microsoft.DotNet.Tools.Compiler.Native/appdep/project.json index 45565a631..353f7ab5c 100644 --- a/src/Microsoft.DotNet.Tools.Compiler.Native/appdep/project.json +++ b/src/Microsoft.DotNet.Tools.Compiler.Native/appdep/project.json @@ -5,7 +5,7 @@ "emitEntryPoint": true }, "dependencies": { - "Microsoft.NETCore.Platforms": "1.0.1-rc2-23704", + "NETStandard.Library": "1.0.0-rc3-23722", "Microsoft.DotNet.AppDep":"1.0.4-*" }, "frameworks": { diff --git a/src/Microsoft.DotNet.Tools.Compiler/Program.cs b/src/Microsoft.DotNet.Tools.Compiler/Program.cs index 520e489fe..fb5d2c909 100644 --- a/src/Microsoft.DotNet.Tools.Compiler/Program.cs +++ b/src/Microsoft.DotNet.Tools.Compiler/Program.cs @@ -303,7 +303,7 @@ namespace Microsoft.DotNet.Tools.Compiler }; RunScripts(context, ScriptNames.PreCompile, contextVariables); - var result = Command.Create($"dotnet-compile-{compilerName}", new string[] {"@" + $"{rsp}" }) + var result = Command.Create($"dotnet-compile-{compilerName}", new [] {"@" + $"{rsp}" }) .OnErrorLine(line => { var diagnostic = ParseDiagnostic(context.ProjectDirectory, line); @@ -335,6 +335,11 @@ namespace Microsoft.DotNet.Tools.Compiler var success = result.ExitCode == 0; + if (!success) + { + Reporter.Error.WriteLine($"{result.StartInfo.FileName} {result.StartInfo.Arguments} returned Exit Code {result.ExitCode}"); + } + if (success) { success &= GenerateCultureResourceAssemblies(context.ProjectFile, dependencies, outputPath); diff --git a/src/Microsoft.DotNet.Tools.New/CSharp_Console/project.json b/src/Microsoft.DotNet.Tools.New/CSharp_Console/project.json index 03a76297a..eeaf01c42 100644 --- a/src/Microsoft.DotNet.Tools.New/CSharp_Console/project.json +++ b/src/Microsoft.DotNet.Tools.New/CSharp_Console/project.json @@ -5,7 +5,7 @@ }, "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" }, "frameworks": { diff --git a/src/Microsoft.DotNet.Tools.New/project.json b/src/Microsoft.DotNet.Tools.New/project.json index 1a2f1f473..ae882bbc9 100644 --- a/src/Microsoft.DotNet.Tools.New/project.json +++ b/src/Microsoft.DotNet.Tools.New/project.json @@ -15,7 +15,7 @@ } }, "compileExclude": [ "CSharp_Console/**", "FSharp_Console/**" ], - "resource": [ "CSharp_Console/**", "FSharp_Console/**" ], + "resource": [ "CSharp_Console/NuGet.Config", "CSharp_Console/Program.cs", "CSharp_Console/project.json", "FSharp_Console/NuGet.config, "FSharp_Console/Program.fs", "FSharp_Console/project.json"], "frameworks": { "dnxcore50": { "imports": "portable-net451+win8" diff --git a/src/Microsoft.Extensions.Testing.Abstractions/project.json b/src/Microsoft.Extensions.Testing.Abstractions/project.json index 12970d03a..4facd9c6b 100644 --- a/src/Microsoft.Extensions.Testing.Abstractions/project.json +++ b/src/Microsoft.Extensions.Testing.Abstractions/project.json @@ -13,7 +13,7 @@ "Newtonsoft.Json": "7.0.1", "Microsoft.DotNet.ProjectModel": "1.0.0-*", "Microsoft.Extensions.Logging.Abstractions": "1.0.0-rc2-15935", - "NETStandard.Library": "1.0.0-rc2-23704", + "NETStandard.Library": "1.0.0-rc3-23722", "System.Resources.ResourceManager": "4.0.1-rc3-23722", "System.Runtime.Serialization.Primitives": "4.1.0-rc3-23722" }, diff --git a/test/ArgumentForwardingTests/ArgumentForwardingTests/project.json b/test/ArgumentForwardingTests/ArgumentForwardingTests/project.json index 2e7e05f6a..5db3ecda4 100644 --- a/test/ArgumentForwardingTests/ArgumentForwardingTests/project.json +++ b/test/ArgumentForwardingTests/ArgumentForwardingTests/project.json @@ -5,8 +5,8 @@ }, "dependencies": { - "NETStandard.Library" : "1.0.0-rc2-23714", - "Microsoft.NETCore.TestHost": "1.0.0-rc2-23714", + "NETStandard.Library" : "1.0.0-rc3-23722", + "Microsoft.NETCore.TestHost": "1.0.0-rc3-23722", "xunit": "2.1.0", "xunit.console.netcore": "1.0.2-prerelease-00101", @@ -19,6 +19,8 @@ }, "frameworks": { - "dnxcore50": { } + "dnxcore50": { + "imports": "portable-net451+win8" + } } } diff --git a/test/ArgumentForwardingTests/Reflector/project.json b/test/ArgumentForwardingTests/Reflector/project.json index 3c07eb367..5db3ecda4 100644 --- a/test/ArgumentForwardingTests/Reflector/project.json +++ b/test/ArgumentForwardingTests/Reflector/project.json @@ -5,8 +5,8 @@ }, "dependencies": { - "NETStandard.Library" : "1.0.0-rc2-23706", - "Microsoft.NETCore.TestHost": "1.0.0-rc2-23706", + "NETStandard.Library" : "1.0.0-rc3-23722", + "Microsoft.NETCore.TestHost": "1.0.0-rc3-23722", "xunit": "2.1.0", "xunit.console.netcore": "1.0.2-prerelease-00101", @@ -19,6 +19,8 @@ }, "frameworks": { - "dnxcore50": { } + "dnxcore50": { + "imports": "portable-net451+win8" + } } } diff --git a/test/Microsoft.DotNet.Tools.Publish.Tests/project.json b/test/Microsoft.DotNet.Tools.Publish.Tests/project.json index 3ddccbabc..9c716c7c5 100644 --- a/test/Microsoft.DotNet.Tools.Publish.Tests/project.json +++ b/test/Microsoft.DotNet.Tools.Publish.Tests/project.json @@ -4,7 +4,6 @@ "dependencies": { "NETStandard.Library": "1.0.0-rc3-23722", "Microsoft.NETCore.TestHost": "1.0.0-rc2-*", - "System.Text.RegularExpressions": "4.0.11-*", "xunit": "2.1.0", "xunit.console.netcore": "1.0.2-prerelease-00101", diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs index 1ee8c938f..cd3cdf4a8 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Assertions/CommandResultAssertions.cs @@ -21,64 +21,74 @@ namespace Microsoft.DotNet.Tools.Test.Utilities public AndConstraint ExitWith(int expectedExitCode) { Execute.Assertion.ForCondition(_commandResult.ExitCode == expectedExitCode) - .FailWith("Expected command to exit with {0} but it exited with {1}.", expectedExitCode, _commandResult.ExitCode); + .FailWith(AppendDiagnosticsTo($"Expected command to exit with {expectedExitCode} but it did not.")); return new AndConstraint(this); } public AndConstraint Pass() { Execute.Assertion.ForCondition(_commandResult.ExitCode == 0) - .FailWith("Expected command to pass but it exited with {0}.", _commandResult.ExitCode); + .FailWith(AppendDiagnosticsTo($"Expected command to pass but it did not.")); return new AndConstraint(this); } public AndConstraint Fail() { Execute.Assertion.ForCondition(_commandResult.ExitCode != 0) - .FailWith("Expected command to fail but it exited with {0}.", _commandResult.ExitCode); + .FailWith(AppendDiagnosticsTo($"Expected command to fail but it did not.")); return new AndConstraint(this); } public AndConstraint HaveStdOut() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith("Command did not output anything to stdout"); + .FailWith(AppendDiagnosticsTo("Command did not output anything to stdout")); return new AndConstraint(this); } public AndConstraint HaveStdOut(string expectedOutput) { Execute.Assertion.ForCondition(_commandResult.StdOut.Equals(expectedOutput, StringComparison.Ordinal)) - .FailWith($"Command did not output with Expected Output. Expected: {expectedOutput} Actual: {_commandResult.StdOut}"); + .FailWith(AppendDiagnosticsTo($"Command did not output with Expected Output. Expected: {expectedOutput}")); return new AndConstraint(this); } public AndConstraint StdOutMatchPattern(string pattern, RegexOptions options = RegexOptions.None) { Execute.Assertion.ForCondition(Regex.Match(_commandResult.StdOut, pattern, options).Success) - .FailWith($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine} input: {_commandResult.StdOut}"); + .FailWith(AppendDiagnosticsTo($"Matching the command output failed. Pattern: {pattern}{Environment.NewLine}")); return new AndConstraint(this); } public AndConstraint HaveStdErr() { Execute.Assertion.ForCondition(!string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith("Command did not output anything to stderr"); + .FailWith(AppendDiagnosticsTo("Command did not output anything to stderr.")); return new AndConstraint(this); } public AndConstraint NotHaveStdOut() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdOut)) - .FailWith("Expected command to not output to stdout but found - {0}{1}", Environment.NewLine, _commandResult.StdOut); + .FailWith(AppendDiagnosticsTo($"Expected command to not output to stdout but it was not:")); return new AndConstraint(this); } public AndConstraint NotHaveStdErr() { Execute.Assertion.ForCondition(string.IsNullOrEmpty(_commandResult.StdErr)) - .FailWith("Expected command to not output to stderr but found - {0}{1}", Environment.NewLine, _commandResult.StdErr); + .FailWith(AppendDiagnosticsTo("Expected command to not output to stderr but it was not:")); return new AndConstraint(this); } + + private string AppendDiagnosticsTo(string s) + { + return s + $"{Environment.NewLine}" + + $"File Name: {_commandResult.StartInfo.FileName}{Environment.NewLine}" + + $"Arguments: {_commandResult.StartInfo.Arguments}{Environment.NewLine}" + + $"Exit Code: {_commandResult.ExitCode}{Environment.NewLine}" + + $"StdOut:{Environment.NewLine}{_commandResult.StdOut}{Environment.NewLine}" + + $"StdErr:{Environment.NewLine}{_commandResult.StdErr}{Environment.NewLine}"; ; + } } } diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs index be35cbfca..0b319ed6f 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/Commands/TestCommand.cs @@ -80,6 +80,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities threadErr.Join(); var result = new CommandResult( + process.StartInfo, process.ExitCode, stdOut.GetCapturedOutput(), stdErr.GetCapturedOutput()); diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs index 28b4269c5..0cff5cb32 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/TempFileSystem/TempRoot.cs @@ -10,22 +10,34 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { public sealed class TempRoot : IDisposable { + private static readonly bool DoDispose; private readonly List _temps = new List(); public static readonly string Root; static TempRoot() { - Root = Path.Combine(Path.GetTempPath(), "DotnetCLITests"); + var persistedRoot = Environment.GetEnvironmentVariable("TEST_ARTIFACTS"); + + if (string.IsNullOrWhiteSpace(persistedRoot)) + { + Root = Path.Combine(Path.GetTempPath(), "DotnetCLITests"); + DoDispose = true; + } + else + { + Root = persistedRoot; + DoDispose = false; + } + Directory.CreateDirectory(Root); } public void Dispose() { - if (_temps != null) - { - DisposeAll(_temps); - _temps.Clear(); - } + if (!DoDispose || _temps == null) return; + + DisposeAll(_temps); + _temps.Clear(); } private static void DisposeAll(IEnumerable temps) @@ -34,10 +46,7 @@ namespace Microsoft.DotNet.Tools.Test.Utilities { try { - if (temp != null) - { - temp.Dispose(); - } + temp?.Dispose(); } catch { diff --git a/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json b/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json index f3844f68c..11b5cc46c 100644 --- a/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json +++ b/test/Microsoft.DotNet.Tools.Tests.Utilities/project.json @@ -3,14 +3,8 @@ "description": "Microsoft.DotNet.Tools.Tests.Utilities Class Library", "dependencies": { - "System.Collections": "4.0.11-rc3-23722", + "NETStandard.Library": "1.0.0-rc3-23722", "System.Collections.Immutable": "1.2.0-rc3-23722", - "System.Linq": "4.0.1-rc3-23722", - "System.Threading": "4.0.11-rc3-23722", - "System.IO.FileSystem": "4.0.1-rc3-23722", - "System.IO": "4.0.11-rc3-23722", - "System.Runtime.InteropServices": "4.0.21-rc3-23722", - "System.Text.RegularExpressions": "4.0.11-rc3-23722", "FluentAssertions": "4.0.0", "xunit": "2.1.0", diff --git a/test/TestProjects/TestLibraryWithRunner/project.json b/test/TestProjects/TestLibraryWithRunner/project.json index f02420c93..8f15916b2 100644 --- a/test/TestProjects/TestLibraryWithRunner/project.json +++ b/test/TestProjects/TestLibraryWithRunner/project.json @@ -3,7 +3,7 @@ "testRunner": "xunit", "dependencies": { "Microsoft.Extensions.DependencyModel": "1.0.0-*", - "Newtonsoft.Json": "6.0.0", + "Newtonsoft.Json": "6.0.0" }, "frameworks": { @@ -11,7 +11,7 @@ "dnxcore50": { "imports" : "portable-net45+wp80+win8", "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" } } } diff --git a/test/TestProjects/TestProjectToProjectDependencies/src/L0/project.json b/test/TestProjects/TestProjectToProjectDependencies/src/L0/project.json index 475d4d304..e22aadc22 100644 --- a/test/TestProjects/TestProjectToProjectDependencies/src/L0/project.json +++ b/test/TestProjects/TestProjectToProjectDependencies/src/L0/project.json @@ -8,7 +8,7 @@ "L11": "1.0.0-*", "L12": "1.0.0-*", - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" }, "frameworks": { diff --git a/test/TestProjects/TestProjectToProjectDependencies/src/L11/project.json b/test/TestProjects/TestProjectToProjectDependencies/src/L11/project.json index a9d00a1ae..7b7da385e 100644 --- a/test/TestProjects/TestProjectToProjectDependencies/src/L11/project.json +++ b/test/TestProjects/TestProjectToProjectDependencies/src/L11/project.json @@ -5,7 +5,7 @@ "L12": "1.0.0-*", "L21": "1.0.0-*", - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" }, "frameworks": { diff --git a/test/TestProjects/TestProjectToProjectDependencies/src/L12/project.json b/test/TestProjects/TestProjectToProjectDependencies/src/L12/project.json index 733193c13..f904d6b5c 100644 --- a/test/TestProjects/TestProjectToProjectDependencies/src/L12/project.json +++ b/test/TestProjects/TestProjectToProjectDependencies/src/L12/project.json @@ -4,7 +4,7 @@ "dependencies": { "L22": "1.0.0-*", - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" }, "frameworks": { diff --git a/test/TestProjects/TestProjectToProjectDependencies/src/L21/project.json b/test/TestProjects/TestProjectToProjectDependencies/src/L21/project.json index 3a656a2dd..ab3869b28 100644 --- a/test/TestProjects/TestProjectToProjectDependencies/src/L21/project.json +++ b/test/TestProjects/TestProjectToProjectDependencies/src/L21/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" }, "frameworks": { diff --git a/test/TestProjects/TestProjectToProjectDependencies/src/L22/project.json b/test/TestProjects/TestProjectToProjectDependencies/src/L22/project.json index 3a656a2dd..ab3869b28 100644 --- a/test/TestProjects/TestProjectToProjectDependencies/src/L22/project.json +++ b/test/TestProjects/TestProjectToProjectDependencies/src/L22/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23704" + "NETStandard.Library": "1.0.0-rc3-23722" }, "frameworks": { diff --git a/testapp/DthTestProjects/src/EmptyConsoleApp/project.json b/testapp/DthTestProjects/src/EmptyConsoleApp/project.json index 9cf9e94b2..6467d8f19 100644 --- a/testapp/DthTestProjects/src/EmptyConsoleApp/project.json +++ b/testapp/DthTestProjects/src/EmptyConsoleApp/project.json @@ -3,7 +3,7 @@ "frameworks": { "dnxcore50": { "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23704", + "NETStandard.Library": "1.0.0-rc3-23722", } }, "dnx451": { } diff --git a/tools/MultiProjectValidator/project.json b/tools/MultiProjectValidator/project.json index ad2f17e57..ff96a048e 100644 --- a/tools/MultiProjectValidator/project.json +++ b/tools/MultiProjectValidator/project.json @@ -6,7 +6,7 @@ }, "dependencies": { - "NETStandard.Library": "1.0.0-rc2-23704", + "NETStandard.Library": "1.0.0-rc3-23722", "Microsoft.DotNet.ProjectModel": "1.0.0-*", "Microsoft.DotNet.Cli.Utils": "1.0.0-*" },