From 9ca52ef182dde6a147a6941916137529c0db0089 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Mon, 24 Feb 2014 14:46:06 -0800 Subject: [PATCH 001/463] Initialize repository --- .gitattributes | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ .gitignore | 24 ++++++++++++++++++++++++ NuGet.Config | 13 +++++++++++++ build.cmd | 23 +++++++++++++++++++++++ makefile.shade | 7 +++++++ 5 files changed, 117 insertions(+) create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 NuGet.Config create mode 100644 build.cmd create mode 100644 makefile.shade diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..bdaa5ba9827 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,50 @@ +*.doc diff=astextplain +*.DOC diff=astextplain +*.docx diff=astextplain +*.DOCX diff=astextplain +*.dot diff=astextplain +*.DOT diff=astextplain +*.pdf diff=astextplain +*.PDF diff=astextplain +*.rtf diff=astextplain +*.RTF diff=astextplain + +*.jpg binary +*.png binary +*.gif binary + +*.cs text=auto diff=csharp +*.vb text=auto +*.resx text=auto +*.c text=auto +*.cpp text=auto +*.cxx text=auto +*.h text=auto +*.hxx text=auto +*.py text=auto +*.rb text=auto +*.java text=auto +*.html text=auto +*.htm text=auto +*.css text=auto +*.scss text=auto +*.sass text=auto +*.less text=auto +*.js text=auto +*.lisp text=auto +*.clj text=auto +*.sql text=auto +*.php text=auto +*.lua text=auto +*.m text=auto +*.asm text=auto +*.erl text=auto +*.fs text=auto +*.fsx text=auto +*.hs text=auto + +*.csproj text=auto +*.vbproj text=auto +*.fsproj text=auto +*.dbproj text=auto +*.sln text=auto eol=crlf diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000000..8bc217058d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,24 @@ +[Oo]bj/ +[Bb]in/ +TestResults/ +.nuget/ +_ReSharper.*/ +packages/ +artifacts/ +PublishProfiles/ +*.user +*.suo +*.cache +*.docstates +_ReSharper.* +nuget.exe +*net45.csproj +*k10.csproj +*.psess +*.vsp +*.pidb +*.userprefs +*DS_Store +*.ncrunchsolution +*.*sdf +*.ipch \ No newline at end of file diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 00000000000..a059188b09f --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,13 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/build.cmd b/build.cmd new file mode 100644 index 00000000000..7045ee1f84e --- /dev/null +++ b/build.cmd @@ -0,0 +1,23 @@ +@echo off +cd %~dp0 + +SETLOCAL +SET CACHED_NUGET=%LocalAppData%\NuGet\NuGet.exe + +IF EXIST %CACHED_NUGET% goto copynuget +echo Downloading latest version of NuGet.exe... +IF NOT EXIST %LocalAppData%\NuGet md %LocalAppData%\NuGet +@powershell -NoProfile -ExecutionPolicy unrestricted -Command "$ProgressPreference = 'SilentlyContinue'; Invoke-WebRequest 'https://www.nuget.org/nuget.exe' -OutFile '%CACHED_NUGET%'" + +:copynuget +IF EXIST .nuget\nuget.exe goto restore +md .nuget +copy %CACHED_NUGET% .nuget\nuget.exe > nul + +:restore +IF EXIST packages\KoreBuild goto run +.nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre +.nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion + +:run +packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/makefile.shade b/makefile.shade new file mode 100644 index 00000000000..6357ea2841d --- /dev/null +++ b/makefile.shade @@ -0,0 +1,7 @@ + +var VERSION='0.1' +var FULL_VERSION='0.1' +var AUTHORS='Microsoft' + +use-standard-lifecycle +k-standard-goals From 769349cf3219cbd5d6df9c44e27b118aa860cec6 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 6 Mar 2014 09:31:23 -0800 Subject: [PATCH 002/463] Create README.md --- README.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 00000000000..62940bce0ff --- /dev/null +++ b/README.md @@ -0,0 +1,5 @@ +Testing +======= +This repository contains testing infrastructure for Project K. + +To get started using it, see [How to create test projects]. From fa2dc721d612632b39258897f9d3efdb4da7aa4d Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 6 Mar 2014 09:32:17 -0800 Subject: [PATCH 003/463] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 62940bce0ff..0f0c8e5adda 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,4 @@ Testing ======= This repository contains testing infrastructure for Project K. -To get started using it, see [How to create test projects]. +To get started using it, see [How to create test projects](https://github.com/aspnet/Testing/wiki/How-to-create-test-projects). From 700d774913e9e4cd472492168eb7dabaa444f984 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 27 Feb 2014 13:56:00 -0800 Subject: [PATCH 004/463] Add xUnit.net runner for Project K --- Testing.sln | 62 +++ global.json | 3 + src/Xunit.KRunner/CommandLine.cs | 61 +++ src/Xunit.KRunner/Common/TestOptionsNames.cs | 12 + .../Frameworks/TestFrameworkOptions.cs | 24 ++ .../Frameworks/v2/XunitDiscoveryOptions.cs | 6 + .../Frameworks/v2/XunitExecutionOptions.cs | 17 + src/Xunit.KRunner/Program.cs | 168 ++++++++ src/Xunit.KRunner/Project/XunitProject.cs | 41 ++ .../Project/XunitProjectAssembly.cs | 13 + .../Services/AssemblyNeutralAttribute.cs | 10 + .../Services/IApplicationEnvironment.cs | 13 + src/Xunit.KRunner/Services/IFileMonitor.cs | 10 + src/Xunit.KRunner/Utility/ExecutionSummary.cs | 28 ++ .../Visitors/StandardOutputVisitor.cs | 136 +++++++ src/Xunit.KRunner/Visitors/TeamCityVisitor.cs | 118 ++++++ .../Visitors/TestMessageVisitor.cs | 359 ++++++++++++++++++ .../Visitors/XmlTestExecutionVisitor.cs | 54 +++ src/Xunit.KRunner/project.json | 12 + test/Sample.Tests/SampleTest.cs | 13 + test/Sample.Tests/project.json | 18 + 21 files changed, 1178 insertions(+) create mode 100644 Testing.sln create mode 100644 global.json create mode 100644 src/Xunit.KRunner/CommandLine.cs create mode 100644 src/Xunit.KRunner/Common/TestOptionsNames.cs create mode 100644 src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs create mode 100644 src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs create mode 100644 src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs create mode 100644 src/Xunit.KRunner/Program.cs create mode 100644 src/Xunit.KRunner/Project/XunitProject.cs create mode 100644 src/Xunit.KRunner/Project/XunitProjectAssembly.cs create mode 100644 src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs create mode 100644 src/Xunit.KRunner/Services/IApplicationEnvironment.cs create mode 100644 src/Xunit.KRunner/Services/IFileMonitor.cs create mode 100644 src/Xunit.KRunner/Utility/ExecutionSummary.cs create mode 100644 src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs create mode 100644 src/Xunit.KRunner/Visitors/TeamCityVisitor.cs create mode 100644 src/Xunit.KRunner/Visitors/TestMessageVisitor.cs create mode 100644 src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs create mode 100644 src/Xunit.KRunner/project.json create mode 100644 test/Sample.Tests/SampleTest.cs create mode 100644 test/Sample.Tests/project.json diff --git a/Testing.sln b/Testing.sln new file mode 100644 index 00000000000..84586588da3 --- /dev/null +++ b/Testing.sln @@ -0,0 +1,62 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2013 +VisualStudioVersion = 12.0.30110.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{D2EDB163-538E-47C3-A8E5-0633FBC9D668}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.KRunner.net45", "src\Xunit.KRunner\Xunit.KRunner.net45.csproj", "{C9D4238C-63BD-4277-A240-9F61647EA884}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{09F799F3-E521-466F-B155-B89E2746C8C9}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{9D51B712-05C0-499D-BE81-0395142837A0}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Tests.net45", "test\Sample.Tests\Sample.Tests.net45.csproj", "{69FBE3CD-3381-4C54-A323-5A724E8A7B4F}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{A345517E-DA14-47AC-B514-54E97D179E97}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.KRunner.k10", "src\Xunit.KRunner\Xunit.KRunner.k10.csproj", "{DDC3C708-5EF4-48B9-BBFF-63AE727A7949}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Tests.k10", "test\Sample.Tests\Sample.Tests.k10.csproj", "{9902DB70-F3E0-42D6-A0DA-585E4091D781}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C9D4238C-63BD-4277-A240-9F61647EA884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9D4238C-63BD-4277-A240-9F61647EA884}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9D4238C-63BD-4277-A240-9F61647EA884}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9D4238C-63BD-4277-A240-9F61647EA884}.Release|Any CPU.Build.0 = Release|Any CPU + {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Release|Any CPU.Build.0 = Release|Any CPU + {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Release|Any CPU.Build.0 = Release|Any CPU + {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {D2EDB163-538E-47C3-A8E5-0633FBC9D668} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {A345517E-DA14-47AC-B514-54E97D179E97} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {C9D4238C-63BD-4277-A240-9F61647EA884} = {D2EDB163-538E-47C3-A8E5-0633FBC9D668} + {9D51B712-05C0-499D-BE81-0395142837A0} = {09F799F3-E521-466F-B155-B89E2746C8C9} + {FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02} = {09F799F3-E521-466F-B155-B89E2746C8C9} + {69FBE3CD-3381-4C54-A323-5A724E8A7B4F} = {9D51B712-05C0-499D-BE81-0395142837A0} + {DDC3C708-5EF4-48B9-BBFF-63AE727A7949} = {A345517E-DA14-47AC-B514-54E97D179E97} + {9902DB70-F3E0-42D6-A0DA-585E4091D781} = {FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02} + EndGlobalSection +EndGlobal diff --git a/global.json b/global.json new file mode 100644 index 00000000000..840c36f6ade --- /dev/null +++ b/global.json @@ -0,0 +1,3 @@ +{ + "sources": ["src"] +} \ No newline at end of file diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs new file mode 100644 index 00000000000..32cd702a50b --- /dev/null +++ b/src/Xunit.KRunner/CommandLine.cs @@ -0,0 +1,61 @@ +using System; +using System.Collections.Generic; + +namespace Xunit.ConsoleClient +{ + public class CommandLine + { + readonly Stack arguments = new Stack(); + + protected CommandLine(string[] args) + { + for (int i = args.Length - 1; i >= 0; i--) + arguments.Push(args[i]); + + TeamCity = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; + Parse(); + } + + public bool TeamCity { get; protected set; } + + static void GuardNoOptionValue(KeyValuePair option) + { + if (option.Value != null) + throw new ArgumentException(String.Format("error: unknown command line option: {0}", option.Value)); + } + + public static CommandLine Parse(params string[] args) + { + return new CommandLine(args); + } + + protected virtual void Parse() + { + while (arguments.Count > 0) + { + KeyValuePair option = PopOption(arguments); + string optionName = option.Key.ToLowerInvariant(); + + if (!optionName.StartsWith("-")) + throw new ArgumentException(String.Format("unknown command line option: {0}", option.Key)); + + if (optionName == "-teamcity") + { + GuardNoOptionValue(option); + TeamCity = true; + } + } + } + + static KeyValuePair PopOption(Stack arguments) + { + string option = arguments.Pop(); + string value = null; + + if (arguments.Count > 0 && !arguments.Peek().StartsWith("/")) + value = arguments.Pop(); + + return new KeyValuePair(option, value); + } + } +} diff --git a/src/Xunit.KRunner/Common/TestOptionsNames.cs b/src/Xunit.KRunner/Common/TestOptionsNames.cs new file mode 100644 index 00000000000..69d2cd2fa2f --- /dev/null +++ b/src/Xunit.KRunner/Common/TestOptionsNames.cs @@ -0,0 +1,12 @@ +internal static class TestOptionsNames +{ + internal static class Discovery + { + } + + internal static class Execution + { + public static readonly string DisableParallelization = "xunit2.DisableParallelization"; + public static readonly string MaxParallelThreads = "xunit2.MaxParallelThreads"; + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs new file mode 100644 index 00000000000..77593acea8c --- /dev/null +++ b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs @@ -0,0 +1,24 @@ +using System.Collections.Generic; +using Xunit.Abstractions; + +namespace Xunit +{ + public class TestFrameworkOptions : ITestFrameworkOptions + { + readonly Dictionary properties = new Dictionary(); + + public TValue GetValue(string name, TValue defaultValue) + { + object result; + if (properties.TryGetValue(name, out result)) + return (TValue)result; + + return defaultValue; + } + + public void SetValue(string name, TValue value) + { + properties[name] = value; + } + } +} diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs new file mode 100644 index 00000000000..bb7b94d7e1c --- /dev/null +++ b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs @@ -0,0 +1,6 @@ +namespace Xunit +{ + public class XunitDiscoveryOptions : TestFrameworkOptions + { + } +} diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs new file mode 100644 index 00000000000..a65ed4102e0 --- /dev/null +++ b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs @@ -0,0 +1,17 @@ +namespace Xunit +{ + public class XunitExecutionOptions : TestFrameworkOptions + { + public bool DisableParallelization + { + get { return GetValue(TestOptionsNames.Execution.DisableParallelization, false); } + set { SetValue(TestOptionsNames.Execution.DisableParallelization, value); } + } + + public int MaxParallelThreads + { + get { return GetValue(TestOptionsNames.Execution.MaxParallelThreads, 0); } + set { SetValue(TestOptionsNames.Execution.MaxParallelThreads, value); } + } + } +} diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs new file mode 100644 index 00000000000..d4c880f01ad --- /dev/null +++ b/src/Xunit.KRunner/Program.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Concurrent; +using System.Diagnostics; +using System.Linq; +using Microsoft.Net.Runtime; +using Xunit.ConsoleClient; + +namespace Xunit.KRunner +{ + internal class Program + { + private volatile bool cancel; + private readonly ConcurrentDictionary completionMessages = + new ConcurrentDictionary(); + private readonly IApplicationEnvironment _environment; + private readonly IFileMonitor _fileMonitor; + + public Program(IApplicationEnvironment environment, IFileMonitor fileMonitor) + { + _environment = environment; + _fileMonitor = fileMonitor; + } + + private int Main(string[] args) + { + Console.WriteLine( + "xUnit.net Project K test runner ({0}-bit {1} {2})", + IntPtr.Size * 8, + _environment.TargetFramework.Identifier, + _environment.TargetFramework.Version); + Console.WriteLine("Copyright (C) 2014 Outercurve Foundation, Microsoft Open Technologies, Inc."); + Console.WriteLine(); + + if (args.Length > 0 && args[0] == "-?") + { + PrintUsage(); + return 1; + } + + AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; +#if NET45 + Console.CancelKeyPress += (sender, e) => + { + if (!cancel) + { + Console.WriteLine("Canceling... (Press Ctrl+C again to terminate)"); + cancel = true; + e.Cancel = true; + } + }; + _fileMonitor.OnChanged += _ => Environment.Exit(-409); +#else + _fileMonitor.OnChanged += _ => Process.GetCurrentProcess().Kill(); +#endif + + try + { + var commandLine = CommandLine.Parse(args); + + int failCount = RunProject(commandLine.TeamCity); + + return failCount; + } + catch (ArgumentException ex) + { + Console.WriteLine(); + Console.WriteLine("error: {0}", ex.Message); + return 1; + } + catch (BadImageFormatException ex) + { + Console.WriteLine(); + Console.WriteLine("{0}", ex.Message); + return 1; + } + } + + private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) + { + var ex = e.ExceptionObject as Exception; + + if (ex != null) + Console.WriteLine(ex.ToString()); + else + Console.WriteLine("Error of unknown type thrown in application domain"); + +#if NET45 + Environment.Exit(1); +#else + Process.GetCurrentProcess().Kill(); +#endif + } + + private static void PrintUsage() + { + Console.WriteLine("usage: Xunit.KRunner [options]"); + Console.WriteLine(); + Console.WriteLine("Valid options:"); + Console.WriteLine(" -teamcity : forces TeamCity mode (normally auto-detected)"); + } + + private int RunProject(bool teamcity) + { + var consoleLock = new object(); + + ExecuteAssembly(consoleLock, _environment.ApplicationName, teamcity); + + if (completionMessages.Count > 0) + { + Console.WriteLine(); + Console.WriteLine("=== TEST EXECUTION SUMMARY ==="); + int longestAssemblyName = completionMessages.Keys.Max(key => key.Length); + int longestTotal = completionMessages.Values.Max(summary => summary.Total.ToString().Length); + int longestFailed = completionMessages.Values.Max(summary => summary.Failed.ToString().Length); + int longestSkipped = completionMessages.Values.Max(summary => summary.Skipped.ToString().Length); + int longestTime = completionMessages.Values.Max(summary => summary.Time.ToString("0.000s").Length); + + foreach (var message in completionMessages.OrderBy(m => m.Key)) + Console.WriteLine(" {0} Total: {1}, Failed: {2}, Skipped: {3}, Time: {4}", + message.Key.PadRight(longestAssemblyName), + message.Value.Total.ToString().PadLeft(longestTotal), + message.Value.Failed.ToString().PadLeft(longestFailed), + message.Value.Skipped.ToString().PadLeft(longestSkipped), + message.Value.Time.ToString("0.000s").PadLeft(longestTime)); + } + + return completionMessages.Values.Sum(summary => summary.Failed); + } + + private XmlTestExecutionVisitor CreateVisitor(object consoleLock, bool teamCity) + { + if (teamCity) + return new TeamCityVisitor(() => cancel); + + return new StandardOutputVisitor(consoleLock, () => cancel, completionMessages); + } + + private void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity) + { + if (cancel) + return; + + try + { + var framework = new Xunit.Sdk.XunitTestFramework(); + var executor = framework.GetExecutor(assemblyName); + + var resultsVisitor = CreateVisitor(consoleLock, teamCity); + executor.Run(resultsVisitor, new XunitDiscoveryOptions(), new XunitExecutionOptions()); + resultsVisitor.Finished.WaitOne(); + } + catch (Exception ex) + { + var e = ex; + + while (e != null) + { + Console.WriteLine("{0}: {1}", e.GetType().FullName, e.Message); + + foreach (string stackLine in e.StackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) + Console.WriteLine(stackLine); + + e = e.InnerException; + } + } + } + } +} diff --git a/src/Xunit.KRunner/Project/XunitProject.cs b/src/Xunit.KRunner/Project/XunitProject.cs new file mode 100644 index 00000000000..7be8c4c9ec0 --- /dev/null +++ b/src/Xunit.KRunner/Project/XunitProject.cs @@ -0,0 +1,41 @@ +using System; +using System.Collections.Generic; + +namespace Xunit +{ + /// + /// Represents an xUnit.net Test Project file (.xunit file) + /// + public class XunitProject + { + readonly List assemblies; + + /// + /// Initializes a new instance of the class. + /// + public XunitProject() + { + assemblies = new List(); + } + + /// + /// Gets or sets the assemblies in the project. + /// + public IEnumerable Assemblies + { + get { return assemblies; } + } + + /// + /// Adds an assembly to the project + /// + /// The assembly to be added + public void AddAssembly(XunitProjectAssembly assembly) + { + if (assembly == null) + throw new ArgumentNullException("assembly"); + + assemblies.Add(assembly); + } + } +} diff --git a/src/Xunit.KRunner/Project/XunitProjectAssembly.cs b/src/Xunit.KRunner/Project/XunitProjectAssembly.cs new file mode 100644 index 00000000000..1f8a0f5400b --- /dev/null +++ b/src/Xunit.KRunner/Project/XunitProjectAssembly.cs @@ -0,0 +1,13 @@ +namespace Xunit +{ + /// + /// Represents an assembly in an . + /// + public class XunitProjectAssembly + { + /// + /// Gets or sets the assembly name. + /// + public string AssemblyName { get; set; } + } +} diff --git a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs new file mode 100644 index 00000000000..2191d5198de --- /dev/null +++ b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs @@ -0,0 +1,10 @@ +using System; + +namespace Microsoft.Net.Runtime +{ + [AssemblyNeutral] + [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] + public sealed class AssemblyNeutralAttribute : Attribute + { + } +} diff --git a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs new file mode 100644 index 00000000000..c7514da6ef3 --- /dev/null +++ b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs @@ -0,0 +1,13 @@ +using System.Runtime.Versioning; + +namespace Microsoft.Net.Runtime +{ + [AssemblyNeutral] + public interface IApplicationEnvironment + { + string ApplicationName { get; } + string Version { get; } + string ApplicationBasePath { get; } + FrameworkName TargetFramework { get; } + } +} diff --git a/src/Xunit.KRunner/Services/IFileMonitor.cs b/src/Xunit.KRunner/Services/IFileMonitor.cs new file mode 100644 index 00000000000..dfff6c85087 --- /dev/null +++ b/src/Xunit.KRunner/Services/IFileMonitor.cs @@ -0,0 +1,10 @@ +using System; + +namespace Microsoft.Net.Runtime +{ + [AssemblyNeutral] + public interface IFileMonitor + { + event Action OnChanged; + } +} diff --git a/src/Xunit.KRunner/Utility/ExecutionSummary.cs b/src/Xunit.KRunner/Utility/ExecutionSummary.cs new file mode 100644 index 00000000000..d6e5bddd98f --- /dev/null +++ b/src/Xunit.KRunner/Utility/ExecutionSummary.cs @@ -0,0 +1,28 @@ +namespace Xunit +{ + /// + /// Collects execution totals for a group of test cases. + /// + public class ExecutionSummary + { + /// + /// Gets or set the total number of tests run. + /// + public int Total { get; set; } + + /// + /// Gets or sets the number of failed tests. + /// + public int Failed { get; set; } + + /// + /// Gets or sets the number of skipped tests. + /// + public int Skipped { get; set; } + + /// + /// Gets or sets the total execution time for the tests. + /// + public decimal Time { get; set; } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs new file mode 100644 index 00000000000..70521ccda27 --- /dev/null +++ b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs @@ -0,0 +1,136 @@ +using System; +using System.Collections.Concurrent; +using Xunit.Abstractions; + +namespace Xunit.ConsoleClient +{ + public class StandardOutputVisitor : XmlTestExecutionVisitor + { + string assemblyName; + readonly object consoleLock; + readonly ConcurrentDictionary completionMessages; + + public StandardOutputVisitor(object consoleLock, + Func cancelThunk, + ConcurrentDictionary completionMessages = null) + : base(cancelThunk) + { + this.consoleLock = consoleLock; + this.completionMessages = completionMessages; + } + + protected override bool Visit(ITestAssemblyStarting assemblyStarting) + { + assemblyName = assemblyStarting.AssemblyFileName; + + lock (consoleLock) + Console.WriteLine("Starting: {0}", assemblyName); + + return base.Visit(assemblyStarting); + } + + protected override bool Visit(ITestAssemblyFinished assemblyFinished) + { + // Base class does computation of results, so call it first. + var result = base.Visit(assemblyFinished); + + lock (consoleLock) + Console.WriteLine("Finished: {0}", assemblyName); + + if (completionMessages != null) + completionMessages.TryAdd(assemblyName, new ExecutionSummary + { + Total = assemblyFinished.TestsRun, + Failed = assemblyFinished.TestsFailed, + Skipped = assemblyFinished.TestsSkipped, + Time = assemblyFinished.ExecutionTime + }); + + return result; + } + + protected override bool Visit(IErrorMessage error) + { + lock (consoleLock) + { +#if NET45 + Console.ForegroundColor = ConsoleColor.Red; +#endif + Console.Error.WriteLine(" {0} [FATAL]", Escape(error.ExceptionType)); +#if NET45 + Console.ForegroundColor = ConsoleColor.Gray; +#endif + Console.Error.WriteLine(" {0}", Escape(error.Message)); + + WriteStackTrace(error.StackTrace); + } + + return base.Visit(error); + } + + protected override bool Visit(ITestFailed testFailed) + { + lock (consoleLock) + { + // TODO: Thread-safe way to figure out the default foreground color +#if NET45 + Console.ForegroundColor = ConsoleColor.Red; +#endif + Console.Error.WriteLine(" {0} [FAIL]", Escape(testFailed.TestDisplayName)); +#if NET45 + Console.ForegroundColor = ConsoleColor.Gray; +#endif + Console.Error.WriteLine(" {0}", Escape(testFailed.Message)); + + WriteStackTrace(testFailed.StackTrace); + } + + return base.Visit(testFailed); + } + + protected override bool Visit(ITestPassed testPassed) + { + return base.Visit(testPassed); + } + + protected override bool Visit(ITestSkipped testSkipped) + { + lock (consoleLock) + { + // TODO: Thread-safe way to figure out the default foreground color +#if NET45 + Console.ForegroundColor = ConsoleColor.Yellow; +#endif + Console.Error.WriteLine(" {0} [SKIP]", Escape(testSkipped.TestDisplayName)); +#if NET45 + Console.ForegroundColor = ConsoleColor.Gray; +#endif + Console.Error.WriteLine(" {0}", Escape(testSkipped.Reason)); + } + + return base.Visit(testSkipped); + } + + protected override bool Visit(ITestStarting testStarting) + { + return base.Visit(testStarting); + } + + void WriteStackTrace(string stackTrace) + { + if (String.IsNullOrWhiteSpace(stackTrace)) + return; + +#if NET45 + Console.ForegroundColor = ConsoleColor.DarkGray; +#endif + Console.Error.WriteLine(" Stack Trace:"); + +#if NET45 + Console.ForegroundColor = ConsoleColor.Gray; +#endif + foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) + Console.Error.WriteLine(" {0}", stackFrame); + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs new file mode 100644 index 00000000000..2c351767b37 --- /dev/null +++ b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs @@ -0,0 +1,118 @@ +using System; +using System.Collections.Concurrent; +using Xunit.Abstractions; + +namespace Xunit.ConsoleClient +{ + public class TeamCityVisitor : XmlTestExecutionVisitor + { + readonly ConcurrentDictionary flowMappings = new ConcurrentDictionary(); + readonly Func flowIdMapper; + + public TeamCityVisitor(Func cancelThunk) + : this(cancelThunk, _ => Guid.NewGuid().ToString("N")) { } + + public TeamCityVisitor(Func cancelThunk, Func flowIdMapper) + : base(cancelThunk) + { + this.flowIdMapper = flowIdMapper; + } + + void LogFinish(ITestResultMessage testResult) + { + Console.WriteLine("##teamcity[testFinished name='{0}' duration='{1}' flowId='{2}']", + TeamCityEscape(testResult.TestDisplayName), + (int)(testResult.ExecutionTime * 1000M), + ToFlowId(testResult.TestCollection.DisplayName)); + } + + protected override bool Visit(IErrorMessage error) + { + Console.Error.WriteLine("{0}: {1}", error.ExceptionType, Escape(error.Message)); + Console.Error.WriteLine(error.StackTrace); + + return base.Visit(error); + } + + protected override bool Visit(ITestCollectionFinished testCollectionFinished) + { + // Base class does computation of results, so call it first. + var result = base.Visit(testCollectionFinished); + + Console.WriteLine("##teamcity[testSuiteFinished name='{0}' flowId='{1}']", + TeamCityEscape(testCollectionFinished.TestCollection.DisplayName), + ToFlowId(testCollectionFinished.TestCollection.DisplayName)); + + return result; + } + + protected override bool Visit(ITestCollectionStarting testCollectionStarting) + { + Console.WriteLine("##teamcity[testSuiteStarted name='{0}' flowId='{1}']", + TeamCityEscape(testCollectionStarting.TestCollection.DisplayName), + ToFlowId(testCollectionStarting.TestCollection.DisplayName)); + + return base.Visit(testCollectionStarting); + } + + protected override bool Visit(ITestFailed testFailed) + { + Console.WriteLine("##teamcity[testFailed name='{0}' details='{1}|r|n{2}' flowId='{3}']", + TeamCityEscape(testFailed.TestDisplayName), + TeamCityEscape(testFailed.Message), + TeamCityEscape(testFailed.StackTrace), + ToFlowId(testFailed.TestCollection.DisplayName)); + LogFinish(testFailed); + + return base.Visit(testFailed); + } + + protected override bool Visit(ITestPassed testPassed) + { + LogFinish(testPassed); + + return base.Visit(testPassed); + } + + protected override bool Visit(ITestSkipped testSkipped) + { + Console.WriteLine("##teamcity[testIgnored name='{0}' message='{1}' flowId='{2}']", + TeamCityEscape(testSkipped.TestDisplayName), + TeamCityEscape(testSkipped.Reason), + ToFlowId(testSkipped.TestCollection.DisplayName)); + LogFinish(testSkipped); + + return base.Visit(testSkipped); + } + + protected override bool Visit(ITestStarting testStarting) + { + Console.WriteLine("##teamcity[testStarted name='{0}' flowId='{1}']", + TeamCityEscape(testStarting.TestDisplayName), + ToFlowId(testStarting.TestCollection.DisplayName)); + + return base.Visit(testStarting); + } + + static string TeamCityEscape(string value) + { + if (value == null) + return String.Empty; + + return value.Replace("|", "||") + .Replace("'", "|'") + .Replace("\r", "|r") + .Replace("\n", "|n") + .Replace("]", "|]") + .Replace("[", "|[") + .Replace("\u0085", "|x") + .Replace("\u2028", "|l") + .Replace("\u2029", "|p"); + } + + string ToFlowId(string testCollectionName) + { + return flowMappings.GetOrAdd(testCollectionName, flowIdMapper); + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs new file mode 100644 index 00000000000..0c8017cb7a3 --- /dev/null +++ b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs @@ -0,0 +1,359 @@ +using System; +using System.Threading; +using Xunit.Abstractions; + +namespace Xunit +{ + /// + /// An implementation of that provides several Visit methods that + /// can provide access to specific message types without the burden of casting. + /// + public class TestMessageVisitor : IMessageSink + { + bool DoVisit(IMessageSinkMessage message, Func callback) + where TMessage : class, IMessageSinkMessage + { + TMessage castMessage = message as TMessage; + if (castMessage != null) + return callback(castMessage); + + return true; + } + + /// + public virtual bool OnMessage(IMessageSinkMessage message) + { + return + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit) && + DoVisit(message, Visit); + } + + public virtual void Dispose() + { + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(IAfterTestFinished afterTestFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(IAfterTestStarting afterTestStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(IBeforeTestFinished beforeTestFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(IBeforeTestStarting beforeTestStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue discovering tests; false otherwise. + protected virtual bool Visit(IDiscoveryCompleteMessage discoveryComplete) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(IErrorMessage error) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestAssemblyFinished assemblyFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestAssemblyStarting assemblyStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue discovering tests; false otherwise. + protected virtual bool Visit(ITestCaseDiscoveryMessage testCaseDiscovered) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestCaseFinished testCaseFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestCaseStarting testCaseStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestClassConstructionFinished testClassConstructionFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestClassConstructionStarting testClassConstructionStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestClassDisposeFinished testClassDisposedFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestClassDisposeStarting testClassDisposeStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestClassFinished testClassFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestClassStarting testClassStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestCollectionFinished testCollectionFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestCollectionStarting testCollectionStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestFailed testFailed) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestFinished testFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestMethodFinished testMethodFinished) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestMethodStarting testMethodStarting) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestPassed testPassed) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestSkipped testSkipped) + { + return true; + } + + /// + /// Called when an instance of is sent to the message sink. + /// + /// The message. + /// Return true to continue executing tests; false otherwise. + protected virtual bool Visit(ITestStarting testStarting) + { + return true; + } + } + + /// + /// An implementation of that provides several Visit methods that + /// can provide access to specific message types without the burden of casting. It also record + /// when it sees a completion message, and sets the event appropriately. + /// + /// The type of the completion message. + public class TestMessageVisitor : TestMessageVisitor + where TCompleteMessage : IMessageSinkMessage + { + /// + /// Initializes a new instance of the class. + /// + public TestMessageVisitor() + { + Finished = new ManualResetEvent(initialState: false); + } + + /// + /// This event is trigged when the completion message has been seen. + /// + public ManualResetEvent Finished { get; private set; } + + /// + public override void Dispose() + { + ((IDisposable)Finished).Dispose(); + } + + /// + public override bool OnMessage(IMessageSinkMessage message) + { + var result = base.OnMessage(message); + + if (message is TCompleteMessage) + Finished.Set(); + + return result; + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs new file mode 100644 index 00000000000..4f3fc338265 --- /dev/null +++ b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs @@ -0,0 +1,54 @@ +using System; +using Xunit.Abstractions; + +namespace Xunit +{ + public class XmlTestExecutionVisitor : TestMessageVisitor + { + public XmlTestExecutionVisitor(Func cancelThunk) + { + CancelThunk = cancelThunk ?? (() => false); + } + + public readonly Func CancelThunk; + public int Failed; + public int Skipped; + public decimal Time; + public int Total; + + public override bool OnMessage(IMessageSinkMessage message) + { + var result = base.OnMessage(message); + if (result) + result = !CancelThunk(); + + return result; + } + + protected override bool Visit(ITestAssemblyFinished assemblyFinished) + { + Total += assemblyFinished.TestsRun; + Failed += assemblyFinished.TestsFailed; + Skipped += assemblyFinished.TestsSkipped; + Time += assemblyFinished.ExecutionTime; + + return base.Visit(assemblyFinished); + } + + protected static string Escape(string value) + { + if (value == null) + return String.Empty; + + return value.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\0", "\\0"); + } + + protected static string XmlEscape(string value) + { + if (value == null) + return String.Empty; + + return value.Replace("\0", "\\0"); + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json new file mode 100644 index 00000000000..3398a1e1d86 --- /dev/null +++ b/src/Xunit.KRunner/project.json @@ -0,0 +1,12 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "System.Runtime": "", + "xunit2": "0.1-alpha-*", + "xunit.abstractions": "3.0.0-alpha-*" + }, + "configurations": { + "net45": {}, + "k10": {} + } +} \ No newline at end of file diff --git a/test/Sample.Tests/SampleTest.cs b/test/Sample.Tests/SampleTest.cs new file mode 100644 index 00000000000..b90f6faa2f3 --- /dev/null +++ b/test/Sample.Tests/SampleTest.cs @@ -0,0 +1,13 @@ +using Xunit; + +namespace Sample.Tests +{ + public class SampleTest + { + [Fact] + public void True_is_true() + { + Assert.True(true); + } + } +} \ No newline at end of file diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json new file mode 100644 index 00000000000..ca111702d02 --- /dev/null +++ b/test/Sample.Tests/project.json @@ -0,0 +1,18 @@ +{ + "dependencies": { + "Xunit.KRunner": "", + "xunit2": "0.1-alpha-*", + "xunit2.assert": "0.1-alpha-*" + }, + "commands": { + "test": "Xunit.KRunner" + }, + "configurations": { + "net45": { + "dependencies": { + "System.Runtime": "" + } + }, + "k10": {} + } +} \ No newline at end of file From 26246e2d3e0f82003488fb854cf2168469dc0203 Mon Sep 17 00:00:00 2001 From: dougbu Date: Sun, 9 Mar 2014 00:52:29 -0800 Subject: [PATCH 005/463] Add required K dependencies - Also reformat project.json files --- src/Xunit.KRunner/project.json | 31 +++++++++++++++++++------- test/Sample.Tests/project.json | 40 ++++++++++++++++++++++------------ 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 3398a1e1d86..7495474989e 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,12 +1,27 @@ { - "version": "0.1-alpha-*", - "dependencies": { - "System.Runtime": "", - "xunit2": "0.1-alpha-*", - "xunit.abstractions": "3.0.0-alpha-*" + "version": "0.1-alpha-*", + "dependencies": { + "xunit2": "0.1-alpha-*", + "xunit.abstractions": "3.0.0-alpha-*" + }, + "configurations": { + "net45": { + "dependencies": { + "System.Runtime": "" + } }, - "configurations": { - "net45": {}, - "k10": {} + "k10": { + "dependencies": { + "System.Collections": "4.0.0.0", + "System.Collections.Concurrent": "4.0.0.0", + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0", + "System.Linq": "4.0.0.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0", + "System.Runtime.Hosting": "3.9.0.0", + "System.Threading": "4.0.0.0" + } } + } } \ No newline at end of file diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index ca111702d02..4b290237dd7 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,18 +1,30 @@ { - "dependencies": { - "Xunit.KRunner": "", - "xunit2": "0.1-alpha-*", - "xunit2.assert": "0.1-alpha-*" + "dependencies": { + "Xunit.KRunner": "", + "xunit2": "0.1-alpha-*", + "xunit2.assert": "0.1-alpha-*" + }, + "commands": { + "test": "Xunit.KRunner" + }, + "configurations": { + "net45": { + "dependencies": { + "System.Runtime": "" + } }, - "commands": { - "test": "Xunit.KRunner" - }, - "configurations": { - "net45": { - "dependencies": { - "System.Runtime": "" - } - }, - "k10": {} + "k10": { + "dependencies": { + "System.Collections": "4.0.0.0", + "System.Collections.Concurrent": "4.0.0.0", + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0", + "System.Linq": "4.0.0.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0", + "System.Runtime.Hosting": "3.9.0.0", + "System.Threading": "4.0.0.0" + } } + } } \ No newline at end of file From fce4683b70c01cb777894fc4bce4f8e22371df61 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Mon, 10 Mar 2014 15:51:36 -0700 Subject: [PATCH 006/463] Terminate on unhanded exception during test execution --- src/Xunit.KRunner/Program.cs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index d4c880f01ad..f7f1884398b 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Concurrent; -using System.Diagnostics; using System.Linq; using Microsoft.Net.Runtime; using Xunit.ConsoleClient; +#if !NET45 +using System.Diagnostics; +#endif namespace Xunit.KRunner { @@ -84,7 +86,7 @@ private static void OnUnhandledException(object sender, UnhandledExceptionEventA else Console.WriteLine("Error of unknown type thrown in application domain"); -#if NET45 +#if NET45 Environment.Exit(1); #else Process.GetCurrentProcess().Kill(); @@ -162,6 +164,12 @@ private void ExecuteAssembly(object consoleLock, string assemblyName, bool teamC e = e.InnerException; } + +#if NET45 + Environment.Exit(1); +#else + Process.GetCurrentProcess().Kill(); +#endif } } } From 18c31eb1418162dee5df28bee3cf9d170d403a9b Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Sun, 9 Mar 2014 21:36:02 -0700 Subject: [PATCH 007/463] React to xunit changes --- src/Xunit.KRunner/project.json | 11 ++++------- test/Sample.Tests/project.json | 10 +++------- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 7495474989e..0a2853639f5 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,21 +1,18 @@ { "version": "0.1-alpha-*", "dependencies": { - "xunit2": "0.1-alpha-*", - "xunit.abstractions": "3.0.0-alpha-*" + "xunit.abstractions": "2.0.0-k-*", + "xunit.execution": "2.0.0-k-*" }, "configurations": { - "net45": { - "dependencies": { - "System.Runtime": "" - } - }, + "net45": {}, "k10": { "dependencies": { "System.Collections": "4.0.0.0", "System.Collections.Concurrent": "4.0.0.0", "System.Console": "4.0.0.0", "System.Diagnostics.Process": "4.0.0.0", + "System.IO": "4.0.0.0", "System.Linq": "4.0.0.0", "System.Runtime": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 4b290237dd7..90dd294d6f7 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,18 +1,14 @@ { "dependencies": { "Xunit.KRunner": "", - "xunit2": "0.1-alpha-*", - "xunit2.assert": "0.1-alpha-*" + "xunit.core": "2.0.0-k-*", + "xunit.assert": "2.0.0-k-*" }, "commands": { "test": "Xunit.KRunner" }, "configurations": { - "net45": { - "dependencies": { - "System.Runtime": "" - } - }, + "net45": {}, "k10": { "dependencies": { "System.Collections": "4.0.0.0", From c814515a02bd6fd18f1cd932b16f5463398980b3 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Mon, 10 Mar 2014 11:31:15 -0700 Subject: [PATCH 008/463] Use renamed packages --- src/Xunit.KRunner/project.json | 10 +++++++--- test/Sample.Tests/project.json | 12 +++++++++--- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 0a2853639f5..ceb068d12c0 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,11 +1,15 @@ { "version": "0.1-alpha-*", "dependencies": { - "xunit.abstractions": "2.0.0-k-*", - "xunit.execution": "2.0.0-k-*" + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" }, "configurations": { - "net45": {}, + "net45": { + "dependencies": { + "System.Runtime": "" + } + }, "k10": { "dependencies": { "System.Collections": "4.0.0.0", diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 90dd294d6f7..ac333c21116 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,14 +1,20 @@ { "dependencies": { "Xunit.KRunner": "", - "xunit.core": "2.0.0-k-*", - "xunit.assert": "2.0.0-k-*" + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" }, "commands": { "test": "Xunit.KRunner" }, "configurations": { - "net45": {}, + "net45": { + "dependencies": { + "System.Runtime": "" + } + }, "k10": { "dependencies": { "System.Collections": "4.0.0.0", From 7f1a0f226321a99d019c5940e6abf98c6a93e4d1 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 12 Mar 2014 11:21:56 -0700 Subject: [PATCH 009/463] Remove unused references in test project --- test/Sample.Tests/project.json | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index ac333c21116..d3e427099b8 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -17,15 +17,7 @@ }, "k10": { "dependencies": { - "System.Collections": "4.0.0.0", - "System.Collections.Concurrent": "4.0.0.0", - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0", - "System.Linq": "4.0.0.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0", - "System.Runtime.Hosting": "3.9.0.0", - "System.Threading": "4.0.0.0" + "System.Runtime": "4.0.20.0" } } } From 2a76121c8fe0b7596131df348dd2c7987ee6b239 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Thu, 13 Mar 2014 15:00:07 -0700 Subject: [PATCH 010/463] Add ExceptionAssert to new shared testing component --- Testing.sln | 16 +- .../ExceptionAssertions.cs | 163 ++++++++++++++++++ src/Microsoft.AspNet.Testing/project.json | 35 ++++ 3 files changed, 213 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.Testing/ExceptionAssertions.cs create mode 100644 src/Microsoft.AspNet.Testing/project.json diff --git a/Testing.sln b/Testing.sln index 84586588da3..0fb8354fc30 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 2013 -VisualStudioVersion = 12.0.30110.0 +VisualStudioVersion = 12.0.21005.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -23,6 +23,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{FDE66C09-CED EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Tests.k10", "test\Sample.Tests\Sample.Tests.k10.csproj", "{9902DB70-F3E0-42D6-A0DA-585E4091D781}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Testing.net45", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.net45.csproj", "{EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Testing.k10", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.k10.csproj", "{817A11AB-E345-4921-B870-72817E70BD3D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +49,14 @@ Global {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Debug|Any CPU.Build.0 = Debug|Any CPU {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Release|Any CPU.ActiveCfg = Release|Any CPU {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Release|Any CPU.Build.0 = Release|Any CPU + {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Release|Any CPU.Build.0 = Release|Any CPU + {817A11AB-E345-4921-B870-72817E70BD3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {817A11AB-E345-4921-B870-72817E70BD3D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {817A11AB-E345-4921-B870-72817E70BD3D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {817A11AB-E345-4921-B870-72817E70BD3D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -53,10 +65,12 @@ Global {D2EDB163-538E-47C3-A8E5-0633FBC9D668} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {A345517E-DA14-47AC-B514-54E97D179E97} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {C9D4238C-63BD-4277-A240-9F61647EA884} = {D2EDB163-538E-47C3-A8E5-0633FBC9D668} + {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F} = {D2EDB163-538E-47C3-A8E5-0633FBC9D668} {9D51B712-05C0-499D-BE81-0395142837A0} = {09F799F3-E521-466F-B155-B89E2746C8C9} {FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02} = {09F799F3-E521-466F-B155-B89E2746C8C9} {69FBE3CD-3381-4C54-A323-5A724E8A7B4F} = {9D51B712-05C0-499D-BE81-0395142837A0} {DDC3C708-5EF4-48B9-BBFF-63AE727A7949} = {A345517E-DA14-47AC-B514-54E97D179E97} + {817A11AB-E345-4921-B870-72817E70BD3D} = {A345517E-DA14-47AC-B514-54E97D179E97} {9902DB70-F3E0-42D6-A0DA-585E4091D781} = {FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs new file mode 100644 index 00000000000..3eb43b0b36f --- /dev/null +++ b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs @@ -0,0 +1,163 @@ +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Microsoft.AspNet.Testing +{ + // TODO: eventually want: public partial class Assert : Xunit.Assert + public static class ExceptionAssert + { + /// + /// Verifies that an exception of the given type is thrown. + /// Also verifies that the exception message matches. + /// + /// The type of the exception expected to be thrown + /// A delegate to the code to be tested + /// The exception message to verify + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static TException Throws(Action testCode, string exceptionMessage) + where TException : Exception + { + var ex = Assert.Throws(testCode); + VerifyExceptionMessage(ex, exceptionMessage); + return ex; + } + + /// + /// Verifies that an exception of the given type is thrown. + /// Also verifies that the exception message matches. + /// + /// The type of the exception expected to be thrown + /// A delegate to the code to be tested + /// The exception message to verify + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static async Task ThrowsAsync(Func testCode, string exceptionMessage) + where TException : Exception + { + var ex = await Assert.ThrowsAsync(testCode); + VerifyExceptionMessage(ex, exceptionMessage); + return ex; + } + + /// + /// Verifies that an exception of the given type is thrown. + /// Also verified that the exception message matches. + /// + /// The type of the exception expected to be thrown + /// A delegate to the code to be tested + /// The exception message to verify + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static TException Throws(Func testCode, string exceptionMessage) + where TException : Exception + { + return Throws(() => { testCode(); }, exceptionMessage); + } + + /// + /// Verifies that the code throws an . + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception message to verify + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static ArgumentException ThrowsArgument(Action testCode, string paramName, string exceptionMessage) + { + var ex = Assert.Throws(paramName, testCode); + VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); + return ex; + } + + /// + /// Verifies that the code throws an . + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception message to verify + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static async Task ThrowsArgumentAsync(Func testCode, string paramName, string exceptionMessage) + { + var ex = await Assert.ThrowsAsync(paramName, testCode); + VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); + return ex; + } + + /// + /// Verifies that the code throws an ArgumentException with the expected message that indicates that the value cannot + /// be null or empty. + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, string paramName) + { + return Throws(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName); + } + + /// + /// Verifies that the code throws an ArgumentException with the expected message that indicates that the value cannot + /// be null or empty. + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static Task ThrowsArgumentNullOrEmptyAsync(Func testCode, string paramName) + { + return ThrowsAsync(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName); + } + + /// + /// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot + /// be null or empty string. + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static ArgumentException ThrowsArgumentNullOrEmptyString(Action testCode, string paramName) + { + return ThrowsArgument(testCode, paramName, "Value cannot be null or an empty string."); + } + + /// + /// Verifies that the code throws an ArgumentNullException with the expected message that indicates that the value cannot + /// be null or empty string. + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static Task ThrowsArgumentNullOrEmptyStringAsync(Func testCode, string paramName) + { + return ThrowsArgumentAsync(testCode, paramName, "Value cannot be null or an empty string."); + } + + private static void VerifyException(Type exceptionType, Exception exception) + { + Assert.NotNull(exception); + Assert.IsAssignableFrom(exceptionType, exception); + } + + private static void VerifyExceptionMessage(Exception exception, string expectedMessage, + bool partialMatch = false) + { + if (expectedMessage != null) + { + if (!partialMatch) + { + Assert.Equal(expectedMessage, exception.Message); + } + else + { + Assert.Contains(expectedMessage, exception.Message); + } + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json new file mode 100644 index 00000000000..993bccf684a --- /dev/null +++ b/src/Microsoft.AspNet.Testing/project.json @@ -0,0 +1,35 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" + }, + "configurations": { + "net45": { + "dependencies": { + "System.Runtime": "" + } + }, + "k10": { + "dependencies": { + "System.Collections": "4.0.0.0", + "System.Collections.Concurrent": "4.0.0.0", + "System.ComponentModel": "4.0.0.0", + "System.Console": "4.0.0.0", + "System.Diagnostics.Debug": "4.0.10.0", + "System.Globalization": "4.0.10.0", + "System.Linq": "4.0.0.0", + "System.Linq.Expressions": "4.0.0.0", + "System.Reflection": "4.0.10.0", + "System.Reflection.Extensions": "4.0.0.0", + "System.Resources.ResourceManager": "4.0.0.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0", + "System.Threading": "4.0.0.0", + "System.Threading.Tasks": "4.0.0.0" + } + } + } +} \ No newline at end of file From 684aebc718ce4fe45aa8ad26e10d05d77e3fd891 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 14 Mar 2014 10:13:15 -0700 Subject: [PATCH 011/463] Remove unneeded dependencies --- src/Microsoft.AspNet.Testing/project.json | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 993bccf684a..1f2658813c3 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -15,15 +15,8 @@ "k10": { "dependencies": { "System.Collections": "4.0.0.0", - "System.Collections.Concurrent": "4.0.0.0", - "System.ComponentModel": "4.0.0.0", - "System.Console": "4.0.0.0", - "System.Diagnostics.Debug": "4.0.10.0", "System.Globalization": "4.0.10.0", "System.Linq": "4.0.0.0", - "System.Linq.Expressions": "4.0.0.0", - "System.Reflection": "4.0.10.0", - "System.Reflection.Extensions": "4.0.0.0", "System.Resources.ResourceManager": "4.0.0.0", "System.Runtime": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", From 1749379565dd0a20f0b10aaa1ebba47c1487e749 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Mon, 24 Mar 2014 13:55:44 -0700 Subject: [PATCH 012/463] Add CultureReplacer logic for WebFX --- .../CultureReplacer.cs | 71 +++++++++++++++++++ .../ExceptionAssertions.cs | 71 +++++++++++++++++-- .../ReplaceCulture.cs | 58 +++++++++++++++ src/Microsoft.AspNet.Testing/project.json | 2 + 4 files changed, 195 insertions(+), 7 deletions(-) create mode 100644 src/Microsoft.AspNet.Testing/CultureReplacer.cs create mode 100644 src/Microsoft.AspNet.Testing/ReplaceCulture.cs diff --git a/src/Microsoft.AspNet.Testing/CultureReplacer.cs b/src/Microsoft.AspNet.Testing/CultureReplacer.cs new file mode 100644 index 00000000000..1437e67d84d --- /dev/null +++ b/src/Microsoft.AspNet.Testing/CultureReplacer.cs @@ -0,0 +1,71 @@ +using System; +using System.Globalization; +using System.Threading; +using Xunit; + +namespace Microsoft.AspNet.Testing +{ + public class CultureReplacer : IDisposable + { + private const string _defaultCultureName = "en-GB"; + private const string _defaultUICultureName = "en-US"; + private static readonly CultureInfo _defaultCulture = new CultureInfo(_defaultCultureName); + private readonly CultureInfo _originalCulture; + private readonly CultureInfo _originalUICulture; + private readonly long _threadId; + + // Culture => Formatting of dates/times/money/etc, defaults to en-GB because en-US is the same as InvariantCulture + // We want to be able to find issues where the InvariantCulture is used, but a specific culture should be. + // + // UICulture => Language + public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _defaultUICultureName) + { + _originalCulture = CultureInfo.DefaultThreadCurrentCulture; + _originalUICulture = CultureInfo.DefaultThreadCurrentUICulture; + _threadId = Thread.CurrentThread.ManagedThreadId; + CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture); + CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(uiCulture); + } + + /// + /// The name of the culture that is used as the default value for CultureInfo.DefaultThreadCurrentCulture when CultureReplacer is used. + /// + public static string DefaultCultureName + { + get { return _defaultCultureName; } + } + + /// + /// The name of the culture that is used as the default value for CultureInfo.DefaultThreadCurrentUICulture when CultureReplacer is used. + /// + public static string DefaultUICultureName + { + get { return _defaultUICultureName; } + } + + /// + /// The culture that is used as the default value for CultureInfo.DefaultThreadCurrentCulture when CultureReplacer is used. + /// + public static CultureInfo DefaultCulture + { + get { return _defaultCulture; } + } + + public void Dispose() + { + Dispose(true); + GC.SuppressFinalize(this); + } + + private void Dispose(bool disposing) + { + if (disposing) + { + Assert.True(Thread.CurrentThread.ManagedThreadId == _threadId, + "The current thread is not the same as the thread invoking the constructor. This should never happen."); + CultureInfo.DefaultThreadCurrentCulture = _originalCulture; + CultureInfo.DefaultThreadCurrentUICulture = _originalUICulture; + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs index 3eb43b0b36f..c173f50e2cc 100644 --- a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs +++ b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs @@ -1,12 +1,27 @@ using System; +using System.Reflection; using System.Threading.Tasks; using Xunit; +using Xunit.Sdk; namespace Microsoft.AspNet.Testing { // TODO: eventually want: public partial class Assert : Xunit.Assert public static class ExceptionAssert { + /// + /// Verifies that an exception of the given type (or optionally a derived type) is thrown. + /// + /// The type of the exception expected to be thrown + /// A delegate to the code to be tested + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static TException Throws(Action testCode) + where TException : Exception + { + return VerifyException(RecordException(testCode)); + } + /// /// Verifies that an exception of the given type is thrown. /// Also verifies that the exception message matches. @@ -19,7 +34,7 @@ public static class ExceptionAssert public static TException Throws(Action testCode, string exceptionMessage) where TException : Exception { - var ex = Assert.Throws(testCode); + var ex = Throws(testCode); VerifyExceptionMessage(ex, exceptionMessage); return ex; } @@ -36,6 +51,9 @@ public static TException Throws(Action testCode, string exceptionMes public static async Task ThrowsAsync(Func testCode, string exceptionMessage) where TException : Exception { + // The 'testCode' Task might execute asynchronously in a different thread making it hard to enforce the thread culture. + // The correct way to verify exception messages in such a scenario would be to run the task synchronously inside of a + // culture enforced block. var ex = await Assert.ThrowsAsync(testCode); VerifyExceptionMessage(ex, exceptionMessage); return ex; @@ -66,7 +84,11 @@ public static TException Throws(Func testCode, string except /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown public static ArgumentException ThrowsArgument(Action testCode, string paramName, string exceptionMessage) { - var ex = Assert.Throws(paramName, testCode); + var ex = Throws(testCode); + if (paramName != null) + { + Assert.Equal(paramName, ex.ParamName); + } VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); return ex; } @@ -81,7 +103,11 @@ public static ArgumentException ThrowsArgument(Action testCode, string paramName /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown public static async Task ThrowsArgumentAsync(Func testCode, string paramName, string exceptionMessage) { - var ex = await Assert.ThrowsAsync(paramName, testCode); + var ex = await Assert.ThrowsAsync(testCode); + if (paramName != null) + { + Assert.Equal(paramName, ex.ParamName); + } VerifyExceptionMessage(ex, exceptionMessage, partialMatch: true); return ex; } @@ -138,14 +164,45 @@ public static Task ThrowsArgumentNullOrEmptyStringAsync(Func< return ThrowsArgumentAsync(testCode, paramName, "Value cannot be null or an empty string."); } - private static void VerifyException(Type exceptionType, Exception exception) + // We've re-implemented all the xUnit.net Throws code so that we can get this + // updated implementation of RecordException which silently unwraps any instances + // of AggregateException. In addition to unwrapping exceptions, this method ensures + // that tests are executed in with a known set of Culture and UICulture. This prevents + // tests from failing when executed on a non-English machine. + private static Exception RecordException(Action testCode) { + try + { + using (new CultureReplacer()) + { + testCode(); + } + return null; + } + catch (Exception exception) + { + return UnwrapException(exception); + } + } + + private static Exception UnwrapException(Exception exception) + { + var aggEx = exception as AggregateException; + return aggEx != null ? aggEx.GetBaseException() : exception; + } + + private static TException VerifyException(Exception exception) + { + var tie = exception as TargetInvocationException; + if (tie != null) + { + exception = tie.InnerException; + } Assert.NotNull(exception); - Assert.IsAssignableFrom(exceptionType, exception); + return Assert.IsAssignableFrom(exception); } - private static void VerifyExceptionMessage(Exception exception, string expectedMessage, - bool partialMatch = false) + private static void VerifyExceptionMessage(Exception exception, string expectedMessage, bool partialMatch = false) { if (expectedMessage != null) { diff --git a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs new file mode 100644 index 00000000000..b58112c60a1 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs @@ -0,0 +1,58 @@ +using System; +using System.Globalization; +using System.Reflection; +using System.Threading; +using Xunit.Sdk; + +namespace Microsoft.AspNet.Testing +{ + /// + /// Replaces the current culture and UI culture for the test. + /// + [AttributeUsage(AttributeTargets.Method)] + public class ReplaceCultureAttribute : BeforeAfterTestAttribute + { + private const string _defaultCultureName = "en-GB"; + private const string _defaultUICultureName = "en-US"; + private static readonly CultureInfo _defaultCulture = new CultureInfo(_defaultCultureName); + private CultureInfo _originalCulture; + private CultureInfo _originalUICulture; + + public ReplaceCultureAttribute() + { + Culture = _defaultCulture; + UICulture = _defaultCulture; + } + + /// + /// Sets for the test. Defaults to en-GB. + /// + /// + /// en-GB is used here as the default because en-US is equivalent to the InvariantCulture. We + /// want to be able to find bugs where we're accidentally relying on the Invariant instead of the + /// user's culture. + /// + public CultureInfo Culture { get; set; } + + /// + /// Sets for the test. Defaults to en-US. + /// + public CultureInfo UICulture { get; set; } + + public override void Before(MethodInfo methodUnderTest) + { + _originalCulture = CultureInfo.DefaultThreadCurrentCulture; + _originalUICulture = CultureInfo.DefaultThreadCurrentUICulture; + + CultureInfo.DefaultThreadCurrentCulture = Culture; + CultureInfo.DefaultThreadCurrentUICulture = UICulture; + } + + public override void After(MethodInfo methodUnderTest) + { + CultureInfo.DefaultThreadCurrentCulture = _originalCulture; + CultureInfo.DefaultThreadCurrentUICulture = _originalUICulture; + } + } +} + diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 1f2658813c3..cca7ad66088 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -9,6 +9,7 @@ "configurations": { "net45": { "dependencies": { + "System.Reflection": "", "System.Runtime": "" } }, @@ -17,6 +18,7 @@ "System.Collections": "4.0.0.0", "System.Globalization": "4.0.10.0", "System.Linq": "4.0.0.0", + "System.Reflection": "4.0.10.0", "System.Resources.ResourceManager": "4.0.0.0", "System.Runtime": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", From c49366c06facc12d99e5616354bacdc4c5928bc6 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Mon, 17 Mar 2014 10:27:52 -0700 Subject: [PATCH 013/463] Merge upstream changes --- src/Microsoft.AspNet.Testing/project.json | 1 + src/Xunit.KRunner/CommandLine.cs | 46 +++++- src/Xunit.KRunner/Common/Guard.cs | 14 ++ .../Common/TestDiscoveryVisitor.cs | 28 ++++ src/Xunit.KRunner/Common/TestOptionsNames.cs | 4 +- .../Frameworks/TestFrameworkOptions.cs | 16 +++ .../Frameworks/v2/XunitDiscoveryOptions.cs | 4 + .../Frameworks/v2/XunitExecutionOptions.cs | 10 ++ src/Xunit.KRunner/ParallelismOption.cs | 9 ++ src/Xunit.KRunner/Program.cs | 78 +++++----- src/Xunit.KRunner/Project/XunitProject.cs | 41 ------ .../Project/XunitProjectAssembly.cs | 13 -- src/Xunit.KRunner/Utility/ExceptionUtility.cs | 134 ++++++++++++++++++ .../Visitors/StandardOutputVisitor.cs | 10 +- src/Xunit.KRunner/Visitors/TeamCityVisitor.cs | 8 +- src/Xunit.KRunner/project.json | 1 + 16 files changed, 307 insertions(+), 110 deletions(-) create mode 100644 src/Xunit.KRunner/Common/Guard.cs create mode 100644 src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs create mode 100644 src/Xunit.KRunner/ParallelismOption.cs delete mode 100644 src/Xunit.KRunner/Project/XunitProject.cs delete mode 100644 src/Xunit.KRunner/Project/XunitProjectAssembly.cs create mode 100644 src/Xunit.KRunner/Utility/ExceptionUtility.cs diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index cca7ad66088..b25c736e685 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -16,6 +16,7 @@ "k10": { "dependencies": { "System.Collections": "4.0.0.0", + "System.Diagnostics.Debug": "4.0.10.0", "System.Globalization": "4.0.10.0", "System.Linq": "4.0.0.0", "System.Reflection": "4.0.10.0", diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs index 32cd702a50b..17ca3cd4ebf 100644 --- a/src/Xunit.KRunner/CommandLine.cs +++ b/src/Xunit.KRunner/CommandLine.cs @@ -13,9 +13,14 @@ protected CommandLine(string[] args) arguments.Push(args[i]); TeamCity = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; + ParallelizeTestCollections = true; Parse(); } + public int MaxParallelThreads { get; set; } + + public bool ParallelizeTestCollections { get; set; } + public bool TeamCity { get; protected set; } static void GuardNoOptionValue(KeyValuePair option) @@ -33,13 +38,46 @@ protected virtual void Parse() { while (arguments.Count > 0) { - KeyValuePair option = PopOption(arguments); - string optionName = option.Key.ToLowerInvariant(); + var option = PopOption(arguments); + var optionName = option.Key.ToLowerInvariant(); if (!optionName.StartsWith("-")) throw new ArgumentException(String.Format("unknown command line option: {0}", option.Key)); - if (optionName == "-teamcity") + if (optionName == "-maxthreads") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -maxthreads"); + + int threadValue; + if (!Int32.TryParse(option.Value, out threadValue) || threadValue < 0) + throw new ArgumentException("incorrect argument value for -maxthreads"); + + MaxParallelThreads = threadValue; + } + else if (optionName == "-parallel") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -parallel"); + + ParallelismOption parallelismOption; + if (!Enum.TryParse(option.Value, out parallelismOption)) + throw new ArgumentException("incorrect argument value for -parallel"); + + switch (parallelismOption) + { + case ParallelismOption.all: + case ParallelismOption.collections: + ParallelizeTestCollections = true; + break; + + case ParallelismOption.none: + default: + ParallelizeTestCollections = false; + break; + } + } + else if (optionName == "-teamcity") { GuardNoOptionValue(option); TeamCity = true; @@ -52,7 +90,7 @@ static KeyValuePair PopOption(Stack arguments) string option = arguments.Pop(); string value = null; - if (arguments.Count > 0 && !arguments.Peek().StartsWith("/")) + if (arguments.Count > 0 && !arguments.Peek().StartsWith("-")) value = arguments.Pop(); return new KeyValuePair(option, value); diff --git a/src/Xunit.KRunner/Common/Guard.cs b/src/Xunit.KRunner/Common/Guard.cs new file mode 100644 index 00000000000..5b00eef6a6b --- /dev/null +++ b/src/Xunit.KRunner/Common/Guard.cs @@ -0,0 +1,14 @@ +using System; + +/// +/// Guard class, used for guard clauses and argument validation +/// +internal static class Guard +{ + /// + public static void ArgumentNotNull(string argName, object argValue) + { + if (argValue == null) + throw new ArgumentNullException(argName); + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs new file mode 100644 index 00000000000..621fa115741 --- /dev/null +++ b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using Xunit.Abstractions; + +namespace Xunit +{ + internal class TestDiscoveryVisitor : TestMessageVisitor + { + public TestDiscoveryVisitor() + { + TestCases = new List(); + } + + public List TestCases { get; private set; } + + public override void Dispose() + { + foreach (var testCase in TestCases) testCase.Dispose(); + TestCases = null; + } + + protected override bool Visit(ITestCaseDiscoveryMessage discovery) + { + TestCases.Add(discovery.TestCase); + + return true; + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Common/TestOptionsNames.cs b/src/Xunit.KRunner/Common/TestOptionsNames.cs index 69d2cd2fa2f..34603dbe90a 100644 --- a/src/Xunit.KRunner/Common/TestOptionsNames.cs +++ b/src/Xunit.KRunner/Common/TestOptionsNames.cs @@ -6,7 +6,7 @@ internal static class Discovery internal static class Execution { - public static readonly string DisableParallelization = "xunit2.DisableParallelization"; - public static readonly string MaxParallelThreads = "xunit2.MaxParallelThreads"; + public static readonly string DisableParallelization = "xunit.DisableParallelization"; + public static readonly string MaxParallelThreads = "xunit.MaxParallelThreads"; } } \ No newline at end of file diff --git a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs index 77593acea8c..003ad6bdd5c 100644 --- a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs +++ b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs @@ -3,10 +3,20 @@ namespace Xunit { + /// + /// Represents options passed to a test framework for discovery or execution. + /// public class TestFrameworkOptions : ITestFrameworkOptions { readonly Dictionary properties = new Dictionary(); + /// + /// Gets a value from the options collection. + /// + /// The type of the value. + /// The name of the value. + /// The default value to use if the value is not present. + /// Returns the value. public TValue GetValue(string name, TValue defaultValue) { object result; @@ -16,6 +26,12 @@ public TValue GetValue(string name, TValue defaultValue) return defaultValue; } + /// + /// Sets a value into the options collection. + /// + /// The type of the value. + /// The name of the value. + /// The value. public void SetValue(string name, TValue value) { properties[name] = value; diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs index bb7b94d7e1c..26cd3920fa1 100644 --- a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs +++ b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs @@ -1,5 +1,9 @@ namespace Xunit { + /// + /// Represents discovery options for xUnit.net v2 tests. + /// + // TODO: Need to figure out what might go here public class XunitDiscoveryOptions : TestFrameworkOptions { } diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs index a65ed4102e0..5747a9747f5 100644 --- a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs +++ b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs @@ -1,13 +1,23 @@ namespace Xunit { + /// + /// Represents execution options for xUnit.net v2 tests. + /// public class XunitExecutionOptions : TestFrameworkOptions { + /// + /// Gets or sets a flag to disable parallelization. + /// public bool DisableParallelization { get { return GetValue(TestOptionsNames.Execution.DisableParallelization, false); } set { SetValue(TestOptionsNames.Execution.DisableParallelization, value); } } + /// + /// Gets or sets the maximum number of threads to use when running tests in parallel. + /// If set to 0 (the default value), does not limit the number of threads. + /// public int MaxParallelThreads { get { return GetValue(TestOptionsNames.Execution.MaxParallelThreads, 0); } diff --git a/src/Xunit.KRunner/ParallelismOption.cs b/src/Xunit.KRunner/ParallelismOption.cs new file mode 100644 index 00000000000..e6d07a04b6a --- /dev/null +++ b/src/Xunit.KRunner/ParallelismOption.cs @@ -0,0 +1,9 @@ +namespace Xunit.ConsoleClient +{ + public enum ParallelismOption + { + none, + collections, + all + } +} diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index f7f1884398b..66de35a69b0 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -1,19 +1,21 @@ -using System; +using System; using System.Collections.Concurrent; using System.Linq; +using System.Reflection; using Microsoft.Net.Runtime; using Xunit.ConsoleClient; +using Xunit.Sdk; #if !NET45 using System.Diagnostics; #endif namespace Xunit.KRunner { - internal class Program + public class Program { - private volatile bool cancel; - private readonly ConcurrentDictionary completionMessages = - new ConcurrentDictionary(); + volatile bool cancel; + bool failed; + readonly ConcurrentDictionary completionMessages = new ConcurrentDictionary(); private readonly IApplicationEnvironment _environment; private readonly IFileMonitor _fileMonitor; @@ -23,13 +25,9 @@ public Program(IApplicationEnvironment environment, IFileMonitor fileMonitor) _fileMonitor = fileMonitor; } - private int Main(string[] args) + public int Main(string[] args) { - Console.WriteLine( - "xUnit.net Project K test runner ({0}-bit {1} {2})", - IntPtr.Size * 8, - _environment.TargetFramework.Identifier, - _environment.TargetFramework.Version); + Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.TargetFramework); Console.WriteLine("Copyright (C) 2014 Outercurve Foundation, Microsoft Open Technologies, Inc."); Console.WriteLine(); @@ -59,25 +57,23 @@ private int Main(string[] args) { var commandLine = CommandLine.Parse(args); - int failCount = RunProject(commandLine.TeamCity); + int failCount = RunProject(commandLine.TeamCity, commandLine.ParallelizeTestCollections, commandLine.MaxParallelThreads); return failCount; } catch (ArgumentException ex) { - Console.WriteLine(); Console.WriteLine("error: {0}", ex.Message); return 1; } catch (BadImageFormatException ex) { - Console.WriteLine(); Console.WriteLine("{0}", ex.Message); return 1; } } - private static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) + static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = e.ExceptionObject as Exception; @@ -93,19 +89,26 @@ private static void OnUnhandledException(object sender, UnhandledExceptionEventA #endif } - private static void PrintUsage() + static void PrintUsage() { Console.WriteLine("usage: Xunit.KRunner [options]"); Console.WriteLine(); Console.WriteLine("Valid options:"); + Console.WriteLine(" -parallel option : set parallelization based on option"); + Console.WriteLine(" : none - turn off all parallelization"); + Console.WriteLine(" : collections - only parallelize collections"); + Console.WriteLine(" : all - parallelize collections"); + Console.WriteLine(" -maxthreads count : maximum thread count for collection parallelization"); + Console.WriteLine(" : 0 - run with unbounded thread count"); + Console.WriteLine(" : >0 - limit task thread pool size to 'count'"); Console.WriteLine(" -teamcity : forces TeamCity mode (normally auto-detected)"); } - private int RunProject(bool teamcity) + int RunProject(bool teamcity, bool parallelizeTestCollections, int maxThreadCount) { var consoleLock = new object(); - ExecuteAssembly(consoleLock, _environment.ApplicationName, teamcity); + ExecuteAssembly(consoleLock, _environment.ApplicationName, teamcity, parallelizeTestCollections, maxThreadCount); if (completionMessages.Count > 0) { @@ -126,10 +129,10 @@ private int RunProject(bool teamcity) message.Value.Time.ToString("0.000s").PadLeft(longestTime)); } - return completionMessages.Values.Sum(summary => summary.Failed); + return failed ? 1 : completionMessages.Values.Sum(summary => summary.Failed); } - private XmlTestExecutionVisitor CreateVisitor(object consoleLock, bool teamCity) + XmlTestExecutionVisitor CreateVisitor(object consoleLock, bool teamCity) { if (teamCity) return new TeamCityVisitor(() => cancel); @@ -137,39 +140,32 @@ private XmlTestExecutionVisitor CreateVisitor(object consoleLock, bool teamCity) return new StandardOutputVisitor(consoleLock, () => cancel, completionMessages); } - private void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity) + void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, bool parallelizeTestCollections, int maxThreadCount) { if (cancel) return; try { - var framework = new Xunit.Sdk.XunitTestFramework(); - var executor = framework.GetExecutor(assemblyName); + var name = new AssemblyName(assemblyName); + var assembly = Reflector.Wrap(Assembly.Load(name)); + var framework = new XunitTestFramework(); + var discoverer = framework.GetDiscoverer(assembly); + var executor = framework.GetExecutor(name); + var discoveryVisitor = new TestDiscoveryVisitor(); + + discoverer.Find(includeSourceInformation: false, messageSink: discoveryVisitor, options: new TestFrameworkOptions()); + discoveryVisitor.Finished.WaitOne(); + var executionOptions = new XunitExecutionOptions { DisableParallelization = !parallelizeTestCollections, MaxParallelThreads = maxThreadCount }; var resultsVisitor = CreateVisitor(consoleLock, teamCity); - executor.Run(resultsVisitor, new XunitDiscoveryOptions(), new XunitExecutionOptions()); + executor.Run(discoveryVisitor.TestCases, resultsVisitor, executionOptions); resultsVisitor.Finished.WaitOne(); } catch (Exception ex) { - var e = ex; - - while (e != null) - { - Console.WriteLine("{0}: {1}", e.GetType().FullName, e.Message); - - foreach (string stackLine in e.StackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries)) - Console.WriteLine(stackLine); - - e = e.InnerException; - } - -#if NET45 - Environment.Exit(1); -#else - Process.GetCurrentProcess().Kill(); -#endif + Console.WriteLine("{0}: {1}", ex.GetType().FullName, ex.Message); + failed = true; } } } diff --git a/src/Xunit.KRunner/Project/XunitProject.cs b/src/Xunit.KRunner/Project/XunitProject.cs deleted file mode 100644 index 7be8c4c9ec0..00000000000 --- a/src/Xunit.KRunner/Project/XunitProject.cs +++ /dev/null @@ -1,41 +0,0 @@ -using System; -using System.Collections.Generic; - -namespace Xunit -{ - /// - /// Represents an xUnit.net Test Project file (.xunit file) - /// - public class XunitProject - { - readonly List assemblies; - - /// - /// Initializes a new instance of the class. - /// - public XunitProject() - { - assemblies = new List(); - } - - /// - /// Gets or sets the assemblies in the project. - /// - public IEnumerable Assemblies - { - get { return assemblies; } - } - - /// - /// Adds an assembly to the project - /// - /// The assembly to be added - public void AddAssembly(XunitProjectAssembly assembly) - { - if (assembly == null) - throw new ArgumentNullException("assembly"); - - assemblies.Add(assembly); - } - } -} diff --git a/src/Xunit.KRunner/Project/XunitProjectAssembly.cs b/src/Xunit.KRunner/Project/XunitProjectAssembly.cs deleted file mode 100644 index 1f8a0f5400b..00000000000 --- a/src/Xunit.KRunner/Project/XunitProjectAssembly.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Xunit -{ - /// - /// Represents an assembly in an . - /// - public class XunitProjectAssembly - { - /// - /// Gets or sets the assembly name. - /// - public string AssemblyName { get; set; } - } -} diff --git a/src/Xunit.KRunner/Utility/ExceptionUtility.cs b/src/Xunit.KRunner/Utility/ExceptionUtility.cs new file mode 100644 index 00000000000..41d2b8d757b --- /dev/null +++ b/src/Xunit.KRunner/Utility/ExceptionUtility.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using Xunit.Abstractions; + +namespace Xunit +{ + /// + /// Utility classes for dealing with Exception objects. + /// + public static class ExceptionUtility + { + /// + /// Combines multiple levels of messages into a single message. + /// + /// The failure information from which to get the messages. + /// The combined string. + public static string CombineMessages(IFailureInformation failureInfo) + { + return GetMessage(failureInfo, 0, 0); + } + + /// + /// Combines multiple levels of stack traces into a single stack trace. + /// + /// The failure information from which to get the stack traces. + /// The combined string. + public static string CombineStackTraces(IFailureInformation failureInfo) + { + return GetStackTrace(failureInfo, 0); + } + + static bool ExcludeStackFrame(string stackFrame) + { + Guard.ArgumentNotNull("stackFrame", stackFrame); + + return stackFrame.StartsWith("at Xunit.", StringComparison.Ordinal); + } + + static string FilterStackTrace(string stack) + { + if (stack == null) + return null; + + var results = new List(); + + foreach (string line in SplitLines(stack)) + { + string trimmedLine = line.TrimStart(); + if (!ExcludeStackFrame(trimmedLine)) + results.Add(line); + } + + return string.Join(Environment.NewLine, results.ToArray()); + } + + static string GetMessage(IFailureInformation failureInfo, int index, int level) + { + string result = ""; + + if (level > 0) + { + for (int idx = 0; idx < level; idx++) + result += "----"; + + result += " "; + } + + var exceptionType = failureInfo.ExceptionTypes[index]; + if (GetNamespace(exceptionType) != "Xunit.Sdk") + result += exceptionType + " : "; + + result += failureInfo.Messages[index]; + + for (int subIndex = index + 1; subIndex < failureInfo.ExceptionParentIndices.Length; ++subIndex) + if (failureInfo.ExceptionParentIndices[subIndex] == index) + result += Environment.NewLine + GetMessage(failureInfo, subIndex, level + 1); + + return result; + } + + private static string GetNamespace(string exceptionType) + { + var nsIndex = exceptionType.LastIndexOf('.'); + if (nsIndex > 0) + return exceptionType.Substring(0, nsIndex); + + return ""; + } + + static string GetStackTrace(IFailureInformation failureInfo, int index) + { + string result = FilterStackTrace(failureInfo.StackTraces[index]); + + var children = new List(); + for (int subIndex = index + 1; subIndex < failureInfo.ExceptionParentIndices.Length; ++subIndex) + if (failureInfo.ExceptionParentIndices[subIndex] == index) + children.Add(subIndex); + + if (children.Count > 1) + { + for (int idx = 0; idx < children.Count; ++idx) + result += String.Format("{0}----- Inner Stack Trace #{1} ({2}) -----{0}{3}", + Environment.NewLine, + idx + 1, + failureInfo.ExceptionTypes[children[idx]], + GetStackTrace(failureInfo, children[idx])); + } + else if (children.Count == 1) + result += Environment.NewLine + + "----- Inner Stack Trace -----" + Environment.NewLine + + GetStackTrace(failureInfo, children[0]); + + return result; + } + + // Our own custom String.Split because Silverlight/CoreCLR doesn't support the version we were using + static IEnumerable SplitLines(string input) + { + while (true) + { + int idx = input.IndexOf(Environment.NewLine); + + if (idx < 0) + { + yield return input; + break; + } + + yield return input.Substring(0, idx); + input = input.Substring(idx + Environment.NewLine.Length); + } + } + } +} diff --git a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs index 70521ccda27..daa3a3f008b 100644 --- a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs +++ b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs @@ -56,13 +56,13 @@ protected override bool Visit(IErrorMessage error) #if NET45 Console.ForegroundColor = ConsoleColor.Red; #endif - Console.Error.WriteLine(" {0} [FATAL]", Escape(error.ExceptionType)); + Console.Error.WriteLine(" {0} [FATAL]", Escape(error.ExceptionTypes[0])); #if NET45 Console.ForegroundColor = ConsoleColor.Gray; #endif - Console.Error.WriteLine(" {0}", Escape(error.Message)); + Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(error))); - WriteStackTrace(error.StackTrace); + WriteStackTrace(ExceptionUtility.CombineStackTraces(error)); } return base.Visit(error); @@ -80,9 +80,9 @@ protected override bool Visit(ITestFailed testFailed) #if NET45 Console.ForegroundColor = ConsoleColor.Gray; #endif - Console.Error.WriteLine(" {0}", Escape(testFailed.Message)); + Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(testFailed))); - WriteStackTrace(testFailed.StackTrace); + WriteStackTrace(ExceptionUtility.CombineStackTraces(testFailed)); } return base.Visit(testFailed); diff --git a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs index 2c351767b37..2ea65ee0bd4 100644 --- a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs +++ b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs @@ -28,8 +28,8 @@ void LogFinish(ITestResultMessage testResult) protected override bool Visit(IErrorMessage error) { - Console.Error.WriteLine("{0}: {1}", error.ExceptionType, Escape(error.Message)); - Console.Error.WriteLine(error.StackTrace); + Console.Error.WriteLine("{0}: {1}", error.ExceptionTypes[0], Escape(ExceptionUtility.CombineMessages(error))); + Console.Error.WriteLine(ExceptionUtility.CombineStackTraces(error)); return base.Visit(error); } @@ -59,8 +59,8 @@ protected override bool Visit(ITestFailed testFailed) { Console.WriteLine("##teamcity[testFailed name='{0}' details='{1}|r|n{2}' flowId='{3}']", TeamCityEscape(testFailed.TestDisplayName), - TeamCityEscape(testFailed.Message), - TeamCityEscape(testFailed.StackTrace), + TeamCityEscape(ExceptionUtility.CombineMessages(testFailed)), + TeamCityEscape(ExceptionUtility.CombineStackTraces(testFailed)), ToFlowId(testFailed.TestCollection.DisplayName)); LogFinish(testFailed); diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index ceb068d12c0..62e2e633d9b 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -18,6 +18,7 @@ "System.Diagnostics.Process": "4.0.0.0", "System.IO": "4.0.0.0", "System.Linq": "4.0.0.0", + "System.Reflection": "4.0.10.0", "System.Runtime": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", "System.Runtime.Hosting": "3.9.0.0", From 38b5f054ffd55a29e60f1eb1bc6c0c766cc7120d Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 27 Mar 2014 17:40:10 -0700 Subject: [PATCH 014/463] Updating CoreCLR package versions --- src/Microsoft.AspNet.Testing/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index b25c736e685..8e09fdbddc6 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -24,7 +24,7 @@ "System.Runtime": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", "System.Threading": "4.0.0.0", - "System.Threading.Tasks": "4.0.0.0" + "System.Threading.Tasks": "4.0.10.0" } } } From 365e1071de5c4aa9603fa30af772a56b474b8ae6 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 27 Mar 2014 18:05:17 -0700 Subject: [PATCH 015/463] Ifdefine AppDomain.CurrentDomain reference to Net45 only --- src/Xunit.KRunner/Program.cs | 10 +++++----- src/Xunit.KRunner/project.json | 1 - 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 66de35a69b0..62ae8ccbabe 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -37,8 +37,9 @@ public int Main(string[] args) return 1; } - AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; #if NET45 + AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; + Console.CancelKeyPress += (sender, e) => { if (!cancel) @@ -73,6 +74,7 @@ public int Main(string[] args) } } +#if NET45 static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = e.ExceptionObject as Exception; @@ -82,12 +84,10 @@ static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) else Console.WriteLine("Error of unknown type thrown in application domain"); -#if NET45 + Environment.Exit(1); -#else - Process.GetCurrentProcess().Kill(); -#endif } +#endif static void PrintUsage() { diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 62e2e633d9b..9361934e183 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -21,7 +21,6 @@ "System.Reflection": "4.0.10.0", "System.Runtime": "4.0.20.0", "System.Runtime.Extensions": "4.0.10.0", - "System.Runtime.Hosting": "3.9.0.0", "System.Threading": "4.0.0.0" } } From 92f4790e04d42ff3afef7deeec4cb060f995a427 Mon Sep 17 00:00:00 2001 From: Hao Kung Date: Fri, 28 Mar 2014 14:43:24 -0700 Subject: [PATCH 016/463] Use new CultureInfo.CurrentCulture setter for K10 --- .../CultureReplacer.cs | 26 +++++++++++++------ .../ReplaceCulture.cs | 23 +++++++++++----- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/CultureReplacer.cs b/src/Microsoft.AspNet.Testing/CultureReplacer.cs index 1437e67d84d..1190f3e8903 100644 --- a/src/Microsoft.AspNet.Testing/CultureReplacer.cs +++ b/src/Microsoft.AspNet.Testing/CultureReplacer.cs @@ -20,11 +20,16 @@ public class CultureReplacer : IDisposable // UICulture => Language public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _defaultUICultureName) { - _originalCulture = CultureInfo.DefaultThreadCurrentCulture; - _originalUICulture = CultureInfo.DefaultThreadCurrentUICulture; + _originalCulture = CultureInfo.CurrentCulture; + _originalUICulture = CultureInfo.CurrentUICulture; _threadId = Thread.CurrentThread.ManagedThreadId; - CultureInfo.DefaultThreadCurrentCulture = new CultureInfo(culture); - CultureInfo.DefaultThreadCurrentUICulture = new CultureInfo(uiCulture); +#if NET45 + Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); + Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiCulture); +#else + CultureInfo.CurrentCulture = new CultureInfo(culture); + CultureInfo.CurrentUICulture = new CultureInfo(uiCulture); +#endif } /// @@ -36,7 +41,7 @@ public static string DefaultCultureName } /// - /// The name of the culture that is used as the default value for CultureInfo.DefaultThreadCurrentUICulture when CultureReplacer is used. + /// The name of the culture that is used as the default value for [Thread.CurrentThread(NET45)/CultureInfo(K10)].CurrentUICulture when CultureReplacer is used. /// public static string DefaultUICultureName { @@ -44,7 +49,7 @@ public static string DefaultUICultureName } /// - /// The culture that is used as the default value for CultureInfo.DefaultThreadCurrentCulture when CultureReplacer is used. + /// The culture that is used as the default value for [Thread.CurrentThread(NET45)/CultureInfo(K10)].CurrentCulture when CultureReplacer is used. /// public static CultureInfo DefaultCulture { @@ -63,8 +68,13 @@ private void Dispose(bool disposing) { Assert.True(Thread.CurrentThread.ManagedThreadId == _threadId, "The current thread is not the same as the thread invoking the constructor. This should never happen."); - CultureInfo.DefaultThreadCurrentCulture = _originalCulture; - CultureInfo.DefaultThreadCurrentUICulture = _originalUICulture; +#if NET45 + Thread.CurrentThread.CurrentCulture = _originalCulture; + Thread.CurrentThread.CurrentUICulture = _originalUICulture; +#else + CultureInfo.CurrentCulture = _originalCulture; + CultureInfo.CurrentUICulture = _originalUICulture; +#endif } } } diff --git a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs index b58112c60a1..e32e28702c9 100644 --- a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs +++ b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs @@ -41,17 +41,28 @@ public ReplaceCultureAttribute() public override void Before(MethodInfo methodUnderTest) { - _originalCulture = CultureInfo.DefaultThreadCurrentCulture; - _originalUICulture = CultureInfo.DefaultThreadCurrentUICulture; + _originalCulture = CultureInfo.CurrentCulture; + _originalUICulture = CultureInfo.CurrentUICulture; + +#if NET45 + Thread.CurrentThread.CurrentCulture = Culture; + Thread.CurrentThread.CurrentUICulture = UICulture; +#else + CultureInfo.CurrentCulture = Culture; + CultureInfo.CurrentUICulture = UICulture; +#endif - CultureInfo.DefaultThreadCurrentCulture = Culture; - CultureInfo.DefaultThreadCurrentUICulture = UICulture; } public override void After(MethodInfo methodUnderTest) { - CultureInfo.DefaultThreadCurrentCulture = _originalCulture; - CultureInfo.DefaultThreadCurrentUICulture = _originalUICulture; +#if NET45 + Thread.CurrentThread.CurrentCulture = _originalCulture; + Thread.CurrentThread.CurrentUICulture = _originalUICulture; +#else + CultureInfo.CurrentCulture = _originalCulture; + CultureInfo.CurrentUICulture = _originalUICulture; +#endif } } } From cc9d162868517e7138777dd0a8093e0fe7e8c951 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 30 Apr 2014 22:11:24 -0700 Subject: [PATCH 017/463] Report full exception details on unhandled test exceptions --- src/Xunit.KRunner/Program.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 62ae8ccbabe..acffb273baf 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -65,11 +65,13 @@ public int Main(string[] args) catch (ArgumentException ex) { Console.WriteLine("error: {0}", ex.Message); + Console.WriteLine(ex); return 1; } catch (BadImageFormatException ex) { Console.WriteLine("{0}", ex.Message); + Console.WriteLine(ex); return 1; } } @@ -165,6 +167,8 @@ void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, boo catch (Exception ex) { Console.WriteLine("{0}: {1}", ex.GetType().FullName, ex.Message); + Console.WriteLine(ex); + failed = true; } } From 544683b7de9165f5a020080f45c878051620d175 Mon Sep 17 00:00:00 2001 From: anpete Date: Thu, 1 May 2014 17:42:20 -0700 Subject: [PATCH 018/463] Update file headers --- .../CultureReplacer.cs | 17 +++++++++++++++++ .../ExceptionAssertions.cs | 17 +++++++++++++++++ .../ReplaceCulture.cs | 17 +++++++++++++++++ src/Xunit.KRunner/CommandLine.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Common/Guard.cs | 19 ++++++++++++++++++- .../Common/TestDiscoveryVisitor.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Common/TestOptionsNames.cs | 17 +++++++++++++++++ .../Frameworks/TestFrameworkOptions.cs | 19 ++++++++++++++++++- .../Frameworks/v2/XunitDiscoveryOptions.cs | 19 ++++++++++++++++++- .../Frameworks/v2/XunitExecutionOptions.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/ParallelismOption.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Program.cs | 17 +++++++++++++++++ .../Services/AssemblyNeutralAttribute.cs | 19 ++++++++++++++++++- .../Services/IApplicationEnvironment.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Services/IFileMonitor.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Utility/ExceptionUtility.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Utility/ExecutionSummary.cs | 19 ++++++++++++++++++- .../Visitors/StandardOutputVisitor.cs | 19 ++++++++++++++++++- src/Xunit.KRunner/Visitors/TeamCityVisitor.cs | 19 ++++++++++++++++++- .../Visitors/TestMessageVisitor.cs | 19 ++++++++++++++++++- .../Visitors/XmlTestExecutionVisitor.cs | 19 ++++++++++++++++++- test/Sample.Tests/SampleTest.cs | 17 +++++++++++++++++ 22 files changed, 390 insertions(+), 16 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/CultureReplacer.cs b/src/Microsoft.AspNet.Testing/CultureReplacer.cs index 1190f3e8903..ad15309f39d 100644 --- a/src/Microsoft.AspNet.Testing/CultureReplacer.cs +++ b/src/Microsoft.AspNet.Testing/CultureReplacer.cs @@ -1,3 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + using System; using System.Globalization; using System.Threading; diff --git a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs index c173f50e2cc..049615504ca 100644 --- a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs +++ b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs @@ -1,3 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + using System; using System.Reflection; using System.Threading.Tasks; diff --git a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs index e32e28702c9..041355ef924 100644 --- a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs +++ b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs @@ -1,3 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + using System; using System.Globalization; using System.Reflection; diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs index 17ca3cd4ebf..74a5d077e82 100644 --- a/src/Xunit.KRunner/CommandLine.cs +++ b/src/Xunit.KRunner/CommandLine.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; using System.Collections.Generic; namespace Xunit.ConsoleClient diff --git a/src/Xunit.KRunner/Common/Guard.cs b/src/Xunit.KRunner/Common/Guard.cs index 5b00eef6a6b..b313626391e 100644 --- a/src/Xunit.KRunner/Common/Guard.cs +++ b/src/Xunit.KRunner/Common/Guard.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; /// /// Guard class, used for guard clauses and argument validation diff --git a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs index 621fa115741..8fb3c40cd51 100644 --- a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs +++ b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs @@ -1,4 +1,21 @@ -using System.Collections.Generic; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System.Collections.Generic; using Xunit.Abstractions; namespace Xunit diff --git a/src/Xunit.KRunner/Common/TestOptionsNames.cs b/src/Xunit.KRunner/Common/TestOptionsNames.cs index 34603dbe90a..b464fd7f100 100644 --- a/src/Xunit.KRunner/Common/TestOptionsNames.cs +++ b/src/Xunit.KRunner/Common/TestOptionsNames.cs @@ -1,3 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + internal static class TestOptionsNames { internal static class Discovery diff --git a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs index 003ad6bdd5c..27b886dd859 100644 --- a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs +++ b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs @@ -1,4 +1,21 @@ -using System.Collections.Generic; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System.Collections.Generic; using Xunit.Abstractions; namespace Xunit diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs index 26cd3920fa1..0a7b269f469 100644 --- a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs +++ b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs @@ -1,4 +1,21 @@ -namespace Xunit +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +namespace Xunit { /// /// Represents discovery options for xUnit.net v2 tests. diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs index 5747a9747f5..e1dd9086ced 100644 --- a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs +++ b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs @@ -1,4 +1,21 @@ -namespace Xunit +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +namespace Xunit { /// /// Represents execution options for xUnit.net v2 tests. diff --git a/src/Xunit.KRunner/ParallelismOption.cs b/src/Xunit.KRunner/ParallelismOption.cs index e6d07a04b6a..96099bf1532 100644 --- a/src/Xunit.KRunner/ParallelismOption.cs +++ b/src/Xunit.KRunner/ParallelismOption.cs @@ -1,4 +1,21 @@ -namespace Xunit.ConsoleClient +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +namespace Xunit.ConsoleClient { public enum ParallelismOption { diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index acffb273baf..80517af9df6 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -1,3 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + using System; using System.Collections.Concurrent; using System.Linq; diff --git a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs index 2191d5198de..7bbdffd73c3 100644 --- a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs +++ b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; namespace Microsoft.Net.Runtime { diff --git a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs index c7514da6ef3..28fc312ab10 100644 --- a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs +++ b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs @@ -1,4 +1,21 @@ -using System.Runtime.Versioning; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System.Runtime.Versioning; namespace Microsoft.Net.Runtime { diff --git a/src/Xunit.KRunner/Services/IFileMonitor.cs b/src/Xunit.KRunner/Services/IFileMonitor.cs index dfff6c85087..528593b39db 100644 --- a/src/Xunit.KRunner/Services/IFileMonitor.cs +++ b/src/Xunit.KRunner/Services/IFileMonitor.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; namespace Microsoft.Net.Runtime { diff --git a/src/Xunit.KRunner/Utility/ExceptionUtility.cs b/src/Xunit.KRunner/Utility/ExceptionUtility.cs index 41d2b8d757b..b7ab3a2f6d6 100644 --- a/src/Xunit.KRunner/Utility/ExceptionUtility.cs +++ b/src/Xunit.KRunner/Utility/ExceptionUtility.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; using System.Collections.Generic; using Xunit.Abstractions; diff --git a/src/Xunit.KRunner/Utility/ExecutionSummary.cs b/src/Xunit.KRunner/Utility/ExecutionSummary.cs index d6e5bddd98f..1e241ced1d2 100644 --- a/src/Xunit.KRunner/Utility/ExecutionSummary.cs +++ b/src/Xunit.KRunner/Utility/ExecutionSummary.cs @@ -1,4 +1,21 @@ -namespace Xunit +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +namespace Xunit { /// /// Collects execution totals for a group of test cases. diff --git a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs index daa3a3f008b..c7a4db5a740 100644 --- a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs +++ b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; using System.Collections.Concurrent; using Xunit.Abstractions; diff --git a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs index 2ea65ee0bd4..8bfeecc62d8 100644 --- a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs +++ b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; using System.Collections.Concurrent; using Xunit.Abstractions; diff --git a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs index 0c8017cb7a3..90c0bcb927b 100644 --- a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs +++ b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; using System.Threading; using Xunit.Abstractions; diff --git a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs index 4f3fc338265..28a9aae82c8 100644 --- a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs +++ b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs @@ -1,4 +1,21 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + +using System; using Xunit.Abstractions; namespace Xunit diff --git a/test/Sample.Tests/SampleTest.cs b/test/Sample.Tests/SampleTest.cs index b90f6faa2f3..7ac30433d12 100644 --- a/test/Sample.Tests/SampleTest.cs +++ b/test/Sample.Tests/SampleTest.cs @@ -1,3 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. +// All Rights Reserved +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR +// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING +// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF +// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR +// NON-INFRINGEMENT. +// See the Apache 2 License for the specific language governing +// permissions and limitations under the License. + using Xunit; namespace Sample.Tests From 4a96b366044b62d1924fb262df138789dc3fd0f8 Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 2 May 2014 14:45:30 -0700 Subject: [PATCH 019/463] Updating build scripts --- .gitignore | 1 + build.cmd | 3 +++ build.sh | 30 ++++++++++++++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100644 build.sh diff --git a/.gitignore b/.gitignore index 8bc217058d9..aba9c594d74 100644 --- a/.gitignore +++ b/.gitignore @@ -13,6 +13,7 @@ PublishProfiles/ _ReSharper.* nuget.exe *net45.csproj +*net451.csproj *k10.csproj *.psess *.vsp diff --git a/build.cmd b/build.cmd index 7045ee1f84e..2c32132fa3d 100644 --- a/build.cmd +++ b/build.cmd @@ -18,6 +18,9 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion +CALL packages\KoreBuild\build\kvm install -svr50 -x86 +CALL packages\KoreBuild\build\kvm install -svrc50 -x86 :run +CALL packages\KoreBuild\build\kvm use default -svr50 -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh new file mode 100644 index 00000000000..db1e0c3dde2 --- /dev/null +++ b/build.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +if test `uname` = Darwin; then + cachedir=~/Library/Caches/KBuild +else + if x$XDG_DATA_HOME = x; then + cachedir=$HOME/.local/share + else + cachedir=$XDG_DATA_HOME; + fi +fi +mkdir -p $cachedir + +url=https://www.nuget.org/nuget.exe + +if test ! -f $cachedir/nuget.exe; then + wget -o $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null +fi + +if test ! -e .nuget; then + mkdir .nuget + cp $cachedir/nuget.exe .nuget +fi + +if test ! -d packages/KoreBuild; then + mono .nuget/nuget.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre + mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion +fi + +mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" \ No newline at end of file From 6529ec24b43b6e8c0079fca9c9293433d91af83e Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Fri, 2 May 2014 15:07:39 -0700 Subject: [PATCH 020/463] Updating build scripts --- build.cmd | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.cmd b/build.cmd index 2c32132fa3d..903d532df3c 100644 --- a/build.cmd +++ b/build.cmd @@ -18,8 +18,8 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -CALL packages\KoreBuild\build\kvm install -svr50 -x86 -CALL packages\KoreBuild\build\kvm install -svrc50 -x86 +CALL packages\KoreBuild\build\kvm upgrade -svr50 -x86 +CALL packages\KoreBuild\build\kvm install default -svrc50 -x86 :run CALL packages\KoreBuild\build\kvm use default -svr50 -x86 From 314d13e355b7086b979dbc33169996093fb4d943 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 7 May 2014 18:12:57 -0700 Subject: [PATCH 021/463] Sort dependencies and remove duplicates in dependencies --- test/Sample.Tests/project.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index d3e427099b8..94262300cb2 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,10 +1,10 @@ { "dependencies": { - "Xunit.KRunner": "", "xunit.abstractions": "2.0.0-aspnet-*", "xunit.assert": "2.0.0-aspnet-*", "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" + "xunit.execution": "2.0.0-aspnet-*", + "Xunit.KRunner": "" }, "commands": { "test": "Xunit.KRunner" From db926290f2375d02cf06ebbe1a000c1eeae26569 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 8 May 2014 03:29:16 -0700 Subject: [PATCH 022/463] React to renames --- src/Xunit.KRunner/Program.cs | 2 +- src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs | 2 +- src/Xunit.KRunner/Services/IApplicationEnvironment.cs | 2 +- src/Xunit.KRunner/Services/IFileMonitor.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 80517af9df6..1a421faff23 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -19,7 +19,7 @@ using System.Collections.Concurrent; using System.Linq; using System.Reflection; -using Microsoft.Net.Runtime; +using Microsoft.Framework.Runtime; using Xunit.ConsoleClient; using Xunit.Sdk; #if !NET45 diff --git a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs index 7bbdffd73c3..8556711eb24 100644 --- a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs +++ b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs @@ -17,7 +17,7 @@ using System; -namespace Microsoft.Net.Runtime +namespace Microsoft.Framework.Runtime { [AssemblyNeutral] [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] diff --git a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs index 28fc312ab10..5d635f5d8ea 100644 --- a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs +++ b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs @@ -17,7 +17,7 @@ using System.Runtime.Versioning; -namespace Microsoft.Net.Runtime +namespace Microsoft.Framework.Runtime { [AssemblyNeutral] public interface IApplicationEnvironment diff --git a/src/Xunit.KRunner/Services/IFileMonitor.cs b/src/Xunit.KRunner/Services/IFileMonitor.cs index 528593b39db..06bd70f68d9 100644 --- a/src/Xunit.KRunner/Services/IFileMonitor.cs +++ b/src/Xunit.KRunner/Services/IFileMonitor.cs @@ -17,7 +17,7 @@ using System; -namespace Microsoft.Net.Runtime +namespace Microsoft.Framework.Runtime { [AssemblyNeutral] public interface IFileMonitor From e13ad03ae450647eda20121ba3178d680d6f488d Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Thu, 8 May 2014 16:37:25 -0700 Subject: [PATCH 023/463] Create LICENSE.txt --- LICENSE.txt | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 LICENSE.txt diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 00000000000..d85a1524adf --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,12 @@ +Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. + +Licensed under the Apache License, Version 2.0 (the "License"); you may not use +these files except in compliance with the License. You may obtain a copy of the +License at + +http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software distributed +under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR +CONDITIONS OF ANY KIND, either express or implied. See the License for the +specific language governing permissions and limitations under the License. From 86d09ea2be335ae048be3f22594dfaf3c8313f60 Mon Sep 17 00:00:00 2001 From: Andrew Peters Date: Thu, 8 May 2014 23:01:43 -0700 Subject: [PATCH 024/463] Updating copyright headers --- .../CultureReplacer.cs | 18 ++---------------- .../ExceptionAssertions.cs | 18 ++---------------- src/Microsoft.AspNet.Testing/ReplaceCulture.cs | 18 ++---------------- src/Xunit.KRunner/CommandLine.cs | 18 ++---------------- src/Xunit.KRunner/Common/Guard.cs | 18 ++---------------- .../Common/TestDiscoveryVisitor.cs | 18 ++---------------- src/Xunit.KRunner/Common/TestOptionsNames.cs | 18 ++---------------- .../Frameworks/TestFrameworkOptions.cs | 18 ++---------------- .../Frameworks/v2/XunitDiscoveryOptions.cs | 18 ++---------------- .../Frameworks/v2/XunitExecutionOptions.cs | 18 ++---------------- src/Xunit.KRunner/ParallelismOption.cs | 18 ++---------------- src/Xunit.KRunner/Program.cs | 18 ++---------------- .../Services/AssemblyNeutralAttribute.cs | 18 ++---------------- .../Services/IApplicationEnvironment.cs | 18 ++---------------- src/Xunit.KRunner/Services/IFileMonitor.cs | 18 ++---------------- src/Xunit.KRunner/Utility/ExceptionUtility.cs | 18 ++---------------- src/Xunit.KRunner/Utility/ExecutionSummary.cs | 18 ++---------------- .../Visitors/StandardOutputVisitor.cs | 18 ++---------------- src/Xunit.KRunner/Visitors/TeamCityVisitor.cs | 18 ++---------------- .../Visitors/TestMessageVisitor.cs | 18 ++---------------- .../Visitors/XmlTestExecutionVisitor.cs | 18 ++---------------- test/Sample.Tests/SampleTest.cs | 18 ++---------------- 22 files changed, 44 insertions(+), 352 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/CultureReplacer.cs b/src/Microsoft.AspNet.Testing/CultureReplacer.cs index ad15309f39d..1b5a7a9eb0e 100644 --- a/src/Microsoft.AspNet.Testing/CultureReplacer.cs +++ b/src/Microsoft.AspNet.Testing/CultureReplacer.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Globalization; diff --git a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs index 049615504ca..426b435548a 100644 --- a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs +++ b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Reflection; diff --git a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs index 041355ef924..3e6e8ca8b2a 100644 --- a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs +++ b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Globalization; diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs index 74a5d077e82..097c632672a 100644 --- a/src/Xunit.KRunner/CommandLine.cs +++ b/src/Xunit.KRunner/CommandLine.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; diff --git a/src/Xunit.KRunner/Common/Guard.cs b/src/Xunit.KRunner/Common/Guard.cs index b313626391e..34bd8667f81 100644 --- a/src/Xunit.KRunner/Common/Guard.cs +++ b/src/Xunit.KRunner/Common/Guard.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs index 8fb3c40cd51..69e67f2abac 100644 --- a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs +++ b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using Xunit.Abstractions; diff --git a/src/Xunit.KRunner/Common/TestOptionsNames.cs b/src/Xunit.KRunner/Common/TestOptionsNames.cs index b464fd7f100..c998c8c4bd7 100644 --- a/src/Xunit.KRunner/Common/TestOptionsNames.cs +++ b/src/Xunit.KRunner/Common/TestOptionsNames.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. internal static class TestOptionsNames { diff --git a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs index 27b886dd859..fd40c9410f8 100644 --- a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs +++ b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using Xunit.Abstractions; diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs index 0a7b269f469..a866b24b565 100644 --- a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs +++ b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Xunit { diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs index e1dd9086ced..96721a30509 100644 --- a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs +++ b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Xunit { diff --git a/src/Xunit.KRunner/ParallelismOption.cs b/src/Xunit.KRunner/ParallelismOption.cs index 96099bf1532..5a5152bb45c 100644 --- a/src/Xunit.KRunner/ParallelismOption.cs +++ b/src/Xunit.KRunner/ParallelismOption.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Xunit.ConsoleClient { diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 1a421faff23..679a3edd459 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; diff --git a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs index 8556711eb24..abb8b245ee1 100644 --- a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs +++ b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs index 5d635f5d8ea..f9fe32ddb00 100644 --- a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs +++ b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Runtime.Versioning; diff --git a/src/Xunit.KRunner/Services/IFileMonitor.cs b/src/Xunit.KRunner/Services/IFileMonitor.cs index 06bd70f68d9..1a2aa9ffc30 100644 --- a/src/Xunit.KRunner/Services/IFileMonitor.cs +++ b/src/Xunit.KRunner/Services/IFileMonitor.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; diff --git a/src/Xunit.KRunner/Utility/ExceptionUtility.cs b/src/Xunit.KRunner/Utility/ExceptionUtility.cs index b7ab3a2f6d6..b64b71369ee 100644 --- a/src/Xunit.KRunner/Utility/ExceptionUtility.cs +++ b/src/Xunit.KRunner/Utility/ExceptionUtility.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; diff --git a/src/Xunit.KRunner/Utility/ExecutionSummary.cs b/src/Xunit.KRunner/Utility/ExecutionSummary.cs index 1e241ced1d2..94be1c2b559 100644 --- a/src/Xunit.KRunner/Utility/ExecutionSummary.cs +++ b/src/Xunit.KRunner/Utility/ExecutionSummary.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. namespace Xunit { diff --git a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs index c7a4db5a740..e4c9f03a228 100644 --- a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs +++ b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; diff --git a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs index 8bfeecc62d8..5412b33f1e2 100644 --- a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs +++ b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Concurrent; diff --git a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs index 90c0bcb927b..04a7e474d68 100644 --- a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs +++ b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Threading; diff --git a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs index 28a9aae82c8..07bcc264143 100644 --- a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs +++ b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using Xunit.Abstractions; diff --git a/test/Sample.Tests/SampleTest.cs b/test/Sample.Tests/SampleTest.cs index 7ac30433d12..f5c5524234e 100644 --- a/test/Sample.Tests/SampleTest.cs +++ b/test/Sample.Tests/SampleTest.cs @@ -1,19 +1,5 @@ -// Copyright (c) Microsoft Open Technologies, Inc. -// All Rights Reserved -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR -// CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING -// WITHOUT LIMITATION ANY IMPLIED WARRANTIES OR CONDITIONS OF -// TITLE, FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABLITY OR -// NON-INFRINGEMENT. -// See the Apache 2 License for the specific language governing -// permissions and limitations under the License. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using Xunit; From 53dcbeb6f2d9741c3f074cf80f2002fdc30caa6d Mon Sep 17 00:00:00 2001 From: Glenn Date: Mon, 12 May 2014 21:41:26 -0700 Subject: [PATCH 025/463] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f0c8e5adda..b24a5f68f49 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ Testing ======= -This repository contains testing infrastructure for Project K. +This repository contains testing infrastructure for ASP.NET To get started using it, see [How to create test projects](https://github.com/aspnet/Testing/wiki/How-to-create-test-projects). + +This project is part of ASP.NET vNext. You can find samples, documentation and getting started instructions for ASP.NET vNext at the [Home](https://github.com/aspnet/home) repo. From 106554dd03215982abc3c9b8db740e4a75af25e8 Mon Sep 17 00:00:00 2001 From: Eilon Lipton Date: Tue, 13 May 2014 01:03:17 -0700 Subject: [PATCH 026/463] Create CONTRIBUTING.md --- CONTRIBUTING.md | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..eac4268e4c9 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,4 @@ +Contributing +====== + +Information on contributing to this repo is in the [Contributing Guide](https://github.com/aspnet/Home/blob/master/CONTRIBUTING.md) in the Home repo. From 987cad55b50ff27a4da9b8411d0a8e57706a93dd Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 15 May 2014 16:15:28 -0700 Subject: [PATCH 027/463] React to xunit changes --- Testing.sln | 73 +++++-------------- .../Microsoft.AspNet.Testing.kproj | 34 +++++++++ src/Microsoft.AspNet.Testing/project.json | 18 ++--- src/Xunit.KRunner/Program.cs | 2 +- src/Xunit.KRunner/Xunit.KRunner.kproj | 49 +++++++++++++ src/Xunit.KRunner/project.json | 18 +---- test/Sample.Tests/Sample.Tests.kproj | 32 ++++++++ test/Sample.Tests/project.json | 16 +--- 8 files changed, 147 insertions(+), 95 deletions(-) create mode 100644 src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj create mode 100644 src/Xunit.KRunner/Xunit.KRunner.kproj create mode 100644 test/Sample.Tests/Sample.Tests.kproj diff --git a/Testing.sln b/Testing.sln index 0fb8354fc30..d075231ffc6 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,31 +1,17 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2013 -VisualStudioVersion = 12.0.21005.1 +# Visual Studio 14 +VisualStudioVersion = 14.0.21708.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{D2EDB163-538E-47C3-A8E5-0633FBC9D668}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.KRunner.net45", "src\Xunit.KRunner\Xunit.KRunner.net45.csproj", "{C9D4238C-63BD-4277-A240-9F61647EA884}" -EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{09F799F3-E521-466F-B155-B89E2746C8C9}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{9D51B712-05C0-499D-BE81-0395142837A0}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Tests.net45", "test\Sample.Tests\Sample.Tests.net45.csproj", "{69FBE3CD-3381-4C54-A323-5A724E8A7B4F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{A345517E-DA14-47AC-B514-54E97D179E97}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Xunit.KRunner.k10", "src\Xunit.KRunner\Xunit.KRunner.k10.csproj", "{DDC3C708-5EF4-48B9-BBFF-63AE727A7949}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "k10", "k10", "{FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Sample.Tests.k10", "test\Sample.Tests\Sample.Tests.k10.csproj", "{9902DB70-F3E0-42D6-A0DA-585E4091D781}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Xunit.KRunner", "src\Xunit.KRunner\Xunit.KRunner.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B7061}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Testing.net45", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.net45.csproj", "{EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.kproj", "{09BE5203-8042-4338-9713-E44169342E72}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.AspNet.Testing.k10", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.k10.csproj", "{817A11AB-E345-4921-B870-72817E70BD3D}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample.Tests", "test\Sample.Tests\Sample.Tests.kproj", "{25D18D0B-119C-4AB4-BCA6-AC06179335FA}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -33,44 +19,25 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {C9D4238C-63BD-4277-A240-9F61647EA884}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C9D4238C-63BD-4277-A240-9F61647EA884}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C9D4238C-63BD-4277-A240-9F61647EA884}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C9D4238C-63BD-4277-A240-9F61647EA884}.Release|Any CPU.Build.0 = Release|Any CPU - {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {69FBE3CD-3381-4C54-A323-5A724E8A7B4F}.Release|Any CPU.Build.0 = Release|Any CPU - {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DDC3C708-5EF4-48B9-BBFF-63AE727A7949}.Release|Any CPU.Build.0 = Release|Any CPU - {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9902DB70-F3E0-42D6-A0DA-585E4091D781}.Release|Any CPU.Build.0 = Release|Any CPU - {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F}.Release|Any CPU.Build.0 = Release|Any CPU - {817A11AB-E345-4921-B870-72817E70BD3D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {817A11AB-E345-4921-B870-72817E70BD3D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {817A11AB-E345-4921-B870-72817E70BD3D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {817A11AB-E345-4921-B870-72817E70BD3D}.Release|Any CPU.Build.0 = Release|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B7061}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B7061}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B7061}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B7061}.Release|Any CPU.Build.0 = Release|Any CPU + {09BE5203-8042-4338-9713-E44169342E72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {09BE5203-8042-4338-9713-E44169342E72}.Debug|Any CPU.Build.0 = Debug|Any CPU + {09BE5203-8042-4338-9713-E44169342E72}.Release|Any CPU.ActiveCfg = Release|Any CPU + {09BE5203-8042-4338-9713-E44169342E72}.Release|Any CPU.Build.0 = Release|Any CPU + {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {D2EDB163-538E-47C3-A8E5-0633FBC9D668} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} - {A345517E-DA14-47AC-B514-54E97D179E97} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} - {C9D4238C-63BD-4277-A240-9F61647EA884} = {D2EDB163-538E-47C3-A8E5-0633FBC9D668} - {EF15F677-FA00-4DFB-A60E-7E2FBDE0FC3F} = {D2EDB163-538E-47C3-A8E5-0633FBC9D668} - {9D51B712-05C0-499D-BE81-0395142837A0} = {09F799F3-E521-466F-B155-B89E2746C8C9} - {FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02} = {09F799F3-E521-466F-B155-B89E2746C8C9} - {69FBE3CD-3381-4C54-A323-5A724E8A7B4F} = {9D51B712-05C0-499D-BE81-0395142837A0} - {DDC3C708-5EF4-48B9-BBFF-63AE727A7949} = {A345517E-DA14-47AC-B514-54E97D179E97} - {817A11AB-E345-4921-B870-72817E70BD3D} = {A345517E-DA14-47AC-B514-54E97D179E97} - {9902DB70-F3E0-42D6-A0DA-585E4091D781} = {FDE66C09-CED8-4CF8-8C80-01AFA0C0CA02} + {F003F228-2AE2-4E9D-877B-93EB773B7061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {09BE5203-8042-4338-9713-E44169342E72} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {25D18D0B-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj new file mode 100644 index 00000000000..140d59009dc --- /dev/null +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj @@ -0,0 +1,34 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 09be5203-8042-4338-9713-e44169342e72 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 8e09fdbddc6..661112d5e4c 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,30 +1,24 @@ { "version": "0.1-alpha-*", "dependencies": { - "xunit.abstractions": "2.0.0-aspnet-*", "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" + "xunit.core": "2.0.0-aspnet-*" }, "configurations": { "net45": { "dependencies": { + "System.Runtime": "", "System.Reflection": "", - "System.Runtime": "" + "System.Threading.Tasks": "" } }, "k10": { "dependencies": { - "System.Collections": "4.0.0.0", - "System.Diagnostics.Debug": "4.0.10.0", + "System.Runtime": "4.0.20.0", "System.Globalization": "4.0.10.0", - "System.Linq": "4.0.0.0", + "System.Threading.Tasks": "4.0.10.0", "System.Reflection": "4.0.10.0", - "System.Resources.ResourceManager": "4.0.0.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0", - "System.Threading": "4.0.0.0", - "System.Threading.Tasks": "4.0.10.0" + "System.Threading.Thread": "4.0.0.0" } } } diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 679a3edd459..702a3920375 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -164,7 +164,7 @@ void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, boo var executionOptions = new XunitExecutionOptions { DisableParallelization = !parallelizeTestCollections, MaxParallelThreads = maxThreadCount }; var resultsVisitor = CreateVisitor(consoleLock, teamCity); - executor.Run(discoveryVisitor.TestCases, resultsVisitor, executionOptions); + executor.RunTests(discoveryVisitor.TestCases, resultsVisitor, executionOptions); resultsVisitor.Finished.WaitOne(); } catch (Exception ex) diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj new file mode 100644 index 00000000000..165a5a3ba51 --- /dev/null +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -0,0 +1,49 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + f003f228-2ae2-4e9d-877b-93eb773b7061 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 9361934e183..8a749b511a6 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,27 +1,15 @@ { "version": "0.1-alpha-*", "dependencies": { - "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", "xunit.execution": "2.0.0-aspnet-*" }, "configurations": { - "net45": { - "dependencies": { - "System.Runtime": "" - } - }, + "net45": {}, "k10": { "dependencies": { - "System.Collections": "4.0.0.0", - "System.Collections.Concurrent": "4.0.0.0", "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0", - "System.IO": "4.0.0.0", - "System.Linq": "4.0.0.0", - "System.Reflection": "4.0.10.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0", - "System.Threading": "4.0.0.0" + "System.Diagnostics.Process": "4.0.0.0" } } } diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj new file mode 100644 index 00000000000..1c30ad90fd6 --- /dev/null +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -0,0 +1,32 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 25d18d0b-119c-4ab4-bca6-ac06179335fa + Library + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + + + + + + + \ No newline at end of file diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 94262300cb2..dd2975376a4 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,24 +1,12 @@ { "dependencies": { - "xunit.abstractions": "2.0.0-aspnet-*", - "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*", "Xunit.KRunner": "" }, "commands": { "test": "Xunit.KRunner" }, "configurations": { - "net45": { - "dependencies": { - "System.Runtime": "" - } - }, - "k10": { - "dependencies": { - "System.Runtime": "4.0.20.0" - } - } + "net45": {}, + "k10": {} } } \ No newline at end of file From 24fffa1b874066395836e8084393dab353948b5b Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 21 May 2014 14:33:28 -0700 Subject: [PATCH 028/463] Updating .gitignore for the new millenium --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index aba9c594d74..9274ba2c888 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ [Bb]in/ TestResults/ .nuget/ +*.sln.ide/ _ReSharper.*/ packages/ artifacts/ @@ -22,4 +23,5 @@ nuget.exe *DS_Store *.ncrunchsolution *.*sdf -*.ipch \ No newline at end of file +*.ipch +*.sln.ide \ No newline at end of file From 5a30e8aae3d8f0a0246b48c7d1a23b4777d9d817 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Tue, 20 May 2014 12:46:15 -0700 Subject: [PATCH 029/463] Adding projects for a stylecop runner - Runner is a console.exe because stylecop won't work on K10 - Rules project is an empty placeholder for now - Next change will port our 'header' rule --- Testing.sln | 16 ++- src/StyleCop.KRules/StyleCop.KRules.kproj | 31 ++++++ src/StyleCop.KRules/project.json | 12 +++ src/StyleCop.KRunner/KCop.Runner.csproj | 62 ++++++++++++ src/StyleCop.KRunner/Program.cs | 114 ++++++++++++++++++++++ src/StyleCop.KRunner/packages.config | 4 + 6 files changed, 238 insertions(+), 1 deletion(-) create mode 100644 src/StyleCop.KRules/StyleCop.KRules.kproj create mode 100644 src/StyleCop.KRules/project.json create mode 100644 src/StyleCop.KRunner/KCop.Runner.csproj create mode 100644 src/StyleCop.KRunner/Program.cs create mode 100644 src/StyleCop.KRunner/packages.config diff --git a/Testing.sln b/Testing.sln index d075231ffc6..53bfe0756fe 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.21708.0 +VisualStudioVersion = 14.0.21719.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -13,6 +13,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing", EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample.Tests", "test\Sample.Tests\Sample.Tests.kproj", "{25D18D0B-119C-4AB4-BCA6-AC06179335FA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCop.Runner", "src\StyleCop.KRunner\KCop.Runner.csproj", "{62BE2FA4-6B9D-4296-9178-5FC2F66372AB}" +EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StyleCop.KRules", "src\StyleCop.KRules\StyleCop.KRules.kproj", "{657EB507-EE7A-451F-90A4-196F6FCD66E5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -31,6 +35,14 @@ Global {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {25D18D0B-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.Build.0 = Release|Any CPU + {62BE2FA4-6B9D-4296-9178-5FC2F66372AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {62BE2FA4-6B9D-4296-9178-5FC2F66372AB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {62BE2FA4-6B9D-4296-9178-5FC2F66372AB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {62BE2FA4-6B9D-4296-9178-5FC2F66372AB}.Release|Any CPU.Build.0 = Release|Any CPU + {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -39,5 +51,7 @@ Global {F003F228-2AE2-4E9D-877B-93EB773B7061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {09BE5203-8042-4338-9713-E44169342E72} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0B-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} + {62BE2FA4-6B9D-4296-9178-5FC2F66372AB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {657EB507-EE7A-451F-90A4-196F6FCD66E5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} EndGlobalSection EndGlobal diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj new file mode 100644 index 00000000000..ea9e8629bcc --- /dev/null +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -0,0 +1,31 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + 657eb507-ee7a-451f-90a4-196f6fcd66e5 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + + + + \ No newline at end of file diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json new file mode 100644 index 00000000000..1df01513ff4 --- /dev/null +++ b/src/StyleCop.KRules/project.json @@ -0,0 +1,12 @@ +{ + "version": "0.1-alpha-*", + "dependencies": { + "StyleCop": "4.7.10.0" + }, + "configurations" : { + "net45" : { + "dependencies": { + } + } + } +} diff --git a/src/StyleCop.KRunner/KCop.Runner.csproj b/src/StyleCop.KRunner/KCop.Runner.csproj new file mode 100644 index 00000000000..9e3c31bdaea --- /dev/null +++ b/src/StyleCop.KRunner/KCop.Runner.csproj @@ -0,0 +1,62 @@ + + + + + Debug + AnyCPU + {62BE2FA4-6B9D-4296-9178-5FC2F66372AB} + Exe + Properties + StyleCop.KRunner + StyleCop.KRunner + v4.5.1 + 512 + obj/net45 + + + AnyCPU + true + full + false + bin\Debug\net45 + DEBUG;TRACE;NET45; + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\net45 + TRACE;NET45; + prompt + 4 + + + + + + + + + False + ..\..\packages\StyleCop.4.7.10.0\lib\StyleCop.dll + + + ..\..\packages\StyleCop.4.7.10.0\lib\StyleCop.CSharp.dll + + + ..\..\packages\StyleCop.4.7.10.0\lib\StyleCop.CSharp.Rules.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/StyleCop.KRunner/Program.cs b/src/StyleCop.KRunner/Program.cs new file mode 100644 index 00000000000..17a4ac412e0 --- /dev/null +++ b/src/StyleCop.KRunner/Program.cs @@ -0,0 +1,114 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using Microsoft.Build.Framework; + +namespace StyleCop.KRunner +{ + public class Program + { + private static readonly List _violations = new List(); + + public static void Main(string[] args) + { + Console.WriteLine("StyleCop.KRunner - A StyleCop commandline runner"); + + if (args.Length == 0) + { + Console.WriteLine("Usage:"); + Console.WriteLine("\tStyleCop.KRunner "); + Console.WriteLine(); + return; + } + + var projectFile = args[0]; + if (!File.Exists(projectFile)) + { + Console.WriteLine("File '{0}' does not exist.", Path.GetFullPath(projectFile)); + return; + } + + var runner = new StyleCopConsole( + settings: null, + writeResultsCache: + false, + outputFile: null, + addInPaths: null, + loadFromDefaultPath: true); // Loads rules next to StyleCop.dll in the file system. + + var projectDirectory = Path.GetDirectoryName(projectFile); + + // It's OK if the settings file is null. + var settingsFile = FindSettingsFile(projectDirectory); + + var project = new CodeProject(0, projectDirectory, new Configuration(null)); + foreach (var file in Directory.EnumerateFiles(projectDirectory, "*.cs", SearchOption.AllDirectories)) + { + runner.Core.Environment.AddSourceCode(project, file, context: null); + } + + try + { + runner.OutputGenerated += Runner_OutputGenerated; + runner.ViolationEncountered += Runner_ViolationEncountered; + + if (settingsFile == null) + { + runner.Core.Analyze(new CodeProject[] { project }); + } + else + { + runner.Core.Analyze(new CodeProject[] { project }, settingsFile); + } + } + finally + { + runner.OutputGenerated -= Runner_OutputGenerated; + runner.ViolationEncountered -= Runner_ViolationEncountered; + } + + Console.WriteLine(); + Console.WriteLine("{0} errors found.", _violations.Count); + Console.WriteLine(); + } + + // Performs an ascending directory search starting at the project directory + private static string FindSettingsFile(string projectDirectory) + { + var current = new DirectoryInfo(projectDirectory); + var root = current.Root; + + do + { + var settingsFile = Path.Combine(current.FullName, "Settings.StyleCop"); + if (File.Exists(settingsFile)) + { + return settingsFile; + } + } + while ((current = current.Parent) != null); + + return null; + } + + private static void Runner_ViolationEncountered(object sender, ViolationEventArgs e) + { + Console.WriteLine("{0}: {1} Line {2} - {3}", e.Violation.Rule.CheckId, e.SourceCode.Path, e.LineNumber, e.Message); + + _violations.Add(e.Violation); + } + + private static void Runner_OutputGenerated(object sender, OutputEventArgs e) + { + // There will be a bunch of message like "processing file Bleh.cs" with low importance, + // we're intentionally excluding those. + if (e.Importance != MessageImportance.Low) + { + Console.WriteLine(e.Output); + } + } + } +} diff --git a/src/StyleCop.KRunner/packages.config b/src/StyleCop.KRunner/packages.config new file mode 100644 index 00000000000..3bf1cfa31af --- /dev/null +++ b/src/StyleCop.KRunner/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file From cac21e2cbc98a243125570fcf62d5db48f2fd91f Mon Sep 17 00:00:00 2001 From: David Fowler Date: Mon, 26 May 2014 02:55:17 -0700 Subject: [PATCH 030/463] Fixed project.json casing in kproj --- src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj | 5 +++-- src/StyleCop.KRules/StyleCop.KRules.kproj | 3 ++- src/Xunit.KRunner/Xunit.KRunner.kproj | 5 +++-- test/Sample.Tests/Sample.Tests.kproj | 5 +++-- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj index 140d59009dc..06abea8e847 100644 --- a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj @@ -23,7 +23,7 @@ 2.0 - + @@ -31,4 +31,5 @@ - \ No newline at end of file + + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index ea9e8629bcc..e8aaa2f9efb 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -28,4 +28,5 @@ - \ No newline at end of file + + diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index 165a5a3ba51..c694768b476 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -23,7 +23,7 @@ 2.0 - + @@ -46,4 +46,5 @@ - \ No newline at end of file + + diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj index 1c30ad90fd6..585c629459e 100644 --- a/test/Sample.Tests/Sample.Tests.kproj +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -23,10 +23,11 @@ 2.0 - + - \ No newline at end of file + + From 749169aba36305e79e6498afed1480a119ba423b Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 29 May 2014 15:25:44 -0700 Subject: [PATCH 031/463] Fixing sln and project files --- src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj | 4 ++-- src/StyleCop.KRules/StyleCop.KRules.kproj | 3 +-- src/Xunit.KRunner/Xunit.KRunner.kproj | 4 ++-- test/Sample.Tests/Sample.Tests.kproj | 4 ++-- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj index 06abea8e847..209fcee9b10 100644 --- a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj @@ -4,7 +4,7 @@ 12.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 09be5203-8042-4338-9713-e44169342e72 Library @@ -30,6 +30,6 @@ - + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index e8aaa2f9efb..ea9e8629bcc 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -28,5 +28,4 @@ - - + \ No newline at end of file diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index c694768b476..46b28a77f51 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -4,7 +4,7 @@ 12.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + f003f228-2ae2-4e9d-877b-93eb773b7061 Library @@ -45,6 +45,6 @@ - + diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj index 585c629459e..e0f704bd199 100644 --- a/test/Sample.Tests/Sample.Tests.kproj +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -4,7 +4,7 @@ 12.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 25d18d0b-119c-4ab4-bca6-ac06179335fa Library @@ -28,6 +28,6 @@ - + From 08a24dcc27535bdfb4646d61e58923f939dde99a Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 2 Jun 2014 14:03:02 -0700 Subject: [PATCH 032/463] Porting old rules from webstack --- src/StyleCop.KRules/FileHeaderRule.cs | 38 ++++++++++++++ .../StyleCop.KRules.FileHeaderRule.xml | 17 +++++++ ...leCop.KRules.UsingOutsideNamespaceRule.xml | 12 +++++ src/StyleCop.KRules/StyleCop.KRules.kproj | 8 +++ .../UsingOutsideNamespaceRule.cs | 49 +++++++++++++++++++ src/StyleCop.KRules/project.json | 1 + 6 files changed, 125 insertions(+) create mode 100644 src/StyleCop.KRules/FileHeaderRule.cs create mode 100644 src/StyleCop.KRules/StyleCop.KRules.FileHeaderRule.xml create mode 100644 src/StyleCop.KRules/StyleCop.KRules.UsingOutsideNamespaceRule.xml create mode 100644 src/StyleCop.KRules/UsingOutsideNamespaceRule.cs diff --git a/src/StyleCop.KRules/FileHeaderRule.cs b/src/StyleCop.KRules/FileHeaderRule.cs new file mode 100644 index 00000000000..05b442d451c --- /dev/null +++ b/src/StyleCop.KRules/FileHeaderRule.cs @@ -0,0 +1,38 @@ +using System; +using StyleCop.CSharp; + +namespace StyleCop.KRules +{ + [SourceAnalyzer(typeof(CsParser))] + public class FileHeaderRule : SourceAnalyzer + { + private const string FileHeaderTextPropertyName = "FileHeaderText"; + private const string RuleName = "FileMustHaveHeader"; + + public override void AnalyzeDocument(CodeDocument document) + { + var csharpDocument = (CsDocument)document; + if (csharpDocument.RootElement != null && !csharpDocument.RootElement.Generated) + { + if (IsRuleEnabled(csharpDocument, RuleName)) + { + CheckDocumentHeader(csharpDocument); + } + } + } + + private void CheckDocumentHeader(CsDocument csharpDocument) + { + var prop = GetSetting(csharpDocument.Settings, FileHeaderTextPropertyName) as StringProperty; + if (prop != null) + { + var expectedText = prop.Value; + var text = csharpDocument.FileHeader.HeaderText; + if (!string.Equals(text, expectedText, StringComparison.Ordinal)) + { + AddViolation(csharpDocument.RootElement, 1, RuleName); + } + } + } + } +} \ No newline at end of file diff --git a/src/StyleCop.KRules/StyleCop.KRules.FileHeaderRule.xml b/src/StyleCop.KRules/StyleCop.KRules.FileHeaderRule.xml new file mode 100644 index 00000000000..87c6914e75d --- /dev/null +++ b/src/StyleCop.KRules/StyleCop.KRules.FileHeaderRule.xml @@ -0,0 +1,17 @@ + + + + Checks for our required license header. + + + + + + + Make sure that the file has the required header. + Validates that the file has the configured header text. + + + + diff --git a/src/StyleCop.KRules/StyleCop.KRules.UsingOutsideNamespaceRule.xml b/src/StyleCop.KRules/StyleCop.KRules.UsingOutsideNamespaceRule.xml new file mode 100644 index 00000000000..c8f0df7271b --- /dev/null +++ b/src/StyleCop.KRules/StyleCop.KRules.UsingOutsideNamespaceRule.xml @@ -0,0 +1,12 @@ + + + + Requires that using be placed outside the namespace. + + + + A using directive should always be placed outside the namespace. + Validates that the code does not put using directives inside of a namespace declaration. + + + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index ea9e8629bcc..739b3a5b42f 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -27,5 +27,13 @@ + + + + + + + + \ No newline at end of file diff --git a/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs b/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs new file mode 100644 index 00000000000..1076b628f4b --- /dev/null +++ b/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs @@ -0,0 +1,49 @@ +using StyleCop.CSharp; + +namespace StyleCop.KRules +{ + [SourceAnalyzer(typeof(CsParser))] + public class UsingOutsideNamespaceRule : SourceAnalyzer + { + private const string RuleName = "UsingDirectivesMustBePlacedOutsideNamespace"; + + public override void AnalyzeDocument(CodeDocument document) + { + var csharpDocument = (CsDocument)document; + if (csharpDocument.RootElement != null && !csharpDocument.RootElement.Generated) + { + if (IsRuleEnabled(csharpDocument, RuleName)) + { + ProcessDocumentRoot(csharpDocument.RootElement); + } + } + } + + private void ProcessDocumentRoot(DocumentRoot documentRoot) + { + foreach (var child in documentRoot.ChildElements) + { + if (child.ElementType == ElementType.Namespace) + { + ProcessNamespace((Namespace)child); + } + } + } + + private void ProcessNamespace(Namespace ns) + { + foreach (var child in ns.ChildElements) + { + switch (child.ElementType) + { + case ElementType.Namespace: + ProcessNamespace((Namespace)child); + break; + case ElementType.UsingDirective: + AddViolation(child, RuleName); + break; + } + } + } + } +} diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index 1df01513ff4..82c76fe24be 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -3,6 +3,7 @@ "dependencies": { "StyleCop": "4.7.10.0" }, + "resources": [ "*.xml" ], "configurations" : { "net45" : { "dependencies": { From f5c1f4f9c62d743046bc184e6c6a6bd07c472734 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Mon, 2 Jun 2014 14:04:19 -0700 Subject: [PATCH 033/463] Adding some color to command output --- src/StyleCop.KRunner/Program.cs | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/StyleCop.KRunner/Program.cs b/src/StyleCop.KRunner/Program.cs index 17a4ac412e0..47ddb85ba86 100644 --- a/src/StyleCop.KRunner/Program.cs +++ b/src/StyleCop.KRunner/Program.cs @@ -12,31 +12,33 @@ public class Program { private static readonly List _violations = new List(); - public static void Main(string[] args) + public static int Main(string[] args) { + Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("StyleCop.KRunner - A StyleCop commandline runner"); + Console.ResetColor(); if (args.Length == 0) { Console.WriteLine("Usage:"); Console.WriteLine("\tStyleCop.KRunner "); Console.WriteLine(); - return; + return -1; } var projectFile = args[0]; if (!File.Exists(projectFile)) { Console.WriteLine("File '{0}' does not exist.", Path.GetFullPath(projectFile)); - return; + return -2; } var runner = new StyleCopConsole( - settings: null, - writeResultsCache: - false, - outputFile: null, - addInPaths: null, + settings: null, + writeResultsCache: + false, + outputFile: null, + addInPaths: null, loadFromDefaultPath: true); // Loads rules next to StyleCop.dll in the file system. var projectDirectory = Path.GetDirectoryName(projectFile); @@ -70,9 +72,23 @@ public static void Main(string[] args) runner.ViolationEncountered -= Runner_ViolationEncountered; } + if (_violations.Count == 0) + { + Console.ForegroundColor = ConsoleColor.Green; + } + else + { + Console.ForegroundColor = ConsoleColor.Red; + } + Console.WriteLine(); + Console.WriteLine("Finished Processing: {0}", projectFile); Console.WriteLine("{0} errors found.", _violations.Count); Console.WriteLine(); + + Console.ResetColor(); + + return _violations.Count; } // Performs an ascending directory search starting at the project directory From f0f26d902f083e4b043c9ec4f419a7032452df16 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 3 Jun 2014 10:17:25 -0700 Subject: [PATCH 034/463] Adding switch to build.cmd to skip KRE install --- build.cmd | 2 ++ 1 file changed, 2 insertions(+) diff --git a/build.cmd b/build.cmd index 903d532df3c..3aaf9575830 100644 --- a/build.cmd +++ b/build.cmd @@ -18,6 +18,8 @@ copy %CACHED_NUGET% .nuget\nuget.exe > nul IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion + +IF "%SKIP_KRE_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -svr50 -x86 CALL packages\KoreBuild\build\kvm install default -svrc50 -x86 From b79b4553b05127d10cbfe619e1bfc9bd3e454259 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 5 Jun 2014 13:37:31 -0700 Subject: [PATCH 035/463] Adding a max-line-length rule --- src/StyleCop.KRules/LineLengthRule.cs | 46 +++++++++++++++++++ .../StyleCop.KRules.LineLengthRule.xml | 17 +++++++ src/StyleCop.KRules/StyleCop.KRules.kproj | 2 + 3 files changed, 65 insertions(+) create mode 100644 src/StyleCop.KRules/LineLengthRule.cs create mode 100644 src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml diff --git a/src/StyleCop.KRules/LineLengthRule.cs b/src/StyleCop.KRules/LineLengthRule.cs new file mode 100644 index 00000000000..4689eb8f267 --- /dev/null +++ b/src/StyleCop.KRules/LineLengthRule.cs @@ -0,0 +1,46 @@ +using StyleCop.CSharp; + +namespace StyleCop.KRules +{ + [SourceAnalyzer(typeof(CsParser))] + public class LineLengthRule : SourceAnalyzer + { + private const string LineLengthProperty = "LineLength"; + private const string RuleName = "LineMustNotBeTooLong"; + + public override void AnalyzeDocument(CodeDocument document) + { + var csharpDocument = (CsDocument)document; + if (csharpDocument.RootElement != null && !csharpDocument.RootElement.Generated) + { + if (IsRuleEnabled(csharpDocument, RuleName)) + { + CheckLineLength(csharpDocument); + } + } + } + + private void CheckLineLength(CsDocument csharpDocument) + { + var lengthProperty = GetSetting(csharpDocument.Settings, LineLengthProperty) as IntProperty; + if (lengthProperty == null) + { + return; + } + + using (var reader = csharpDocument.SourceCode.Read()) + { + string line; + var lineNumber = 0; + while ((line = reader.ReadLine()) != null) + { + lineNumber++; + if (line.Length > lengthProperty.Value) + { + AddViolation(csharpDocument.RootElement, lineNumber, RuleName); + } + } + } + } + } +} \ No newline at end of file diff --git a/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml b/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml new file mode 100644 index 00000000000..538e6993594 --- /dev/null +++ b/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml @@ -0,0 +1,17 @@ + + + + Checks for lines that are too long. + + + + + + + Makes sure the lines aren't too long. + Makes sure the lines aren't too long. + + + + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index 739b3a5b42f..29578e399c3 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -29,9 +29,11 @@ + + From ca7f65d9339d35e5dfbebfb6a890d6a1a23afb8e Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 5 Jun 2014 13:39:10 -0700 Subject: [PATCH 036/463] adding headers for other rules --- src/StyleCop.KRules/FileHeaderRule.cs | 5 ++++- src/StyleCop.KRules/LineLengthRule.cs | 5 ++++- src/StyleCop.KRules/UsingOutsideNamespaceRule.cs | 5 ++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/StyleCop.KRules/FileHeaderRule.cs b/src/StyleCop.KRules/FileHeaderRule.cs index 05b442d451c..18de407fa24 100644 --- a/src/StyleCop.KRules/FileHeaderRule.cs +++ b/src/StyleCop.KRules/FileHeaderRule.cs @@ -1,4 +1,7 @@ -using System; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; using StyleCop.CSharp; namespace StyleCop.KRules diff --git a/src/StyleCop.KRules/LineLengthRule.cs b/src/StyleCop.KRules/LineLengthRule.cs index 4689eb8f267..6397c65789a 100644 --- a/src/StyleCop.KRules/LineLengthRule.cs +++ b/src/StyleCop.KRules/LineLengthRule.cs @@ -1,4 +1,7 @@ -using StyleCop.CSharp; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using StyleCop.CSharp; namespace StyleCop.KRules { diff --git a/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs b/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs index 1076b628f4b..47df5e881ed 100644 --- a/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs +++ b/src/StyleCop.KRules/UsingOutsideNamespaceRule.cs @@ -1,4 +1,7 @@ -using StyleCop.CSharp; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using StyleCop.CSharp; namespace StyleCop.KRules { From 0895c8b77b102b4492051dce51bcfd5a6cbd8af1 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 5 Jun 2014 14:22:31 -0700 Subject: [PATCH 037/463] enhancements to line length rule --- src/StyleCop.KRules/LineLengthRule.cs | 6 +++++- src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/StyleCop.KRules/LineLengthRule.cs b/src/StyleCop.KRules/LineLengthRule.cs index 6397c65789a..097c310263d 100644 --- a/src/StyleCop.KRules/LineLengthRule.cs +++ b/src/StyleCop.KRules/LineLengthRule.cs @@ -40,7 +40,11 @@ private void CheckLineLength(CsDocument csharpDocument) lineNumber++; if (line.Length > lengthProperty.Value) { - AddViolation(csharpDocument.RootElement, lineNumber, RuleName); + AddViolation( + csharpDocument.RootElement, + lineNumber, + RuleName, + lengthProperty.Value); } } } diff --git a/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml b/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml index 538e6993594..853d277bdc6 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml +++ b/src/StyleCop.KRules/StyleCop.KRules.LineLengthRule.xml @@ -4,12 +4,12 @@ Checks for lines that are too long. - - Makes sure the lines aren't too long. + Line must not be longer than {0} characters. Makes sure the lines aren't too long. From 81b312cadb9b741b63418094876f98afe6e03258 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 5 Jun 2014 16:21:22 -0700 Subject: [PATCH 038/463] Adding a use-var rule --- .../StyleCop.KRules.UseVarRule.xml | 12 +++ src/StyleCop.KRules/StyleCop.KRules.kproj | 2 + src/StyleCop.KRules/UseVarRule.cs | 98 +++++++++++++++++++ 3 files changed, 112 insertions(+) create mode 100644 src/StyleCop.KRules/StyleCop.KRules.UseVarRule.xml create mode 100644 src/StyleCop.KRules/UseVarRule.cs diff --git a/src/StyleCop.KRules/StyleCop.KRules.UseVarRule.xml b/src/StyleCop.KRules/StyleCop.KRules.UseVarRule.xml new file mode 100644 index 00000000000..6df525faeac --- /dev/null +++ b/src/StyleCop.KRules/StyleCop.KRules.UseVarRule.xml @@ -0,0 +1,12 @@ + + + + Requires that var be used when possible. + + + + Expression should use var '{0}' + Validates that declarations use var when possible. + + + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index 29578e399c3..e244eceff3b 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -26,10 +26,12 @@ + + diff --git a/src/StyleCop.KRules/UseVarRule.cs b/src/StyleCop.KRules/UseVarRule.cs new file mode 100644 index 00000000000..4917180a5da --- /dev/null +++ b/src/StyleCop.KRules/UseVarRule.cs @@ -0,0 +1,98 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Linq; +using StyleCop.CSharp; + +namespace StyleCop.KRules +{ + [SourceAnalyzer(typeof(CsParser))] + public class UseVarRule : SourceAnalyzer + { + private const string RuleName = "UseVarWhenPossible"; + + public override bool DoAnalysis(CodeDocument document) + { + var doc = (CsDocument)document; + + // skipping wrong or auto-generated documents + if (doc.RootElement == null || doc.RootElement.Generated) + { + return true; + } + + if (IsRuleEnabled(document, RuleName)) + { + doc.WalkDocument(null, null, VisitExpression); + } + + return true; + } + + private bool VisitExpression( + Expression expression, + Expression parentExpression, + Statement parentStatement, + CsElement parentElement, + object context) + { + if (expression.ExpressionType == ExpressionType.VariableDeclaration) + { + var declarationExpression = expression as VariableDeclarationExpression; + if (declarationExpression == null) + { + this.Log(StyleCopLogLevel.High, "Unknown variable declaration type. " + expression.Location); + return true; + } + + // Fields can't use var. + if (declarationExpression.Parent != null && declarationExpression.Parent.Parent is Field) + { + return true; + } + + // Variables declared as const can't use var. + var declarationStatement = parentStatement as VariableDeclarationStatement; + if (declarationStatement != null && + declarationStatement.Tokens.Any() && + declarationStatement.Tokens.First().Text == "const") + { + + return true; + } + + // Variables declared without an initializer can't use var. + // + // Ex: + // object obj; + // if (dictionary.TryGetValue(..., out obj)) + if (declarationExpression.Declarators.Count == 1 && + declarationExpression.Declarators.First().Initializer == null) + { + return true; + } + + // Variables initialized to null can't use var. + // + // Ex: + // string s = null; + if (declarationExpression.Declarators.Count == 1 && + declarationExpression.Declarators.First().Initializer != null && + declarationExpression.Declarators.First().Initializer.Text == "null") + { + return true; + } + + if (declarationExpression.Type.Text == "var") + { + return true; + } + + AddViolation(parentElement, expression.Location, RuleName, expression.Text); + return true; + } + + return true; + } + } +} \ No newline at end of file From ec4322e2d6f5344f366ee1b1905dd767119675bf Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Fri, 6 Jun 2014 13:38:19 -0700 Subject: [PATCH 039/463] Fixing an issue with the var rule --- src/StyleCop.KRules/UseVarRule.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/StyleCop.KRules/UseVarRule.cs b/src/StyleCop.KRules/UseVarRule.cs index 4917180a5da..65dd937c486 100644 --- a/src/StyleCop.KRules/UseVarRule.cs +++ b/src/StyleCop.KRules/UseVarRule.cs @@ -83,6 +83,17 @@ private bool VisitExpression( return true; } + // Variables initialized with a lambda can't use var. + // + // Ex: + // Func f = () => true; + if (declarationExpression.Declarators.Count == 1 && + declarationExpression.Declarators.First().Initializer != null && + declarationExpression.Declarators.First().Initializer.ExpressionType == ExpressionType.Lambda) + { + return true; + } + if (declarationExpression.Type.Text == "var") { return true; From 5b5b03410caf5b458b8236bba1a9177ba7d2b6bd Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Tue, 10 Jun 2014 11:41:40 -0700 Subject: [PATCH 040/463] Reference Microsoft.Framework.Runtime.Interfaces --- .../Services/AssemblyNeutralAttribute.cs | 13 ------------- .../Services/IApplicationEnvironment.cs | 16 ---------------- src/Xunit.KRunner/Services/IFileMonitor.cs | 13 ------------- src/Xunit.KRunner/Xunit.KRunner.kproj | 3 --- src/Xunit.KRunner/project.json | 1 + 5 files changed, 1 insertion(+), 45 deletions(-) delete mode 100644 src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs delete mode 100644 src/Xunit.KRunner/Services/IApplicationEnvironment.cs delete mode 100644 src/Xunit.KRunner/Services/IFileMonitor.cs diff --git a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs b/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs deleted file mode 100644 index abb8b245ee1..00000000000 --- a/src/Xunit.KRunner/Services/AssemblyNeutralAttribute.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.Framework.Runtime -{ - [AssemblyNeutral] - [AttributeUsage(AttributeTargets.All, Inherited = false, AllowMultiple = true)] - public sealed class AssemblyNeutralAttribute : Attribute - { - } -} diff --git a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs b/src/Xunit.KRunner/Services/IApplicationEnvironment.cs deleted file mode 100644 index f9fe32ddb00..00000000000 --- a/src/Xunit.KRunner/Services/IApplicationEnvironment.cs +++ /dev/null @@ -1,16 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Runtime.Versioning; - -namespace Microsoft.Framework.Runtime -{ - [AssemblyNeutral] - public interface IApplicationEnvironment - { - string ApplicationName { get; } - string Version { get; } - string ApplicationBasePath { get; } - FrameworkName TargetFramework { get; } - } -} diff --git a/src/Xunit.KRunner/Services/IFileMonitor.cs b/src/Xunit.KRunner/Services/IFileMonitor.cs deleted file mode 100644 index 1a2aa9ffc30..00000000000 --- a/src/Xunit.KRunner/Services/IFileMonitor.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -namespace Microsoft.Framework.Runtime -{ - [AssemblyNeutral] - public interface IFileMonitor - { - event Action OnChanged; - } -} diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index 46b28a77f51..aee1e674625 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -35,9 +35,6 @@ - - - diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 8a749b511a6..78dccf24f8c 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,6 +1,7 @@ { "version": "0.1-alpha-*", "dependencies": { + "Microsoft.Framework.Runtime.Interfaces": "0.1-alpha-*", "xunit.assert": "2.0.0-aspnet-*", "xunit.execution": "2.0.0-aspnet-*" }, From e747bbc522d029b4e2b6935b34e65f915178aabe Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 10 Jun 2014 17:24:57 -0700 Subject: [PATCH 041/463] Updating build.sh based on KRuntime changes --- build.sh | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/build.sh b/build.sh index db1e0c3dde2..4323aefc489 100644 --- a/build.sh +++ b/build.sh @@ -3,10 +3,10 @@ if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild else - if x$XDG_DATA_HOME = x; then - cachedir=$HOME/.local/share + if [ -z $XDG_DATA_HOME ]; then + cachedir=$HOME/.local/share else - cachedir=$XDG_DATA_HOME; + cachedir=$XDG_DATA_HOME; fi fi mkdir -p $cachedir @@ -14,12 +14,12 @@ mkdir -p $cachedir url=https://www.nuget.org/nuget.exe if test ! -f $cachedir/nuget.exe; then - wget -o $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null + wget -O $cachedir/nuget.exe $url 2>/dev/null || curl -o $cachedir/nuget.exe --location $url /dev/null fi if test ! -e .nuget; then mkdir .nuget - cp $cachedir/nuget.exe .nuget + cp $cachedir/nuget.exe .nuget/nuget.exe fi if test ! -d packages/KoreBuild; then @@ -27,4 +27,12 @@ if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion fi -mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" \ No newline at end of file +if ! type k > /dev/null 2>&1; then + source setup/kvm.sh +fi + +if ! type k > /dev/null 2>&1; then + kvm upgrade +fi + +mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 45271287c553e0c3835d44413179e4497cb3630d Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 18 Jun 2014 16:46:18 -0700 Subject: [PATCH 042/463] Change the default author in makefile.shade --- makefile.shade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile.shade b/makefile.shade index 6357ea2841d..562494d144c 100644 --- a/makefile.shade +++ b/makefile.shade @@ -1,7 +1,7 @@ var VERSION='0.1' var FULL_VERSION='0.1' -var AUTHORS='Microsoft' +var AUTHORS='Microsoft Open Technologies, Inc.' use-standard-lifecycle k-standard-goals From 246838dcbe6fe04540dbba91254a95d5fcaa182d Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 19 Jun 2014 11:41:11 -0700 Subject: [PATCH 043/463] Bump version to 1.0.0-* --- src/Microsoft.AspNet.Testing/project.json | 2 +- src/StyleCop.KRules/project.json | 2 +- src/Xunit.KRunner/project.json | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 661112d5e4c..f37f3fc2ad6 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,5 +1,5 @@ { - "version": "0.1-alpha-*", + "version": "1.0.0-*", "dependencies": { "xunit.assert": "2.0.0-aspnet-*", "xunit.core": "2.0.0-aspnet-*" diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index 82c76fe24be..55a02f7e61c 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -1,5 +1,5 @@ { - "version": "0.1-alpha-*", + "version": "1.0.0-*", "dependencies": { "StyleCop": "4.7.10.0" }, diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 78dccf24f8c..d8d81f6f576 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,7 +1,7 @@ { - "version": "0.1-alpha-*", + "version": "1.0.0-*", "dependencies": { - "Microsoft.Framework.Runtime.Interfaces": "0.1-alpha-*", + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", "xunit.assert": "2.0.0-aspnet-*", "xunit.execution": "2.0.0-aspnet-*" }, From 6f79d138573bff7f9d5129b0146c88935777db32 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Fri, 20 Jun 2014 14:32:10 -0700 Subject: [PATCH 044/463] Updating release Nuget.config --- NuGet.Config | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index a059188b09f..1ce6b9e2573 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,13 +1,7 @@ - + - + - - - - - - - \ No newline at end of file + From 7055ce83bb217c0e6560f2367c59357e190b8d6a Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Fri, 20 Jun 2014 14:32:11 -0700 Subject: [PATCH 045/463] Updating dev Nuget.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e2573..f41e9c631de 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 72c7e586b6309d9f85b1d5604f06344dbd780849 Mon Sep 17 00:00:00 2001 From: Nate McMaster Date: Thu, 19 Jun 2014 11:24:55 -0700 Subject: [PATCH 046/463] Reflect the test framework using TestFrameworkAttribute --- src/Xunit.KRunner/Program.cs | 16 +++++++++++++++- src/Xunit.KRunner/project.json | 33 +++++++++++++++++---------------- 2 files changed, 32 insertions(+), 17 deletions(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 702a3920375..76489d614f6 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -8,6 +8,7 @@ using Microsoft.Framework.Runtime; using Xunit.ConsoleClient; using Xunit.Sdk; +using Xunit.Abstractions; #if !NET45 using System.Diagnostics; #endif @@ -154,7 +155,7 @@ void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, boo { var name = new AssemblyName(assemblyName); var assembly = Reflector.Wrap(Assembly.Load(name)); - var framework = new XunitTestFramework(); + var framework = GetFramework(assembly); var discoverer = framework.GetDiscoverer(assembly); var executor = framework.GetExecutor(name); var discoveryVisitor = new TestDiscoveryVisitor(); @@ -175,5 +176,18 @@ void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, boo failed = true; } } + + ITestFramework GetFramework(IAssemblyInfo assemblyInfo) + { + var frameworkAttribute = assemblyInfo.GetCustomAttributes(typeof(TestFrameworkAttribute)).FirstOrDefault(); + if (frameworkAttribute == null) + { + return new XunitTestFramework(); + } + var ctorArgs = frameworkAttribute.GetConstructorArguments().Cast().ToArray(); + var testFrameworkType = Reflector.GetType(ctorArgs[1], ctorArgs[0]); + var framework = Activator.CreateInstance(testFrameworkType) as ITestFramework; + return framework ?? new XunitTestFramework(); + } } } diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index d8d81f6f576..237ba090f91 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,17 +1,18 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "xunit.assert": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" - }, - "configurations": { - "net45": {}, - "k10": { - "dependencies": { - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0" - } - } - } +{ + "version": "1.0.0-*", + "dependencies": { + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" + }, + "configurations": { + "net45": {}, + "k10": { + "dependencies": { + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0" + } + } + } } \ No newline at end of file From 33804c7dedd3581ed92648eed2f0563d3af06b92 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 10 Jul 2014 22:59:03 -0700 Subject: [PATCH 047/463] Adding design-time integration --- src/Xunit.KRunner/CommandLine.cs | 25 +++++++ .../DesignTime/DesignTimeExecutionVisitor.cs | 68 +++++++++++++++++++ .../DesignTime/TestCaseExtensions.cs | 28 ++++++++ src/Xunit.KRunner/Program.cs | 67 +++++++++++++++--- src/Xunit.KRunner/Xunit.KRunner.kproj | 5 +- src/Xunit.KRunner/project.json | 1 + 6 files changed, 181 insertions(+), 13 deletions(-) create mode 100644 src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs create mode 100644 src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs index 097c632672a..06c3805cc4e 100644 --- a/src/Xunit.KRunner/CommandLine.cs +++ b/src/Xunit.KRunner/CommandLine.cs @@ -20,12 +20,18 @@ protected CommandLine(string[] args) Parse(); } + public bool DesignTime { get; set; } + + public bool List { get; set; } + public int MaxParallelThreads { get; set; } public bool ParallelizeTestCollections { get; set; } public bool TeamCity { get; protected set; } + public string[] Tests { get; set; } + static void GuardNoOptionValue(KeyValuePair option) { if (option.Value != null) @@ -80,11 +86,30 @@ protected virtual void Parse() break; } } + else if (optionName == "--test") + { + if (option.Value == null) + { + throw new ArgumentException("missing argument for --test"); + } + + Tests = option.Value.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); + } else if (optionName == "-teamcity") { GuardNoOptionValue(option); TeamCity = true; } + else if (optionName == "--list") + { + GuardNoOptionValue(option); + List = true; + } + else if (optionName == "--designtime") + { + GuardNoOptionValue(option); + DesignTime = true; + } } } diff --git a/src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs b/src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs new file mode 100644 index 00000000000..689f8ee3e9b --- /dev/null +++ b/src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs @@ -0,0 +1,68 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Framework.TestAdapter; +using Xunit.Abstractions; + +namespace Xunit.KRunner +{ + public class DesignTimeExecutionVisitor : TestMessageVisitor + { + private readonly ITestExecutionSink _sink; + + public DesignTimeExecutionVisitor(ITestExecutionSink sink) + { + _sink = sink; + } + + protected override bool Visit(ITestStarting testStarting) + { + _sink.RecordStart(testStarting.TestCase.ToDesignTimeTest()); + return base.Visit(testStarting); + } + + protected override bool Visit(ITestSkipped testSkipped) + { + var test = testSkipped.TestCase.ToDesignTimeTest(); + _sink.RecordResult(new TestResult(test) + { + Outcome = TestOutcome.Skipped, + }); + + return base.Visit(testSkipped); + } + + protected override bool Visit(ITestFailed testFailed) + { + var test = testFailed.TestCase.ToDesignTimeTest(); + var result = new TestResult(test) + { + Outcome = TestOutcome.Failed, + + Duration = TimeSpan.FromSeconds((double)testFailed.ExecutionTime), + ErrorMessage = string.Join(Environment.NewLine, testFailed.Messages), + ErrorStackTrace = string.Join(Environment.NewLine, testFailed.StackTraces), + }; + + result.Messages.Add(testFailed.Output); + + _sink.RecordResult(result); + + return base.Visit(testFailed); + } + + protected override bool Visit(ITestPassed testPassed) + { + var test = testPassed.TestCase.ToDesignTimeTest(); + _sink.RecordResult(new TestResult(test) + { + Outcome = TestOutcome.Passed, + + Duration = TimeSpan.FromSeconds((double)testPassed.ExecutionTime), + }); + + return base.Visit(testPassed); + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs b/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs new file mode 100644 index 00000000000..76c43ef7c8e --- /dev/null +++ b/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.TestAdapter; +using Xunit.Abstractions; + +namespace Xunit.KRunner +{ + public static class TestCaseExtensions + { + public static Test ToDesignTimeTest(this ITestCase testCase) + { + var test = new Test() + { + DisplayName = testCase.DisplayName, + FullyQualifiedName = testCase.DisplayName, + }; + + if (testCase.SourceInformation != null) + { + test.CodeFilePath = testCase.SourceInformation.FileName; + test.LineNumber = testCase.SourceInformation.LineNumber; + } + + return test; + } + } +} \ No newline at end of file diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 76489d614f6..a79189facd9 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -9,6 +9,7 @@ using Xunit.ConsoleClient; using Xunit.Sdk; using Xunit.Abstractions; +using Microsoft.Framework.TestAdapter; #if !NET45 using System.Diagnostics; #endif @@ -22,9 +23,11 @@ public class Program readonly ConcurrentDictionary completionMessages = new ConcurrentDictionary(); private readonly IApplicationEnvironment _environment; private readonly IFileMonitor _fileMonitor; + private readonly IServiceProvider _services; - public Program(IApplicationEnvironment environment, IFileMonitor fileMonitor) + public Program(IServiceProvider services, IApplicationEnvironment environment, IFileMonitor fileMonitor) { + _services = services; _environment = environment; _fileMonitor = fileMonitor; } @@ -62,7 +65,7 @@ public int Main(string[] args) { var commandLine = CommandLine.Parse(args); - int failCount = RunProject(commandLine.TeamCity, commandLine.ParallelizeTestCollections, commandLine.MaxParallelThreads); + int failCount = RunProject(commandLine); return failCount; } @@ -110,11 +113,11 @@ static void PrintUsage() Console.WriteLine(" -teamcity : forces TeamCity mode (normally auto-detected)"); } - int RunProject(bool teamcity, bool parallelizeTestCollections, int maxThreadCount) + int RunProject(CommandLine options) { var consoleLock = new object(); - ExecuteAssembly(consoleLock, _environment.ApplicationName, teamcity, parallelizeTestCollections, maxThreadCount); + ExecuteAssembly(consoleLock, _environment.ApplicationName, options); if (completionMessages.Count > 0) { @@ -138,15 +141,26 @@ int RunProject(bool teamcity, bool parallelizeTestCollections, int maxThreadCoun return failed ? 1 : completionMessages.Values.Sum(summary => summary.Failed); } - XmlTestExecutionVisitor CreateVisitor(object consoleLock, bool teamCity) + TestMessageVisitor CreateVisitor(object consoleLock, CommandLine options) { - if (teamCity) + if (options.TeamCity) + { return new TeamCityVisitor(() => cancel); + } + + if (options.DesignTime) + { + var executionSink = (ITestExecutionSink)_services.GetService(typeof(ITestExecutionSink)); + if (executionSink != null) + { + return new DesignTimeExecutionVisitor(executionSink); + } + } return new StandardOutputVisitor(consoleLock, () => cancel, completionMessages); } - void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, bool parallelizeTestCollections, int maxThreadCount) + void ExecuteAssembly(object consoleLock, string assemblyName, CommandLine options) { if (cancel) return; @@ -160,12 +174,43 @@ void ExecuteAssembly(object consoleLock, string assemblyName, bool teamCity, boo var executor = framework.GetExecutor(name); var discoveryVisitor = new TestDiscoveryVisitor(); - discoverer.Find(includeSourceInformation: false, messageSink: discoveryVisitor, options: new TestFrameworkOptions()); + discoverer.Find(includeSourceInformation: true, messageSink: discoveryVisitor, options: new TestFrameworkOptions()); discoveryVisitor.Finished.WaitOne(); - var executionOptions = new XunitExecutionOptions { DisableParallelization = !parallelizeTestCollections, MaxParallelThreads = maxThreadCount }; - var resultsVisitor = CreateVisitor(consoleLock, teamCity); - executor.RunTests(discoveryVisitor.TestCases, resultsVisitor, executionOptions); + if (options.List) + { + ITestDiscoverySink discoverySink = null; + if (options.DesignTime) + { + discoverySink = (ITestDiscoverySink)_services.GetService(typeof(ITestDiscoverySink)); + } + + lock (consoleLock) + { + foreach (var test in discoveryVisitor.TestCases) + { + if (discoverySink != null) + { + discoverySink.SendTest(test.ToDesignTimeTest()); + } + + Console.WriteLine(test.DisplayName); + } + } + + return; + } + + var executionOptions = new XunitExecutionOptions { DisableParallelization = !options.ParallelizeTestCollections, MaxParallelThreads = options.MaxParallelThreads }; + var resultsVisitor = CreateVisitor(consoleLock, options); + + var tests = discoveryVisitor.TestCases; + if (options.Tests != null && options.Tests.Length > 0) + { + tests = tests.Where(t => options.Tests.Contains(t.DisplayName)).ToList(); + } + + executor.RunTests(tests, resultsVisitor, executionOptions); resultsVisitor.Finished.WaitOne(); } catch (Exception ex) diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index aee1e674625..72586961919 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -30,6 +30,8 @@ + + @@ -43,5 +45,4 @@ - - + \ No newline at end of file diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 237ba090f91..f1650c19f04 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,6 +1,7 @@ { "version": "1.0.0-*", "dependencies": { + "Microsoft.Framework.TestAdapter": "1.0.0-*", "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", "xunit.abstractions": "2.0.0-aspnet-*", "xunit.assert": "2.0.0-aspnet-*", From 7da0203b677269e48e949a4ac9a7ad90d4326d82 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 13 Jul 2014 22:07:33 -0700 Subject: [PATCH 048/463] Renamed configurations to frameworks in project.json --- src/Microsoft.AspNet.Testing/project.json | 6 +++--- src/StyleCop.KRules/project.json | 2 +- src/Xunit.KRunner/project.json | 6 +++--- test/Sample.Tests/project.json | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index f37f3fc2ad6..e793121d555 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,10 +1,10 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "xunit.assert": "2.0.0-aspnet-*", "xunit.core": "2.0.0-aspnet-*" }, - "configurations": { + "frameworks": { "net45": { "dependencies": { "System.Runtime": "", @@ -22,4 +22,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index 55a02f7e61c..ac3da1feae7 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -4,7 +4,7 @@ "StyleCop": "4.7.10.0" }, "resources": [ "*.xml" ], - "configurations" : { + "frameworks" : { "net45" : { "dependencies": { } diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index f1650c19f04..d37b9233e40 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Microsoft.Framework.TestAdapter": "1.0.0-*", @@ -7,7 +7,7 @@ "xunit.assert": "2.0.0-aspnet-*", "xunit.execution": "2.0.0-aspnet-*" }, - "configurations": { + "frameworks": { "net45": {}, "k10": { "dependencies": { @@ -16,4 +16,4 @@ } } } -} \ No newline at end of file +} diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index dd2975376a4..40a4b11b4d6 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,12 +1,12 @@ -{ +{ "dependencies": { "Xunit.KRunner": "" }, "commands": { "test": "Xunit.KRunner" }, - "configurations": { + "frameworks": { "net45": {}, "k10": {} } -} \ No newline at end of file +} From b4363f540b7105127a212f340e5270015c0ab36a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 5 Aug 2014 15:50:52 -0700 Subject: [PATCH 049/463] Updating release Nuget.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631de..1ce6b9e2573 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From da0e2de7e897da132fe5ac4fbecc68467fab9d3e Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Aug 2014 12:30:38 -0700 Subject: [PATCH 050/463] Updating dev Nuget.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e2573..f41e9c631de 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From de8085927b769f56107490ee51609f228781ca77 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 6 Aug 2014 14:08:50 -0700 Subject: [PATCH 051/463] Modify Program.cs to return failure code when tests fail The TeamCity visitor does not collate summary messages and consequently prints messages but fails to report an error code. This causes TeamCity to fail the build, but pass the step --- src/Xunit.KRunner/Program.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index a79189facd9..5dcea89c309 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -212,6 +212,14 @@ void ExecuteAssembly(object consoleLock, string assemblyName, CommandLine option executor.RunTests(tests, resultsVisitor, executionOptions); resultsVisitor.Finished.WaitOne(); + + // When executing under TeamCity, we record the results in a format TeamCity understands, but do not return an error code. + // This causes TeamCity to treat the step as completed, but the build as failed. We'll work around this by special casing the TeamCityVisitor + var teamCityVisitor = resultsVisitor as TeamCityVisitor; + if (teamCityVisitor != null) + { + failed = teamCityVisitor.Failed > 0; + } } catch (Exception ex) { From 00ea237b829bf2a853498283a53924e38f30f319 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 15 Aug 2014 09:28:48 -0700 Subject: [PATCH 052/463] Removed source files from the project --- .../Microsoft.AspNet.Testing.kproj | 11 +--------- src/StyleCop.KRules/StyleCop.KRules.kproj | 10 --------- src/Xunit.KRunner/Xunit.KRunner.kproj | 22 ------------------- test/Sample.Tests/Sample.Tests.kproj | 9 +------- 4 files changed, 2 insertions(+), 50 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj index 209fcee9b10..c0eee03f72c 100644 --- a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj @@ -22,14 +22,5 @@ 2.0 - - - - - - - - - - + \ No newline at end of file diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index e244eceff3b..3a30da0de7e 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -24,16 +24,6 @@ 2.0 - - - - - - - - - - diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index 72586961919..c8782b8b681 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -22,27 +22,5 @@ 2.0 - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj index e0f704bd199..c21c975ec36 100644 --- a/test/Sample.Tests/Sample.Tests.kproj +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -22,12 +22,5 @@ 2.0 - - - - - - - - + \ No newline at end of file From 7ff84fff037dc3891acd7df71bc5b33445ca3b10 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 28 Aug 2014 23:59:32 -0700 Subject: [PATCH 053/463] Updated to use the new target framework in project.json --- src/Microsoft.AspNet.Testing/project.json | 4 ++-- src/StyleCop.KRules/project.json | 2 +- src/Xunit.KRunner/project.json | 4 ++-- test/Sample.Tests/project.json | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index e793121d555..b8e9261350c 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "xunit.assert": "2.0.0-aspnet-*", @@ -12,7 +12,7 @@ "System.Threading.Tasks": "" } }, - "k10": { + "aspnetcore50": { "dependencies": { "System.Runtime": "4.0.20.0", "System.Globalization": "4.0.10.0", diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index ac3da1feae7..1bb8a902d56 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "StyleCop": "4.7.10.0" diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index d37b9233e40..1222bdcfbd8 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Microsoft.Framework.TestAdapter": "1.0.0-*", @@ -9,7 +9,7 @@ }, "frameworks": { "net45": {}, - "k10": { + "aspnetcore50": { "dependencies": { "System.Console": "4.0.0.0", "System.Diagnostics.Process": "4.0.0.0" diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 40a4b11b4d6..3ed0047eb75 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,4 +1,4 @@ -{ +{ "dependencies": { "Xunit.KRunner": "" }, @@ -7,6 +7,6 @@ }, "frameworks": { "net45": {}, - "k10": {} + "aspnetcore50": {} } } From 4e7dd3db401bc36668850f07cc9cc3e2ca353339 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 5 Sep 2014 01:52:50 -0700 Subject: [PATCH 054/463] Updated build.cmd --- build.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 3aaf9575830..86ca5bbbf14 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_KRE_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -svr50 -x86 -CALL packages\KoreBuild\build\kvm install default -svrc50 -x86 +CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -svr50 -x86 +CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* From 78f57010826f148a206c9ca687da2c016be9b5f0 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 3 Sep 2014 15:19:36 -0700 Subject: [PATCH 055/463] Fix for testing #38 - VS cannot run [Theory] tests with multiple parameters The problem here is the way we're using for VS to communicate with the test runner via the commandline isn't very well suited for the problem space. If VS wants to run MyTestClass.Test1 and MyTestClass.Test2 then it will build a commandline like: k test --design-time --test MyTestClass.Test1,MyTestClass.Test2 The runner knows to split the argument on , or ; and then we have the test names to run. This is problematic when the test name contains either of these characters. This change implements context-aware splitting on , - a comma inside parens is not treated as a delimiter, as well as a host of other parameter passing options. For now this is compatible with what VS does. We might want to remove support for delimiters and choose a better option. --- src/Xunit.KRunner/CommandLine.cs | 5 ++- .../DesignTime/TestCaseExtensions.cs | 2 +- src/Xunit.KRunner/Program.cs | 40 +++++++++++++++++-- test/Sample.Tests/SampleTest.cs | 16 ++++++++ 4 files changed, 56 insertions(+), 7 deletions(-) diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs index 06c3805cc4e..1b0a51b91ae 100644 --- a/src/Xunit.KRunner/CommandLine.cs +++ b/src/Xunit.KRunner/CommandLine.cs @@ -17,6 +17,7 @@ protected CommandLine(string[] args) TeamCity = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; ParallelizeTestCollections = true; + Tests = new List(); Parse(); } @@ -30,7 +31,7 @@ protected CommandLine(string[] args) public bool TeamCity { get; protected set; } - public string[] Tests { get; set; } + public List Tests { get; private set; } static void GuardNoOptionValue(KeyValuePair option) { @@ -93,7 +94,7 @@ protected virtual void Parse() throw new ArgumentException("missing argument for --test"); } - Tests = option.Value.Split(new char[] { ';', ',' }, StringSplitOptions.RemoveEmptyEntries); + Tests.AddRange(option.Value.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)); } else if (optionName == "-teamcity") { diff --git a/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs b/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs index 76c43ef7c8e..97b9d8c91c0 100644 --- a/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs +++ b/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs @@ -13,7 +13,7 @@ public static Test ToDesignTimeTest(this ITestCase testCase) var test = new Test() { DisplayName = testCase.DisplayName, - FullyQualifiedName = testCase.DisplayName, + FullyQualifiedName = testCase.UniqueID, }; if (testCase.SourceInformation != null) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 5dcea89c309..f6e6fe27d95 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -3,13 +3,14 @@ using System; using System.Collections.Concurrent; +using System.Collections.Generic; using System.Linq; using System.Reflection; using Microsoft.Framework.Runtime; +using Microsoft.Framework.TestAdapter; +using Xunit.Abstractions; using Xunit.ConsoleClient; using Xunit.Sdk; -using Xunit.Abstractions; -using Microsoft.Framework.TestAdapter; #if !NET45 using System.Diagnostics; #endif @@ -205,9 +206,9 @@ void ExecuteAssembly(object consoleLock, string assemblyName, CommandLine option var resultsVisitor = CreateVisitor(consoleLock, options); var tests = discoveryVisitor.TestCases; - if (options.Tests != null && options.Tests.Length > 0) + if (options.Tests != null && options.Tests.Count > 0) { - tests = tests.Where(t => options.Tests.Contains(t.DisplayName)).ToList(); + tests = tests.Where(t => IsTestNameMatch(t, options.Tests)).ToList(); } executor.RunTests(tests, resultsVisitor, executionOptions); @@ -242,5 +243,36 @@ ITestFramework GetFramework(IAssemblyInfo assemblyInfo) var framework = Activator.CreateInstance(testFrameworkType) as ITestFramework; return framework ?? new XunitTestFramework(); } + + // Performs fuzzy matching for test names specified at the commandline. + // - test name specified at the command line might be a test uniqueId (guid) OR + // - test name might be a full test display name (including parameters) + // - test name might be the test class + method name + private bool IsTestNameMatch(ITestCase test, IList testNames) + { + foreach (var testName in testNames) + { + if (string.Equals(testName, test.UniqueID, StringComparison.Ordinal)) + { + return true; + } + else if (string.Equals(testName, test.DisplayName, StringComparison.Ordinal)) + { + return true; + } + else if (!testName.Contains('(') && test.DisplayName.Contains('(')) + { + // No parameters in testName, and parameters in the displayname, it might be + // the 'short' display name (without parameters). + var shortName = test.DisplayName.Substring(0, test.DisplayName.IndexOf('(')); + if (string.Equals(testName, shortName, StringComparison.Ordinal)) + { + return true; + } + } + } + + return false; + } } } diff --git a/test/Sample.Tests/SampleTest.cs b/test/Sample.Tests/SampleTest.cs index f5c5524234e..7adfa4a8d72 100644 --- a/test/Sample.Tests/SampleTest.cs +++ b/test/Sample.Tests/SampleTest.cs @@ -12,5 +12,21 @@ public void True_is_true() { Assert.True(true); } + + [Theory] + [InlineData(1)] + [InlineData(2)] + [InlineData(3)] + public void TheoryTest1(int x) + { + } + + [Theory] + [InlineData(1, "Hi")] + [InlineData(2, "Hi")] + [InlineData(3, "Hi")] + public void TheoryTest2(int x, string s) + { + } } } \ No newline at end of file From 63f13aabb42e27d6febc39e63ed13a9663167218 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 10 Sep 2014 12:26:28 -0700 Subject: [PATCH 056/463] React to renaming TargetFramework to RuntimeFramework --- src/Xunit.KRunner/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index f6e6fe27d95..70652954eed 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -35,7 +35,7 @@ public Program(IServiceProvider services, IApplicationEnvironment environment, I public int Main(string[] args) { - Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.TargetFramework); + Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.RuntimeFramework); Console.WriteLine("Copyright (C) 2014 Outercurve Foundation, Microsoft Open Technologies, Inc."); Console.WriteLine(); From a7665add3f02199b062ed34efda80f9c99e27978 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Thu, 11 Sep 2014 12:52:45 -0700 Subject: [PATCH 057/463] Temporary rollback to make build of KRuntime pass --- src/Xunit.KRunner/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 70652954eed..f6e6fe27d95 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -35,7 +35,7 @@ public Program(IServiceProvider services, IApplicationEnvironment environment, I public int Main(string[] args) { - Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.RuntimeFramework); + Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.TargetFramework); Console.WriteLine("Copyright (C) 2014 Outercurve Foundation, Microsoft Open Technologies, Inc."); Console.WriteLine(); From eb89c5f47cabac6539230baf0051148d4a411e1a Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Thu, 11 Sep 2014 14:59:43 -0700 Subject: [PATCH 058/463] Restore reaction to renaming TargetFramework to RuntimeFramework --- src/Xunit.KRunner/Program.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index f6e6fe27d95..70652954eed 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -35,7 +35,7 @@ public Program(IServiceProvider services, IApplicationEnvironment environment, I public int Main(string[] args) { - Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.TargetFramework); + Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.RuntimeFramework); Console.WriteLine("Copyright (C) 2014 Outercurve Foundation, Microsoft Open Technologies, Inc."); Console.WriteLine(); From cbe377d3f5e61ae798ad40bb77f7e0acf8b4ded4 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 17 Sep 2014 09:56:49 -0700 Subject: [PATCH 059/463] Updating release NuGet.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631de..1ce6b9e2573 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 4019cb03c9346562983a05061528a7a8ee80cf59 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Wed, 17 Sep 2014 09:56:51 -0700 Subject: [PATCH 060/463] Updating dev NuGet.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index 1ce6b9e2573..f41e9c631de 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@ - + - + From 6e2b135b8c51b02feb6231d23aff97a05b6efcfa Mon Sep 17 00:00:00 2001 From: Pranav K Date: Sun, 21 Sep 2014 22:55:54 -0700 Subject: [PATCH 061/463] *Adding ThrowsArgOutOfRange method to ExceptionAssert * Changing error messages to use Environment.NewLine --- .../ExceptionAssertions.cs | 42 ++++++++++++++++++- .../PlatformHelper.cs | 20 +++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/Microsoft.AspNet.Testing/PlatformHelper.cs diff --git a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs index 426b435548a..4f461ddb9bf 100644 --- a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs +++ b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs @@ -125,7 +125,7 @@ public static async Task ThrowsArgumentAsync(Func testC /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, string paramName) { - return Throws(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName); + return Throws(testCode, "Value cannot be null or empty." + Environment.NewLine + "Parameter name: " + paramName); } /// @@ -138,7 +138,7 @@ public static ArgumentException ThrowsArgumentNullOrEmpty(Action testCode, strin /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown public static Task ThrowsArgumentNullOrEmptyAsync(Func testCode, string paramName) { - return ThrowsAsync(testCode, "Value cannot be null or empty.\r\nParameter name: " + paramName); + return ThrowsAsync(testCode, "Value cannot be null or empty." + Environment.NewLine + "Parameter name: " + paramName); } /// @@ -167,6 +167,44 @@ public static Task ThrowsArgumentNullOrEmptyStringAsync(Func< return ThrowsArgumentAsync(testCode, paramName, "Value cannot be null or an empty string."); } + /// + /// Verifies that the code throws an ArgumentOutOfRangeException (or optionally any exception which derives from it). + /// + /// A delegate to the code to be tested + /// The name of the parameter that should throw the exception + /// The exception message to verify + /// The actual value provided + /// The exception that was thrown, when successful + /// Thrown when an exception was not thrown, or when an exception of the incorrect type is thrown + public static ArgumentOutOfRangeException ThrowsArgumentOutOfRange(Action testCode, string paramName, string exceptionMessage, object actualValue = null) + { + if (exceptionMessage != null) + { + exceptionMessage = exceptionMessage + Environment.NewLine + "Parameter name: " + paramName; + if (actualValue != null) + { + exceptionMessage += Environment.NewLine; + if (PlatformHelper.IsMono) + { + exceptionMessage += actualValue; + } + else + { + exceptionMessage += String.Format(CultureReplacer.DefaultCulture, "Actual value was {0}.", actualValue); + } + } + } + + var ex = Throws(testCode, exceptionMessage); + + if (paramName != null) + { + Assert.Equal(paramName, ex.ParamName); + } + + return ex; + } + // We've re-implemented all the xUnit.net Throws code so that we can get this // updated implementation of RecordException which silently unwraps any instances // of AggregateException. In addition to unwrapping exceptions, this method ensures diff --git a/src/Microsoft.AspNet.Testing/PlatformHelper.cs b/src/Microsoft.AspNet.Testing/PlatformHelper.cs new file mode 100644 index 00000000000..8f5134dd1a2 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/PlatformHelper.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Testing +{ + internal static class PlatformHelper + { + private static Lazy _isMono = new Lazy(() => Type.GetType("Mono.Runtime") != null); + + public static bool IsMono + { + get + { + return _isMono.Value; + } + } + } +} \ No newline at end of file From 9cf2caaf305d483fa46cd51a55a70843cfd48313 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 22 Sep 2014 11:14:52 -0700 Subject: [PATCH 062/463] Renaming PlatformHelper to TestPlatformHelper and making the type public --- src/Microsoft.AspNet.Testing/ExceptionAssertions.cs | 2 +- .../{PlatformHelper.cs => TestPlatformHelper.cs} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename src/Microsoft.AspNet.Testing/{PlatformHelper.cs => TestPlatformHelper.cs} (91%) diff --git a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs index 4f461ddb9bf..2ef473f20b2 100644 --- a/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs +++ b/src/Microsoft.AspNet.Testing/ExceptionAssertions.cs @@ -184,7 +184,7 @@ public static ArgumentOutOfRangeException ThrowsArgumentOutOfRange(Action testCo if (actualValue != null) { exceptionMessage += Environment.NewLine; - if (PlatformHelper.IsMono) + if (TestPlatformHelper.IsMono) { exceptionMessage += actualValue; } diff --git a/src/Microsoft.AspNet.Testing/PlatformHelper.cs b/src/Microsoft.AspNet.Testing/TestPlatformHelper.cs similarity index 91% rename from src/Microsoft.AspNet.Testing/PlatformHelper.cs rename to src/Microsoft.AspNet.Testing/TestPlatformHelper.cs index 8f5134dd1a2..7009b2dabc8 100644 --- a/src/Microsoft.AspNet.Testing/PlatformHelper.cs +++ b/src/Microsoft.AspNet.Testing/TestPlatformHelper.cs @@ -5,7 +5,7 @@ namespace Microsoft.AspNet.Testing { - internal static class PlatformHelper + public static class TestPlatformHelper { private static Lazy _isMono = new Lazy(() => Type.GetType("Mono.Runtime") != null); From f9e0db10c3e9978ad2b278a9a4fdc84cbdcf6742 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Wed, 1 Oct 2014 23:51:00 -0700 Subject: [PATCH 063/463] Adding TestHost as a separate project from design-time-host --- Testing.sln | 9 +- .../Messages/ErrorMessage.cs | 10 + .../Messages/Message.cs | 20 ++ .../Microsoft.AspNet.TestHost.kproj | 26 +++ .../Microsoft.Framework.DesignTimeHost.kproj | 20 ++ src/Microsoft.AspNet.TestHost/Program.cs | 173 ++++++++++++++++++ .../ProjectCommand.cs | 32 ++++ .../ReportingChannel.cs | 82 +++++++++ .../TestAdapter/TestDiscoverySink.cs | 29 +++ .../TestAdapter/TestExecutionSink.cs | 39 ++++ src/Microsoft.AspNet.TestHost/project.json | 25 +++ 11 files changed, 464 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.TestHost/Messages/ErrorMessage.cs create mode 100644 src/Microsoft.AspNet.TestHost/Messages/Message.cs create mode 100644 src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj create mode 100644 src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj create mode 100644 src/Microsoft.AspNet.TestHost/Program.cs create mode 100644 src/Microsoft.AspNet.TestHost/ProjectCommand.cs create mode 100644 src/Microsoft.AspNet.TestHost/ReportingChannel.cs create mode 100644 src/Microsoft.AspNet.TestHost/TestAdapter/TestDiscoverySink.cs create mode 100644 src/Microsoft.AspNet.TestHost/TestAdapter/TestExecutionSink.cs create mode 100644 src/Microsoft.AspNet.TestHost/project.json diff --git a/Testing.sln b/Testing.sln index 53bfe0756fe..ddc88218e2c 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.21719.0 +VisualStudioVersion = 14.0.22201.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -17,6 +17,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCop.Runner", "src\StyleCop EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StyleCop.KRules", "src\StyleCop.KRules\StyleCop.KRules.kproj", "{657EB507-EE7A-451F-90A4-196F6FCD66E5}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.TestHost", "src\Microsoft.AspNet.TestHost\Microsoft.AspNet.TestHost.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B5061}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -43,6 +45,10 @@ Global {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Debug|Any CPU.Build.0 = Debug|Any CPU {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Release|Any CPU.ActiveCfg = Release|Any CPU {657EB507-EE7A-451F-90A4-196F6FCD66E5}.Release|Any CPU.Build.0 = Release|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B5061}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B5061}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B5061}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F003F228-2AE2-4E9D-877B-93EB773B5061}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -53,5 +59,6 @@ Global {25D18D0B-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} {62BE2FA4-6B9D-4296-9178-5FC2F66372AB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {657EB507-EE7A-451F-90A4-196F6FCD66E5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {F003F228-2AE2-4E9D-877B-93EB773B5061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.TestHost/Messages/ErrorMessage.cs b/src/Microsoft.AspNet.TestHost/Messages/ErrorMessage.cs new file mode 100644 index 00000000000..a096e0cb770 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/Messages/ErrorMessage.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.TestHost +{ + public class ErrorMessage + { + public string Message { get; set; } + } +} diff --git a/src/Microsoft.AspNet.TestHost/Messages/Message.cs b/src/Microsoft.AspNet.TestHost/Messages/Message.cs new file mode 100644 index 00000000000..e71f0b8a647 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/Messages/Message.cs @@ -0,0 +1,20 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNet.TestHost +{ + public class Message + { + public string MessageType { get; set; } + + public JToken Payload { get; set; } + + public override string ToString() + { + return "(" + MessageType + ") -> " + (Payload == null ? "null" : Payload.ToString(Formatting.Indented)); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj b/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj new file mode 100644 index 00000000000..a023d490793 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj @@ -0,0 +1,26 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + f003f228-2ae2-4e9d-877b-93eb773b5061 + Console + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj b/src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj new file mode 100644 index 00000000000..afa7437d017 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj @@ -0,0 +1,20 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + b8208d93-75c4-44bf-80bc-deb9678fa05e + Library + + + + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/Program.cs b/src/Microsoft.AspNet.TestHost/Program.cs new file mode 100644 index 00000000000..4152a0e61c4 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/Program.cs @@ -0,0 +1,173 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Threading.Tasks; +using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Common.CommandLine; +using Microsoft.Framework.Runtime.Common.DependencyInjection; +using Microsoft.Framework.TestAdapter; + +namespace Microsoft.AspNet.TestHost +{ + public class Program + { + private readonly IServiceProvider _services; + + public Program(IServiceProvider services) + { + _services = services; + } + + public int Main(string[] args) + { + var application = new CommandLineApplication(); + application.HelpOption("-?|-h|--help"); + + var port = application.Argument("port", "Port number to listen for a connection."); + var project = application.Argument("project", "Path to a project file."); + + application.Command("list", command => + { + command.Name = "list tests"; + command.Description = "Lists all available tests."; + + command.OnExecute(async () => + { + await DiscoverTests(int.Parse(port.Value), project.Value); + return 0; + }); + }); + + application.Command("run", command => + { + command.Name = "run tests"; + command.Description = "Runs specified tests."; + + var tests = command.Option("--test ", "test to run", CommandOptionType.MultipleValue); + + command.OnExecute(async () => + { + await ExecuteTests(int.Parse(port.Value), project.Value, tests.Values); + return 0; + }); + + }); + + return application.Execute(args); + } + + private async Task ExecuteTests(int port, string projectPath, IList tests) + { + Console.WriteLine("Listening on port {0}", port); + using (var channel = await ReportingChannel.ListenOn(port)) + { + Console.WriteLine("Client accepted {0}", channel.Socket.LocalEndPoint); + + string testCommand = null; + Project project = null; + if (Project.TryGetProject(projectPath, out project)) + { + project.Commands.TryGetValue("test", out testCommand); + } + + if (testCommand == null) + { + // No test command means no tests. + Trace.TraceInformation("[ReportingChannel]: OnTransmit(ExecuteTests)"); + channel.Send(new Message() + { + MessageType = "TestExecution.Response", + }); + + return; + } + + var testServices = new ServiceProvider(_services); + testServices.Add(typeof(ITestExecutionSink), new TestExecutionSink(channel)); + + var args = new List() + { + "test", + "--designtime" + }; + + if (tests != null) + { + foreach (var test in tests) + { + args.Add("--test"); + args.Add(test); + } + } + + try + { + await ProjectCommand.Execute(testServices, project, args.ToArray()); + } + catch + { + // For now we're not doing anything with these exceptions, we might want to report them + // to VS. + } + + Trace.TraceInformation("[ReportingChannel]: OnTransmit(ExecuteTests)"); + channel.Send(new Message() + { + MessageType = "TestExecution.Response", + }); + } + } + + private async Task DiscoverTests(int port, string projectPath) + { + Console.WriteLine("Listening on port {0}", port); + using (var channel = await ReportingChannel.ListenOn(port)) + { + Console.WriteLine("Client accepted {0}", channel.Socket.LocalEndPoint); + + string testCommand = null; + Project project = null; + if (Project.TryGetProject(projectPath, out project)) + { + project.Commands.TryGetValue("test", out testCommand); + } + + if (testCommand == null) + { + // No test command means no tests. + Trace.TraceInformation("[ReportingChannel]: OnTransmit(DiscoverTests)"); + channel.Send(new Message() + { + MessageType = "TestDiscovery.Response", + }); + + return; + } + + var testServices = new ServiceProvider(_services); + testServices.Add(typeof(ITestDiscoverySink), new TestDiscoverySink(channel)); + + var args = new string[] { "test", "--list", "--designtime" }; + + try + { + await ProjectCommand.Execute(testServices, project, args); + } + catch + { + // For now we're not doing anything with these exceptions, we might want to report them + // to VS. + } + + Trace.TraceInformation("[ReportingChannel]: OnTransmit(DiscoverTests)"); + channel.Send(new Message() + { + MessageType = "TestDiscovery.Response", + }); + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/ProjectCommand.cs b/src/Microsoft.AspNet.TestHost/ProjectCommand.cs new file mode 100644 index 00000000000..95e98a4df41 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/ProjectCommand.cs @@ -0,0 +1,32 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Threading.Tasks; +using Microsoft.Framework.Runtime; + +namespace Microsoft.AspNet.TestHost +{ + public class ProjectCommand + { + public static async Task Execute( + IServiceProvider services, + Project project, + string[] args) + { + var oldEnvironment = (IApplicationEnvironment)services.GetService(typeof(IApplicationEnvironment)); + + var environment = new ApplicationEnvironment( + project, + oldEnvironment.RuntimeFramework, + oldEnvironment.Configuration); + + var applicationHost = new Microsoft.Framework.ApplicationHost.Program( + (IAssemblyLoaderContainer)services.GetService(typeof(IAssemblyLoaderContainer)), + environment, + services); + + return await applicationHost.Main(args); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/ReportingChannel.cs b/src/Microsoft.AspNet.TestHost/ReportingChannel.cs new file mode 100644 index 00000000000..e317753f5e5 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/ReportingChannel.cs @@ -0,0 +1,82 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Diagnostics; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading.Tasks; +using Newtonsoft.Json; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNet.TestHost +{ + public class ReportingChannel : IDisposable + { + public static async Task ListenOn(int port) + { + // This fixes the mono incompatibility but ties it to ipv4 connections + using (var listenSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) + { + listenSocket.Bind(new IPEndPoint(IPAddress.Loopback, port)); + listenSocket.Listen(10); + + var socket = await AcceptAsync(listenSocket); + + return new ReportingChannel(socket); + } + } + + private readonly BinaryWriter _writer; + + private ReportingChannel(Socket socket) + { + Socket = socket; + + var stream = new NetworkStream(Socket); + _writer = new BinaryWriter(stream); + } + + public Socket Socket { get; private set; } + + public void Send(Message message) + { + lock (_writer) + { + try + { + Trace.TraceInformation("[ReportingChannel]: Send({0})", message); + _writer.Write(JsonConvert.SerializeObject(message)); + } + catch (Exception ex) + { + Trace.TraceInformation("[ReportingChannel]: Error sending {0}", ex); + throw; + } + } + } + + public void SendError(Exception ex) + { + Send(new Message() + { + MessageType = "Error", + Payload = JToken.FromObject(new ErrorMessage() + { + Message = ex.Message, + }), + }); + } + + public void Dispose() + { + Socket.Dispose(); + } + + private static Task AcceptAsync(Socket socket) + { + return Task.Factory.FromAsync((cb, state) => socket.BeginAccept(cb, state), ar => socket.EndAccept(ar), null); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/TestAdapter/TestDiscoverySink.cs b/src/Microsoft.AspNet.TestHost/TestAdapter/TestDiscoverySink.cs new file mode 100644 index 00000000000..141437d47d9 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/TestAdapter/TestDiscoverySink.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Diagnostics; +using Microsoft.Framework.TestAdapter; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNet.TestHost +{ + public class TestDiscoverySink : ITestDiscoverySink + { + private readonly ReportingChannel _channel; + + public TestDiscoverySink(ReportingChannel channel) + { + _channel = channel; + } + + public void SendTest(Test test) + { + Trace.TraceInformation("[TestDiscoverySink]: OnTransmit(TestDiscovery.TestFound)"); + _channel.Send(new Message + { + MessageType = "TestDiscovery.TestFound", + Payload = JToken.FromObject(test), + }); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/TestAdapter/TestExecutionSink.cs b/src/Microsoft.AspNet.TestHost/TestAdapter/TestExecutionSink.cs new file mode 100644 index 00000000000..06dffb69550 --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/TestAdapter/TestExecutionSink.cs @@ -0,0 +1,39 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Diagnostics; +using Microsoft.Framework.TestAdapter; +using Newtonsoft.Json.Linq; + +namespace Microsoft.AspNet.TestHost +{ + public class TestExecutionSink : ITestExecutionSink + { + private readonly ReportingChannel _channel; + + public TestExecutionSink(ReportingChannel channel) + { + _channel = channel; + } + + public void RecordResult(TestResult testResult) + { + Trace.TraceInformation("[TestExecutionSink]: OnTransmit(TestExecution.TestResult)"); + _channel.Send(new Message + { + MessageType = "TestExecution.TestResult", + Payload = JToken.FromObject(testResult), + }); + } + + public void RecordStart(Test test) + { + Trace.TraceInformation("[TestExecutionSink]: OnTransmit(TestExecution.TestStarted)"); + _channel.Send(new Message + { + MessageType = "TestExecution.TestStarted", + Payload = JToken.FromObject(test), + }); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/project.json b/src/Microsoft.AspNet.TestHost/project.json new file mode 100644 index 00000000000..90fd0ea70da --- /dev/null +++ b/src/Microsoft.AspNet.TestHost/project.json @@ -0,0 +1,25 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.Framework.TestAdapter": "1.0.0-*", + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "Microsoft.Framework.ApplicationHost": "1.0.0-*", + "Microsoft.Framework.CommandLineUtils": "1.0.0-*", + "Microsoft.Framework.Runtime": "1.0.0-*", + "Microsoft.Framework.Runtime.Common": "1.0.0-*", + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "Newtonsoft.Json": "6.0.4" + }, + "frameworks": { + "net45": { }, + "aspnetcore50": { + "dependencies": { + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0" + } + } + } +} From 3b2c403b3ba3a924e176304fdaef4e555b17177d Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 3 Oct 2014 23:38:43 -0700 Subject: [PATCH 064/463] Made some changes - Show help when no arguments were specified. - Changed port and project to be optional - Made xunit.runner depend on TestHost by default --- Testing.sln | 4 +-- .../Microsoft.Framework.DesignTimeHost.kproj | 20 ------------- src/Microsoft.AspNet.TestHost/project.json | 25 ----------------- .../Messages/ErrorMessage.cs | 0 .../Messages/Message.cs | 0 .../Microsoft.Framework.TestHost.kproj} | 0 .../Program.cs | 27 +++++++++++++----- .../ProjectCommand.cs | 0 .../ReportingChannel.cs | 0 .../TestAdapter/TestDiscoverySink.cs | 0 .../TestAdapter/TestExecutionSink.cs | 0 src/Microsoft.Framework.TestHost/project.json | 28 +++++++++++++++++++ src/Xunit.KRunner/project.json | 3 +- test/Sample.Tests/Sample.Tests.kproj | 2 +- test/Sample.Tests/project.json | 7 +++-- 15 files changed, 57 insertions(+), 59 deletions(-) delete mode 100644 src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj delete mode 100644 src/Microsoft.AspNet.TestHost/project.json rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/Messages/ErrorMessage.cs (100%) rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/Messages/Message.cs (100%) rename src/{Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj => Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj} (100%) rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/Program.cs (85%) rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/ProjectCommand.cs (100%) rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/ReportingChannel.cs (100%) rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/TestAdapter/TestDiscoverySink.cs (100%) rename src/{Microsoft.AspNet.TestHost => Microsoft.Framework.TestHost}/TestAdapter/TestExecutionSink.cs (100%) create mode 100644 src/Microsoft.Framework.TestHost/project.json diff --git a/Testing.sln b/Testing.sln index ddc88218e2c..d14753c08ae 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22201.0 +VisualStudioVersion = 14.0.22111.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -17,7 +17,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCop.Runner", "src\StyleCop EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StyleCop.KRules", "src\StyleCop.KRules\StyleCop.KRules.kproj", "{657EB507-EE7A-451F-90A4-196F6FCD66E5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.TestHost", "src\Microsoft.AspNet.TestHost\Microsoft.AspNet.TestHost.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B5061}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost", "src\Microsoft.Framework.TestHost\Microsoft.Framework.TestHost.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B5061}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj b/src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj deleted file mode 100644 index afa7437d017..00000000000 --- a/src/Microsoft.AspNet.TestHost/Microsoft.Framework.DesignTimeHost.kproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 12.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - b8208d93-75c4-44bf-80bc-deb9678fa05e - Library - - - - - - - 2.0 - - - \ No newline at end of file diff --git a/src/Microsoft.AspNet.TestHost/project.json b/src/Microsoft.AspNet.TestHost/project.json deleted file mode 100644 index 90fd0ea70da..00000000000 --- a/src/Microsoft.AspNet.TestHost/project.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "version": "1.0.0-*", - "compilationOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "Microsoft.Framework.TestAdapter": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "Microsoft.Framework.ApplicationHost": "1.0.0-*", - "Microsoft.Framework.CommandLineUtils": "1.0.0-*", - "Microsoft.Framework.Runtime": "1.0.0-*", - "Microsoft.Framework.Runtime.Common": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "Newtonsoft.Json": "6.0.4" - }, - "frameworks": { - "net45": { }, - "aspnetcore50": { - "dependencies": { - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0" - } - } - } -} diff --git a/src/Microsoft.AspNet.TestHost/Messages/ErrorMessage.cs b/src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs similarity index 100% rename from src/Microsoft.AspNet.TestHost/Messages/ErrorMessage.cs rename to src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs diff --git a/src/Microsoft.AspNet.TestHost/Messages/Message.cs b/src/Microsoft.Framework.TestHost/Messages/Message.cs similarity index 100% rename from src/Microsoft.AspNet.TestHost/Messages/Message.cs rename to src/Microsoft.Framework.TestHost/Messages/Message.cs diff --git a/src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj similarity index 100% rename from src/Microsoft.AspNet.TestHost/Microsoft.AspNet.TestHost.kproj rename to src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj diff --git a/src/Microsoft.AspNet.TestHost/Program.cs b/src/Microsoft.Framework.TestHost/Program.cs similarity index 85% rename from src/Microsoft.AspNet.TestHost/Program.cs rename to src/Microsoft.Framework.TestHost/Program.cs index 4152a0e61c4..e21fd00fb09 100644 --- a/src/Microsoft.AspNet.TestHost/Program.cs +++ b/src/Microsoft.Framework.TestHost/Program.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Diagnostics; +using System.Linq; using System.Threading.Tasks; using Microsoft.Framework.Runtime; using Microsoft.Framework.Runtime.Common.CommandLine; @@ -26,37 +27,49 @@ public int Main(string[] args) var application = new CommandLineApplication(); application.HelpOption("-?|-h|--help"); - var port = application.Argument("port", "Port number to listen for a connection."); - var project = application.Argument("project", "Path to a project file."); + var env = (IApplicationEnvironment)_services.GetService(typeof(IApplicationEnvironment)); + + var portOption = application.Option("--port", "Port number to listen for a connection.", CommandOptionType.SingleValue); + var projectOption = application.Option("--project", "Path to a project file.", CommandOptionType.SingleValue); + + var projectPath = projectOption.Value() ?? env.ApplicationBasePath; application.Command("list", command => { - command.Name = "list tests"; + command.Name = "list"; command.Description = "Lists all available tests."; command.OnExecute(async () => { - await DiscoverTests(int.Parse(port.Value), project.Value); + await DiscoverTests(int.Parse(portOption.Value()), projectPath); return 0; }); }); application.Command("run", command => { - command.Name = "run tests"; + command.Name = "run"; command.Description = "Runs specified tests."; var tests = command.Option("--test ", "test to run", CommandOptionType.MultipleValue); command.OnExecute(async () => { - await ExecuteTests(int.Parse(port.Value), project.Value, tests.Values); + await ExecuteTests(int.Parse(portOption.Value()), projectPath, tests.Values); return 0; }); }); - return application.Execute(args); + + var result = application.Execute(args); + + if (!application.IsShowingInformation && !application.RemainingArguments.Any()) + { + application.ShowHelp(); + } + + return result; } private async Task ExecuteTests(int port, string projectPath, IList tests) diff --git a/src/Microsoft.AspNet.TestHost/ProjectCommand.cs b/src/Microsoft.Framework.TestHost/ProjectCommand.cs similarity index 100% rename from src/Microsoft.AspNet.TestHost/ProjectCommand.cs rename to src/Microsoft.Framework.TestHost/ProjectCommand.cs diff --git a/src/Microsoft.AspNet.TestHost/ReportingChannel.cs b/src/Microsoft.Framework.TestHost/ReportingChannel.cs similarity index 100% rename from src/Microsoft.AspNet.TestHost/ReportingChannel.cs rename to src/Microsoft.Framework.TestHost/ReportingChannel.cs diff --git a/src/Microsoft.AspNet.TestHost/TestAdapter/TestDiscoverySink.cs b/src/Microsoft.Framework.TestHost/TestAdapter/TestDiscoverySink.cs similarity index 100% rename from src/Microsoft.AspNet.TestHost/TestAdapter/TestDiscoverySink.cs rename to src/Microsoft.Framework.TestHost/TestAdapter/TestDiscoverySink.cs diff --git a/src/Microsoft.AspNet.TestHost/TestAdapter/TestExecutionSink.cs b/src/Microsoft.Framework.TestHost/TestAdapter/TestExecutionSink.cs similarity index 100% rename from src/Microsoft.AspNet.TestHost/TestAdapter/TestExecutionSink.cs rename to src/Microsoft.Framework.TestHost/TestAdapter/TestExecutionSink.cs diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json new file mode 100644 index 00000000000..c9f2c6f1541 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/project.json @@ -0,0 +1,28 @@ +{ + "version": "1.0.0-*", + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.Framework.TestAdapter": "1.0.0-*", + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "Microsoft.Framework.ApplicationHost": "1.0.0-*", + "Microsoft.Framework.CommandLineUtils": "1.0.0-*", + "Microsoft.Framework.Runtime": "1.0.0-*", + "Microsoft.Framework.Runtime.Common": "1.0.0-*", + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "Newtonsoft.Json": "6.0.4" + }, + "commands": { + "run": "run" + }, + "frameworks": { + "net45": { }, + "aspnetcore50": { + "dependencies": { + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0" + } + } + } +} diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 1222bdcfbd8..14d2c37e64a 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -3,12 +3,13 @@ "dependencies": { "Microsoft.Framework.TestAdapter": "1.0.0-*", "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "Microsoft.Framework.TestHost": "1.0.0-*", "xunit.abstractions": "2.0.0-aspnet-*", "xunit.assert": "2.0.0-aspnet-*", "xunit.execution": "2.0.0-aspnet-*" }, "frameworks": { - "net45": {}, + "net45": { }, "aspnetcore50": { "dependencies": { "System.Console": "4.0.0.0", diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj index c21c975ec36..337799ad4ec 100644 --- a/test/Sample.Tests/Sample.Tests.kproj +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -7,7 +7,7 @@ 25d18d0b-119c-4ab4-bca6-ac06179335fa - Library + Console ConsoleDebugger diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 3ed0047eb75..fbc72f794bc 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -3,10 +3,11 @@ "Xunit.KRunner": "" }, "commands": { - "test": "Xunit.KRunner" + "test": "Xunit.KRunner", + "run": "Microsoft.Framework.TestHost --port 1234 list" }, "frameworks": { - "net45": {}, - "aspnetcore50": {} + "aspnet50": { }, + "aspnetcore50": { } } } From a785847ad34376ddab817cd530ed180eb0454114 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Fri, 3 Oct 2014 23:38:50 -0700 Subject: [PATCH 065/463] Updated to use the new target framework in project.json --- .../CultureReplacer.cs | 6 +++--- src/Microsoft.AspNet.Testing/ReplaceCulture.cs | 4 ++-- src/Microsoft.AspNet.Testing/project.json | 2 +- src/Microsoft.Framework.TestHost/project.json | 2 +- src/StyleCop.KRules/project.json | 2 +- src/Xunit.KRunner/Program.cs | 6 +++--- .../Visitors/StandardOutputVisitor.cs | 18 +++++++++--------- src/Xunit.KRunner/project.json | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/CultureReplacer.cs b/src/Microsoft.AspNet.Testing/CultureReplacer.cs index 1b5a7a9eb0e..4716558bb5c 100644 --- a/src/Microsoft.AspNet.Testing/CultureReplacer.cs +++ b/src/Microsoft.AspNet.Testing/CultureReplacer.cs @@ -26,7 +26,7 @@ public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _originalCulture = CultureInfo.CurrentCulture; _originalUICulture = CultureInfo.CurrentUICulture; _threadId = Thread.CurrentThread.ManagedThreadId; -#if NET45 +#if ASPNET50 Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiCulture); #else @@ -71,7 +71,7 @@ private void Dispose(bool disposing) { Assert.True(Thread.CurrentThread.ManagedThreadId == _threadId, "The current thread is not the same as the thread invoking the constructor. This should never happen."); -#if NET45 +#if ASPNET50 Thread.CurrentThread.CurrentCulture = _originalCulture; Thread.CurrentThread.CurrentUICulture = _originalUICulture; #else @@ -81,4 +81,4 @@ private void Dispose(bool disposing) } } } -} \ No newline at end of file +} diff --git a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs index 3e6e8ca8b2a..1719a1d87dc 100644 --- a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs +++ b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs @@ -47,7 +47,7 @@ public override void Before(MethodInfo methodUnderTest) _originalCulture = CultureInfo.CurrentCulture; _originalUICulture = CultureInfo.CurrentUICulture; -#if NET45 +#if ASPNET50 Thread.CurrentThread.CurrentCulture = Culture; Thread.CurrentThread.CurrentUICulture = UICulture; #else @@ -59,7 +59,7 @@ public override void Before(MethodInfo methodUnderTest) public override void After(MethodInfo methodUnderTest) { -#if NET45 +#if ASPNET50 Thread.CurrentThread.CurrentCulture = _originalCulture; Thread.CurrentThread.CurrentUICulture = _originalUICulture; #else diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index b8e9261350c..6d3a94a9532 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -5,7 +5,7 @@ "xunit.core": "2.0.0-aspnet-*" }, "frameworks": { - "net45": { + "aspnet50": { "dependencies": { "System.Runtime": "", "System.Reflection": "", diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index c9f2c6f1541..8db9c8ad55f 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -17,7 +17,7 @@ "run": "run" }, "frameworks": { - "net45": { }, + "aspnet50": { }, "aspnetcore50": { "dependencies": { "System.Console": "4.0.0.0", diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index 1bb8a902d56..60d6c06425f 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -5,7 +5,7 @@ }, "resources": [ "*.xml" ], "frameworks" : { - "net45" : { + "aspnet50" : { "dependencies": { } } diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs index 70652954eed..792358d26cc 100644 --- a/src/Xunit.KRunner/Program.cs +++ b/src/Xunit.KRunner/Program.cs @@ -11,7 +11,7 @@ using Xunit.Abstractions; using Xunit.ConsoleClient; using Xunit.Sdk; -#if !NET45 +#if !ASPNET50 using System.Diagnostics; #endif @@ -45,7 +45,7 @@ public int Main(string[] args) return 1; } -#if NET45 +#if ASPNET50 AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; Console.CancelKeyPress += (sender, e) => @@ -84,7 +84,7 @@ public int Main(string[] args) } } -#if NET45 +#if ASPNET50 static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) { var ex = e.ExceptionObject as Exception; diff --git a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs index e4c9f03a228..bacd7fd6eb3 100644 --- a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs +++ b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs @@ -56,11 +56,11 @@ protected override bool Visit(IErrorMessage error) { lock (consoleLock) { -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Red; #endif Console.Error.WriteLine(" {0} [FATAL]", Escape(error.ExceptionTypes[0])); -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Gray; #endif Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(error))); @@ -76,11 +76,11 @@ protected override bool Visit(ITestFailed testFailed) lock (consoleLock) { // TODO: Thread-safe way to figure out the default foreground color -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Red; #endif Console.Error.WriteLine(" {0} [FAIL]", Escape(testFailed.TestDisplayName)); -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Gray; #endif Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(testFailed))); @@ -101,11 +101,11 @@ protected override bool Visit(ITestSkipped testSkipped) lock (consoleLock) { // TODO: Thread-safe way to figure out the default foreground color -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Yellow; #endif Console.Error.WriteLine(" {0} [SKIP]", Escape(testSkipped.TestDisplayName)); -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Gray; #endif Console.Error.WriteLine(" {0}", Escape(testSkipped.Reason)); @@ -124,16 +124,16 @@ void WriteStackTrace(string stackTrace) if (String.IsNullOrWhiteSpace(stackTrace)) return; -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.DarkGray; #endif Console.Error.WriteLine(" Stack Trace:"); -#if NET45 +#if ASPNET50 Console.ForegroundColor = ConsoleColor.Gray; #endif foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) Console.Error.WriteLine(" {0}", stackFrame); } } -} \ No newline at end of file +} diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index 14d2c37e64a..efcbe29bf82 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -9,7 +9,7 @@ "xunit.execution": "2.0.0-aspnet-*" }, "frameworks": { - "net45": { }, + "aspnet50": { }, "aspnetcore50": { "dependencies": { "System.Console": "4.0.0.0", From e9af43993b4a11e60e05dc02328c17bee0c754bb Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 4 Oct 2014 12:24:18 -0700 Subject: [PATCH 066/463] Cleaned up the test host logic a little bit - Parse arguments after executing the command - Clean up how help is displayed if no subcommands are run --- src/Microsoft.Framework.TestHost/Program.cs | 26 ++++++++++++--------- test/Sample.Tests/project.json | 3 +-- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/Microsoft.Framework.TestHost/Program.cs b/src/Microsoft.Framework.TestHost/Program.cs index e21fd00fb09..9b52a66daa4 100644 --- a/src/Microsoft.Framework.TestHost/Program.cs +++ b/src/Microsoft.Framework.TestHost/Program.cs @@ -32,7 +32,12 @@ public int Main(string[] args) var portOption = application.Option("--port", "Port number to listen for a connection.", CommandOptionType.SingleValue); var projectOption = application.Option("--project", "Path to a project file.", CommandOptionType.SingleValue); - var projectPath = projectOption.Value() ?? env.ApplicationBasePath; + // Show help information if no subcommand was specified + application.OnExecute(() => + { + application.ShowHelp(); + return 0; + }); application.Command("list", command => { @@ -41,7 +46,10 @@ public int Main(string[] args) command.OnExecute(async () => { - await DiscoverTests(int.Parse(portOption.Value()), projectPath); + var projectPath = projectOption.Value() ?? env.ApplicationBasePath; + var port = int.Parse(portOption.Value()); + + await DiscoverTests(port, projectPath); return 0; }); }); @@ -55,21 +63,17 @@ public int Main(string[] args) command.OnExecute(async () => { - await ExecuteTests(int.Parse(portOption.Value()), projectPath, tests.Values); + var projectPath = projectOption.Value() ?? env.ApplicationBasePath; + var port = int.Parse(portOption.Value()); + + await ExecuteTests(port, projectPath, tests.Values); return 0; }); }); - var result = application.Execute(args); - - if (!application.IsShowingInformation && !application.RemainingArguments.Any()) - { - application.ShowHelp(); - } - - return result; + return application.Execute(args); } private async Task ExecuteTests(int port, string projectPath, IList tests) diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index fbc72f794bc..83edc7e3633 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -3,8 +3,7 @@ "Xunit.KRunner": "" }, "commands": { - "test": "Xunit.KRunner", - "run": "Microsoft.Framework.TestHost --port 1234 list" + "test": "Xunit.KRunner" }, "frameworks": { "aspnet50": { }, From 70d65e391d36fea3928c213ab6693dae6399b5a2 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 4 Oct 2014 13:17:31 -0700 Subject: [PATCH 067/463] Added the TestAdapter project --- Testing.sln | 7 ++++ .../ITestDiscoverySink.cs | 10 +++++ .../ITestExecutionSink.cs | 12 ++++++ .../Microsoft.Framework.TestAdapter.kproj | 28 +++++++++++++ src/Microsoft.Framework.TestAdapter/Test.cs | 28 +++++++++++++ .../TestOutcome.cs | 14 +++++++ .../TestResult.cs | 42 +++++++++++++++++++ .../project.json | 14 +++++++ 8 files changed, 155 insertions(+) create mode 100644 src/Microsoft.Framework.TestAdapter/ITestDiscoverySink.cs create mode 100644 src/Microsoft.Framework.TestAdapter/ITestExecutionSink.cs create mode 100644 src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj create mode 100644 src/Microsoft.Framework.TestAdapter/Test.cs create mode 100644 src/Microsoft.Framework.TestAdapter/TestOutcome.cs create mode 100644 src/Microsoft.Framework.TestAdapter/TestResult.cs create mode 100644 src/Microsoft.Framework.TestAdapter/project.json diff --git a/Testing.sln b/Testing.sln index d14753c08ae..4c7535c5456 100644 --- a/Testing.sln +++ b/Testing.sln @@ -19,6 +19,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StyleCop.KRules", "src\Styl EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost", "src\Microsoft.Framework.TestHost\Microsoft.Framework.TestHost.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B5061}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAdapter", "src\Microsoft.Framework.TestAdapter\Microsoft.Framework.TestAdapter.kproj", "{71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -49,6 +51,10 @@ Global {F003F228-2AE2-4E9D-877B-93EB773B5061}.Debug|Any CPU.Build.0 = Debug|Any CPU {F003F228-2AE2-4E9D-877B-93EB773B5061}.Release|Any CPU.ActiveCfg = Release|Any CPU {F003F228-2AE2-4E9D-877B-93EB773B5061}.Release|Any CPU.Build.0 = Release|Any CPU + {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -60,5 +66,6 @@ Global {62BE2FA4-6B9D-4296-9178-5FC2F66372AB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {657EB507-EE7A-451F-90A4-196F6FCD66E5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {F003F228-2AE2-4E9D-877B-93EB773B5061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} EndGlobalSection EndGlobal diff --git a/src/Microsoft.Framework.TestAdapter/ITestDiscoverySink.cs b/src/Microsoft.Framework.TestAdapter/ITestDiscoverySink.cs new file mode 100644 index 00000000000..93a322525ea --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/ITestDiscoverySink.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.Framework.TestAdapter +{ + public interface ITestDiscoverySink + { + void SendTest(Test test); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/ITestExecutionSink.cs b/src/Microsoft.Framework.TestAdapter/ITestExecutionSink.cs new file mode 100644 index 00000000000..4736a749c08 --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/ITestExecutionSink.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.Framework.TestAdapter +{ + public interface ITestExecutionSink + { + void RecordStart(Test test); + + void RecordResult(TestResult testResult); + } +} diff --git a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj new file mode 100644 index 00000000000..e65c169bdf6 --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj @@ -0,0 +1,28 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + Debug + AnyCPU + + + + 71c2f8aa-05e6-47db-9a1a-d2760cef7dc1 + Library + + + ConsoleDebugger + + + WebDebugger + + + + + 2.0 + + + \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/Test.cs b/src/Microsoft.Framework.TestAdapter/Test.cs new file mode 100644 index 00000000000..fcef61435e1 --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/Test.cs @@ -0,0 +1,28 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; + +namespace Microsoft.Framework.TestAdapter +{ + public class Test + { + public Test() + { + Properties = new Dictionary(StringComparer.Ordinal); + } + + public string CodeFilePath { get; set; } + + public string DisplayName { get; set; } + + public string FullyQualifiedName { get; set; } + + public Guid? Id { get; set; } + + public int? LineNumber { get; set; } + + public IDictionary Properties { get; private set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/TestOutcome.cs b/src/Microsoft.Framework.TestAdapter/TestOutcome.cs new file mode 100644 index 00000000000..8d6a314e22e --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/TestOutcome.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.Framework.TestAdapter +{ + public enum TestOutcome + { + None, + Passed, + Failed, + Skipped, + NotFound + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/TestResult.cs b/src/Microsoft.Framework.TestAdapter/TestResult.cs new file mode 100644 index 00000000000..774999481a5 --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/TestResult.cs @@ -0,0 +1,42 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.ObjectModel; + +namespace Microsoft.Framework.TestAdapter +{ + public sealed class TestResult + { + public TestResult(Test test) + { + if (test == null) + { + throw new ArgumentNullException("test"); + } + + Test = test; + Messages = new Collection(); + } + + public Test Test { get; private set; } + + public TestOutcome Outcome { get; set; } + + public string ErrorMessage { get; set; } + + public string ErrorStackTrace { get; set; } + + public string DisplayName { get; set; } + + public Collection Messages { get; private set; } + + public string ComputerName { get; set; } + + public TimeSpan Duration { get; set; } + + public DateTimeOffset StartTime { get; set; } + + public DateTimeOffset EndTime { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/project.json b/src/Microsoft.Framework.TestAdapter/project.json new file mode 100644 index 00000000000..541ab8fd0b1 --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/project.json @@ -0,0 +1,14 @@ +{ + "version": "1.0.0-*", + "dependencies": { }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { + "dependencies": { + "System.Collections": "4.0.10.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0" + } + } + } +} From 42b0a31327fbc9f5a01f5721ab73056ef1e0e27e Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 5 Oct 2014 14:03:38 -0700 Subject: [PATCH 068/463] Fixup references --- src/Microsoft.AspNet.Testing/project.json | 42 ++++++++-------- .../project.json | 22 ++++----- src/Microsoft.Framework.TestHost/project.json | 49 +++++++++---------- src/Xunit.KRunner/project.json | 34 ++++++------- test/Sample.Tests/project.json | 2 +- 5 files changed, 74 insertions(+), 75 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 6d3a94a9532..28028fb8cf7 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,25 +1,25 @@ { - "version": "1.0.0-*", - "dependencies": { - "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*" - }, - "frameworks": { - "aspnet50": { - "dependencies": { - "System.Runtime": "", - "System.Reflection": "", - "System.Threading.Tasks": "" - } + "version": "1.0.0-*", + "dependencies": { + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*" }, - "aspnetcore50": { - "dependencies": { - "System.Runtime": "4.0.20.0", - "System.Globalization": "4.0.10.0", - "System.Threading.Tasks": "4.0.10.0", - "System.Reflection": "4.0.10.0", - "System.Threading.Thread": "4.0.0.0" - } + "frameworks": { + "aspnet50": { + "frameworkAssemblies": { + "System.Runtime": "4.0.10.0", + "System.Reflection": "4.0.0.0", + "System.Threading.Tasks": "4.0.0.0" + } + }, + "aspnetcore50": { + "dependencies": { + "System.Runtime": "4.0.20.0", + "System.Globalization": "4.0.10.0", + "System.Threading.Tasks": "4.0.10.0", + "System.Reflection": "4.0.10.0", + "System.Threading.Thread": "4.0.0.0" + } + } } - } } diff --git a/src/Microsoft.Framework.TestAdapter/project.json b/src/Microsoft.Framework.TestAdapter/project.json index 541ab8fd0b1..feffc65180f 100644 --- a/src/Microsoft.Framework.TestAdapter/project.json +++ b/src/Microsoft.Framework.TestAdapter/project.json @@ -1,14 +1,14 @@ { - "version": "1.0.0-*", - "dependencies": { }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { - "dependencies": { - "System.Collections": "4.0.10.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0" - } + "version": "1.0.0-*", + "dependencies": { }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { + "dependencies": { + "System.Collections": "4.0.10.0", + "System.Runtime": "4.0.20.0", + "System.Runtime.Extensions": "4.0.10.0" + } + } } - } } diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index 8db9c8ad55f..85613aacc44 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -1,28 +1,27 @@ { - "version": "1.0.0-*", - "compilationOptions": { - "warningsAsErrors": true - }, - "dependencies": { - "Microsoft.Framework.TestAdapter": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "Microsoft.Framework.ApplicationHost": "1.0.0-*", - "Microsoft.Framework.CommandLineUtils": "1.0.0-*", - "Microsoft.Framework.Runtime": "1.0.0-*", - "Microsoft.Framework.Runtime.Common": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "Newtonsoft.Json": "6.0.4" - }, - "commands": { - "run": "run" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { - "dependencies": { - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0" - } + "version": "1.0.0-*", + "compilationOptions": { + "warningsAsErrors": true + }, + "dependencies": { + "Microsoft.Framework.TestAdapter": "1.0.0-*", + "Microsoft.Framework.ApplicationHost": "1.0.0-*", + "Microsoft.Framework.CommandLineUtils": "1.0.0-*", + "Microsoft.Framework.Runtime": "1.0.0-*", + "Microsoft.Framework.Runtime.Common": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" }, + "Newtonsoft.Json": "6.0.4" + }, + "commands": { + "run": "run" + }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { + "dependencies": { + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0" + } + } } - } } diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index efcbe29bf82..bd270600170 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -1,20 +1,20 @@ { - "version": "1.0.0-*", - "dependencies": { - "Microsoft.Framework.TestAdapter": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "Microsoft.Framework.TestHost": "1.0.0-*", - "xunit.abstractions": "2.0.0-aspnet-*", - "xunit.assert": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { - "dependencies": { - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0" - } + "version": "1.0.0-*", + "dependencies": { + "Microsoft.Framework.TestAdapter": "1.0.0-*", + "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.Framework.TestHost": "1.0.0-*", + "xunit.abstractions": "2.0.0-aspnet-*", + "xunit.assert": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" + }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { + "dependencies": { + "System.Console": "4.0.0.0", + "System.Diagnostics.Process": "4.0.0.0" + } + } } - } } diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 83edc7e3633..cb68a996ec8 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,6 +1,6 @@ { "dependencies": { - "Xunit.KRunner": "" + "Xunit.KRunner": "1.0.0-*" }, "commands": { "test": "Xunit.KRunner" From badc376d066e3cc1b8e3b33e80f54c2e31801390 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 5 Oct 2014 13:34:44 -0700 Subject: [PATCH 069/463] Rename namespace --- src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs | 2 +- src/Microsoft.Framework.TestHost/Messages/Message.cs | 2 +- src/Microsoft.Framework.TestHost/Program.cs | 2 +- src/Microsoft.Framework.TestHost/ProjectCommand.cs | 2 +- src/Microsoft.Framework.TestHost/ReportingChannel.cs | 2 +- .../TestAdapter/TestDiscoverySink.cs | 2 +- .../TestAdapter/TestExecutionSink.cs | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs b/src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs index a096e0cb770..543ae51254a 100644 --- a/src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs +++ b/src/Microsoft.Framework.TestHost/Messages/ErrorMessage.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class ErrorMessage { diff --git a/src/Microsoft.Framework.TestHost/Messages/Message.cs b/src/Microsoft.Framework.TestHost/Messages/Message.cs index e71f0b8a647..d5f0e2e4453 100644 --- a/src/Microsoft.Framework.TestHost/Messages/Message.cs +++ b/src/Microsoft.Framework.TestHost/Messages/Message.cs @@ -4,7 +4,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class Message { diff --git a/src/Microsoft.Framework.TestHost/Program.cs b/src/Microsoft.Framework.TestHost/Program.cs index 9b52a66daa4..a0d66f01491 100644 --- a/src/Microsoft.Framework.TestHost/Program.cs +++ b/src/Microsoft.Framework.TestHost/Program.cs @@ -11,7 +11,7 @@ using Microsoft.Framework.Runtime.Common.DependencyInjection; using Microsoft.Framework.TestAdapter; -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class Program { diff --git a/src/Microsoft.Framework.TestHost/ProjectCommand.cs b/src/Microsoft.Framework.TestHost/ProjectCommand.cs index 95e98a4df41..38f77672825 100644 --- a/src/Microsoft.Framework.TestHost/ProjectCommand.cs +++ b/src/Microsoft.Framework.TestHost/ProjectCommand.cs @@ -5,7 +5,7 @@ using System.Threading.Tasks; using Microsoft.Framework.Runtime; -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class ProjectCommand { diff --git a/src/Microsoft.Framework.TestHost/ReportingChannel.cs b/src/Microsoft.Framework.TestHost/ReportingChannel.cs index e317753f5e5..7e67bdb9d82 100644 --- a/src/Microsoft.Framework.TestHost/ReportingChannel.cs +++ b/src/Microsoft.Framework.TestHost/ReportingChannel.cs @@ -10,7 +10,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class ReportingChannel : IDisposable { diff --git a/src/Microsoft.Framework.TestHost/TestAdapter/TestDiscoverySink.cs b/src/Microsoft.Framework.TestHost/TestAdapter/TestDiscoverySink.cs index 141437d47d9..2eae31b3ab0 100644 --- a/src/Microsoft.Framework.TestHost/TestAdapter/TestDiscoverySink.cs +++ b/src/Microsoft.Framework.TestHost/TestAdapter/TestDiscoverySink.cs @@ -5,7 +5,7 @@ using Microsoft.Framework.TestAdapter; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class TestDiscoverySink : ITestDiscoverySink { diff --git a/src/Microsoft.Framework.TestHost/TestAdapter/TestExecutionSink.cs b/src/Microsoft.Framework.TestHost/TestAdapter/TestExecutionSink.cs index 06dffb69550..a75a8fc6f3e 100644 --- a/src/Microsoft.Framework.TestHost/TestAdapter/TestExecutionSink.cs +++ b/src/Microsoft.Framework.TestHost/TestAdapter/TestExecutionSink.cs @@ -5,7 +5,7 @@ using Microsoft.Framework.TestAdapter; using Newtonsoft.Json.Linq; -namespace Microsoft.AspNet.TestHost +namespace Microsoft.Framework.TestHost { public class TestExecutionSink : ITestExecutionSink { From bf44a60431c3da1dba06eef85a4e8f4876bb35a2 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 5 Oct 2014 15:25:49 -0700 Subject: [PATCH 070/463] adding tests for testhost --- Testing.sln | 9 +- .../ProjectCommand.cs | 6 +- .../Microsoft.Framework.TestHost.Tests.kproj | 26 +++ .../TestHostTest.cs | 205 ++++++++++++++++++ .../TestHostWrapper.cs | 130 +++++++++++ .../project.json | 15 ++ test/Sample.Tests/project.json | 21 +- 7 files changed, 400 insertions(+), 12 deletions(-) create mode 100644 test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj create mode 100644 test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs create mode 100644 test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs create mode 100644 test/Microsoft.Framework.TestHost.Tests/project.json diff --git a/Testing.sln b/Testing.sln index 4c7535c5456..7a62f70b6e6 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22111.0 +VisualStudioVersion = 14.0.22201.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -21,6 +21,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHos EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAdapter", "src\Microsoft.Framework.TestAdapter\Microsoft.Framework.TestAdapter.kproj", "{71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.kproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,10 @@ Global {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Debug|Any CPU.Build.0 = Debug|Any CPU {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Release|Any CPU.ActiveCfg = Release|Any CPU {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}.Release|Any CPU.Build.0 = Release|Any CPU + {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.Build.0 = Debug|Any CPU + {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.ActiveCfg = Release|Any CPU + {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,5 +73,6 @@ Global {657EB507-EE7A-451F-90A4-196F6FCD66E5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {F003F228-2AE2-4E9D-877B-93EB773B5061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} EndGlobalSection EndGlobal diff --git a/src/Microsoft.Framework.TestHost/ProjectCommand.cs b/src/Microsoft.Framework.TestHost/ProjectCommand.cs index 38f77672825..4311cacad20 100644 --- a/src/Microsoft.Framework.TestHost/ProjectCommand.cs +++ b/src/Microsoft.Framework.TestHost/ProjectCommand.cs @@ -4,6 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.Framework.Runtime; +using System.ComponentModel.Design; namespace Microsoft.Framework.TestHost { @@ -21,10 +22,13 @@ public static async Task Execute( oldEnvironment.RuntimeFramework, oldEnvironment.Configuration); + var newServices = new ServiceContainer(services); + newServices.AddService(typeof(IApplicationEnvironment), environment); + var applicationHost = new Microsoft.Framework.ApplicationHost.Program( (IAssemblyLoaderContainer)services.GetService(typeof(IAssemblyLoaderContainer)), environment, - services); + newServices); return await applicationHost.Main(args); } diff --git a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj new file mode 100644 index 00000000000..47a54974b99 --- /dev/null +++ b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj @@ -0,0 +1,26 @@ + + + + 12.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 25d18d0c-119c-4ab4-bca6-ac06179335fa + Console + + + ConsoleDebugger + + + WebDebugger + + + + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs new file mode 100644 index 00000000000..83fb362ed02 --- /dev/null +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -0,0 +1,205 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Infrastructure; +using Microsoft.Framework.TestAdapter; +using Xunit; + +namespace Microsoft.Framework.TestHost +{ + public class TestHostTest + { + private readonly IServiceProvider _services; + private readonly IApplicationEnvironment _environment; + private readonly string _testProject; + + public TestHostTest() + { + _services = CallContextServiceLocator.Locator.ServiceProvider; + _environment = (IApplicationEnvironment)_services.GetService(typeof(IApplicationEnvironment)); + + var libraryManager = (ILibraryManager)_services.GetService(typeof(ILibraryManager)); + _testProject = libraryManager.GetLibraryInformation("Sample.Tests").Path; + } + + [Fact] + public async Task ListTest() + { + // Arrange + var host = new TestHostWrapper(_services); + + // Act + var result = await host.RunListAsync(_testProject); + + // Assert + Assert.Equal(0, result); + + Assert.Equal(8, host.Output.Count); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.True_is_true")); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); + Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); + Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); + } + + [Fact] + public async Task RunTest_All() + { + // Arrange + var host = new TestHostWrapper(_services); + + // Act + var result = await host.RunTestsAsync(_testProject); + + // Assert + Assert.Equal(0, result); + + Assert.Equal(15, host.Output.Count); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.True_is_true")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.True_is_true")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); + Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); + } + + [Fact] + public async Task RunTest_ByDisplayName() + { + // Arrange + var host = new TestHostWrapper(_services); + + // Act + var result = await host.RunTestsAsync( + _testProject, + "Sample.Tests.SampleTest.TheoryTest1(x: 1)", + "Sample.Tests.SampleTest.TheoryTest1(x: 2)"); + + // Assert + Assert.Equal(0, result); + + Assert.Equal(5, host.Output.Count); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); + } + + [Fact] + public async Task RunTest_ByDisplayName_Short() + { + // Arrange + var host = new TestHostWrapper(_services); + + // Act + var result = await host.RunTestsAsync(_testProject, "Sample.Tests.SampleTest.TheoryTest1"); + + // Assert + Assert.Equal(0, result); + + Assert.Equal(7, host.Output.Count); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); + Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); + } + + [Fact] + public async Task RunTest_ByUniqueName() + { + // Arrange + var host = new TestHostWrapper(_services); + + await host.RunListAsync(_testProject); + + var test = host.Output + .Where(m => m.MessageType == "TestDiscovery.TestFound") + .First() + .Payload.ToObject(); + + host.Output.Clear(); + + // Act + var result = await host.RunTestsAsync(_testProject, test.FullyQualifiedName); + + // Assert + Assert.Equal(0, result); + + Assert.Equal(3, host.Output.Count); + Assert.Single(host.Output, m => TestStarted(m, test.DisplayName)); + Assert.Single(host.Output, m => TestPassed(m, test.DisplayName)); + Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); + } + + private static bool TestFound(Message message, string name) + { + if (!string.Equals("TestDiscovery.TestFound", message.MessageType)) + { + return false; + } + + if (!string.Equals(name, message.Payload.ToObject().DisplayName)) + { + return false; + } + + return true; + } + + private static bool TestStarted(Message message, string name) + { + if (!string.Equals("TestExecution.TestStarted", message.MessageType)) + { + return false; + } + + if (!string.Equals(name, message.Payload.ToObject().DisplayName)) + { + return false; + } + + return true; + } + + private static bool TestPassed(Message message, string name) + { + if (!string.Equals("TestExecution.TestResult", message.MessageType)) + { + return false; + } + + var result = message.Payload.ToObject(); + if (!string.Equals(name, result.Test.DisplayName)) + { + return false; + } + + if (TestOutcome.Passed != result.Outcome) + { + return false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs new file mode 100644 index 00000000000..36d7d0b3460 --- /dev/null +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Threading.Tasks; +using Newtonsoft.Json; + +namespace Microsoft.Framework.TestHost +{ + public class TestHostWrapper + { + private readonly IServiceProvider _services; + + public TestHostWrapper(IServiceProvider services) + { + _services = services; + } + + public List Output { get; } = new List(); + + public async Task RunListAsync(string project) + { + var port = FindFreePort(); + + var arguments = new List(); + + arguments.Add("--port"); + arguments.Add(port.ToString()); + + arguments.Add("--project"); + arguments.Add(project); + + arguments.Add("list"); + + // This will block until the test host opens the port + var listener = Task.Run(() => GetMessage(port)); + + var program = new Program(_services); + var result = program.Main(arguments.ToArray()); + + await listener; + + return result; + } + + public async Task RunTestsAsync(string project, params string[] tests) + { + var port = FindFreePort(); + + var arguments = new List(); + + arguments.Add("--port"); + arguments.Add(port.ToString()); + + arguments.Add("--project"); + arguments.Add(project); + + arguments.Add("run"); + + foreach (var test in tests) + { + arguments.Add("--test"); + arguments.Add(test); + } + + // This will block until the test host opens the port + var listener = Task.Run(() => GetMessage(port)); + + var program = new Program(_services); + var result = program.Main(arguments.ToArray()); + + await listener; + + return result; + } + + private void GetMessage(int port) + { + try + { + using (var client = new TcpClient()) + { + for (var i = 0; i < 10; i++) + { + try + { + client.Connect(new IPEndPoint(IPAddress.Loopback, port)); + break; + } + catch (SocketException) + { + Thread.Sleep(100); + } + } + + using (var reader = new BinaryReader(client.GetStream())) + { + while (true) + { + var message =JsonConvert.DeserializeObject(reader.ReadString()); + Output.Add(message); + } + } + } + } + catch (ObjectDisposedException) + { + // Thrown when the socket is closed by the test process. + } + catch (EndOfStreamException) + { + // Thrown if nothing was written by the test process. + } + } + + private int FindFreePort() + { + using (var socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp)) + { + socket.Bind(new IPEndPoint(IPAddress.Loopback, 0)); + return ((IPEndPoint)socket.LocalEndPoint).Port; + } + } + } +} \ No newline at end of file diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json new file mode 100644 index 00000000000..2fd2c1ba3cf --- /dev/null +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -0,0 +1,15 @@ +{ + "version": "1.0.0-*", + "dependencies": { + "Microsoft.Framework.TestHost": "1.0.0-*", + "Sample.Tests": "1.0.0-*", + "Xunit.KRunner": "1.0.0-*" + }, + "commands": { + "test": "Xunit.KRunner" + }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { } + } +} diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index cb68a996ec8..e1fd82cf556 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,12 +1,13 @@ { - "dependencies": { - "Xunit.KRunner": "1.0.0-*" - }, - "commands": { - "test": "Xunit.KRunner" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } - } + "version": "1.0.0-*", + "dependencies": { + "Xunit.KRunner": "1.0.0-*" + }, + "commands": { + "test": "Xunit.KRunner" + }, + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { } + } } From 42f4f29d26efc016e5ee21c270ee0af6da38df00 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 5 Oct 2014 21:43:22 -0700 Subject: [PATCH 071/463] Disable core clr tests for now since JSON.NET fails --- src/Microsoft.Framework.TestHost/ProjectCommand.cs | 6 +++--- test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs | 2 +- test/Microsoft.Framework.TestHost.Tests/project.json | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/Microsoft.Framework.TestHost/ProjectCommand.cs b/src/Microsoft.Framework.TestHost/ProjectCommand.cs index 4311cacad20..e9a5cedf665 100644 --- a/src/Microsoft.Framework.TestHost/ProjectCommand.cs +++ b/src/Microsoft.Framework.TestHost/ProjectCommand.cs @@ -4,7 +4,7 @@ using System; using System.Threading.Tasks; using Microsoft.Framework.Runtime; -using System.ComponentModel.Design; +using Microsoft.Framework.Runtime.Common.DependencyInjection; namespace Microsoft.Framework.TestHost { @@ -22,8 +22,8 @@ public static async Task Execute( oldEnvironment.RuntimeFramework, oldEnvironment.Configuration); - var newServices = new ServiceContainer(services); - newServices.AddService(typeof(IApplicationEnvironment), environment); + var newServices = new ServiceProvider(services); + newServices.Add(typeof(IApplicationEnvironment), environment); var applicationHost = new Microsoft.Framework.ApplicationHost.Program( (IAssemblyLoaderContainer)services.GetService(typeof(IAssemblyLoaderContainer)), diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs index 36d7d0b3460..c61aea4d9a7 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs @@ -102,7 +102,7 @@ private void GetMessage(int port) { while (true) { - var message =JsonConvert.DeserializeObject(reader.ReadString()); + var message = JsonConvert.DeserializeObject(reader.ReadString()); Output.Add(message); } } diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index 2fd2c1ba3cf..b060499a7a6 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -9,7 +9,6 @@ "test": "Xunit.KRunner" }, "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } + "aspnet50": { } } } From 178b501899e27e34037cd97782e787a842a6f405 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sun, 5 Oct 2014 23:12:23 -0700 Subject: [PATCH 072/463] Enable a single test to to diagnose CI failures --- test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index 83fb362ed02..518705bc050 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -49,7 +49,7 @@ public async Task ListTest() Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosting failures")] public async Task RunTest_All() { // Arrange @@ -79,7 +79,7 @@ public async Task RunTest_All() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosting failures")] public async Task RunTest_ByDisplayName() { // Arrange @@ -102,7 +102,7 @@ public async Task RunTest_ByDisplayName() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosting failures")] public async Task RunTest_ByDisplayName_Short() { // Arrange @@ -124,7 +124,7 @@ public async Task RunTest_ByDisplayName_Short() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosting failures")] public async Task RunTest_ByUniqueName() { // Arrange From 51d9c6fe996d8224b679ca1c4837d65352be9bea Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Mon, 6 Oct 2014 14:54:43 -0700 Subject: [PATCH 073/463] Remove framework assembly versions --- src/Microsoft.AspNet.Testing/project.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 28028fb8cf7..f7742e58b61 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -7,9 +7,9 @@ "frameworks": { "aspnet50": { "frameworkAssemblies": { - "System.Runtime": "4.0.10.0", - "System.Reflection": "4.0.0.0", - "System.Threading.Tasks": "4.0.0.0" + "System.Runtime": "", + "System.Reflection": "", + "System.Threading.Tasks": "" } }, "aspnetcore50": { From 917f2a12bd40709424fb28c476c5366d8500f9aa Mon Sep 17 00:00:00 2001 From: David Fowler Date: Mon, 6 Oct 2014 20:20:41 -0700 Subject: [PATCH 074/463] Added support for acks from the host - The framework host should wait for an ack from the client before quitting. - Reenabled the tests --- .../ReportingChannel.cs | 36 +++++++++++++++++++ .../TestHostTest.cs | 8 ++--- .../TestHostWrapper.cs | 18 +++++++--- 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.Framework.TestHost/ReportingChannel.cs b/src/Microsoft.Framework.TestHost/ReportingChannel.cs index 7e67bdb9d82..df36e749f8a 100644 --- a/src/Microsoft.Framework.TestHost/ReportingChannel.cs +++ b/src/Microsoft.Framework.TestHost/ReportingChannel.cs @@ -6,6 +6,7 @@ using System.IO; using System.Net; using System.Net.Sockets; +using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -29,6 +30,8 @@ public static async Task ListenOn(int port) } private readonly BinaryWriter _writer; + private readonly BinaryReader _reader; + private readonly ManualResetEventSlim _ackWaitHandle; private ReportingChannel(Socket socket) { @@ -36,6 +39,11 @@ private ReportingChannel(Socket socket) var stream = new NetworkStream(Socket); _writer = new BinaryWriter(stream); + _reader = new BinaryReader(stream); + _ackWaitHandle = new ManualResetEventSlim(); + + // Waiting for the ack message on a background thread + new Thread(WaitForAck) { IsBackground = true }.Start(); } public Socket Socket { get; private set; } @@ -69,8 +77,36 @@ public void SendError(Exception ex) }); } + + private void WaitForAck() + { + try + { + var message = JsonConvert.DeserializeObject(_reader.ReadString()); + + if (string.Equals(message.MessageType, "TestHost.Acknowledge")) + { + _ackWaitHandle.Set(); + } + } + catch (Exception ex) + { + Trace.TraceInformation("[ReportingChannel]: Waiting for ack failed {0}", ex); + } + } + public void Dispose() { + // Wait for a graceful disconnect + if (_ackWaitHandle.Wait(TimeSpan.FromSeconds(10))) + { + Trace.TraceInformation("[ReportingChannel]: Received for ack from test host"); + } + else + { + Trace.TraceInformation("[ReportingChannel]: Timed out waiting for ack from test host"); + } + Socket.Dispose(); } diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index 518705bc050..83fb362ed02 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -49,7 +49,7 @@ public async Task ListTest() Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "diagnosting failures")] + [Fact] public async Task RunTest_All() { // Arrange @@ -79,7 +79,7 @@ public async Task RunTest_All() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "diagnosting failures")] + [Fact] public async Task RunTest_ByDisplayName() { // Arrange @@ -102,7 +102,7 @@ public async Task RunTest_ByDisplayName() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "diagnosting failures")] + [Fact] public async Task RunTest_ByDisplayName_Short() { // Arrange @@ -124,7 +124,7 @@ public async Task RunTest_ByDisplayName_Short() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "diagnosting failures")] + [Fact] public async Task RunTest_ByUniqueName() { // Arrange diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs index c61aea4d9a7..6c1303217eb 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs @@ -38,7 +38,7 @@ public async Task RunListAsync(string project) arguments.Add("list"); // This will block until the test host opens the port - var listener = Task.Run(() => GetMessage(port)); + var listener = Task.Run(() => GetMessage(port, "TestDiscovery.Response")); var program = new Program(_services); var result = program.Main(arguments.ToArray()); @@ -69,7 +69,7 @@ public async Task RunTestsAsync(string project, params string[] tests) } // This will block until the test host opens the port - var listener = Task.Run(() => GetMessage(port)); + var listener = Task.Run(() => GetMessage(port, "TestExecution.Response")); var program = new Program(_services); var result = program.Main(arguments.ToArray()); @@ -79,7 +79,7 @@ public async Task RunTestsAsync(string project, params string[] tests) return result; } - private void GetMessage(int port) + private void GetMessage(int port, string terminalMessageType) { try { @@ -98,12 +98,22 @@ private void GetMessage(int port) } } - using (var reader = new BinaryReader(client.GetStream())) + var stream = client.GetStream(); + using (var reader = new BinaryReader(stream)) { while (true) { var message = JsonConvert.DeserializeObject(reader.ReadString()); Output.Add(message); + + if (string.Equals(message.MessageType, terminalMessageType)) + { + var writer = new BinaryWriter(stream); + writer.Write(JsonConvert.SerializeObject(new Message + { + MessageType = "TestHost.Acknowledge" + })); + } } } } From a03f397fab34e670cca1f26e7f3f8e5b9b174b71 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Mon, 6 Oct 2014 22:32:04 -0700 Subject: [PATCH 075/463] Make the test host launch a process. --- .../TestHostTest.cs | 20 +++++----- .../TestHostWrapper.cs | 40 +++++++++++++------ .../project.json | 1 - 3 files changed, 36 insertions(+), 25 deletions(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index 83fb362ed02..d9134b4f40c 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -2,6 +2,7 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; +using System.IO; using System.Linq; using System.Threading.Tasks; using Microsoft.Framework.Runtime; @@ -13,24 +14,21 @@ namespace Microsoft.Framework.TestHost { public class TestHostTest { - private readonly IServiceProvider _services; - private readonly IApplicationEnvironment _environment; private readonly string _testProject; public TestHostTest() { - _services = CallContextServiceLocator.Locator.ServiceProvider; - _environment = (IApplicationEnvironment)_services.GetService(typeof(IApplicationEnvironment)); + var services = CallContextServiceLocator.Locator.ServiceProvider; - var libraryManager = (ILibraryManager)_services.GetService(typeof(ILibraryManager)); - _testProject = libraryManager.GetLibraryInformation("Sample.Tests").Path; + var libraryManager = (ILibraryManager)services.GetService(typeof(ILibraryManager)); + _testProject = Path.GetDirectoryName(libraryManager.GetLibraryInformation("Sample.Tests").Path); } [Fact] public async Task ListTest() { // Arrange - var host = new TestHostWrapper(_services); + var host = new TestHostWrapper(); // Act var result = await host.RunListAsync(_testProject); @@ -53,7 +51,7 @@ public async Task ListTest() public async Task RunTest_All() { // Arrange - var host = new TestHostWrapper(_services); + var host = new TestHostWrapper(); // Act var result = await host.RunTestsAsync(_testProject); @@ -83,7 +81,7 @@ public async Task RunTest_All() public async Task RunTest_ByDisplayName() { // Arrange - var host = new TestHostWrapper(_services); + var host = new TestHostWrapper(); // Act var result = await host.RunTestsAsync( @@ -106,7 +104,7 @@ public async Task RunTest_ByDisplayName() public async Task RunTest_ByDisplayName_Short() { // Arrange - var host = new TestHostWrapper(_services); + var host = new TestHostWrapper(); // Act var result = await host.RunTestsAsync(_testProject, "Sample.Tests.SampleTest.TheoryTest1"); @@ -128,7 +126,7 @@ public async Task RunTest_ByDisplayName_Short() public async Task RunTest_ByUniqueName() { // Arrange - var host = new TestHostWrapper(_services); + var host = new TestHostWrapper(); await host.RunListAsync(_testProject); diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs index 6c1303217eb..ed83f9ded6c 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs @@ -3,7 +3,9 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.IO; +using System.Linq; using System.Net; using System.Net.Sockets; using System.Threading; @@ -14,13 +16,6 @@ namespace Microsoft.Framework.TestHost { public class TestHostWrapper { - private readonly IServiceProvider _services; - - public TestHostWrapper(IServiceProvider services) - { - _services = services; - } - public List Output { get; } = new List(); public async Task RunListAsync(string project) @@ -40,12 +35,12 @@ public async Task RunListAsync(string project) // This will block until the test host opens the port var listener = Task.Run(() => GetMessage(port, "TestDiscovery.Response")); - var program = new Program(_services); - var result = program.Main(arguments.ToArray()); + var process = RunKRE(project, arguments); + process.WaitForExit(); await listener; - return result; + return process.ExitCode; } public async Task RunTestsAsync(string project, params string[] tests) @@ -71,12 +66,31 @@ public async Task RunTestsAsync(string project, params string[] tests) // This will block until the test host opens the port var listener = Task.Run(() => GetMessage(port, "TestExecution.Response")); - var program = new Program(_services); - var result = program.Main(arguments.ToArray()); + var process = RunKRE(project, arguments); + process.WaitForExit(); await listener; - return result; + return process.ExitCode; + } + + private static Process RunKRE(string projectDirectory, IEnumerable args) + { + // TODO: Mono? + + var allArgs = "/c k Microsoft.Framework.TestHost " + string.Join(" ", args.Select(Quote)); + return Process.Start(new ProcessStartInfo + { + FileName = "cmd", + WorkingDirectory = projectDirectory, + Arguments = allArgs, + UseShellExecute = false + }); + } + + private static string Quote(string arg) + { + return "\"" + arg + "\""; } private void GetMessage(int port, string terminalMessageType) diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index b060499a7a6..43ee263679d 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -1,7 +1,6 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.Framework.TestHost": "1.0.0-*", "Sample.Tests": "1.0.0-*", "Xunit.KRunner": "1.0.0-*" }, From 6828bac3e30177b074b1bdd8c907f167cb28d9f0 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Mon, 6 Oct 2014 23:28:41 -0700 Subject: [PATCH 076/463] Skipped tests again --- test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index d9134b4f40c..f47ab7cc4c6 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -47,7 +47,7 @@ public async Task ListTest() Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosing ci failures")] public async Task RunTest_All() { // Arrange @@ -77,7 +77,7 @@ public async Task RunTest_All() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosing ci failures")] public async Task RunTest_ByDisplayName() { // Arrange @@ -100,7 +100,7 @@ public async Task RunTest_ByDisplayName() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosing ci failures")] public async Task RunTest_ByDisplayName_Short() { // Arrange @@ -122,7 +122,7 @@ public async Task RunTest_ByDisplayName_Short() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "diagnosing ci failures")] public async Task RunTest_ByUniqueName() { // Arrange From fd9e767638f323bd8d16103c8d6e7ea6033bc203 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 10 Oct 2014 10:34:44 -0700 Subject: [PATCH 077/463] Reacting to CLR package versioning changes --- src/Microsoft.AspNet.Testing/project.json | 10 +++++----- src/Microsoft.Framework.TestAdapter/project.json | 6 +++--- src/Microsoft.Framework.TestHost/project.json | 4 ++-- src/Xunit.KRunner/project.json | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index f7742e58b61..9f10539e85d 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -14,11 +14,11 @@ }, "aspnetcore50": { "dependencies": { - "System.Runtime": "4.0.20.0", - "System.Globalization": "4.0.10.0", - "System.Threading.Tasks": "4.0.10.0", - "System.Reflection": "4.0.10.0", - "System.Threading.Thread": "4.0.0.0" + "System.Runtime": "4.0.20-beta-*", + "System.Globalization": "4.0.10-beta-*", + "System.Threading.Tasks": "4.0.10-beta-*", + "System.Reflection": "4.0.10-beta-*", + "System.Threading.Thread": "4.0.0-beta-*" } } } diff --git a/src/Microsoft.Framework.TestAdapter/project.json b/src/Microsoft.Framework.TestAdapter/project.json index feffc65180f..993ec4d4ca4 100644 --- a/src/Microsoft.Framework.TestAdapter/project.json +++ b/src/Microsoft.Framework.TestAdapter/project.json @@ -5,9 +5,9 @@ "aspnet50": { }, "aspnetcore50": { "dependencies": { - "System.Collections": "4.0.10.0", - "System.Runtime": "4.0.20.0", - "System.Runtime.Extensions": "4.0.10.0" + "System.Collections": "4.0.10-beta-*", + "System.Runtime": "4.0.20-beta-*", + "System.Runtime.Extensions": "4.0.10-beta-*" } } } diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index 85613aacc44..2d0c3f1f063 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -19,8 +19,8 @@ "aspnet50": { }, "aspnetcore50": { "dependencies": { - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0" + "System.Console": "4.0.0-beta-*", + "System.Diagnostics.Process": "4.0.0-beta-*" } } } diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json index bd270600170..674017a9755 100644 --- a/src/Xunit.KRunner/project.json +++ b/src/Xunit.KRunner/project.json @@ -12,8 +12,8 @@ "aspnet50": { }, "aspnetcore50": { "dependencies": { - "System.Console": "4.0.0.0", - "System.Diagnostics.Process": "4.0.0.0" + "System.Console": "4.0.0-beta-*", + "System.Diagnostics.Process": "4.0.0-beta-*" } } } From 578a7c8a50a7332cfa608941729764c1698304a1 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 21 Oct 2014 12:48:14 -0700 Subject: [PATCH 078/463] Updating build.sh to work on Mono --- build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 4323aefc489..c7873ef58ec 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild @@ -28,7 +28,7 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source setup/kvm.sh + source packages/KoreBuild/build/kvm.sh fi if ! type k > /dev/null 2>&1; then From 5b0d157e96213a7c56d65196d5fb474a4621b28c Mon Sep 17 00:00:00 2001 From: Pranav K Date: Fri, 24 Oct 2014 00:32:59 -0700 Subject: [PATCH 079/463] Changing Newtonsoft.json to 6.0.6 --- src/Microsoft.Framework.TestHost/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index 2d0c3f1f063..2887cd22e32 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -10,7 +10,7 @@ "Microsoft.Framework.Runtime": "1.0.0-*", "Microsoft.Framework.Runtime.Common": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" }, - "Newtonsoft.Json": "6.0.4" + "Newtonsoft.Json": "6.0.6" }, "commands": { "run": "run" From 155420b21ba6dc191df7a558d54304d9fa04d596 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 6 Nov 2014 10:13:37 -0800 Subject: [PATCH 080/463] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631de..2d3b0cb857e 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From ba98624770fdabe3a7e76897c41af2a419b1b536 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Wed, 12 Nov 2014 15:37:54 -0800 Subject: [PATCH 081/463] Update KProj to the latest format --- .../Microsoft.AspNet.Testing.kproj | 24 ++++---------- .../Microsoft.Framework.TestAdapter.kproj | 26 ++++------------ .../Microsoft.Framework.TestHost.kproj | 24 ++++---------- src/StyleCop.KRules/StyleCop.KRules.kproj | 31 ++++--------------- src/Xunit.KRunner/Xunit.KRunner.kproj | 24 ++++---------- .../Microsoft.Framework.TestHost.Tests.kproj | 24 ++++---------- test/Sample.Tests/Sample.Tests.kproj | 24 ++++---------- 7 files changed, 42 insertions(+), 135 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj index c0eee03f72c..266cf3b0f7b 100644 --- a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 09be5203-8042-4338-9713-e44169342e72 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj index e65c169bdf6..a137a68856c 100644 --- a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj +++ b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj @@ -1,28 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - Debug - AnyCPU - 71c2f8aa-05e6-47db-9a1a-d2760cef7dc1 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj index a023d490793..5361d04f779 100644 --- a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj +++ b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) f003f228-2ae2-4e9d-877b-93eb773b5061 - Console - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index 3a30da0de7e..ee6cc03b2a0 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -1,33 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - Debug - AnyCPU - 657eb507-ee7a-451f-90a4-196f6fcd66e5 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - - - - \ No newline at end of file + diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index c8782b8b681..c738fe53d46 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) f003f228-2ae2-4e9d-877b-93eb773b7061 - Library - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj index 47a54974b99..e15203df8f4 100644 --- a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj +++ b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 25d18d0c-119c-4ab4-bca6-ac06179335fa - Console - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj index 337799ad4ec..fbb4eb92c0f 100644 --- a/test/Sample.Tests/Sample.Tests.kproj +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -1,26 +1,14 @@ - - + + - 12.0 + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) 25d18d0b-119c-4ab4-bca6-ac06179335fa - Console - - - ConsoleDebugger - - - WebDebugger - - - - - - - 2.0 + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ - \ No newline at end of file + From 68d88288a42d4d22935a7b5d907aa8e3c528caef Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Tue, 25 Nov 2014 11:07:03 -0800 Subject: [PATCH 082/463] Add schema version to kproj files --- src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj | 3 +++ .../Microsoft.Framework.TestAdapter.kproj | 3 +++ .../Microsoft.Framework.TestHost.kproj | 3 +++ src/StyleCop.KRules/StyleCop.KRules.kproj | 3 +++ src/Xunit.KRunner/Xunit.KRunner.kproj | 3 +++ .../Microsoft.Framework.TestHost.Tests.kproj | 3 +++ test/Sample.Tests/Sample.Tests.kproj | 3 +++ 7 files changed, 21 insertions(+) diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj index 266cf3b0f7b..3583805ddbf 100644 --- a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj index a137a68856c..d3a44ce9b12 100644 --- a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj +++ b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj index 5361d04f779..72646b7e308 100644 --- a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj +++ b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.kproj index ee6cc03b2a0..19565bcba8d 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.kproj +++ b/src/StyleCop.KRules/StyleCop.KRules.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj index c738fe53d46..2a511152d41 100644 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ b/src/Xunit.KRunner/Xunit.KRunner.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj index e15203df8f4..a869473eb63 100644 --- a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj +++ b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.kproj index fbb4eb92c0f..7a7ca46e92f 100644 --- a/test/Sample.Tests/Sample.Tests.kproj +++ b/test/Sample.Tests/Sample.Tests.kproj @@ -10,5 +10,8 @@ ..\..\artifacts\obj\$(MSBuildProjectName) ..\..\artifacts\bin\$(MSBuildProjectName)\ + + 2.0 + From 2fd1b0f11e329cbb141560e87ae966e24f41b363 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Mon, 8 Dec 2014 15:13:20 -0800 Subject: [PATCH 083/463] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631de..2d3b0cb857e 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From 51c260f8686b53594f28fb823a53a2b6a491f386 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Mon, 8 Dec 2014 15:24:26 -0800 Subject: [PATCH 084/463] Updating to dev NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 2d3b0cb857e..f41e9c631de 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From e757c4c93fc99c2514392c249f1f35f9e98c38e1 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 10 Dec 2014 10:05:28 -0800 Subject: [PATCH 085/463] Add xunit.runner.kre --- Testing.sln | 9 +- src/xunit.runner.kre/CommandLine.cs | 225 +++++++++++ .../Common/AssemblyExtensions.cs | 26 ++ .../Common/DictionaryExtensions.cs | 40 ++ src/xunit.runner.kre/Common/Guard.cs | 49 +++ .../Common/TestDiscoveryVisitor.cs | 26 ++ .../Common/XmlTestExecutionVisitor.cs | 270 ++++++++++++++ .../DesignTime/DesignTimeExecutionVisitor.cs | 102 +++++ .../DesignTime/DesignTimeTestConverter.cs | 127 +++++++ src/xunit.runner.kre/ParallelismOption.cs | 9 + src/xunit.runner.kre/Program.cs | 350 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 3 + .../Properties/GlobalAssemblyInfo.cs | 13 + .../RunnerCallbacks/RunnerCallback.cs | 84 +++++ .../RunnerCallbacks/StandardRunnerCallback.cs | 115 ++++++ .../RunnerCallbacks/TeamCityRunnerCallback.cs | 106 ++++++ .../Utility/StackFrameTransformer.cs | 54 +++ src/xunit.runner.kre/Utility/Transform.cs | 12 + .../Utility/TransformFactory.cs | 38 ++ .../Visitors/StandardOutputVisitor.cs | 174 +++++++++ .../Visitors/TeamCityVisitor.cs | 168 +++++++++ src/xunit.runner.kre/project.json | 47 +++ src/xunit.runner.kre/xunit.runner.kre.kproj | 21 ++ test/Sample.Tests/project.json | 5 +- 24 files changed, 2070 insertions(+), 3 deletions(-) create mode 100644 src/xunit.runner.kre/CommandLine.cs create mode 100644 src/xunit.runner.kre/Common/AssemblyExtensions.cs create mode 100644 src/xunit.runner.kre/Common/DictionaryExtensions.cs create mode 100644 src/xunit.runner.kre/Common/Guard.cs create mode 100644 src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs create mode 100644 src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs create mode 100644 src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs create mode 100644 src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs create mode 100644 src/xunit.runner.kre/ParallelismOption.cs create mode 100644 src/xunit.runner.kre/Program.cs create mode 100644 src/xunit.runner.kre/Properties/AssemblyInfo.cs create mode 100644 src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs create mode 100644 src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs create mode 100644 src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs create mode 100644 src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs create mode 100644 src/xunit.runner.kre/Utility/StackFrameTransformer.cs create mode 100644 src/xunit.runner.kre/Utility/Transform.cs create mode 100644 src/xunit.runner.kre/Utility/TransformFactory.cs create mode 100644 src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs create mode 100644 src/xunit.runner.kre/Visitors/TeamCityVisitor.cs create mode 100644 src/xunit.runner.kre/project.json create mode 100644 src/xunit.runner.kre/xunit.runner.kre.kproj diff --git a/Testing.sln b/Testing.sln index 7a62f70b6e6..eef57143d9e 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22201.0 +VisualStudioVersion = 14.0.22310.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -23,6 +23,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAda EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.kproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "xunit.runner.kre", "src\xunit.runner.kre\xunit.runner.kre.kproj", "{002D321E-170E-4E55-BDD1-77C6353A6EB5}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -61,6 +63,10 @@ Global {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.Build.0 = Release|Any CPU + {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -74,5 +80,6 @@ Global {F003F228-2AE2-4E9D-877B-93EB773B5061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} + {002D321E-170E-4E55-BDD1-77C6353A6EB5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} EndGlobalSection EndGlobal diff --git a/src/xunit.runner.kre/CommandLine.cs b/src/xunit.runner.kre/CommandLine.cs new file mode 100644 index 00000000000..ffd5623046d --- /dev/null +++ b/src/xunit.runner.kre/CommandLine.cs @@ -0,0 +1,225 @@ +using System; +using System.Collections.Generic; +using System.IO; + +namespace Xunit.ConsoleClient +{ + public class CommandLine + { + readonly Stack arguments = new Stack(); + + protected CommandLine(string[] args) + { + for (var i = args.Length - 1; i >= 0; i--) + arguments.Push(args[i]); + + TeamCity = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; + ParallelizeTestCollections = true; + DesignTimeTestUniqueNames = new List(); + Project = Parse(); + } + + public bool DesignTime { get; set; } + + // Used with --designtime - to specify specific tests by uniqueId. + public List DesignTimeTestUniqueNames { get; private set; } + + public bool List { get; set; } + + public int MaxParallelThreads { get; set; } + + public XunitProject Project { get; protected set; } + + public bool ParallelizeTestCollections { get; set; } + + public bool TeamCity { get; protected set; } + + public bool Wait { get; protected set; } + + static XunitProject GetProjectFile(List> assemblies) + { + var result = new XunitProject(); + + foreach (var assembly in assemblies) + result.Add(new XunitProjectAssembly + { + AssemblyFilename = Path.GetFullPath(assembly.Item1), + ConfigFilename = assembly.Item2 != null ? Path.GetFullPath(assembly.Item2) : null, + ShadowCopy = true + }); + + return result; + } + + static void GuardNoOptionValue(KeyValuePair option) + { + if (option.Value != null) + throw new ArgumentException(String.Format("error: unknown command line option: {0}", option.Value)); + } + + public static CommandLine Parse(params string[] args) + { + return new CommandLine(args); + } + + protected XunitProject Parse() + { + var assemblies = new List>(); + + while (arguments.Count > 0) + { + if (arguments.Peek().StartsWith("-")) + break; + + var assemblyFile = arguments.Pop(); + + string configFile = null; + + assemblies.Add(Tuple.Create(assemblyFile, configFile)); + } + + if (assemblies.Count == 0) + throw new ArgumentException("must specify at least one assembly"); + + var project = GetProjectFile(assemblies); + + while (arguments.Count > 0) + { + var option = PopOption(arguments); + var optionName = option.Key.ToLowerInvariant(); + + if (!optionName.StartsWith("-")) + throw new ArgumentException(String.Format("unknown command line option: {0}", option.Key)); + + if (optionName == "-wait") + { + GuardNoOptionValue(option); + Wait = true; + } + else if (optionName == "-maxthreads") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -maxthreads"); + + int threadValue; + if (!Int32.TryParse(option.Value, out threadValue) || threadValue < 0) + throw new ArgumentException("incorrect argument value for -maxthreads"); + + MaxParallelThreads = threadValue; + } + else if (optionName == "-parallel") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -parallel"); + + ParallelismOption parallelismOption; + if (!Enum.TryParse(option.Value, out parallelismOption)) + throw new ArgumentException("incorrect argument value for -parallel"); + + switch (parallelismOption) + { + case ParallelismOption.all: + case ParallelismOption.collections: + ParallelizeTestCollections = true; + break; + + case ParallelismOption.none: + default: + ParallelizeTestCollections = false; + break; + } + } + else if (optionName == "-teamcity") + { + GuardNoOptionValue(option); + TeamCity = true; + } + else if (optionName == "-noshadow") + { + GuardNoOptionValue(option); + foreach (var assembly in project.Assemblies) + assembly.ShadowCopy = false; + } + else if (optionName == "-trait") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -trait"); + + var pieces = option.Value.Split('='); + if (pieces.Length != 2 || String.IsNullOrEmpty(pieces[0]) || String.IsNullOrEmpty(pieces[1])) + throw new ArgumentException("incorrect argument format for -trait (should be \"name=value\")"); + + var name = pieces[0]; + var value = pieces[1]; + project.Filters.IncludedTraits.Add(name, value); + } + else if (optionName == "-notrait") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -notrait"); + + var pieces = option.Value.Split('='); + if (pieces.Length != 2 || String.IsNullOrEmpty(pieces[0]) || String.IsNullOrEmpty(pieces[1])) + throw new ArgumentException("incorrect argument format for -notrait (should be \"name=value\")"); + + var name = pieces[0]; + var value = pieces[1]; + project.Filters.ExcludedTraits.Add(name, value); + } + else if (optionName == "-class") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -class"); + + project.Filters.IncludedClasses.Add(option.Value); + } + else if (optionName == "-method") + { + if (option.Value == null) + throw new ArgumentException("missing argument for -method"); + + project.Filters.IncludedMethods.Add(option.Value); + } + else if (optionName == "-test" || optionName == "--test") + { + if (option.Value == null) + { + throw new ArgumentException("missing argument for --test"); + } + + DesignTimeTestUniqueNames.Add(option.Value); + } + else if (optionName == "-list" || optionName == "--list") + { + GuardNoOptionValue(option); + List = true; + } + else if (optionName == "-designtime" || optionName == "--designtime") + { + GuardNoOptionValue(option); + DesignTime = true; + } + else + { + if (option.Value == null) + throw new ArgumentException(String.Format("missing filename for {0}", option.Key)); + + project.Output.Add(optionName.Substring(1), option.Value); + } + } + + return project; + } + + static KeyValuePair PopOption(Stack arguments) + { + var option = arguments.Pop(); + string value = null; + + if (arguments.Count > 0 && !arguments.Peek().StartsWith("-")) + value = arguments.Pop(); + + return new KeyValuePair(option, value); + } + } +} diff --git a/src/xunit.runner.kre/Common/AssemblyExtensions.cs b/src/xunit.runner.kre/Common/AssemblyExtensions.cs new file mode 100644 index 00000000000..0fee337ae38 --- /dev/null +++ b/src/xunit.runner.kre/Common/AssemblyExtensions.cs @@ -0,0 +1,26 @@ +#if !ASPNETCORE50 + +using System; +using System.IO; +using System.Reflection; + +internal static class AssemblyExtensions +{ + public static string GetLocalCodeBase(this Assembly assembly) + { + string codeBase = assembly.CodeBase; + if (codeBase == null) + return null; + + if (!codeBase.StartsWith("file:///")) + throw new ArgumentException(String.Format("Code base {0} in wrong format; must start with file:///", codeBase), "assembly"); + + codeBase = codeBase.Substring(8); + if (Path.DirectorySeparatorChar == '/') + return "/" + codeBase; + + return codeBase.Replace('/', Path.DirectorySeparatorChar); + } +} + +#endif diff --git a/src/xunit.runner.kre/Common/DictionaryExtensions.cs b/src/xunit.runner.kre/Common/DictionaryExtensions.cs new file mode 100644 index 00000000000..7e65323a8ca --- /dev/null +++ b/src/xunit.runner.kre/Common/DictionaryExtensions.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; + +internal static class DictionaryExtensions +{ + public static void Add(this IDictionary> dictionary, TKey key, TValue value) + { + dictionary.GetOrAdd(key).Add(value); + } + + public static bool Contains(this IDictionary> dictionary, TKey key, TValue value, IEqualityComparer valueComparer) + { + List values; + + if (!dictionary.TryGetValue(key, out values)) + return false; + + return values.Contains(value, valueComparer); + } + + public static TValue GetOrAdd(this IDictionary dictionary, TKey key) + where TValue : new() + { + return dictionary.GetOrAdd(key, () => new TValue()); + } + + public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func newValue) + { + TValue result; + + if (!dictionary.TryGetValue(key, out result)) + { + result = newValue(); + dictionary[key] = result; + } + + return result; + } +} diff --git a/src/xunit.runner.kre/Common/Guard.cs b/src/xunit.runner.kre/Common/Guard.cs new file mode 100644 index 00000000000..5e9e5c040f9 --- /dev/null +++ b/src/xunit.runner.kre/Common/Guard.cs @@ -0,0 +1,49 @@ +using System; +using System.Collections; +using System.Diagnostics.CodeAnalysis; +using System.IO; + +/// +/// Guard class, used for guard clauses and argument validation +/// +internal static class Guard +{ + /// + public static void ArgumentNotNull(string argName, object argValue) + { + if (argValue == null) + throw new ArgumentNullException(argName); + } + + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This method may not be called by all users of Guard.")] + public static void ArgumentNotNullOrEmpty(string argName, IEnumerable argValue) + { + ArgumentNotNull(argName, argValue); + + if (!argValue.GetEnumerator().MoveNext()) + throw new ArgumentException("Argument was empty", argName); + } + + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This method may not be called by all users of Guard.")] + public static void ArgumentValid(string argName, string message, bool test) + { + if (!test) + throw new ArgumentException(message, argName); + } + +#if !XUNIT_CORE_DLL + /// + [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This method may not be called by all users of Guard.")] + public static void FileExists(string argName, string fileName) + { +#if !ANDROID && !ASPNET50 && !ASPNETCORE50 + Guard.ArgumentNotNullOrEmpty(argName, fileName); + Guard.ArgumentValid("assemblyFileName", + String.Format("File not found: {0}", fileName), + File.Exists(fileName)); +#endif + } +#endif +} \ No newline at end of file diff --git a/src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs b/src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs new file mode 100644 index 00000000000..51408e88873 --- /dev/null +++ b/src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs @@ -0,0 +1,26 @@ +using System.Collections.Generic; +using Xunit.Abstractions; + +#if XUNIT_CORE_DLL +namespace Xunit.Sdk +#else +namespace Xunit +#endif +{ + internal class TestDiscoveryVisitor : TestMessageVisitor + { + public TestDiscoveryVisitor() + { + TestCases = new List(); + } + + public List TestCases { get; private set; } + + protected override bool Visit(ITestCaseDiscoveryMessage discovery) + { + TestCases.Add(discovery.TestCase); + + return true; + } + } +} \ No newline at end of file diff --git a/src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs b/src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs new file mode 100644 index 00000000000..d87d4c73c4a --- /dev/null +++ b/src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs @@ -0,0 +1,270 @@ +using System; +using System.Collections.Concurrent; +using System.Linq; +using System.Xml.Linq; +using Xunit.Abstractions; + +namespace Xunit +{ + public class XmlTestExecutionVisitor : TestMessageVisitor + { + readonly XElement assemblyElement; + readonly XElement errorsElement; + readonly ConcurrentDictionary testCollectionElements = new ConcurrentDictionary(); + + public XmlTestExecutionVisitor(XElement assemblyElement, Func cancelThunk) + { + CancelThunk = cancelThunk ?? (() => false); + + this.assemblyElement = assemblyElement; + + if (this.assemblyElement != null) + { + errorsElement = new XElement("errors"); + this.assemblyElement.Add(errorsElement); + } + } + + public readonly Func CancelThunk; + public int Errors; + public int Failed; + public int Skipped; + public decimal Time; + public int Total; + + XElement CreateTestResultElement(ITestResultMessage testResult, string resultText) + { + var collectionElement = GetTestCollectionElement(testResult.TestCase.TestMethod.TestClass.TestCollection); + var testResultElement = + new XElement("test", + new XAttribute("name", XmlEscape(testResult.Test.DisplayName)), + new XAttribute("type", testResult.TestCase.TestMethod.TestClass.Class.Name), + new XAttribute("method", testResult.TestCase.TestMethod.Method.Name), + new XAttribute("time", testResult.ExecutionTime.ToString("0.000")), + new XAttribute("result", resultText) + ); + + if (testResult.TestCase.SourceInformation != null) + { + if (testResult.TestCase.SourceInformation.FileName != null) + testResultElement.Add(new XAttribute("source-file", testResult.TestCase.SourceInformation.FileName)); + if (testResult.TestCase.SourceInformation.LineNumber != null) + testResultElement.Add(new XAttribute("source-line", testResult.TestCase.SourceInformation.LineNumber.GetValueOrDefault())); + } + + if (testResult.TestCase.Traits != null && testResult.TestCase.Traits.Count > 0) + { + var traitsElement = new XElement("traits"); + + foreach (var key in testResult.TestCase.Traits.Keys) + foreach (var value in testResult.TestCase.Traits[key]) + traitsElement.Add( + new XElement("trait", + new XAttribute("name", XmlEscape(key)), + new XAttribute("value", XmlEscape(value)) + ) + ); + + testResultElement.Add(traitsElement); + } + + collectionElement.Add(testResultElement); + + return testResultElement; + } + + XElement GetTestCollectionElement(ITestCollection testCollection) + { + return testCollectionElements.GetOrAdd(testCollection, tc => new XElement("collection")); + } + + public override bool OnMessage(IMessageSinkMessage message) + { + var result = base.OnMessage(message); + if (result) + result = !CancelThunk(); + + return result; + } + + protected override bool Visit(ITestAssemblyFinished assemblyFinished) + { + Total += assemblyFinished.TestsRun; + Failed += assemblyFinished.TestsFailed; + Skipped += assemblyFinished.TestsSkipped; + Time += assemblyFinished.ExecutionTime; + + if (assemblyElement != null) + { + assemblyElement.Add( + new XAttribute("total", Total), + new XAttribute("passed", Total - Failed - Skipped), + new XAttribute("failed", Failed), + new XAttribute("skipped", Skipped), + new XAttribute("time", Time.ToString("0.000")), + new XAttribute("errors", Errors) + ); + + foreach (var element in testCollectionElements.Values) + assemblyElement.Add(element); + } + + return base.Visit(assemblyFinished); + } + + protected override bool Visit(ITestAssemblyStarting assemblyStarting) + { + if (assemblyElement != null) + { + assemblyElement.Add( + new XAttribute("name", assemblyStarting.TestAssembly.Assembly.AssemblyPath), + new XAttribute("environment", assemblyStarting.TestEnvironment), + new XAttribute("test-framework", assemblyStarting.TestFrameworkDisplayName), + new XAttribute("run-date", assemblyStarting.StartTime.ToString("yyyy-MM-dd")), + new XAttribute("run-time", assemblyStarting.StartTime.ToString("HH:mm:ss")) + ); + + if (assemblyStarting.TestAssembly.ConfigFileName != null) + assemblyElement.Add(new XAttribute("config-file", assemblyStarting.TestAssembly.ConfigFileName)); + } + + return base.Visit(assemblyStarting); + } + + protected override bool Visit(ITestCollectionFinished testCollectionFinished) + { + if (assemblyElement != null) + { + var collectionElement = GetTestCollectionElement(testCollectionFinished.TestCollection); + collectionElement.Add( + new XAttribute("total", testCollectionFinished.TestsRun), + new XAttribute("passed", testCollectionFinished.TestsRun - testCollectionFinished.TestsFailed - testCollectionFinished.TestsSkipped), + new XAttribute("failed", testCollectionFinished.TestsFailed), + new XAttribute("skipped", testCollectionFinished.TestsSkipped), + new XAttribute("name", XmlEscape(testCollectionFinished.TestCollection.DisplayName)), + new XAttribute("time", testCollectionFinished.ExecutionTime.ToString("0.000")) + ); + } + + return base.Visit(testCollectionFinished); + } + + protected override bool Visit(ITestFailed testFailed) + { + if (assemblyElement != null) + { + var testElement = CreateTestResultElement(testFailed, "Fail"); + testElement.Add(CreateFailureElement(testFailed)); + } + + return base.Visit(testFailed); + } + + protected override bool Visit(ITestPassed testPassed) + { + if (assemblyElement != null) + CreateTestResultElement(testPassed, "Pass"); + + return base.Visit(testPassed); + } + + protected override bool Visit(ITestSkipped testSkipped) + { + if (assemblyElement != null) + { + var testElement = CreateTestResultElement(testSkipped, "Skip"); + testElement.Add(new XElement("reason", new XCData(XmlEscape(testSkipped.Reason)))); + } + + return base.Visit(testSkipped); + } + + protected override bool Visit(IErrorMessage error) + { + AddError("fatal", null, error); + + return base.Visit(error); + } + + protected override bool Visit(ITestAssemblyCleanupFailure cleanupFailure) + { + AddError("assembly-cleanup", cleanupFailure.TestAssembly.Assembly.AssemblyPath, cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCaseCleanupFailure cleanupFailure) + { + AddError("test-case-cleanup", cleanupFailure.TestCase.DisplayName, cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestClassCleanupFailure cleanupFailure) + { + AddError("test-class-cleanup", cleanupFailure.TestClass.Class.Name, cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCollectionCleanupFailure cleanupFailure) + { + AddError("test-collection-cleanup", cleanupFailure.TestCollection.DisplayName, cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCleanupFailure cleanupFailure) + { + AddError("test-cleanup", cleanupFailure.Test.DisplayName, cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestMethodCleanupFailure cleanupFailure) + { + AddError("test-method-cleanup", cleanupFailure.TestMethod.Method.Name, cleanupFailure); + + return base.Visit(cleanupFailure); + } + + void AddError(string type, string name, IFailureInformation failureInfo) + { + Errors++; + + if (errorsElement == null) + return; + + var errorElement = new XElement("error", new XAttribute("type", type), CreateFailureElement(failureInfo)); + if (name != null) + errorElement.Add(new XAttribute("name", name)); + + errorsElement.Add(errorElement); + } + + static XElement CreateFailureElement(IFailureInformation failureInfo) + { + return new XElement("failure", + new XAttribute("exception-type", failureInfo.ExceptionTypes[0]), + new XElement("message", new XCData(XmlEscape(ExceptionUtility.CombineMessages(failureInfo)))), + new XElement("stack-trace", new XCData(ExceptionUtility.CombineStackTraces(failureInfo) ?? String.Empty)) + ); + } + + protected static string Escape(string value) + { + if (value == null) + return String.Empty; + + return value.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\0", "\\0"); + } + + protected static string XmlEscape(string value) + { + if (value == null) + return String.Empty; + + return value.Replace("\0", "\\0"); + } + } +} \ No newline at end of file diff --git a/src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs b/src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs new file mode 100644 index 00000000000..aef89156ac1 --- /dev/null +++ b/src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs @@ -0,0 +1,102 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.Framework.TestAdapter; +using Xunit.Abstractions; +using VsTestCase = Microsoft.Framework.TestAdapter.Test; + + +namespace Xunit.ConsoleClient +{ + public class DesignTimeExecutionVisitor : TestMessageVisitor + { + private readonly ITestExecutionSink _sink; + private readonly IDictionary _conversions; + private readonly TestMessageVisitor _next; + + public DesignTimeExecutionVisitor( + ITestExecutionSink sink, + IDictionary conversions, + TestMessageVisitor next) + { + _sink = sink; + _conversions = conversions; + _next = next; + } + + protected override bool Visit(ITestStarting testStarting) + { + var test = _conversions[testStarting.TestCase]; + + if (_sink != null) + { + _sink.RecordStart(test); + } + + return true; + } + + protected override bool Visit(ITestSkipped testSkipped) + { + var test = _conversions[testSkipped.TestCase]; + + if (_sink != null) + { + _sink.RecordResult(new TestResult(test) + { + Outcome = TestOutcome.Skipped, + }); + } + + return true; + } + + protected override bool Visit(ITestFailed testFailed) + { + var test = _conversions[testFailed.TestCase]; + var result = new TestResult(test) + { + Outcome = TestOutcome.Failed, + + Duration = TimeSpan.FromSeconds((double)testFailed.ExecutionTime), + ErrorMessage = string.Join(Environment.NewLine, testFailed.Messages), + ErrorStackTrace = string.Join(Environment.NewLine, testFailed.StackTraces), + }; + + result.Messages.Add(testFailed.Output); + + if (_sink != null) + { + _sink.RecordResult(result); + } + + return true; + } + + protected override bool Visit(ITestPassed testPassed) + { + var test = _conversions[testPassed.TestCase]; + + if (_sink != null) + { + _sink.RecordResult(new TestResult(test) + { + Outcome = TestOutcome.Passed, + + Duration = TimeSpan.FromSeconds((double)testPassed.ExecutionTime), + }); + } + + return true; + } + + public override bool OnMessage(IMessageSinkMessage message) + { + return + base.OnMessage(message) && + _next.OnMessage(message); + } + } +} \ No newline at end of file diff --git a/src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs b/src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs new file mode 100644 index 00000000000..dc26c7324b5 --- /dev/null +++ b/src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs @@ -0,0 +1,127 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Security.Cryptography; +using Microsoft.Framework.TestAdapter; +using Xunit.Abstractions; +using VsTestCase = Microsoft.Framework.TestAdapter.Test; + +namespace Xunit.ConsoleClient +{ + public static class DesignTimeTestConverter + { +#if ASPNETCORE50 + private readonly static HashAlgorithm _hash = SHA1.Create(); +#else + private readonly static HashAlgorithm _hash = new SHA1Managed(); +#endif + public static IDictionary Convert(IEnumerable testcases) + { + // When tests have the same class name and method name, generate unique names for display + var groups = testcases + .Select(tc => new + { + testcase = tc, + shortName = GetShortName(tc), + fullyQualifiedName = string.Format("{0}.{1}", tc.TestMethod.TestClass.Class.Name, tc.TestMethod.Method.Name) + }) + .GroupBy(tc => tc.fullyQualifiedName); + + var results = new Dictionary(); + foreach (var group in groups) + { + var uniquifyNames = group.Count() > 1; + foreach (var testcase in group) + { + results.Add( + testcase.testcase, + Convert( + testcase.testcase, + testcase.shortName, + testcase.fullyQualifiedName, + uniquifyNames)); + } + } + + return results; + } + + private static string GetShortName(ITestCase tc) + { + var shortName = new StringBuilder(); + + var classFullName = tc.TestMethod.TestClass.Class.Name; + var dotIndex = classFullName.LastIndexOf('.'); + if (dotIndex >= 0) + { + shortName.Append(classFullName.Substring(dotIndex + 1)); + } + else + { + shortName.Append(classFullName); + } + + shortName.Append("."); + shortName.Append(tc.TestMethod.Method.Name); + + // We need to shorten the arguments list if it's long. Let's arbitrarily pick 50 characters. + var argumentsIndex = tc.DisplayName.IndexOf('('); + if (argumentsIndex >= 0 && tc.DisplayName.Length - argumentsIndex > 50) + { + shortName.Append(tc.DisplayName.Substring(argumentsIndex, 46)); + shortName.Append("..."); + shortName.Append(")"); + } + else if (argumentsIndex >= 0) + { + shortName.Append(tc.DisplayName.Substring(argumentsIndex)); + } + else + { + // No need to handle argments + } + + return shortName.ToString(); + } + + private static VsTestCase Convert( + ITestCase testcase, + string shortName, + string fullyQualifiedName, + bool uniquifyNames) + { + string uniqueName; + if (uniquifyNames) + { + uniqueName = string.Format("{0}({1})", fullyQualifiedName, testcase.UniqueID); + } + else + { + uniqueName = fullyQualifiedName; + } + + var result = new VsTestCase(); + result.DisplayName = shortName; + result.FullyQualifiedName = uniqueName; + + result.Id = GuidFromString(testcase.UniqueID); + + if (testcase.SourceInformation != null) + { + result.CodeFilePath = testcase.SourceInformation.FileName; + result.LineNumber = testcase.SourceInformation.LineNumber; + } + + return result; + } + + private static Guid GuidFromString(string data) + { + var hash = _hash.ComputeHash(Encoding.Unicode.GetBytes(data)); + var b = new byte[16]; + Array.Copy((Array)hash, (Array)b, 16); + return new Guid(b); + } + } +} \ No newline at end of file diff --git a/src/xunit.runner.kre/ParallelismOption.cs b/src/xunit.runner.kre/ParallelismOption.cs new file mode 100644 index 00000000000..e6d07a04b6a --- /dev/null +++ b/src/xunit.runner.kre/ParallelismOption.cs @@ -0,0 +1,9 @@ +namespace Xunit.ConsoleClient +{ + public enum ParallelismOption + { + none, + collections, + all + } +} diff --git a/src/xunit.runner.kre/Program.cs b/src/xunit.runner.kre/Program.cs new file mode 100644 index 00000000000..4807ff4218d --- /dev/null +++ b/src/xunit.runner.kre/Program.cs @@ -0,0 +1,350 @@ +using System; +using System.Collections.Concurrent; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using Microsoft.Framework.Runtime; +using Microsoft.Framework.TestAdapter; +using Xunit.Abstractions; +using VsTestCase = Microsoft.Framework.TestAdapter.Test; + +namespace Xunit.ConsoleClient +{ + public class Program + { + volatile bool cancel; + bool failed; + readonly ConcurrentDictionary completionMessages = new ConcurrentDictionary(); + + private readonly IApplicationEnvironment _appEnv; + private readonly IServiceProvider _services; + + public Program(IApplicationEnvironment appEnv, IServiceProvider services) + { + _appEnv = appEnv; + _services = services; + } + + [STAThread] + public int Main(string[] args) + { + args = Enumerable.Repeat(_appEnv.ApplicationName + ".dll", 1).Concat(args).ToArray(); + + var originalForegroundColor = Console.ForegroundColor; + + try + { + var framework = _appEnv.RuntimeFramework; + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine("xUnit.net K Runtime Environment test runner ({0}-bit {1} {2})", IntPtr.Size * 8, framework.Identifier, framework.Version); + Console.WriteLine("Copyright (C) 2014 Outercurve Foundation."); + Console.WriteLine(); + Console.ForegroundColor = ConsoleColor.Gray; + + if (args.Length == 0 || args[0] == "-?") + { + PrintUsage(); + return 1; + } + +#if !ASPNETCORE50 + AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; + Console.CancelKeyPress += (sender, e) => + { + if (!cancel) + { + Console.WriteLine("Canceling... (Press Ctrl+C again to terminate)"); + cancel = true; + e.Cancel = true; + } + }; +#endif + + var defaultDirectory = Directory.GetCurrentDirectory(); + if (!defaultDirectory.EndsWith(new String(new[] { Path.DirectorySeparatorChar }))) + defaultDirectory += Path.DirectorySeparatorChar; + + var commandLine = CommandLine.Parse(args); + + var failCount = RunProject(defaultDirectory, commandLine.Project, commandLine.TeamCity, + commandLine.ParallelizeTestCollections, + commandLine.MaxParallelThreads, + commandLine.DesignTime, + commandLine.List, + commandLine.DesignTimeTestUniqueNames); + + if (commandLine.Wait) + { + Console.WriteLine(); +#if ASPNETCORE50 + Console.Write("Press ENTER to continue..."); + Console.ReadLine(); +#else + Console.Write("Press any key to continue..."); + Console.ReadKey(); +#endif + Console.WriteLine(); + } + + return failCount; + } + catch (ArgumentException ex) + { + Console.WriteLine("error: {0}", ex.Message); + return 1; + } + catch (BadImageFormatException ex) + { + Console.WriteLine("{0}", ex.Message); + return 1; + } + finally + { + Console.ForegroundColor = originalForegroundColor; + } + } + +#if !ASPNETCORE50 + static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) + { + var ex = e.ExceptionObject as Exception; + + if (ex != null) + Console.WriteLine(ex.ToString()); + else + Console.WriteLine("Error of unknown type thrown in application domain"); + + Environment.Exit(1); + } +#endif + + static void PrintUsage() + { + Console.WriteLine("usage: xunit.runner.kre [assemblyFile ...] [options]"); + Console.WriteLine(); + Console.WriteLine("Valid options:"); + Console.WriteLine(" -parallel option : set parallelization based on option"); + Console.WriteLine(" : none - turn off all parallelization"); + Console.WriteLine(" : collections - only parallelize collections"); + Console.WriteLine(" : all - parallelize collections"); + Console.WriteLine(" -maxthreads count : maximum thread count for collection parallelization"); + Console.WriteLine(" : 0 - run with unbounded thread count"); + Console.WriteLine(" : >0 - limit task thread pool size to 'count'"); + Console.WriteLine(" -noshadow : do not shadow copy assemblies"); + Console.WriteLine(" -teamcity : forces TeamCity mode (normally auto-detected)"); + Console.WriteLine(" -wait : wait for input after completion"); + Console.WriteLine(" -trait \"name=value\" : only run tests with matching name/value traits"); + Console.WriteLine(" : if specified more than once, acts as an OR operation"); + Console.WriteLine(" -notrait \"name=value\" : do not run tests with matching name/value traits"); + Console.WriteLine(" : if specified more than once, acts as an AND operation"); + Console.WriteLine(" -method \"name\" : run a given test method (should be fully specified;"); + Console.WriteLine(" : i.e., 'MyNamespace.MyClass.MyTestMethod')"); + Console.WriteLine(" : if specified more than once, acts as an OR operation"); + Console.WriteLine(" -class \"name\" : run all methods in a given test class (should be fully"); + Console.WriteLine(" : specified; i.e., 'MyNamespace.MyClass')"); + Console.WriteLine(" : if specified more than once, acts as an OR operation"); + + foreach (var transform in TransformFactory.AvailableTransforms) + Console.WriteLine(" {0} : {1}", + String.Format("-{0} ", transform.CommandLine).PadRight(22).Substring(0, 22), + transform.Description); + } + + int RunProject(string defaultDirectory, XunitProject project, bool teamcity, bool parallelizeTestCollections, int maxThreadCount, bool designTime, bool list, IReadOnlyList designTimeFullyQualifiedNames) + { + XElement assembliesElement = null; + var xmlTransformers = TransformFactory.GetXmlTransformers(project); + var needsXml = xmlTransformers.Count > 0; + var consoleLock = new object(); + + if (needsXml) + assembliesElement = new XElement("assemblies"); + + var originalWorkingFolder = Directory.GetCurrentDirectory(); + + using (AssemblyHelper.SubscribeResolve()) + { + var clockTime = Stopwatch.StartNew(); + + foreach (var assembly in project.Assemblies) + { + var assemblyElement = ExecuteAssembly(consoleLock, defaultDirectory, assembly, needsXml, teamcity, parallelizeTestCollections, maxThreadCount, project.Filters, designTime, list, designTimeFullyQualifiedNames); + if (assemblyElement != null) + assembliesElement.Add(assemblyElement); + } + + clockTime.Stop(); + + if (completionMessages.Count > 0) + { + Console.ForegroundColor = ConsoleColor.White; + Console.WriteLine(); + Console.WriteLine("=== TEST EXECUTION SUMMARY ==="); + Console.ForegroundColor = ConsoleColor.Gray; + + var totalTestsRun = completionMessages.Values.Sum(summary => summary.Total); + var totalTestsFailed = completionMessages.Values.Sum(summary => summary.Failed); + var totalTestsSkipped = completionMessages.Values.Sum(summary => summary.Skipped); + var totalTime = completionMessages.Values.Sum(summary => summary.Time).ToString("0.000s"); + var totalErrors = completionMessages.Values.Sum(summary => summary.Errors); + var longestAssemblyName = completionMessages.Keys.Max(key => key.Length); + var longestTotal = totalTestsRun.ToString().Length; + var longestFailed = totalTestsFailed.ToString().Length; + var longestSkipped = totalTestsSkipped.ToString().Length; + var longestTime = totalTime.Length; + var longestErrors = totalErrors.ToString().Length; + + foreach (var message in completionMessages.OrderBy(m => m.Key)) + Console.WriteLine(" {0} Total: {1}, Errors: {2}, Failed: {3}, Skipped: {4}, Time: {5}", + message.Key.PadRight(longestAssemblyName), + message.Value.Total.ToString().PadLeft(longestTotal), + message.Value.Errors.ToString().PadLeft(longestErrors), + message.Value.Failed.ToString().PadLeft(longestFailed), + message.Value.Skipped.ToString().PadLeft(longestSkipped), + message.Value.Time.ToString("0.000s").PadLeft(longestTime)); + + if (completionMessages.Count > 1) + Console.WriteLine(" {0} {1} {2} {3} {4} {5}" + Environment.NewLine + + " {6} {7} {8} {9} {10} {11} ({12})", + " ".PadRight(longestAssemblyName), + "-".PadRight(longestTotal, '-'), + "-".PadRight(longestErrors, '-'), + "-".PadRight(longestFailed, '-'), + "-".PadRight(longestSkipped, '-'), + "-".PadRight(longestTime, '-'), + "GRAND TOTAL:".PadLeft(longestAssemblyName), + totalTestsRun, + totalErrors, + totalTestsFailed, + totalTestsSkipped, + totalTime, + clockTime.Elapsed.TotalSeconds.ToString("0.000s")); + + } + } + + Directory.SetCurrentDirectory(originalWorkingFolder); + + foreach (var transformer in xmlTransformers) transformer(assembliesElement); + + return failed ? 1 : completionMessages.Values.Sum(summary => summary.Failed); + } + + TestMessageVisitor CreateVisitor(object consoleLock, string defaultDirectory, XElement assemblyElement, bool teamCity) + { + if (teamCity) + return new TeamCityVisitor(assemblyElement, () => cancel); + + return new StandardOutputVisitor(consoleLock, defaultDirectory, assemblyElement, () => cancel, completionMessages); + } + + XElement ExecuteAssembly(object consoleLock, string defaultDirectory, XunitProjectAssembly assembly, bool needsXml, bool teamCity, bool parallelizeTestCollections, int maxThreadCount, XunitFilters filters, bool designTime, bool list, IReadOnlyList designTimeFullyQualifiedNames) + { + if (cancel) + return null; + + var assemblyElement = needsXml ? new XElement("assembly") : null; + + try + { + lock (consoleLock) + Console.WriteLine("Discovering: {0}", Path.GetFileNameWithoutExtension(assembly.AssemblyFilename)); + + using (var controller = new XunitFrontController(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy)) + using (var discoveryVisitor = new TestDiscoveryVisitor()) + { + controller.Find(includeSourceInformation: false, messageSink: discoveryVisitor, options: new TestFrameworkOptions()); + discoveryVisitor.Finished.WaitOne(); + + IDictionary vsTestcases = null; + if (designTime) + { + vsTestcases = DesignTimeTestConverter.Convert(discoveryVisitor.TestCases); + } + + lock (consoleLock) + Console.WriteLine("Discovered: {0}", Path.GetFileNameWithoutExtension(assembly.AssemblyFilename)); + + if (list) + { + lock (consoleLock) + { + if (designTime) + { + var sink = (ITestDiscoverySink)_services.GetService(typeof(ITestDiscoverySink)); + + foreach (var testcase in vsTestcases.Values) + { + if (sink != null) + { + sink.SendTest(testcase); + } + + Console.WriteLine(testcase.FullyQualifiedName); + } + } + else + { + foreach (var testcase in discoveryVisitor.TestCases) + { + Console.WriteLine(testcase.DisplayName); + } + } + } + + return assemblyElement; + } + + var executionOptions = new XunitExecutionOptions { DisableParallelization = !parallelizeTestCollections, MaxParallelThreads = maxThreadCount }; + var resultsVisitor = CreateVisitor(consoleLock, defaultDirectory, assemblyElement, teamCity); + + if (designTime) + { + var sink = (ITestExecutionSink)_services.GetService(typeof(ITestExecutionSink)); + resultsVisitor = new DesignTimeExecutionVisitor( + sink, + vsTestcases, + resultsVisitor); + } + + IList filteredTestCases; + if (!designTime || designTimeFullyQualifiedNames.Count == 0) + { + filteredTestCases = discoveryVisitor.TestCases.Where(filters.Filter).ToList(); + } + else + { + filteredTestCases = (from t in vsTestcases + where designTimeFullyQualifiedNames.Contains(t.Value.FullyQualifiedName) + select t.Key) + .ToList(); + } + + if (filteredTestCases.Count == 0) + { + lock (consoleLock) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine("ERROR: {0} has no tests to run", Path.GetFileNameWithoutExtension(assembly.AssemblyFilename)); + Console.ForegroundColor = ConsoleColor.Gray; + } + } + else + { + controller.RunTests(filteredTestCases, resultsVisitor, executionOptions); + resultsVisitor.Finished.WaitOne(); + } + } + } + catch (Exception ex) + { + Console.WriteLine("{0}: {1}", ex.GetType().FullName, ex.Message); + failed = true; + } + + return assemblyElement; + } + } +} diff --git a/src/xunit.runner.kre/Properties/AssemblyInfo.cs b/src/xunit.runner.kre/Properties/AssemblyInfo.cs new file mode 100644 index 00000000000..0afdef48eb7 --- /dev/null +++ b/src/xunit.runner.kre/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Reflection; + +[assembly : AssemblyTitle("xUnit.net Console Test Runner")] \ No newline at end of file diff --git a/src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs b/src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs new file mode 100644 index 00000000000..47982706663 --- /dev/null +++ b/src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs @@ -0,0 +1,13 @@ +using System.Diagnostics.CodeAnalysis; +using System.Reflection; + +[assembly: AssemblyCompany("Outercurve Foundation")] +[assembly: AssemblyProduct("xUnit.net Testing Framework")] +[assembly: AssemblyCopyright("Copyright (C) Outercurve Foundation")] +[assembly: AssemblyVersion("99.99.99.0")] + +[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Xunit.Sdk")] +[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "xunit")] +[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "extensions")] +[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "utility")] +[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "runner")] \ No newline at end of file diff --git a/src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs b/src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs new file mode 100644 index 00000000000..65328da7033 --- /dev/null +++ b/src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs @@ -0,0 +1,84 @@ +//using System; + +//namespace Xunit.ConsoleClient +//{ +// public class RunnerCallback : ITestMethodRunnerCallback +// { +// public int TotalTests { get; set; } +// public int TotalFailures { get; set; } +// public int TotalSkips { get; set; } +// public double TotalTime { get; set; } + +// public virtual void AssemblyFinished(TestAssembly testAssembly, int total, int failed, int skipped, double time) +// { +// TotalTests = total; +// TotalFailures = failed; +// TotalSkips = skipped; +// TotalTime = time; +// } + +// public virtual void AssemblyStart(TestAssembly testAssembly) +// { +// } + +// public virtual bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace) +// { +// return true; +// } + +// public virtual void ExceptionThrown(TestAssembly testAssembly, Exception exception) +// { +// Console.WriteLine(); +// Console.WriteLine("CATASTROPHIC ERROR OCCURRED:"); +// Console.WriteLine(exception.ToString()); +// Console.WriteLine("WHILE RUNNING:"); +// Console.WriteLine(testAssembly.AssemblyFilename); +// Console.WriteLine(); +// } + +// protected virtual void TestFailed(TestMethod method, TestFailedResult result) +// { +// } + +// public bool TestFinished(TestMethod method) +// { +// TestResult result = method.RunResults[method.RunResults.Count - 1]; + +// TestPassedResult passedResult = result as TestPassedResult; +// if (passedResult != null) +// TestPassed(method, passedResult); +// else +// { +// TestFailedResult failedResult = result as TestFailedResult; +// if (failedResult != null) +// TestFailed(method, failedResult); +// else +// { +// TestSkippedResult skippedResult = result as TestSkippedResult; +// if (skippedResult != null) +// TestSkipped(method, skippedResult); +// } +// } + +// return TestFinished(method, result); +// } + +// protected virtual bool TestFinished(TestMethod method, TestResult result) +// { +// return true; +// } + +// protected virtual void TestPassed(TestMethod method, TestPassedResult result) +// { +// } + +// protected virtual void TestSkipped(TestMethod method, TestSkippedResult result) +// { +// } + +// public virtual bool TestStart(TestMethod method) +// { +// return true; +// } +// } +//} \ No newline at end of file diff --git a/src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs b/src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs new file mode 100644 index 00000000000..6b9c2d83f0f --- /dev/null +++ b/src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs @@ -0,0 +1,115 @@ +//using System; +//using System.Globalization; + +//namespace Xunit.ConsoleClient +//{ +// public class StandardRunnerCallback : RunnerCallback +// { +// readonly bool silent; +// int testCount = 0; +// readonly int totalCount; + +// public StandardRunnerCallback(bool silent, int totalCount) +// { +// this.silent = silent; +// this.totalCount = totalCount; +// } + +// public override void AssemblyFinished(TestAssembly testAssembly, int total, int failed, int skipped, double time) +// { +// base.AssemblyFinished(testAssembly, total, failed, skipped, time); + +// if (!silent) +// Console.Write("\r"); + +// Console.WriteLine("{0} total, {1} failed, {2} skipped, took {3} seconds", total, failed, skipped, time.ToString("0.000", CultureInfo.CurrentCulture)); +// } + +// public override bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace) +// { +// if (!silent) +// Console.Write("\r"); + +// Console.ForegroundColor = ConsoleColor.Red; +// Console.WriteLine("{0} [FIXTURE FAIL]", testClass.TypeName); +// Console.ResetColor(); + +// Console.WriteLine(Indent(message)); + +// if (stackTrace != null) +// { +// Console.WriteLine(Indent("Stack Trace:")); +// Console.WriteLine(Indent(StackFrameTransformer.TransformStack(stackTrace))); +// } + +// Console.WriteLine(); +// return true; +// } + +// protected override void TestFailed(TestMethod testMethod, TestFailedResult result) +// { +// if (!silent) +// Console.Write("\r"); + +// Console.ForegroundColor = ConsoleColor.Red; +// Console.WriteLine("{0} [FAIL]", result.DisplayName); +// Console.ResetColor(); + +// Console.WriteLine(Indent(result.ExceptionMessage)); + +// if (result.ExceptionStackTrace != null) +// { +// Console.ForegroundColor = ConsoleColor.DarkGray; +// Console.WriteLine(Indent("Stack Trace:")); +// Console.ResetColor(); + +// Console.WriteLine(Indent(StackFrameTransformer.TransformStack(result.ExceptionStackTrace))); +// } + +// Console.WriteLine(); +// } + +// protected override bool TestFinished(TestMethod testMethod, TestResult testResult) +// { +// if (!silent) +// { +// Console.ForegroundColor = ConsoleColor.DarkGray; +// Console.Write("\rTests complete: {0} of {1}", ++testCount, totalCount); +// Console.ResetColor(); +// } + +// return true; +// } + +// protected override void TestSkipped(TestMethod testMethod, TestSkippedResult result) +// { +// if (!silent) +// Console.Write("\r"); + +// Console.ForegroundColor = ConsoleColor.Yellow; +// Console.WriteLine("{0} [SKIP]", result.DisplayName); +// Console.ResetColor(); + +// Console.WriteLine(Indent(result.Reason)); +// Console.WriteLine(); +// } + +// // Helpers + +// string Indent(string message) +// { +// return Indent(message, 0); +// } + +// string Indent(string message, int additionalSpaces) +// { +// string result = ""; +// string indent = "".PadRight(additionalSpaces + 3); + +// foreach (string line in message.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) +// result += indent + line + Environment.NewLine; + +// return result.TrimEnd(); +// } +// } +//} \ No newline at end of file diff --git a/src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs b/src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs new file mode 100644 index 00000000000..ff4300143fe --- /dev/null +++ b/src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs @@ -0,0 +1,106 @@ +//using System; +//using System.IO; + +//namespace Xunit.ConsoleClient +//{ +// public class TeamCityRunnerCallback : RunnerCallback +// { +// public override void AssemblyFinished(TestAssembly testAssembly, int total, int failed, int skipped, double time) +// { +// base.AssemblyFinished(testAssembly, total, failed, skipped, time); + +// Console.WriteLine( +// "##teamcity[testSuiteFinished name='{0}']", +// Escape(Path.GetFileName(testAssembly.AssemblyFilename)) +// ); +// } + +// public override void AssemblyStart(TestAssembly testAssembly) +// { +// Console.WriteLine( +// "##teamcity[testSuiteStarted name='{0}']", +// Escape(Path.GetFileName(testAssembly.AssemblyFilename)) +// ); +// } + +// public override bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace) +// { +// Console.WriteLine( +// "##teamcity[buildStatus status='FAILURE' text='Class failed: {0}: {1}|r|n{2}']", +// Escape(testClass.TypeName), +// Escape(message), +// Escape(stackTrace) +// ); + +// return true; +// } + +// protected override void TestFailed(TestMethod method, TestFailedResult result) +// { +// Console.WriteLine( +// "##teamcity[testFailed name='{0}' details='{1}|r|n{2}']", +// Escape(method.DisplayName), +// Escape(result.ExceptionMessage), +// Escape(result.ExceptionStackTrace) +// ); + +// WriteOutput(result.DisplayName, result.Output); +// } + +// protected override bool TestFinished(TestMethod method, TestResult result) +// { +// WriteFinished(method.DisplayName, result.Duration); +// return true; +// } + +// protected override void TestPassed(TestMethod method, TestPassedResult result) +// { +// WriteOutput(method.DisplayName, result.Output); +// } + +// protected override void TestSkipped(TestMethod method, TestSkippedResult result) +// { +// Console.WriteLine( +// "##teamcity[testIgnored name='{0}' message='{1}']", +// Escape(method.DisplayName), +// Escape(result.Reason) +// ); +// } + +// public override bool TestStart(TestMethod method) +// { +// Console.WriteLine( +// "##teamcity[testStarted name='{0}']", +// Escape(method.DisplayName) +// ); + +// return true; +// } + +// // Helpers + +// static string Escape(string value) +// { +// if (value == null) +// return String.Empty; + +// return value.Replace("|", "||") +// .Replace("'", "|'") +// .Replace("\r", "|r") +// .Replace("\n", "|n") +// .Replace("]", "|]"); +// } + +// static void WriteFinished(string name, double duration) +// { +// Console.WriteLine("##teamcity[testFinished name='{0}' duration='{1}']", +// Escape(name), (int)(duration * 1000D)); +// } + +// static void WriteOutput(string name, string output) +// { +// if (output != null) +// Console.WriteLine("##teamcity[testStdOut name='{0}' out='{1}']", Escape(name), Escape(output)); +// } +// } +//} \ No newline at end of file diff --git a/src/xunit.runner.kre/Utility/StackFrameTransformer.cs b/src/xunit.runner.kre/Utility/StackFrameTransformer.cs new file mode 100644 index 00000000000..ff907e891ee --- /dev/null +++ b/src/xunit.runner.kre/Utility/StackFrameTransformer.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; +using System.Text.RegularExpressions; + +namespace Xunit.ConsoleClient +{ + /// + /// Transforms stack frames and stack traces into compiler-like output + /// so they can be double-clicked in Visual Studio. + /// + public static class StackFrameTransformer + { + static Regex regex; + + static StackFrameTransformer() + { + regex = new Regex(@"^\s*at (?.*) in (?.*):(line )?(?\d+)$"); + } + + /// + public static string TransformFrame(string stackFrame, string defaultDirectory) + { + if (stackFrame == null) + return null; + + var match = regex.Match(stackFrame); + if (match == Match.Empty) + return stackFrame; + + var file = match.Groups["file"].Value; + if (file.StartsWith(defaultDirectory, StringComparison.OrdinalIgnoreCase)) + file = file.Substring(defaultDirectory.Length); + + return String.Format("{0}({1},0): at {2}", + file, + match.Groups["line"].Value, + match.Groups["method"].Value); + } + + /// + public static string TransformStack(string stack, string defaultDirectory) + { + if (stack == null) + return null; + + List results = new List(); + + foreach (string frame in stack.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) + results.Add(TransformFrame(frame, defaultDirectory)); + + return String.Join(Environment.NewLine, results.ToArray()); + } + } +} diff --git a/src/xunit.runner.kre/Utility/Transform.cs b/src/xunit.runner.kre/Utility/Transform.cs new file mode 100644 index 00000000000..5b4541a0f8f --- /dev/null +++ b/src/xunit.runner.kre/Utility/Transform.cs @@ -0,0 +1,12 @@ +using System; +using System.Xml.Linq; + +namespace Xunit.ConsoleClient +{ + public class Transform + { + public string CommandLine; + public string Description; + public Action OutputHandler; + } +} diff --git a/src/xunit.runner.kre/Utility/TransformFactory.cs b/src/xunit.runner.kre/Utility/TransformFactory.cs new file mode 100644 index 00000000000..4b24644b5b0 --- /dev/null +++ b/src/xunit.runner.kre/Utility/TransformFactory.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Reflection; +using System.Xml; +using System.Xml.Linq; + +namespace Xunit.ConsoleClient +{ + public class TransformFactory + { + static readonly TransformFactory instance = new TransformFactory(); + + readonly Dictionary availableTransforms = new Dictionary(StringComparer.OrdinalIgnoreCase); + + protected TransformFactory() + { + availableTransforms.Add("xml", new Transform { CommandLine = "xml", Description = "output results to xUnit.net v2 style XML file", OutputHandler = Handler_DirectWrite }); + } + + public static List AvailableTransforms + { + get { return instance.availableTransforms.Values.ToList(); } + } + + public static List> GetXmlTransformers(XunitProject project) + { + return project.Output.Select(output => new Action(xml => instance.availableTransforms[output.Key].OutputHandler(xml, output.Value))).ToList(); + } + + static void Handler_DirectWrite(XElement xml, string outputFileName) + { + using (var stream = File.OpenWrite(outputFileName)) + xml.Save(stream); + } + } +} diff --git a/src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs b/src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs new file mode 100644 index 00000000000..a1f5f74cc58 --- /dev/null +++ b/src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections.Concurrent; +using System.IO; +using System.Xml.Linq; +using Xunit.Abstractions; + +namespace Xunit.ConsoleClient +{ + public class StandardOutputVisitor : XmlTestExecutionVisitor + { + string assemblyFileName; + readonly object consoleLock; + readonly ConcurrentDictionary completionMessages; + readonly string defaultDirectory; + + public StandardOutputVisitor(object consoleLock, + string defaultDirectory, + XElement assemblyElement, + Func cancelThunk, + ConcurrentDictionary completionMessages = null) + : base(assemblyElement, cancelThunk) + { + this.consoleLock = consoleLock; + this.defaultDirectory = defaultDirectory; + this.completionMessages = completionMessages; + } + + protected override bool Visit(ITestAssemblyStarting assemblyStarting) + { + assemblyFileName = Path.GetFileName(assemblyStarting.TestAssembly.Assembly.AssemblyPath); + + lock (consoleLock) + Console.WriteLine("Starting: {0}", Path.GetFileNameWithoutExtension(assemblyFileName)); + + return base.Visit(assemblyStarting); + } + + protected override bool Visit(ITestAssemblyFinished assemblyFinished) + { + // Base class does computation of results, so call it first. + var result = base.Visit(assemblyFinished); + + lock (consoleLock) + Console.WriteLine("Finished: {0}", Path.GetFileNameWithoutExtension(assemblyFileName)); + + if (completionMessages != null) + completionMessages.TryAdd(Path.GetFileNameWithoutExtension(assemblyFileName), new ExecutionSummary + { + Total = assemblyFinished.TestsRun, + Failed = assemblyFinished.TestsFailed, + Skipped = assemblyFinished.TestsSkipped, + Time = assemblyFinished.ExecutionTime, + Errors = Errors + }); + + return result; + } + + protected override bool Visit(ITestFailed testFailed) + { + lock (consoleLock) + { + // TODO: Thread-safe way to figure out the default foreground color + Console.ForegroundColor = ConsoleColor.Red; + Console.Error.WriteLine(" {0} [FAIL]", Escape(testFailed.Test.DisplayName)); + Console.ForegroundColor = ConsoleColor.Gray; + Console.Error.WriteLine(" {0}", ExceptionUtility.CombineMessages(testFailed).Replace(Environment.NewLine, Environment.NewLine + " ")); + + WriteStackTrace(ExceptionUtility.CombineStackTraces(testFailed)); + } + + return base.Visit(testFailed); + } + + protected override bool Visit(ITestPassed testPassed) + { + return base.Visit(testPassed); + } + + protected override bool Visit(ITestSkipped testSkipped) + { + lock (consoleLock) + { + // TODO: Thread-safe way to figure out the default foreground color + Console.ForegroundColor = ConsoleColor.Yellow; + Console.Error.WriteLine(" {0} [SKIP]", Escape(testSkipped.Test.DisplayName)); + Console.ForegroundColor = ConsoleColor.Gray; + Console.Error.WriteLine(" {0}", Escape(testSkipped.Reason)); + } + + return base.Visit(testSkipped); + } + + protected override bool Visit(ITestStarting testStarting) + { + return base.Visit(testStarting); + } + + protected override bool Visit(IErrorMessage error) + { + WriteError("FATAL", error); + + return base.Visit(error); + } + + protected override bool Visit(ITestAssemblyCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Assembly Cleanup Failure ({0})", cleanupFailure.TestAssembly.Assembly.AssemblyPath), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCaseCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Case Cleanup Failure ({0})", cleanupFailure.TestCase.DisplayName), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestClassCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Class Cleanup Failure ({0})", cleanupFailure.TestClass.Class.Name), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCollectionCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Collection Cleanup Failure ({0})", cleanupFailure.TestCollection.DisplayName), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Cleanup Failure ({0})", cleanupFailure.Test.DisplayName), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestMethodCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Method Cleanup Failure ({0})", cleanupFailure.TestMethod.Method.Name), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected void WriteError(string failureName, IFailureInformation failureInfo) + { + lock (consoleLock) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.Error.WriteLine(" [{0}] {1}", failureName, Escape(failureInfo.ExceptionTypes[0])); + Console.ForegroundColor = ConsoleColor.Gray; + Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(failureInfo))); + + WriteStackTrace(ExceptionUtility.CombineStackTraces(failureInfo)); + } + } + + void WriteStackTrace(string stackTrace) + { + if (String.IsNullOrWhiteSpace(stackTrace)) + return; + + Console.ForegroundColor = ConsoleColor.DarkGray; + Console.Error.WriteLine(" Stack Trace:"); + + Console.ForegroundColor = ConsoleColor.Gray; + foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) + Console.Error.WriteLine(" {0}", StackFrameTransformer.TransformFrame(stackFrame, defaultDirectory)); + } + } +} \ No newline at end of file diff --git a/src/xunit.runner.kre/Visitors/TeamCityVisitor.cs b/src/xunit.runner.kre/Visitors/TeamCityVisitor.cs new file mode 100644 index 00000000000..01a3ac294c3 --- /dev/null +++ b/src/xunit.runner.kre/Visitors/TeamCityVisitor.cs @@ -0,0 +1,168 @@ +using System; +using System.Collections.Concurrent; +using System.Xml.Linq; +using Xunit.Abstractions; + +namespace Xunit.ConsoleClient +{ + public class TeamCityVisitor : XmlTestExecutionVisitor + { + readonly ConcurrentDictionary flowMappings = new ConcurrentDictionary(); + readonly Func flowIdMapper; + + public TeamCityVisitor(XElement assembliesElement, Func cancelThunk) + : this(assembliesElement, cancelThunk, _ => Guid.NewGuid().ToString("N")) { } + + public TeamCityVisitor(XElement assembliesElement, Func cancelThunk, Func flowIdMapper) + : base(assembliesElement, cancelThunk) + { + this.flowIdMapper = flowIdMapper; + } + + void LogFinish(ITestResultMessage testResult) + { + Console.WriteLine("##teamcity[testFinished name='{0}' duration='{1}' flowId='{2}']", + TeamCityEscape(testResult.Test.DisplayName), + (int)(testResult.ExecutionTime * 1000M), + ToFlowId(testResult.TestCollection.DisplayName)); + } + + protected override bool Visit(ITestCollectionFinished testCollectionFinished) + { + // Base class does computation of results, so call it first. + var result = base.Visit(testCollectionFinished); + + Console.WriteLine("##teamcity[testSuiteFinished name='{0}' flowId='{1}']", + TeamCityEscape(testCollectionFinished.TestCollection.DisplayName), + ToFlowId(testCollectionFinished.TestCollection.DisplayName)); + + return result; + } + + protected override bool Visit(ITestCollectionStarting testCollectionStarting) + { + Console.WriteLine("##teamcity[testSuiteStarted name='{0}' flowId='{1}']", + TeamCityEscape(testCollectionStarting.TestCollection.DisplayName), + ToFlowId(testCollectionStarting.TestCollection.DisplayName)); + + return base.Visit(testCollectionStarting); + } + + protected override bool Visit(ITestFailed testFailed) + { + Console.WriteLine("##teamcity[testFailed name='{0}' details='{1}|r|n{2}' flowId='{3}']", + TeamCityEscape(testFailed.Test.DisplayName), + TeamCityEscape(ExceptionUtility.CombineMessages(testFailed)), + TeamCityEscape(ExceptionUtility.CombineStackTraces(testFailed)), + ToFlowId(testFailed.TestCollection.DisplayName)); + LogFinish(testFailed); + + return base.Visit(testFailed); + } + + protected override bool Visit(ITestPassed testPassed) + { + LogFinish(testPassed); + + return base.Visit(testPassed); + } + + protected override bool Visit(ITestSkipped testSkipped) + { + Console.WriteLine("##teamcity[testIgnored name='{0}' message='{1}' flowId='{2}']", + TeamCityEscape(testSkipped.Test.DisplayName), + TeamCityEscape(testSkipped.Reason), + ToFlowId(testSkipped.TestCollection.DisplayName)); + LogFinish(testSkipped); + + return base.Visit(testSkipped); + } + + protected override bool Visit(ITestStarting testStarting) + { + Console.WriteLine("##teamcity[testStarted name='{0}' flowId='{1}']", + TeamCityEscape(testStarting.Test.DisplayName), + ToFlowId(testStarting.TestCollection.DisplayName)); + + return base.Visit(testStarting); + } + + protected override bool Visit(IErrorMessage error) + { + WriteError("FATAL", error); + + return base.Visit(error); + } + + protected override bool Visit(ITestAssemblyCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Assembly Cleanup Failure ({0})", cleanupFailure.TestAssembly.Assembly.AssemblyPath), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCaseCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Case Cleanup Failure ({0})", cleanupFailure.TestCase.DisplayName), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestClassCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Class Cleanup Failure ({0})", cleanupFailure.TestClass.Class.Name), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCollectionCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Collection Cleanup Failure ({0})", cleanupFailure.TestCollection.DisplayName), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Cleanup Failure ({0})", cleanupFailure.Test.DisplayName), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + protected override bool Visit(ITestMethodCleanupFailure cleanupFailure) + { + WriteError(String.Format("Test Method Cleanup Failure ({0})", cleanupFailure.TestMethod.Method.Name), cleanupFailure); + + return base.Visit(cleanupFailure); + } + + static string TeamCityEscape(string value) + { + if (value == null) + return String.Empty; + + return value.Replace("|", "||") + .Replace("'", "|'") + .Replace("\r", "|r") + .Replace("\n", "|n") + .Replace("]", "|]") + .Replace("[", "|[") + .Replace("\u0085", "|x") + .Replace("\u2028", "|l") + .Replace("\u2029", "|p"); + } + + string ToFlowId(string testCollectionName) + { + return flowMappings.GetOrAdd(testCollectionName, flowIdMapper); + } + + static void WriteError(string messageType, IFailureInformation failureInfo) + { + var message = String.Format("[{0}] {1}: {2}", messageType, failureInfo.ExceptionTypes[0], ExceptionUtility.CombineMessages(failureInfo)); + var stack = ExceptionUtility.CombineStackTraces(failureInfo); + + Console.WriteLine("##teamcity[message text='{0}' errorDetails='{1}' status='ERROR']", TeamCityEscape(message), TeamCityEscape(stack)); + } + } +} \ No newline at end of file diff --git a/src/xunit.runner.kre/project.json b/src/xunit.runner.kre/project.json new file mode 100644 index 00000000000..9854d7345a1 --- /dev/null +++ b/src/xunit.runner.kre/project.json @@ -0,0 +1,47 @@ +{ + "version": "1.0.0-*", + "frameworks": { + "aspnet50": { + "frameworkAssemblies": { + "System.Configuration": "", + "System.Reflection": "", + "System.Runtime": "", + "System.Threading.Tasks": "", + "System.Web": "", + "System.Web.Extensions": "", + "System.XML": "", + "System.Xml.Linq": "" + } + }, + "aspnetcore50": { + "dependencies": { + "System.Collections": "4.0.10-beta-*", + "System.Collections.Concurrent": "4.0.0-beta-*", + "System.Console": "4.0.0-beta-*", + "System.Diagnostics.Debug": "4.0.10-beta-*", + "System.Diagnostics.Tools": "4.0.0-beta-*", + "System.Globalization": "4.0.10-beta-*", + "System.IO.FileSystem": "4.0.0-beta-*", + "System.Linq": "4.0.0-beta-*", + "System.Reflection": "4.0.10-beta-*", + "System.Reflection.Extensions": "4.0.0-beta-*", + "System.Runtime.Extensions": "4.0.10-beta-*", + "System.Security.Cryptography.Hashing": "4.0.0-beta-*", + "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", + "System.Text.RegularExpressions": "4.0.0-beta-*", + "System.Threading": "4.0.0-beta-*", + "System.Threading.ExecutionContext": "4.0.0-beta-*", + "System.Threading.Thread": "4.0.0-beta-*", + "System.Threading.ThreadPool": "4.0.10-beta-*", + "System.Xml.XDocument": "4.0.0-beta-*" + } + } + }, + "dependencies": { + "Microsoft.Framework.TestAdapter": "1.0.0-*", + "Microsoft.Framework.TestHost": "1.0.0-*", + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", + "xunit.execution": "2.0.0-beta5-build2785", + "xunit.runner.utility": "2.0.0-beta5-build2785" + } +} diff --git a/src/xunit.runner.kre/xunit.runner.kre.kproj b/src/xunit.runner.kre/xunit.runner.kre.kproj new file mode 100644 index 00000000000..2916d7acb7b --- /dev/null +++ b/src/xunit.runner.kre/xunit.runner.kre.kproj @@ -0,0 +1,21 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 002d321e-170e-4e55-bdd1-77c6353a6eb5 + Library + + + + + + + + 2.0 + + + \ No newline at end of file diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index e1fd82cf556..6081f8ca185 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,10 +1,11 @@ { "version": "1.0.0-*", "dependencies": { - "Xunit.KRunner": "1.0.0-*" + "xunit": "2.0.0-beta5-build2785", + "xunit.runner.kre": "1.0.0-*" }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { }, From fd854dc0ca8dbae405dcbe403c2e19d24224af16 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 10 Dec 2014 10:22:22 -0800 Subject: [PATCH 086/463] Revert change to Sample.Tests --- Testing.sln | 7 + test/Sample.Tests/project.json | 5 +- .../CommandLineTests.cs | 633 ++++++++++++++++++ test/xunit.runner.kre.tests/project.json | 13 + .../xunit.runner.kre.tests.kproj | 20 + 5 files changed, 675 insertions(+), 3 deletions(-) create mode 100644 test/xunit.runner.kre.tests/CommandLineTests.cs create mode 100644 test/xunit.runner.kre.tests/project.json create mode 100644 test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj diff --git a/Testing.sln b/Testing.sln index eef57143d9e..51e0848844c 100644 --- a/Testing.sln +++ b/Testing.sln @@ -25,6 +25,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHos EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "xunit.runner.kre", "src\xunit.runner.kre\xunit.runner.kre.kproj", "{002D321E-170E-4E55-BDD1-77C6353A6EB5}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "xunit.runner.kre.tests", "test\xunit.runner.kre.tests\xunit.runner.kre.tests.kproj", "{838070AB-04F2-4A37-9C86-91669E633F70}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +69,10 @@ Global {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Debug|Any CPU.Build.0 = Debug|Any CPU {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.Build.0 = Release|Any CPU + {838070AB-04F2-4A37-9C86-91669E633F70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {838070AB-04F2-4A37-9C86-91669E633F70}.Debug|Any CPU.Build.0 = Debug|Any CPU + {838070AB-04F2-4A37-9C86-91669E633F70}.Release|Any CPU.ActiveCfg = Release|Any CPU + {838070AB-04F2-4A37-9C86-91669E633F70}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,5 +87,6 @@ Global {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} {002D321E-170E-4E55-BDD1-77C6353A6EB5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {838070AB-04F2-4A37-9C86-91669E633F70} = {09F799F3-E521-466F-B155-B89E2746C8C9} EndGlobalSection EndGlobal diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 6081f8ca185..e1fd82cf556 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,11 +1,10 @@ { "version": "1.0.0-*", "dependencies": { - "xunit": "2.0.0-beta5-build2785", - "xunit.runner.kre": "1.0.0-*" + "Xunit.KRunner": "1.0.0-*" }, "commands": { - "test": "xunit.runner.kre" + "test": "Xunit.KRunner" }, "frameworks": { "aspnet50": { }, diff --git a/test/xunit.runner.kre.tests/CommandLineTests.cs b/test/xunit.runner.kre.tests/CommandLineTests.cs new file mode 100644 index 00000000000..6f6568ec1d9 --- /dev/null +++ b/test/xunit.runner.kre.tests/CommandLineTests.cs @@ -0,0 +1,633 @@ +using System; +using System.IO; +using System.Linq; +using System.Reflection; +using Xunit; +using Xunit.ConsoleClient; +using Xunit.Sdk; + +public class CommandLineTests +{ + public class Filename + { + [Fact] + public static void MultipleAssembliesDoesNotThrow() + { + var arguments = new[] { "assemblyName.dll", "assemblyName2.dll" }; + + var result = TestableCommandLine.Parse(arguments); + + Assert.Collection(result.Project, + a => + { + Assert.Equal(Path.GetFullPath("assemblyName.dll"), a.AssemblyFilename); + Assert.Null(a.ConfigFilename); + Assert.True(a.ShadowCopy); + }, + a => + { + Assert.Equal(Path.GetFullPath("assemblyName2.dll"), a.AssemblyFilename); + Assert.Null(a.ConfigFilename); + Assert.True(a.ShadowCopy); + } + ); + } + } + + public class MaxThreadsOption + { + [Fact] + public static void DefaultValueIsZero() + { + var commandLine = TestableCommandLine.Parse("assemblyName.dll"); + + Assert.Equal(0, commandLine.MaxParallelThreads); + } + + [Fact] + public static void MissingValue() + { + var ex = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-maxthreads")); + + Assert.Equal("missing argument for -maxthreads", ex.Message); + } + + [Fact] + public static void InvalidValue() + { + var ex = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-maxthreads", "abc")); + + Assert.Equal("incorrect argument value for -maxthreads", ex.Message); + } + + [Fact] + public static void SetsMaxParallelThreads() + { + var commandLine = TestableCommandLine.Parse("assemblyName.dll", "-maxthreads", "16"); + + Assert.Equal(16, commandLine.MaxParallelThreads); + } + } + + public class NoShadowOption + { + [Fact] + public static void NoShadowNotSetShadowCopyTrue() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + var assembly = Assert.Single(commandLine.Project.Assemblies); + Assert.True(assembly.ShadowCopy); + } + + [Fact] + public static void NoShadowSetShadowCopyFalse() + { + var arguments = new[] { "assemblyName.dll", "-noshadow" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + var assembly = Assert.Single(commandLine.Project.Assemblies); + Assert.False(assembly.ShadowCopy); + } + } + + public class WaitOption + { + [Fact] + public static void WaitOptionNotPassedWaitFalse() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.False(commandLine.Wait); + } + + [Fact] + public static void WaitOptionWaitIsTrue() + { + var arguments = new[] { "assemblyName.dll", "-wait" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.Wait); + } + + [Fact] + public static void WaitOptionIgnoreCaseWaitIsTrue() + { + var arguments = new[] { "assemblyName.dll", "-wAiT" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.Wait); + } + } + + public class TeamCityArgument + { + [Fact, TeamCityEnvironmentRestore] + public static void TeamCityOptionNotPassedTeamCityFalse() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.False(commandLine.TeamCity); + } + + [Fact, TeamCityEnvironmentRestore(Value = "TeamCity")] + public static void TeamCityOptionNotPassedEnvironmentSetTeamCityTrue() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.TeamCity); + } + + [Fact, TeamCityEnvironmentRestore] + public static void TeamCityOptionTeamCityTrue() + { + var arguments = new[] { "assemblyName.dll", "-teamcity" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.TeamCity); + } + + [Fact, TeamCityEnvironmentRestore] + public static void TeamCityOptionIgnoreCaseTeamCityTrue() + { + var arguments = new[] { "assemblyName.dll", "-tEaMcItY" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.TeamCity); + } + + class TeamCityEnvironmentRestore : BeforeAfterTestAttribute + { + string originalValue; + + public string Value { get; set; } + + public override void Before(MethodInfo methodUnderTest) + { + originalValue = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME"); + Environment.SetEnvironmentVariable("TEAMCITY_PROJECT_NAME", Value); + } + + public override void After(MethodInfo methodUnderTest) + { + Environment.SetEnvironmentVariable("TEAMCITY_PROJECT_NAME", originalValue); + } + } + } + + public class TraitArgument + { + [Fact] + public static void TraitArgumentNotPassed() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(0, commandLine.Project.Filters.IncludedTraits.Count); + } + + [Fact] + public static void SingleValidTraitArgument() + { + var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(1, commandLine.Project.Filters.IncludedTraits.Count); + Assert.Equal(1, commandLine.Project.Filters.IncludedTraits["foo"].Count()); + Assert.Contains("bar", commandLine.Project.Filters.IncludedTraits["foo"]); + } + + [Fact] + public static void MultipleValidTraitArguments_SameName() + { + var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar", "-trait", "foo=baz" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(1, commandLine.Project.Filters.IncludedTraits.Count); + Assert.Equal(2, commandLine.Project.Filters.IncludedTraits["foo"].Count()); + Assert.Contains("bar", commandLine.Project.Filters.IncludedTraits["foo"]); + Assert.Contains("baz", commandLine.Project.Filters.IncludedTraits["foo"]); + } + + [Fact] + public static void MultipleValidTraitArguments_DifferentName() + { + var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar", "-trait", "baz=biff" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(2, commandLine.Project.Filters.IncludedTraits.Count); + Assert.Equal(1, commandLine.Project.Filters.IncludedTraits["foo"].Count()); + Assert.Contains("bar", commandLine.Project.Filters.IncludedTraits["foo"]); + Assert.Equal(1, commandLine.Project.Filters.IncludedTraits["baz"].Count()); + Assert.Contains("biff", commandLine.Project.Filters.IncludedTraits["baz"]); + } + + [Fact] + public static void MissingOptionValue() + { + var arguments = new[] { "assemblyName.dll", "-trait" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("missing argument for -trait", ex.Message); + } + + [Fact] + public static void OptionValueMissingEquals() + { + var arguments = new[] { "assemblyName.dll", "-trait", "foobar" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); + } + + [Fact] + public static void OptionValueMissingName() + { + var arguments = new[] { "assemblyName.dll", "-trait", "=bar" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); + } + + [Fact] + public static void OptionNameMissingValue() + { + var arguments = new[] { "assemblyName.dll", "-trait", "foo=" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); + } + + [Fact] + public static void TooManyEqualsSigns() + { + var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar=baz" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); + } + } + + public class MinusTraitArgument + { + [Fact] + public static void TraitArgumentNotPassed() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(0, commandLine.Project.Filters.ExcludedTraits.Count); + } + + [Fact] + public static void SingleValidTraitArgument() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits.Count); + Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits["foo"].Count()); + Assert.Contains("bar", commandLine.Project.Filters.ExcludedTraits["foo"]); + } + + [Fact] + public static void MultipleValidTraitArguments_SameName() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar", "-notrait", "foo=baz" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits.Count); + Assert.Equal(2, commandLine.Project.Filters.ExcludedTraits["foo"].Count()); + Assert.Contains("bar", commandLine.Project.Filters.ExcludedTraits["foo"]); + Assert.Contains("baz", commandLine.Project.Filters.ExcludedTraits["foo"]); + } + + [Fact] + public static void MultipleValidTraitArguments_DifferentName() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar", "-notrait", "baz=biff" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(2, commandLine.Project.Filters.ExcludedTraits.Count); + Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits["foo"].Count()); + Assert.Contains("bar", commandLine.Project.Filters.ExcludedTraits["foo"]); + Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits["baz"].Count()); + Assert.Contains("biff", commandLine.Project.Filters.ExcludedTraits["baz"]); + } + + [Fact] + public static void MissingOptionValue() + { + var arguments = new[] { "assemblyName.dll", "-notrait" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("missing argument for -notrait", ex.Message); + } + + [Fact] + public static void OptionValueMissingEquals() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "foobar" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); + } + + [Fact] + public static void OptionValueMissingName() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "=bar" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); + } + + [Fact] + public static void OptionNameMissingValue() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "foo=" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); + } + + [Fact] + public static void TooManyEqualsSigns() + { + var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar=baz" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); + } + } + + public class MethodArgument + { + [Fact] + public static void MethodArgumentNotPassed() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(0, commandLine.Project.Filters.IncludedMethods.Count); + } + + [Fact] + public static void SingleValidMethodArgument() + { + const string name = "Namespace.Class.Method1"; + + var arguments = new[] { "assemblyName.dll", "-method", name }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(1, commandLine.Project.Filters.IncludedMethods.Count); + Assert.True(commandLine.Project.Filters.IncludedMethods.Contains(name)); + } + + [Fact] + public static void MultipleValidMethodArguments() + { + const string name1 = "Namespace.Class.Method1"; + const string name2 = "Namespace.Class.Method2"; + + var arguments = new[] { "assemblyName.dll", "-method", name1, "-method", name2 }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(2, commandLine.Project.Filters.IncludedMethods.Count); + Assert.True(commandLine.Project.Filters.IncludedMethods.Contains(name1)); + Assert.True(commandLine.Project.Filters.IncludedMethods.Contains(name2)); + } + + [Fact] + public static void MissingOptionValue() + { + var arguments = new[] { "assemblyName.dll", "-method" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("missing argument for -method", ex.Message); + } + } + + public class ClassArgument + { + [Fact] + public static void ClassArgumentNotPassed() + { + var arguments = new[] { "assemblyName.dll" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(0, commandLine.Project.Filters.IncludedMethods.Count); + } + + [Fact] + public static void SingleValidClassArgument() + { + const string name = "Namespace.Class"; + + var arguments = new[] { "assemblyName.dll", "-class", name }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(1, commandLine.Project.Filters.IncludedClasses.Count); + Assert.True(commandLine.Project.Filters.IncludedClasses.Contains(name)); + } + + [Fact] + public static void MultipleValidClassArguments() + { + const string name1 = "Namespace.Class1"; + const string name2 = "Namespace.Class2"; + + var arguments = new[] { "assemblyName.dll", "-class", name1, "-class", name2 }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(2, commandLine.Project.Filters.IncludedClasses.Count); + Assert.True(commandLine.Project.Filters.IncludedClasses.Contains(name1)); + Assert.True(commandLine.Project.Filters.IncludedClasses.Contains(name2)); + } + + [Fact] + public static void MissingOptionValue() + { + var arguments = new[] { "assemblyName.dll", "-class" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("missing argument for -class", ex.Message); + } + } + + public class ParallelizationOptions + { + [Fact] + public static void ParallelIsCollectionsOnlyByDefault() + { + var project = TestableCommandLine.Parse("assemblyName.dll"); + + Assert.True(project.ParallelizeTestCollections); + } + + [Fact] + public static void FailsWithoutOptionOrWithIncorrectOptions() + { + var aex1 = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-parallel")); + Assert.Equal("missing argument for -parallel", aex1.Message); + + var aex2 = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-parallel", "nonsense")); + Assert.Equal("incorrect argument value for -parallel", aex2.Message); + } + + [Theory] + [InlineData("none", false)] + [InlineData("collections", true)] + [InlineData("all", true)] + public static void ParallelCanBeTurnedOn(string parallelOption, bool expectedCollectionsParallelization) + { + var project = TestableCommandLine.Parse("assemblyName.dll", "-parallel", parallelOption); + + Assert.Equal(expectedCollectionsParallelization, project.ParallelizeTestCollections); + } + } + + public class Transform + { + [Fact] + public static void OutputMissingFilename() + { + var arguments = new[] { "assemblyName.dll", "-xml" }; + + var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); + + Assert.IsType(ex); + Assert.Equal("missing filename for -xml", ex.Message); + } + + [Fact] + public static void Output() + { + var arguments = new[] { "assemblyName.dll", "-xml", "foo.xml" }; + + var commandLine = TestableCommandLine.Parse(arguments); + + var output = Assert.Single(commandLine.Project.Output); + Assert.Equal("xml", output.Key); + Assert.Equal("foo.xml", output.Value); + } + } + + public class DesignTimeSwitch + { + [Theory] + [InlineData("-designtime")] + [InlineData("--designtime")] + public static void DesignTime(string arg) + { + var arguments = new[] { "assemblyName.dll", arg }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.DesignTime); + } + } + + public class ListSwitch + { + [Theory] + [InlineData("-list")] + [InlineData("--list")] + public static void List(string arg) + { + var arguments = new[] { "assemblyName.dll", arg }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.True(commandLine.List); + } + } + + public class TestArgument + { + [Fact] + public static void TestUniqueNames() + { + var arguments = new[] + { + "assemblyName.dll", + "-test", + "foo", + "--test", + "bar", + "--test", + "baz", + }; + + var commandLine = TestableCommandLine.Parse(arguments); + + Assert.Equal(3, commandLine.DesignTimeTestUniqueNames.Count); + Assert.Contains("foo", commandLine.DesignTimeTestUniqueNames); + Assert.Contains("bar", commandLine.DesignTimeTestUniqueNames); + Assert.Contains("baz", commandLine.DesignTimeTestUniqueNames); + } + } + + class TestableCommandLine : CommandLine + { + private TestableCommandLine(params string[] arguments) + : base(arguments) + { } + + public new static TestableCommandLine Parse(params string[] arguments) + { + return new TestableCommandLine(arguments); + } + } +} diff --git a/test/xunit.runner.kre.tests/project.json b/test/xunit.runner.kre.tests/project.json new file mode 100644 index 00000000000..ab1a29f785d --- /dev/null +++ b/test/xunit.runner.kre.tests/project.json @@ -0,0 +1,13 @@ +{ + "frameworks": { + "aspnet50": { }, + "aspnetcore50": { } + }, + "dependencies": { + "xunit": "2.0.0-beta5-build2785", + "xunit.runner.kre": "" + }, + "commands": { + "test": "xunit.runner.kre" + } +} diff --git a/test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj b/test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj new file mode 100644 index 00000000000..d3615c1c6ae --- /dev/null +++ b/test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj @@ -0,0 +1,20 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 838070ab-04f2-4a37-9c86-91669e633f70 + Console + + + + + + + 2.0 + + + \ No newline at end of file From e2d8f58927d51436f4725eb9bcd02d3b603aacf5 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 10 Dec 2014 12:06:59 -0800 Subject: [PATCH 087/463] Revert "Revert change to Sample.Tests" This reverts commit fd854dc0ca8dbae405dcbe403c2e19d24224af16. --- Testing.sln | 7 - test/Sample.Tests/project.json | 5 +- .../CommandLineTests.cs | 633 ------------------ test/xunit.runner.kre.tests/project.json | 13 - .../xunit.runner.kre.tests.kproj | 20 - 5 files changed, 3 insertions(+), 675 deletions(-) delete mode 100644 test/xunit.runner.kre.tests/CommandLineTests.cs delete mode 100644 test/xunit.runner.kre.tests/project.json delete mode 100644 test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj diff --git a/Testing.sln b/Testing.sln index 51e0848844c..eef57143d9e 100644 --- a/Testing.sln +++ b/Testing.sln @@ -25,8 +25,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHos EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "xunit.runner.kre", "src\xunit.runner.kre\xunit.runner.kre.kproj", "{002D321E-170E-4E55-BDD1-77C6353A6EB5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "xunit.runner.kre.tests", "test\xunit.runner.kre.tests\xunit.runner.kre.tests.kproj", "{838070AB-04F2-4A37-9C86-91669E633F70}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -69,10 +67,6 @@ Global {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Debug|Any CPU.Build.0 = Debug|Any CPU {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.Build.0 = Release|Any CPU - {838070AB-04F2-4A37-9C86-91669E633F70}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {838070AB-04F2-4A37-9C86-91669E633F70}.Debug|Any CPU.Build.0 = Debug|Any CPU - {838070AB-04F2-4A37-9C86-91669E633F70}.Release|Any CPU.ActiveCfg = Release|Any CPU - {838070AB-04F2-4A37-9C86-91669E633F70}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -87,6 +81,5 @@ Global {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} {002D321E-170E-4E55-BDD1-77C6353A6EB5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} - {838070AB-04F2-4A37-9C86-91669E633F70} = {09F799F3-E521-466F-B155-B89E2746C8C9} EndGlobalSection EndGlobal diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index e1fd82cf556..6081f8ca185 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,10 +1,11 @@ { "version": "1.0.0-*", "dependencies": { - "Xunit.KRunner": "1.0.0-*" + "xunit": "2.0.0-beta5-build2785", + "xunit.runner.kre": "1.0.0-*" }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { }, diff --git a/test/xunit.runner.kre.tests/CommandLineTests.cs b/test/xunit.runner.kre.tests/CommandLineTests.cs deleted file mode 100644 index 6f6568ec1d9..00000000000 --- a/test/xunit.runner.kre.tests/CommandLineTests.cs +++ /dev/null @@ -1,633 +0,0 @@ -using System; -using System.IO; -using System.Linq; -using System.Reflection; -using Xunit; -using Xunit.ConsoleClient; -using Xunit.Sdk; - -public class CommandLineTests -{ - public class Filename - { - [Fact] - public static void MultipleAssembliesDoesNotThrow() - { - var arguments = new[] { "assemblyName.dll", "assemblyName2.dll" }; - - var result = TestableCommandLine.Parse(arguments); - - Assert.Collection(result.Project, - a => - { - Assert.Equal(Path.GetFullPath("assemblyName.dll"), a.AssemblyFilename); - Assert.Null(a.ConfigFilename); - Assert.True(a.ShadowCopy); - }, - a => - { - Assert.Equal(Path.GetFullPath("assemblyName2.dll"), a.AssemblyFilename); - Assert.Null(a.ConfigFilename); - Assert.True(a.ShadowCopy); - } - ); - } - } - - public class MaxThreadsOption - { - [Fact] - public static void DefaultValueIsZero() - { - var commandLine = TestableCommandLine.Parse("assemblyName.dll"); - - Assert.Equal(0, commandLine.MaxParallelThreads); - } - - [Fact] - public static void MissingValue() - { - var ex = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-maxthreads")); - - Assert.Equal("missing argument for -maxthreads", ex.Message); - } - - [Fact] - public static void InvalidValue() - { - var ex = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-maxthreads", "abc")); - - Assert.Equal("incorrect argument value for -maxthreads", ex.Message); - } - - [Fact] - public static void SetsMaxParallelThreads() - { - var commandLine = TestableCommandLine.Parse("assemblyName.dll", "-maxthreads", "16"); - - Assert.Equal(16, commandLine.MaxParallelThreads); - } - } - - public class NoShadowOption - { - [Fact] - public static void NoShadowNotSetShadowCopyTrue() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - var assembly = Assert.Single(commandLine.Project.Assemblies); - Assert.True(assembly.ShadowCopy); - } - - [Fact] - public static void NoShadowSetShadowCopyFalse() - { - var arguments = new[] { "assemblyName.dll", "-noshadow" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - var assembly = Assert.Single(commandLine.Project.Assemblies); - Assert.False(assembly.ShadowCopy); - } - } - - public class WaitOption - { - [Fact] - public static void WaitOptionNotPassedWaitFalse() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.False(commandLine.Wait); - } - - [Fact] - public static void WaitOptionWaitIsTrue() - { - var arguments = new[] { "assemblyName.dll", "-wait" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.Wait); - } - - [Fact] - public static void WaitOptionIgnoreCaseWaitIsTrue() - { - var arguments = new[] { "assemblyName.dll", "-wAiT" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.Wait); - } - } - - public class TeamCityArgument - { - [Fact, TeamCityEnvironmentRestore] - public static void TeamCityOptionNotPassedTeamCityFalse() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.False(commandLine.TeamCity); - } - - [Fact, TeamCityEnvironmentRestore(Value = "TeamCity")] - public static void TeamCityOptionNotPassedEnvironmentSetTeamCityTrue() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.TeamCity); - } - - [Fact, TeamCityEnvironmentRestore] - public static void TeamCityOptionTeamCityTrue() - { - var arguments = new[] { "assemblyName.dll", "-teamcity" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.TeamCity); - } - - [Fact, TeamCityEnvironmentRestore] - public static void TeamCityOptionIgnoreCaseTeamCityTrue() - { - var arguments = new[] { "assemblyName.dll", "-tEaMcItY" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.TeamCity); - } - - class TeamCityEnvironmentRestore : BeforeAfterTestAttribute - { - string originalValue; - - public string Value { get; set; } - - public override void Before(MethodInfo methodUnderTest) - { - originalValue = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME"); - Environment.SetEnvironmentVariable("TEAMCITY_PROJECT_NAME", Value); - } - - public override void After(MethodInfo methodUnderTest) - { - Environment.SetEnvironmentVariable("TEAMCITY_PROJECT_NAME", originalValue); - } - } - } - - public class TraitArgument - { - [Fact] - public static void TraitArgumentNotPassed() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(0, commandLine.Project.Filters.IncludedTraits.Count); - } - - [Fact] - public static void SingleValidTraitArgument() - { - var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(1, commandLine.Project.Filters.IncludedTraits.Count); - Assert.Equal(1, commandLine.Project.Filters.IncludedTraits["foo"].Count()); - Assert.Contains("bar", commandLine.Project.Filters.IncludedTraits["foo"]); - } - - [Fact] - public static void MultipleValidTraitArguments_SameName() - { - var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar", "-trait", "foo=baz" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(1, commandLine.Project.Filters.IncludedTraits.Count); - Assert.Equal(2, commandLine.Project.Filters.IncludedTraits["foo"].Count()); - Assert.Contains("bar", commandLine.Project.Filters.IncludedTraits["foo"]); - Assert.Contains("baz", commandLine.Project.Filters.IncludedTraits["foo"]); - } - - [Fact] - public static void MultipleValidTraitArguments_DifferentName() - { - var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar", "-trait", "baz=biff" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(2, commandLine.Project.Filters.IncludedTraits.Count); - Assert.Equal(1, commandLine.Project.Filters.IncludedTraits["foo"].Count()); - Assert.Contains("bar", commandLine.Project.Filters.IncludedTraits["foo"]); - Assert.Equal(1, commandLine.Project.Filters.IncludedTraits["baz"].Count()); - Assert.Contains("biff", commandLine.Project.Filters.IncludedTraits["baz"]); - } - - [Fact] - public static void MissingOptionValue() - { - var arguments = new[] { "assemblyName.dll", "-trait" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("missing argument for -trait", ex.Message); - } - - [Fact] - public static void OptionValueMissingEquals() - { - var arguments = new[] { "assemblyName.dll", "-trait", "foobar" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); - } - - [Fact] - public static void OptionValueMissingName() - { - var arguments = new[] { "assemblyName.dll", "-trait", "=bar" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); - } - - [Fact] - public static void OptionNameMissingValue() - { - var arguments = new[] { "assemblyName.dll", "-trait", "foo=" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); - } - - [Fact] - public static void TooManyEqualsSigns() - { - var arguments = new[] { "assemblyName.dll", "-trait", "foo=bar=baz" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -trait (should be \"name=value\")", ex.Message); - } - } - - public class MinusTraitArgument - { - [Fact] - public static void TraitArgumentNotPassed() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(0, commandLine.Project.Filters.ExcludedTraits.Count); - } - - [Fact] - public static void SingleValidTraitArgument() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits.Count); - Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits["foo"].Count()); - Assert.Contains("bar", commandLine.Project.Filters.ExcludedTraits["foo"]); - } - - [Fact] - public static void MultipleValidTraitArguments_SameName() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar", "-notrait", "foo=baz" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits.Count); - Assert.Equal(2, commandLine.Project.Filters.ExcludedTraits["foo"].Count()); - Assert.Contains("bar", commandLine.Project.Filters.ExcludedTraits["foo"]); - Assert.Contains("baz", commandLine.Project.Filters.ExcludedTraits["foo"]); - } - - [Fact] - public static void MultipleValidTraitArguments_DifferentName() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar", "-notrait", "baz=biff" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(2, commandLine.Project.Filters.ExcludedTraits.Count); - Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits["foo"].Count()); - Assert.Contains("bar", commandLine.Project.Filters.ExcludedTraits["foo"]); - Assert.Equal(1, commandLine.Project.Filters.ExcludedTraits["baz"].Count()); - Assert.Contains("biff", commandLine.Project.Filters.ExcludedTraits["baz"]); - } - - [Fact] - public static void MissingOptionValue() - { - var arguments = new[] { "assemblyName.dll", "-notrait" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("missing argument for -notrait", ex.Message); - } - - [Fact] - public static void OptionValueMissingEquals() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "foobar" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); - } - - [Fact] - public static void OptionValueMissingName() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "=bar" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); - } - - [Fact] - public static void OptionNameMissingValue() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "foo=" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); - } - - [Fact] - public static void TooManyEqualsSigns() - { - var arguments = new[] { "assemblyName.dll", "-notrait", "foo=bar=baz" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("incorrect argument format for -notrait (should be \"name=value\")", ex.Message); - } - } - - public class MethodArgument - { - [Fact] - public static void MethodArgumentNotPassed() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(0, commandLine.Project.Filters.IncludedMethods.Count); - } - - [Fact] - public static void SingleValidMethodArgument() - { - const string name = "Namespace.Class.Method1"; - - var arguments = new[] { "assemblyName.dll", "-method", name }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(1, commandLine.Project.Filters.IncludedMethods.Count); - Assert.True(commandLine.Project.Filters.IncludedMethods.Contains(name)); - } - - [Fact] - public static void MultipleValidMethodArguments() - { - const string name1 = "Namespace.Class.Method1"; - const string name2 = "Namespace.Class.Method2"; - - var arguments = new[] { "assemblyName.dll", "-method", name1, "-method", name2 }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(2, commandLine.Project.Filters.IncludedMethods.Count); - Assert.True(commandLine.Project.Filters.IncludedMethods.Contains(name1)); - Assert.True(commandLine.Project.Filters.IncludedMethods.Contains(name2)); - } - - [Fact] - public static void MissingOptionValue() - { - var arguments = new[] { "assemblyName.dll", "-method" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("missing argument for -method", ex.Message); - } - } - - public class ClassArgument - { - [Fact] - public static void ClassArgumentNotPassed() - { - var arguments = new[] { "assemblyName.dll" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(0, commandLine.Project.Filters.IncludedMethods.Count); - } - - [Fact] - public static void SingleValidClassArgument() - { - const string name = "Namespace.Class"; - - var arguments = new[] { "assemblyName.dll", "-class", name }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(1, commandLine.Project.Filters.IncludedClasses.Count); - Assert.True(commandLine.Project.Filters.IncludedClasses.Contains(name)); - } - - [Fact] - public static void MultipleValidClassArguments() - { - const string name1 = "Namespace.Class1"; - const string name2 = "Namespace.Class2"; - - var arguments = new[] { "assemblyName.dll", "-class", name1, "-class", name2 }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(2, commandLine.Project.Filters.IncludedClasses.Count); - Assert.True(commandLine.Project.Filters.IncludedClasses.Contains(name1)); - Assert.True(commandLine.Project.Filters.IncludedClasses.Contains(name2)); - } - - [Fact] - public static void MissingOptionValue() - { - var arguments = new[] { "assemblyName.dll", "-class" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("missing argument for -class", ex.Message); - } - } - - public class ParallelizationOptions - { - [Fact] - public static void ParallelIsCollectionsOnlyByDefault() - { - var project = TestableCommandLine.Parse("assemblyName.dll"); - - Assert.True(project.ParallelizeTestCollections); - } - - [Fact] - public static void FailsWithoutOptionOrWithIncorrectOptions() - { - var aex1 = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-parallel")); - Assert.Equal("missing argument for -parallel", aex1.Message); - - var aex2 = Assert.Throws(() => TestableCommandLine.Parse("assemblyName.dll", "-parallel", "nonsense")); - Assert.Equal("incorrect argument value for -parallel", aex2.Message); - } - - [Theory] - [InlineData("none", false)] - [InlineData("collections", true)] - [InlineData("all", true)] - public static void ParallelCanBeTurnedOn(string parallelOption, bool expectedCollectionsParallelization) - { - var project = TestableCommandLine.Parse("assemblyName.dll", "-parallel", parallelOption); - - Assert.Equal(expectedCollectionsParallelization, project.ParallelizeTestCollections); - } - } - - public class Transform - { - [Fact] - public static void OutputMissingFilename() - { - var arguments = new[] { "assemblyName.dll", "-xml" }; - - var ex = Record.Exception(() => TestableCommandLine.Parse(arguments)); - - Assert.IsType(ex); - Assert.Equal("missing filename for -xml", ex.Message); - } - - [Fact] - public static void Output() - { - var arguments = new[] { "assemblyName.dll", "-xml", "foo.xml" }; - - var commandLine = TestableCommandLine.Parse(arguments); - - var output = Assert.Single(commandLine.Project.Output); - Assert.Equal("xml", output.Key); - Assert.Equal("foo.xml", output.Value); - } - } - - public class DesignTimeSwitch - { - [Theory] - [InlineData("-designtime")] - [InlineData("--designtime")] - public static void DesignTime(string arg) - { - var arguments = new[] { "assemblyName.dll", arg }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.DesignTime); - } - } - - public class ListSwitch - { - [Theory] - [InlineData("-list")] - [InlineData("--list")] - public static void List(string arg) - { - var arguments = new[] { "assemblyName.dll", arg }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.True(commandLine.List); - } - } - - public class TestArgument - { - [Fact] - public static void TestUniqueNames() - { - var arguments = new[] - { - "assemblyName.dll", - "-test", - "foo", - "--test", - "bar", - "--test", - "baz", - }; - - var commandLine = TestableCommandLine.Parse(arguments); - - Assert.Equal(3, commandLine.DesignTimeTestUniqueNames.Count); - Assert.Contains("foo", commandLine.DesignTimeTestUniqueNames); - Assert.Contains("bar", commandLine.DesignTimeTestUniqueNames); - Assert.Contains("baz", commandLine.DesignTimeTestUniqueNames); - } - } - - class TestableCommandLine : CommandLine - { - private TestableCommandLine(params string[] arguments) - : base(arguments) - { } - - public new static TestableCommandLine Parse(params string[] arguments) - { - return new TestableCommandLine(arguments); - } - } -} diff --git a/test/xunit.runner.kre.tests/project.json b/test/xunit.runner.kre.tests/project.json deleted file mode 100644 index ab1a29f785d..00000000000 --- a/test/xunit.runner.kre.tests/project.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } - }, - "dependencies": { - "xunit": "2.0.0-beta5-build2785", - "xunit.runner.kre": "" - }, - "commands": { - "test": "xunit.runner.kre" - } -} diff --git a/test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj b/test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj deleted file mode 100644 index d3615c1c6ae..00000000000 --- a/test/xunit.runner.kre.tests/xunit.runner.kre.tests.kproj +++ /dev/null @@ -1,20 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 838070ab-04f2-4a37-9c86-91669e633f70 - Console - - - - - - - 2.0 - - - \ No newline at end of file From 49c978bf46072ba781ab0d0b5c09158059e0ca1f Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Wed, 10 Dec 2014 12:07:03 -0800 Subject: [PATCH 088/463] Revert "Add xunit.runner.kre" This reverts commit e757c4c93fc99c2514392c249f1f35f9e98c38e1. --- Testing.sln | 9 +- src/xunit.runner.kre/CommandLine.cs | 225 ----------- .../Common/AssemblyExtensions.cs | 26 -- .../Common/DictionaryExtensions.cs | 40 -- src/xunit.runner.kre/Common/Guard.cs | 49 --- .../Common/TestDiscoveryVisitor.cs | 26 -- .../Common/XmlTestExecutionVisitor.cs | 270 -------------- .../DesignTime/DesignTimeExecutionVisitor.cs | 102 ----- .../DesignTime/DesignTimeTestConverter.cs | 127 ------- src/xunit.runner.kre/ParallelismOption.cs | 9 - src/xunit.runner.kre/Program.cs | 350 ------------------ .../Properties/AssemblyInfo.cs | 3 - .../Properties/GlobalAssemblyInfo.cs | 13 - .../RunnerCallbacks/RunnerCallback.cs | 84 ----- .../RunnerCallbacks/StandardRunnerCallback.cs | 115 ------ .../RunnerCallbacks/TeamCityRunnerCallback.cs | 106 ------ .../Utility/StackFrameTransformer.cs | 54 --- src/xunit.runner.kre/Utility/Transform.cs | 12 - .../Utility/TransformFactory.cs | 38 -- .../Visitors/StandardOutputVisitor.cs | 174 --------- .../Visitors/TeamCityVisitor.cs | 168 --------- src/xunit.runner.kre/project.json | 47 --- src/xunit.runner.kre/xunit.runner.kre.kproj | 21 -- test/Sample.Tests/project.json | 5 +- 24 files changed, 3 insertions(+), 2070 deletions(-) delete mode 100644 src/xunit.runner.kre/CommandLine.cs delete mode 100644 src/xunit.runner.kre/Common/AssemblyExtensions.cs delete mode 100644 src/xunit.runner.kre/Common/DictionaryExtensions.cs delete mode 100644 src/xunit.runner.kre/Common/Guard.cs delete mode 100644 src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs delete mode 100644 src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs delete mode 100644 src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs delete mode 100644 src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs delete mode 100644 src/xunit.runner.kre/ParallelismOption.cs delete mode 100644 src/xunit.runner.kre/Program.cs delete mode 100644 src/xunit.runner.kre/Properties/AssemblyInfo.cs delete mode 100644 src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs delete mode 100644 src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs delete mode 100644 src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs delete mode 100644 src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs delete mode 100644 src/xunit.runner.kre/Utility/StackFrameTransformer.cs delete mode 100644 src/xunit.runner.kre/Utility/Transform.cs delete mode 100644 src/xunit.runner.kre/Utility/TransformFactory.cs delete mode 100644 src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs delete mode 100644 src/xunit.runner.kre/Visitors/TeamCityVisitor.cs delete mode 100644 src/xunit.runner.kre/project.json delete mode 100644 src/xunit.runner.kre/xunit.runner.kre.kproj diff --git a/Testing.sln b/Testing.sln index eef57143d9e..7a62f70b6e6 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22310.1 +VisualStudioVersion = 14.0.22201.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -23,8 +23,6 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAda EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.kproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "xunit.runner.kre", "src\xunit.runner.kre\xunit.runner.kre.kproj", "{002D321E-170E-4E55-BDD1-77C6353A6EB5}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -63,10 +61,6 @@ Global {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.Build.0 = Release|Any CPU - {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {002D321E-170E-4E55-BDD1-77C6353A6EB5}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -80,6 +74,5 @@ Global {F003F228-2AE2-4E9D-877B-93EB773B5061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} - {002D321E-170E-4E55-BDD1-77C6353A6EB5} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} EndGlobalSection EndGlobal diff --git a/src/xunit.runner.kre/CommandLine.cs b/src/xunit.runner.kre/CommandLine.cs deleted file mode 100644 index ffd5623046d..00000000000 --- a/src/xunit.runner.kre/CommandLine.cs +++ /dev/null @@ -1,225 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; - -namespace Xunit.ConsoleClient -{ - public class CommandLine - { - readonly Stack arguments = new Stack(); - - protected CommandLine(string[] args) - { - for (var i = args.Length - 1; i >= 0; i--) - arguments.Push(args[i]); - - TeamCity = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; - ParallelizeTestCollections = true; - DesignTimeTestUniqueNames = new List(); - Project = Parse(); - } - - public bool DesignTime { get; set; } - - // Used with --designtime - to specify specific tests by uniqueId. - public List DesignTimeTestUniqueNames { get; private set; } - - public bool List { get; set; } - - public int MaxParallelThreads { get; set; } - - public XunitProject Project { get; protected set; } - - public bool ParallelizeTestCollections { get; set; } - - public bool TeamCity { get; protected set; } - - public bool Wait { get; protected set; } - - static XunitProject GetProjectFile(List> assemblies) - { - var result = new XunitProject(); - - foreach (var assembly in assemblies) - result.Add(new XunitProjectAssembly - { - AssemblyFilename = Path.GetFullPath(assembly.Item1), - ConfigFilename = assembly.Item2 != null ? Path.GetFullPath(assembly.Item2) : null, - ShadowCopy = true - }); - - return result; - } - - static void GuardNoOptionValue(KeyValuePair option) - { - if (option.Value != null) - throw new ArgumentException(String.Format("error: unknown command line option: {0}", option.Value)); - } - - public static CommandLine Parse(params string[] args) - { - return new CommandLine(args); - } - - protected XunitProject Parse() - { - var assemblies = new List>(); - - while (arguments.Count > 0) - { - if (arguments.Peek().StartsWith("-")) - break; - - var assemblyFile = arguments.Pop(); - - string configFile = null; - - assemblies.Add(Tuple.Create(assemblyFile, configFile)); - } - - if (assemblies.Count == 0) - throw new ArgumentException("must specify at least one assembly"); - - var project = GetProjectFile(assemblies); - - while (arguments.Count > 0) - { - var option = PopOption(arguments); - var optionName = option.Key.ToLowerInvariant(); - - if (!optionName.StartsWith("-")) - throw new ArgumentException(String.Format("unknown command line option: {0}", option.Key)); - - if (optionName == "-wait") - { - GuardNoOptionValue(option); - Wait = true; - } - else if (optionName == "-maxthreads") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -maxthreads"); - - int threadValue; - if (!Int32.TryParse(option.Value, out threadValue) || threadValue < 0) - throw new ArgumentException("incorrect argument value for -maxthreads"); - - MaxParallelThreads = threadValue; - } - else if (optionName == "-parallel") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -parallel"); - - ParallelismOption parallelismOption; - if (!Enum.TryParse(option.Value, out parallelismOption)) - throw new ArgumentException("incorrect argument value for -parallel"); - - switch (parallelismOption) - { - case ParallelismOption.all: - case ParallelismOption.collections: - ParallelizeTestCollections = true; - break; - - case ParallelismOption.none: - default: - ParallelizeTestCollections = false; - break; - } - } - else if (optionName == "-teamcity") - { - GuardNoOptionValue(option); - TeamCity = true; - } - else if (optionName == "-noshadow") - { - GuardNoOptionValue(option); - foreach (var assembly in project.Assemblies) - assembly.ShadowCopy = false; - } - else if (optionName == "-trait") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -trait"); - - var pieces = option.Value.Split('='); - if (pieces.Length != 2 || String.IsNullOrEmpty(pieces[0]) || String.IsNullOrEmpty(pieces[1])) - throw new ArgumentException("incorrect argument format for -trait (should be \"name=value\")"); - - var name = pieces[0]; - var value = pieces[1]; - project.Filters.IncludedTraits.Add(name, value); - } - else if (optionName == "-notrait") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -notrait"); - - var pieces = option.Value.Split('='); - if (pieces.Length != 2 || String.IsNullOrEmpty(pieces[0]) || String.IsNullOrEmpty(pieces[1])) - throw new ArgumentException("incorrect argument format for -notrait (should be \"name=value\")"); - - var name = pieces[0]; - var value = pieces[1]; - project.Filters.ExcludedTraits.Add(name, value); - } - else if (optionName == "-class") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -class"); - - project.Filters.IncludedClasses.Add(option.Value); - } - else if (optionName == "-method") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -method"); - - project.Filters.IncludedMethods.Add(option.Value); - } - else if (optionName == "-test" || optionName == "--test") - { - if (option.Value == null) - { - throw new ArgumentException("missing argument for --test"); - } - - DesignTimeTestUniqueNames.Add(option.Value); - } - else if (optionName == "-list" || optionName == "--list") - { - GuardNoOptionValue(option); - List = true; - } - else if (optionName == "-designtime" || optionName == "--designtime") - { - GuardNoOptionValue(option); - DesignTime = true; - } - else - { - if (option.Value == null) - throw new ArgumentException(String.Format("missing filename for {0}", option.Key)); - - project.Output.Add(optionName.Substring(1), option.Value); - } - } - - return project; - } - - static KeyValuePair PopOption(Stack arguments) - { - var option = arguments.Pop(); - string value = null; - - if (arguments.Count > 0 && !arguments.Peek().StartsWith("-")) - value = arguments.Pop(); - - return new KeyValuePair(option, value); - } - } -} diff --git a/src/xunit.runner.kre/Common/AssemblyExtensions.cs b/src/xunit.runner.kre/Common/AssemblyExtensions.cs deleted file mode 100644 index 0fee337ae38..00000000000 --- a/src/xunit.runner.kre/Common/AssemblyExtensions.cs +++ /dev/null @@ -1,26 +0,0 @@ -#if !ASPNETCORE50 - -using System; -using System.IO; -using System.Reflection; - -internal static class AssemblyExtensions -{ - public static string GetLocalCodeBase(this Assembly assembly) - { - string codeBase = assembly.CodeBase; - if (codeBase == null) - return null; - - if (!codeBase.StartsWith("file:///")) - throw new ArgumentException(String.Format("Code base {0} in wrong format; must start with file:///", codeBase), "assembly"); - - codeBase = codeBase.Substring(8); - if (Path.DirectorySeparatorChar == '/') - return "/" + codeBase; - - return codeBase.Replace('/', Path.DirectorySeparatorChar); - } -} - -#endif diff --git a/src/xunit.runner.kre/Common/DictionaryExtensions.cs b/src/xunit.runner.kre/Common/DictionaryExtensions.cs deleted file mode 100644 index 7e65323a8ca..00000000000 --- a/src/xunit.runner.kre/Common/DictionaryExtensions.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; - -internal static class DictionaryExtensions -{ - public static void Add(this IDictionary> dictionary, TKey key, TValue value) - { - dictionary.GetOrAdd(key).Add(value); - } - - public static bool Contains(this IDictionary> dictionary, TKey key, TValue value, IEqualityComparer valueComparer) - { - List values; - - if (!dictionary.TryGetValue(key, out values)) - return false; - - return values.Contains(value, valueComparer); - } - - public static TValue GetOrAdd(this IDictionary dictionary, TKey key) - where TValue : new() - { - return dictionary.GetOrAdd(key, () => new TValue()); - } - - public static TValue GetOrAdd(this IDictionary dictionary, TKey key, Func newValue) - { - TValue result; - - if (!dictionary.TryGetValue(key, out result)) - { - result = newValue(); - dictionary[key] = result; - } - - return result; - } -} diff --git a/src/xunit.runner.kre/Common/Guard.cs b/src/xunit.runner.kre/Common/Guard.cs deleted file mode 100644 index 5e9e5c040f9..00000000000 --- a/src/xunit.runner.kre/Common/Guard.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections; -using System.Diagnostics.CodeAnalysis; -using System.IO; - -/// -/// Guard class, used for guard clauses and argument validation -/// -internal static class Guard -{ - /// - public static void ArgumentNotNull(string argName, object argValue) - { - if (argValue == null) - throw new ArgumentNullException(argName); - } - - /// - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This method may not be called by all users of Guard.")] - public static void ArgumentNotNullOrEmpty(string argName, IEnumerable argValue) - { - ArgumentNotNull(argName, argValue); - - if (!argValue.GetEnumerator().MoveNext()) - throw new ArgumentException("Argument was empty", argName); - } - - /// - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This method may not be called by all users of Guard.")] - public static void ArgumentValid(string argName, string message, bool test) - { - if (!test) - throw new ArgumentException(message, argName); - } - -#if !XUNIT_CORE_DLL - /// - [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "This method may not be called by all users of Guard.")] - public static void FileExists(string argName, string fileName) - { -#if !ANDROID && !ASPNET50 && !ASPNETCORE50 - Guard.ArgumentNotNullOrEmpty(argName, fileName); - Guard.ArgumentValid("assemblyFileName", - String.Format("File not found: {0}", fileName), - File.Exists(fileName)); -#endif - } -#endif -} \ No newline at end of file diff --git a/src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs b/src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs deleted file mode 100644 index 51408e88873..00000000000 --- a/src/xunit.runner.kre/Common/TestDiscoveryVisitor.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System.Collections.Generic; -using Xunit.Abstractions; - -#if XUNIT_CORE_DLL -namespace Xunit.Sdk -#else -namespace Xunit -#endif -{ - internal class TestDiscoveryVisitor : TestMessageVisitor - { - public TestDiscoveryVisitor() - { - TestCases = new List(); - } - - public List TestCases { get; private set; } - - protected override bool Visit(ITestCaseDiscoveryMessage discovery) - { - TestCases.Add(discovery.TestCase); - - return true; - } - } -} \ No newline at end of file diff --git a/src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs b/src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs deleted file mode 100644 index d87d4c73c4a..00000000000 --- a/src/xunit.runner.kre/Common/XmlTestExecutionVisitor.cs +++ /dev/null @@ -1,270 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Linq; -using System.Xml.Linq; -using Xunit.Abstractions; - -namespace Xunit -{ - public class XmlTestExecutionVisitor : TestMessageVisitor - { - readonly XElement assemblyElement; - readonly XElement errorsElement; - readonly ConcurrentDictionary testCollectionElements = new ConcurrentDictionary(); - - public XmlTestExecutionVisitor(XElement assemblyElement, Func cancelThunk) - { - CancelThunk = cancelThunk ?? (() => false); - - this.assemblyElement = assemblyElement; - - if (this.assemblyElement != null) - { - errorsElement = new XElement("errors"); - this.assemblyElement.Add(errorsElement); - } - } - - public readonly Func CancelThunk; - public int Errors; - public int Failed; - public int Skipped; - public decimal Time; - public int Total; - - XElement CreateTestResultElement(ITestResultMessage testResult, string resultText) - { - var collectionElement = GetTestCollectionElement(testResult.TestCase.TestMethod.TestClass.TestCollection); - var testResultElement = - new XElement("test", - new XAttribute("name", XmlEscape(testResult.Test.DisplayName)), - new XAttribute("type", testResult.TestCase.TestMethod.TestClass.Class.Name), - new XAttribute("method", testResult.TestCase.TestMethod.Method.Name), - new XAttribute("time", testResult.ExecutionTime.ToString("0.000")), - new XAttribute("result", resultText) - ); - - if (testResult.TestCase.SourceInformation != null) - { - if (testResult.TestCase.SourceInformation.FileName != null) - testResultElement.Add(new XAttribute("source-file", testResult.TestCase.SourceInformation.FileName)); - if (testResult.TestCase.SourceInformation.LineNumber != null) - testResultElement.Add(new XAttribute("source-line", testResult.TestCase.SourceInformation.LineNumber.GetValueOrDefault())); - } - - if (testResult.TestCase.Traits != null && testResult.TestCase.Traits.Count > 0) - { - var traitsElement = new XElement("traits"); - - foreach (var key in testResult.TestCase.Traits.Keys) - foreach (var value in testResult.TestCase.Traits[key]) - traitsElement.Add( - new XElement("trait", - new XAttribute("name", XmlEscape(key)), - new XAttribute("value", XmlEscape(value)) - ) - ); - - testResultElement.Add(traitsElement); - } - - collectionElement.Add(testResultElement); - - return testResultElement; - } - - XElement GetTestCollectionElement(ITestCollection testCollection) - { - return testCollectionElements.GetOrAdd(testCollection, tc => new XElement("collection")); - } - - public override bool OnMessage(IMessageSinkMessage message) - { - var result = base.OnMessage(message); - if (result) - result = !CancelThunk(); - - return result; - } - - protected override bool Visit(ITestAssemblyFinished assemblyFinished) - { - Total += assemblyFinished.TestsRun; - Failed += assemblyFinished.TestsFailed; - Skipped += assemblyFinished.TestsSkipped; - Time += assemblyFinished.ExecutionTime; - - if (assemblyElement != null) - { - assemblyElement.Add( - new XAttribute("total", Total), - new XAttribute("passed", Total - Failed - Skipped), - new XAttribute("failed", Failed), - new XAttribute("skipped", Skipped), - new XAttribute("time", Time.ToString("0.000")), - new XAttribute("errors", Errors) - ); - - foreach (var element in testCollectionElements.Values) - assemblyElement.Add(element); - } - - return base.Visit(assemblyFinished); - } - - protected override bool Visit(ITestAssemblyStarting assemblyStarting) - { - if (assemblyElement != null) - { - assemblyElement.Add( - new XAttribute("name", assemblyStarting.TestAssembly.Assembly.AssemblyPath), - new XAttribute("environment", assemblyStarting.TestEnvironment), - new XAttribute("test-framework", assemblyStarting.TestFrameworkDisplayName), - new XAttribute("run-date", assemblyStarting.StartTime.ToString("yyyy-MM-dd")), - new XAttribute("run-time", assemblyStarting.StartTime.ToString("HH:mm:ss")) - ); - - if (assemblyStarting.TestAssembly.ConfigFileName != null) - assemblyElement.Add(new XAttribute("config-file", assemblyStarting.TestAssembly.ConfigFileName)); - } - - return base.Visit(assemblyStarting); - } - - protected override bool Visit(ITestCollectionFinished testCollectionFinished) - { - if (assemblyElement != null) - { - var collectionElement = GetTestCollectionElement(testCollectionFinished.TestCollection); - collectionElement.Add( - new XAttribute("total", testCollectionFinished.TestsRun), - new XAttribute("passed", testCollectionFinished.TestsRun - testCollectionFinished.TestsFailed - testCollectionFinished.TestsSkipped), - new XAttribute("failed", testCollectionFinished.TestsFailed), - new XAttribute("skipped", testCollectionFinished.TestsSkipped), - new XAttribute("name", XmlEscape(testCollectionFinished.TestCollection.DisplayName)), - new XAttribute("time", testCollectionFinished.ExecutionTime.ToString("0.000")) - ); - } - - return base.Visit(testCollectionFinished); - } - - protected override bool Visit(ITestFailed testFailed) - { - if (assemblyElement != null) - { - var testElement = CreateTestResultElement(testFailed, "Fail"); - testElement.Add(CreateFailureElement(testFailed)); - } - - return base.Visit(testFailed); - } - - protected override bool Visit(ITestPassed testPassed) - { - if (assemblyElement != null) - CreateTestResultElement(testPassed, "Pass"); - - return base.Visit(testPassed); - } - - protected override bool Visit(ITestSkipped testSkipped) - { - if (assemblyElement != null) - { - var testElement = CreateTestResultElement(testSkipped, "Skip"); - testElement.Add(new XElement("reason", new XCData(XmlEscape(testSkipped.Reason)))); - } - - return base.Visit(testSkipped); - } - - protected override bool Visit(IErrorMessage error) - { - AddError("fatal", null, error); - - return base.Visit(error); - } - - protected override bool Visit(ITestAssemblyCleanupFailure cleanupFailure) - { - AddError("assembly-cleanup", cleanupFailure.TestAssembly.Assembly.AssemblyPath, cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCaseCleanupFailure cleanupFailure) - { - AddError("test-case-cleanup", cleanupFailure.TestCase.DisplayName, cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestClassCleanupFailure cleanupFailure) - { - AddError("test-class-cleanup", cleanupFailure.TestClass.Class.Name, cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCollectionCleanupFailure cleanupFailure) - { - AddError("test-collection-cleanup", cleanupFailure.TestCollection.DisplayName, cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCleanupFailure cleanupFailure) - { - AddError("test-cleanup", cleanupFailure.Test.DisplayName, cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestMethodCleanupFailure cleanupFailure) - { - AddError("test-method-cleanup", cleanupFailure.TestMethod.Method.Name, cleanupFailure); - - return base.Visit(cleanupFailure); - } - - void AddError(string type, string name, IFailureInformation failureInfo) - { - Errors++; - - if (errorsElement == null) - return; - - var errorElement = new XElement("error", new XAttribute("type", type), CreateFailureElement(failureInfo)); - if (name != null) - errorElement.Add(new XAttribute("name", name)); - - errorsElement.Add(errorElement); - } - - static XElement CreateFailureElement(IFailureInformation failureInfo) - { - return new XElement("failure", - new XAttribute("exception-type", failureInfo.ExceptionTypes[0]), - new XElement("message", new XCData(XmlEscape(ExceptionUtility.CombineMessages(failureInfo)))), - new XElement("stack-trace", new XCData(ExceptionUtility.CombineStackTraces(failureInfo) ?? String.Empty)) - ); - } - - protected static string Escape(string value) - { - if (value == null) - return String.Empty; - - return value.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\0", "\\0"); - } - - protected static string XmlEscape(string value) - { - if (value == null) - return String.Empty; - - return value.Replace("\0", "\\0"); - } - } -} \ No newline at end of file diff --git a/src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs b/src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs deleted file mode 100644 index aef89156ac1..00000000000 --- a/src/xunit.runner.kre/DesignTime/DesignTimeExecutionVisitor.cs +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using Microsoft.Framework.TestAdapter; -using Xunit.Abstractions; -using VsTestCase = Microsoft.Framework.TestAdapter.Test; - - -namespace Xunit.ConsoleClient -{ - public class DesignTimeExecutionVisitor : TestMessageVisitor - { - private readonly ITestExecutionSink _sink; - private readonly IDictionary _conversions; - private readonly TestMessageVisitor _next; - - public DesignTimeExecutionVisitor( - ITestExecutionSink sink, - IDictionary conversions, - TestMessageVisitor next) - { - _sink = sink; - _conversions = conversions; - _next = next; - } - - protected override bool Visit(ITestStarting testStarting) - { - var test = _conversions[testStarting.TestCase]; - - if (_sink != null) - { - _sink.RecordStart(test); - } - - return true; - } - - protected override bool Visit(ITestSkipped testSkipped) - { - var test = _conversions[testSkipped.TestCase]; - - if (_sink != null) - { - _sink.RecordResult(new TestResult(test) - { - Outcome = TestOutcome.Skipped, - }); - } - - return true; - } - - protected override bool Visit(ITestFailed testFailed) - { - var test = _conversions[testFailed.TestCase]; - var result = new TestResult(test) - { - Outcome = TestOutcome.Failed, - - Duration = TimeSpan.FromSeconds((double)testFailed.ExecutionTime), - ErrorMessage = string.Join(Environment.NewLine, testFailed.Messages), - ErrorStackTrace = string.Join(Environment.NewLine, testFailed.StackTraces), - }; - - result.Messages.Add(testFailed.Output); - - if (_sink != null) - { - _sink.RecordResult(result); - } - - return true; - } - - protected override bool Visit(ITestPassed testPassed) - { - var test = _conversions[testPassed.TestCase]; - - if (_sink != null) - { - _sink.RecordResult(new TestResult(test) - { - Outcome = TestOutcome.Passed, - - Duration = TimeSpan.FromSeconds((double)testPassed.ExecutionTime), - }); - } - - return true; - } - - public override bool OnMessage(IMessageSinkMessage message) - { - return - base.OnMessage(message) && - _next.OnMessage(message); - } - } -} \ No newline at end of file diff --git a/src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs b/src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs deleted file mode 100644 index dc26c7324b5..00000000000 --- a/src/xunit.runner.kre/DesignTime/DesignTimeTestConverter.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Security.Cryptography; -using Microsoft.Framework.TestAdapter; -using Xunit.Abstractions; -using VsTestCase = Microsoft.Framework.TestAdapter.Test; - -namespace Xunit.ConsoleClient -{ - public static class DesignTimeTestConverter - { -#if ASPNETCORE50 - private readonly static HashAlgorithm _hash = SHA1.Create(); -#else - private readonly static HashAlgorithm _hash = new SHA1Managed(); -#endif - public static IDictionary Convert(IEnumerable testcases) - { - // When tests have the same class name and method name, generate unique names for display - var groups = testcases - .Select(tc => new - { - testcase = tc, - shortName = GetShortName(tc), - fullyQualifiedName = string.Format("{0}.{1}", tc.TestMethod.TestClass.Class.Name, tc.TestMethod.Method.Name) - }) - .GroupBy(tc => tc.fullyQualifiedName); - - var results = new Dictionary(); - foreach (var group in groups) - { - var uniquifyNames = group.Count() > 1; - foreach (var testcase in group) - { - results.Add( - testcase.testcase, - Convert( - testcase.testcase, - testcase.shortName, - testcase.fullyQualifiedName, - uniquifyNames)); - } - } - - return results; - } - - private static string GetShortName(ITestCase tc) - { - var shortName = new StringBuilder(); - - var classFullName = tc.TestMethod.TestClass.Class.Name; - var dotIndex = classFullName.LastIndexOf('.'); - if (dotIndex >= 0) - { - shortName.Append(classFullName.Substring(dotIndex + 1)); - } - else - { - shortName.Append(classFullName); - } - - shortName.Append("."); - shortName.Append(tc.TestMethod.Method.Name); - - // We need to shorten the arguments list if it's long. Let's arbitrarily pick 50 characters. - var argumentsIndex = tc.DisplayName.IndexOf('('); - if (argumentsIndex >= 0 && tc.DisplayName.Length - argumentsIndex > 50) - { - shortName.Append(tc.DisplayName.Substring(argumentsIndex, 46)); - shortName.Append("..."); - shortName.Append(")"); - } - else if (argumentsIndex >= 0) - { - shortName.Append(tc.DisplayName.Substring(argumentsIndex)); - } - else - { - // No need to handle argments - } - - return shortName.ToString(); - } - - private static VsTestCase Convert( - ITestCase testcase, - string shortName, - string fullyQualifiedName, - bool uniquifyNames) - { - string uniqueName; - if (uniquifyNames) - { - uniqueName = string.Format("{0}({1})", fullyQualifiedName, testcase.UniqueID); - } - else - { - uniqueName = fullyQualifiedName; - } - - var result = new VsTestCase(); - result.DisplayName = shortName; - result.FullyQualifiedName = uniqueName; - - result.Id = GuidFromString(testcase.UniqueID); - - if (testcase.SourceInformation != null) - { - result.CodeFilePath = testcase.SourceInformation.FileName; - result.LineNumber = testcase.SourceInformation.LineNumber; - } - - return result; - } - - private static Guid GuidFromString(string data) - { - var hash = _hash.ComputeHash(Encoding.Unicode.GetBytes(data)); - var b = new byte[16]; - Array.Copy((Array)hash, (Array)b, 16); - return new Guid(b); - } - } -} \ No newline at end of file diff --git a/src/xunit.runner.kre/ParallelismOption.cs b/src/xunit.runner.kre/ParallelismOption.cs deleted file mode 100644 index e6d07a04b6a..00000000000 --- a/src/xunit.runner.kre/ParallelismOption.cs +++ /dev/null @@ -1,9 +0,0 @@ -namespace Xunit.ConsoleClient -{ - public enum ParallelismOption - { - none, - collections, - all - } -} diff --git a/src/xunit.runner.kre/Program.cs b/src/xunit.runner.kre/Program.cs deleted file mode 100644 index 4807ff4218d..00000000000 --- a/src/xunit.runner.kre/Program.cs +++ /dev/null @@ -1,350 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Xml.Linq; -using Microsoft.Framework.Runtime; -using Microsoft.Framework.TestAdapter; -using Xunit.Abstractions; -using VsTestCase = Microsoft.Framework.TestAdapter.Test; - -namespace Xunit.ConsoleClient -{ - public class Program - { - volatile bool cancel; - bool failed; - readonly ConcurrentDictionary completionMessages = new ConcurrentDictionary(); - - private readonly IApplicationEnvironment _appEnv; - private readonly IServiceProvider _services; - - public Program(IApplicationEnvironment appEnv, IServiceProvider services) - { - _appEnv = appEnv; - _services = services; - } - - [STAThread] - public int Main(string[] args) - { - args = Enumerable.Repeat(_appEnv.ApplicationName + ".dll", 1).Concat(args).ToArray(); - - var originalForegroundColor = Console.ForegroundColor; - - try - { - var framework = _appEnv.RuntimeFramework; - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine("xUnit.net K Runtime Environment test runner ({0}-bit {1} {2})", IntPtr.Size * 8, framework.Identifier, framework.Version); - Console.WriteLine("Copyright (C) 2014 Outercurve Foundation."); - Console.WriteLine(); - Console.ForegroundColor = ConsoleColor.Gray; - - if (args.Length == 0 || args[0] == "-?") - { - PrintUsage(); - return 1; - } - -#if !ASPNETCORE50 - AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; - Console.CancelKeyPress += (sender, e) => - { - if (!cancel) - { - Console.WriteLine("Canceling... (Press Ctrl+C again to terminate)"); - cancel = true; - e.Cancel = true; - } - }; -#endif - - var defaultDirectory = Directory.GetCurrentDirectory(); - if (!defaultDirectory.EndsWith(new String(new[] { Path.DirectorySeparatorChar }))) - defaultDirectory += Path.DirectorySeparatorChar; - - var commandLine = CommandLine.Parse(args); - - var failCount = RunProject(defaultDirectory, commandLine.Project, commandLine.TeamCity, - commandLine.ParallelizeTestCollections, - commandLine.MaxParallelThreads, - commandLine.DesignTime, - commandLine.List, - commandLine.DesignTimeTestUniqueNames); - - if (commandLine.Wait) - { - Console.WriteLine(); -#if ASPNETCORE50 - Console.Write("Press ENTER to continue..."); - Console.ReadLine(); -#else - Console.Write("Press any key to continue..."); - Console.ReadKey(); -#endif - Console.WriteLine(); - } - - return failCount; - } - catch (ArgumentException ex) - { - Console.WriteLine("error: {0}", ex.Message); - return 1; - } - catch (BadImageFormatException ex) - { - Console.WriteLine("{0}", ex.Message); - return 1; - } - finally - { - Console.ForegroundColor = originalForegroundColor; - } - } - -#if !ASPNETCORE50 - static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) - { - var ex = e.ExceptionObject as Exception; - - if (ex != null) - Console.WriteLine(ex.ToString()); - else - Console.WriteLine("Error of unknown type thrown in application domain"); - - Environment.Exit(1); - } -#endif - - static void PrintUsage() - { - Console.WriteLine("usage: xunit.runner.kre [assemblyFile ...] [options]"); - Console.WriteLine(); - Console.WriteLine("Valid options:"); - Console.WriteLine(" -parallel option : set parallelization based on option"); - Console.WriteLine(" : none - turn off all parallelization"); - Console.WriteLine(" : collections - only parallelize collections"); - Console.WriteLine(" : all - parallelize collections"); - Console.WriteLine(" -maxthreads count : maximum thread count for collection parallelization"); - Console.WriteLine(" : 0 - run with unbounded thread count"); - Console.WriteLine(" : >0 - limit task thread pool size to 'count'"); - Console.WriteLine(" -noshadow : do not shadow copy assemblies"); - Console.WriteLine(" -teamcity : forces TeamCity mode (normally auto-detected)"); - Console.WriteLine(" -wait : wait for input after completion"); - Console.WriteLine(" -trait \"name=value\" : only run tests with matching name/value traits"); - Console.WriteLine(" : if specified more than once, acts as an OR operation"); - Console.WriteLine(" -notrait \"name=value\" : do not run tests with matching name/value traits"); - Console.WriteLine(" : if specified more than once, acts as an AND operation"); - Console.WriteLine(" -method \"name\" : run a given test method (should be fully specified;"); - Console.WriteLine(" : i.e., 'MyNamespace.MyClass.MyTestMethod')"); - Console.WriteLine(" : if specified more than once, acts as an OR operation"); - Console.WriteLine(" -class \"name\" : run all methods in a given test class (should be fully"); - Console.WriteLine(" : specified; i.e., 'MyNamespace.MyClass')"); - Console.WriteLine(" : if specified more than once, acts as an OR operation"); - - foreach (var transform in TransformFactory.AvailableTransforms) - Console.WriteLine(" {0} : {1}", - String.Format("-{0} ", transform.CommandLine).PadRight(22).Substring(0, 22), - transform.Description); - } - - int RunProject(string defaultDirectory, XunitProject project, bool teamcity, bool parallelizeTestCollections, int maxThreadCount, bool designTime, bool list, IReadOnlyList designTimeFullyQualifiedNames) - { - XElement assembliesElement = null; - var xmlTransformers = TransformFactory.GetXmlTransformers(project); - var needsXml = xmlTransformers.Count > 0; - var consoleLock = new object(); - - if (needsXml) - assembliesElement = new XElement("assemblies"); - - var originalWorkingFolder = Directory.GetCurrentDirectory(); - - using (AssemblyHelper.SubscribeResolve()) - { - var clockTime = Stopwatch.StartNew(); - - foreach (var assembly in project.Assemblies) - { - var assemblyElement = ExecuteAssembly(consoleLock, defaultDirectory, assembly, needsXml, teamcity, parallelizeTestCollections, maxThreadCount, project.Filters, designTime, list, designTimeFullyQualifiedNames); - if (assemblyElement != null) - assembliesElement.Add(assemblyElement); - } - - clockTime.Stop(); - - if (completionMessages.Count > 0) - { - Console.ForegroundColor = ConsoleColor.White; - Console.WriteLine(); - Console.WriteLine("=== TEST EXECUTION SUMMARY ==="); - Console.ForegroundColor = ConsoleColor.Gray; - - var totalTestsRun = completionMessages.Values.Sum(summary => summary.Total); - var totalTestsFailed = completionMessages.Values.Sum(summary => summary.Failed); - var totalTestsSkipped = completionMessages.Values.Sum(summary => summary.Skipped); - var totalTime = completionMessages.Values.Sum(summary => summary.Time).ToString("0.000s"); - var totalErrors = completionMessages.Values.Sum(summary => summary.Errors); - var longestAssemblyName = completionMessages.Keys.Max(key => key.Length); - var longestTotal = totalTestsRun.ToString().Length; - var longestFailed = totalTestsFailed.ToString().Length; - var longestSkipped = totalTestsSkipped.ToString().Length; - var longestTime = totalTime.Length; - var longestErrors = totalErrors.ToString().Length; - - foreach (var message in completionMessages.OrderBy(m => m.Key)) - Console.WriteLine(" {0} Total: {1}, Errors: {2}, Failed: {3}, Skipped: {4}, Time: {5}", - message.Key.PadRight(longestAssemblyName), - message.Value.Total.ToString().PadLeft(longestTotal), - message.Value.Errors.ToString().PadLeft(longestErrors), - message.Value.Failed.ToString().PadLeft(longestFailed), - message.Value.Skipped.ToString().PadLeft(longestSkipped), - message.Value.Time.ToString("0.000s").PadLeft(longestTime)); - - if (completionMessages.Count > 1) - Console.WriteLine(" {0} {1} {2} {3} {4} {5}" + Environment.NewLine + - " {6} {7} {8} {9} {10} {11} ({12})", - " ".PadRight(longestAssemblyName), - "-".PadRight(longestTotal, '-'), - "-".PadRight(longestErrors, '-'), - "-".PadRight(longestFailed, '-'), - "-".PadRight(longestSkipped, '-'), - "-".PadRight(longestTime, '-'), - "GRAND TOTAL:".PadLeft(longestAssemblyName), - totalTestsRun, - totalErrors, - totalTestsFailed, - totalTestsSkipped, - totalTime, - clockTime.Elapsed.TotalSeconds.ToString("0.000s")); - - } - } - - Directory.SetCurrentDirectory(originalWorkingFolder); - - foreach (var transformer in xmlTransformers) transformer(assembliesElement); - - return failed ? 1 : completionMessages.Values.Sum(summary => summary.Failed); - } - - TestMessageVisitor CreateVisitor(object consoleLock, string defaultDirectory, XElement assemblyElement, bool teamCity) - { - if (teamCity) - return new TeamCityVisitor(assemblyElement, () => cancel); - - return new StandardOutputVisitor(consoleLock, defaultDirectory, assemblyElement, () => cancel, completionMessages); - } - - XElement ExecuteAssembly(object consoleLock, string defaultDirectory, XunitProjectAssembly assembly, bool needsXml, bool teamCity, bool parallelizeTestCollections, int maxThreadCount, XunitFilters filters, bool designTime, bool list, IReadOnlyList designTimeFullyQualifiedNames) - { - if (cancel) - return null; - - var assemblyElement = needsXml ? new XElement("assembly") : null; - - try - { - lock (consoleLock) - Console.WriteLine("Discovering: {0}", Path.GetFileNameWithoutExtension(assembly.AssemblyFilename)); - - using (var controller = new XunitFrontController(assembly.AssemblyFilename, assembly.ConfigFilename, assembly.ShadowCopy)) - using (var discoveryVisitor = new TestDiscoveryVisitor()) - { - controller.Find(includeSourceInformation: false, messageSink: discoveryVisitor, options: new TestFrameworkOptions()); - discoveryVisitor.Finished.WaitOne(); - - IDictionary vsTestcases = null; - if (designTime) - { - vsTestcases = DesignTimeTestConverter.Convert(discoveryVisitor.TestCases); - } - - lock (consoleLock) - Console.WriteLine("Discovered: {0}", Path.GetFileNameWithoutExtension(assembly.AssemblyFilename)); - - if (list) - { - lock (consoleLock) - { - if (designTime) - { - var sink = (ITestDiscoverySink)_services.GetService(typeof(ITestDiscoverySink)); - - foreach (var testcase in vsTestcases.Values) - { - if (sink != null) - { - sink.SendTest(testcase); - } - - Console.WriteLine(testcase.FullyQualifiedName); - } - } - else - { - foreach (var testcase in discoveryVisitor.TestCases) - { - Console.WriteLine(testcase.DisplayName); - } - } - } - - return assemblyElement; - } - - var executionOptions = new XunitExecutionOptions { DisableParallelization = !parallelizeTestCollections, MaxParallelThreads = maxThreadCount }; - var resultsVisitor = CreateVisitor(consoleLock, defaultDirectory, assemblyElement, teamCity); - - if (designTime) - { - var sink = (ITestExecutionSink)_services.GetService(typeof(ITestExecutionSink)); - resultsVisitor = new DesignTimeExecutionVisitor( - sink, - vsTestcases, - resultsVisitor); - } - - IList filteredTestCases; - if (!designTime || designTimeFullyQualifiedNames.Count == 0) - { - filteredTestCases = discoveryVisitor.TestCases.Where(filters.Filter).ToList(); - } - else - { - filteredTestCases = (from t in vsTestcases - where designTimeFullyQualifiedNames.Contains(t.Value.FullyQualifiedName) - select t.Key) - .ToList(); - } - - if (filteredTestCases.Count == 0) - { - lock (consoleLock) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.WriteLine("ERROR: {0} has no tests to run", Path.GetFileNameWithoutExtension(assembly.AssemblyFilename)); - Console.ForegroundColor = ConsoleColor.Gray; - } - } - else - { - controller.RunTests(filteredTestCases, resultsVisitor, executionOptions); - resultsVisitor.Finished.WaitOne(); - } - } - } - catch (Exception ex) - { - Console.WriteLine("{0}: {1}", ex.GetType().FullName, ex.Message); - failed = true; - } - - return assemblyElement; - } - } -} diff --git a/src/xunit.runner.kre/Properties/AssemblyInfo.cs b/src/xunit.runner.kre/Properties/AssemblyInfo.cs deleted file mode 100644 index 0afdef48eb7..00000000000 --- a/src/xunit.runner.kre/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Reflection; - -[assembly : AssemblyTitle("xUnit.net Console Test Runner")] \ No newline at end of file diff --git a/src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs b/src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs deleted file mode 100644 index 47982706663..00000000000 --- a/src/xunit.runner.kre/Properties/GlobalAssemblyInfo.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Diagnostics.CodeAnalysis; -using System.Reflection; - -[assembly: AssemblyCompany("Outercurve Foundation")] -[assembly: AssemblyProduct("xUnit.net Testing Framework")] -[assembly: AssemblyCopyright("Copyright (C) Outercurve Foundation")] -[assembly: AssemblyVersion("99.99.99.0")] - -[assembly: SuppressMessage("Microsoft.Design", "CA1020:AvoidNamespacesWithFewTypes", Scope = "namespace", Target = "Xunit.Sdk")] -[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "xunit")] -[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "extensions")] -[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "utility")] -[assembly: SuppressMessage("Microsoft.Naming", "CA1709:IdentifiersShouldBeCasedCorrectly", MessageId = "runner")] \ No newline at end of file diff --git a/src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs b/src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs deleted file mode 100644 index 65328da7033..00000000000 --- a/src/xunit.runner.kre/RunnerCallbacks/RunnerCallback.cs +++ /dev/null @@ -1,84 +0,0 @@ -//using System; - -//namespace Xunit.ConsoleClient -//{ -// public class RunnerCallback : ITestMethodRunnerCallback -// { -// public int TotalTests { get; set; } -// public int TotalFailures { get; set; } -// public int TotalSkips { get; set; } -// public double TotalTime { get; set; } - -// public virtual void AssemblyFinished(TestAssembly testAssembly, int total, int failed, int skipped, double time) -// { -// TotalTests = total; -// TotalFailures = failed; -// TotalSkips = skipped; -// TotalTime = time; -// } - -// public virtual void AssemblyStart(TestAssembly testAssembly) -// { -// } - -// public virtual bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace) -// { -// return true; -// } - -// public virtual void ExceptionThrown(TestAssembly testAssembly, Exception exception) -// { -// Console.WriteLine(); -// Console.WriteLine("CATASTROPHIC ERROR OCCURRED:"); -// Console.WriteLine(exception.ToString()); -// Console.WriteLine("WHILE RUNNING:"); -// Console.WriteLine(testAssembly.AssemblyFilename); -// Console.WriteLine(); -// } - -// protected virtual void TestFailed(TestMethod method, TestFailedResult result) -// { -// } - -// public bool TestFinished(TestMethod method) -// { -// TestResult result = method.RunResults[method.RunResults.Count - 1]; - -// TestPassedResult passedResult = result as TestPassedResult; -// if (passedResult != null) -// TestPassed(method, passedResult); -// else -// { -// TestFailedResult failedResult = result as TestFailedResult; -// if (failedResult != null) -// TestFailed(method, failedResult); -// else -// { -// TestSkippedResult skippedResult = result as TestSkippedResult; -// if (skippedResult != null) -// TestSkipped(method, skippedResult); -// } -// } - -// return TestFinished(method, result); -// } - -// protected virtual bool TestFinished(TestMethod method, TestResult result) -// { -// return true; -// } - -// protected virtual void TestPassed(TestMethod method, TestPassedResult result) -// { -// } - -// protected virtual void TestSkipped(TestMethod method, TestSkippedResult result) -// { -// } - -// public virtual bool TestStart(TestMethod method) -// { -// return true; -// } -// } -//} \ No newline at end of file diff --git a/src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs b/src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs deleted file mode 100644 index 6b9c2d83f0f..00000000000 --- a/src/xunit.runner.kre/RunnerCallbacks/StandardRunnerCallback.cs +++ /dev/null @@ -1,115 +0,0 @@ -//using System; -//using System.Globalization; - -//namespace Xunit.ConsoleClient -//{ -// public class StandardRunnerCallback : RunnerCallback -// { -// readonly bool silent; -// int testCount = 0; -// readonly int totalCount; - -// public StandardRunnerCallback(bool silent, int totalCount) -// { -// this.silent = silent; -// this.totalCount = totalCount; -// } - -// public override void AssemblyFinished(TestAssembly testAssembly, int total, int failed, int skipped, double time) -// { -// base.AssemblyFinished(testAssembly, total, failed, skipped, time); - -// if (!silent) -// Console.Write("\r"); - -// Console.WriteLine("{0} total, {1} failed, {2} skipped, took {3} seconds", total, failed, skipped, time.ToString("0.000", CultureInfo.CurrentCulture)); -// } - -// public override bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace) -// { -// if (!silent) -// Console.Write("\r"); - -// Console.ForegroundColor = ConsoleColor.Red; -// Console.WriteLine("{0} [FIXTURE FAIL]", testClass.TypeName); -// Console.ResetColor(); - -// Console.WriteLine(Indent(message)); - -// if (stackTrace != null) -// { -// Console.WriteLine(Indent("Stack Trace:")); -// Console.WriteLine(Indent(StackFrameTransformer.TransformStack(stackTrace))); -// } - -// Console.WriteLine(); -// return true; -// } - -// protected override void TestFailed(TestMethod testMethod, TestFailedResult result) -// { -// if (!silent) -// Console.Write("\r"); - -// Console.ForegroundColor = ConsoleColor.Red; -// Console.WriteLine("{0} [FAIL]", result.DisplayName); -// Console.ResetColor(); - -// Console.WriteLine(Indent(result.ExceptionMessage)); - -// if (result.ExceptionStackTrace != null) -// { -// Console.ForegroundColor = ConsoleColor.DarkGray; -// Console.WriteLine(Indent("Stack Trace:")); -// Console.ResetColor(); - -// Console.WriteLine(Indent(StackFrameTransformer.TransformStack(result.ExceptionStackTrace))); -// } - -// Console.WriteLine(); -// } - -// protected override bool TestFinished(TestMethod testMethod, TestResult testResult) -// { -// if (!silent) -// { -// Console.ForegroundColor = ConsoleColor.DarkGray; -// Console.Write("\rTests complete: {0} of {1}", ++testCount, totalCount); -// Console.ResetColor(); -// } - -// return true; -// } - -// protected override void TestSkipped(TestMethod testMethod, TestSkippedResult result) -// { -// if (!silent) -// Console.Write("\r"); - -// Console.ForegroundColor = ConsoleColor.Yellow; -// Console.WriteLine("{0} [SKIP]", result.DisplayName); -// Console.ResetColor(); - -// Console.WriteLine(Indent(result.Reason)); -// Console.WriteLine(); -// } - -// // Helpers - -// string Indent(string message) -// { -// return Indent(message, 0); -// } - -// string Indent(string message, int additionalSpaces) -// { -// string result = ""; -// string indent = "".PadRight(additionalSpaces + 3); - -// foreach (string line in message.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) -// result += indent + line + Environment.NewLine; - -// return result.TrimEnd(); -// } -// } -//} \ No newline at end of file diff --git a/src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs b/src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs deleted file mode 100644 index ff4300143fe..00000000000 --- a/src/xunit.runner.kre/RunnerCallbacks/TeamCityRunnerCallback.cs +++ /dev/null @@ -1,106 +0,0 @@ -//using System; -//using System.IO; - -//namespace Xunit.ConsoleClient -//{ -// public class TeamCityRunnerCallback : RunnerCallback -// { -// public override void AssemblyFinished(TestAssembly testAssembly, int total, int failed, int skipped, double time) -// { -// base.AssemblyFinished(testAssembly, total, failed, skipped, time); - -// Console.WriteLine( -// "##teamcity[testSuiteFinished name='{0}']", -// Escape(Path.GetFileName(testAssembly.AssemblyFilename)) -// ); -// } - -// public override void AssemblyStart(TestAssembly testAssembly) -// { -// Console.WriteLine( -// "##teamcity[testSuiteStarted name='{0}']", -// Escape(Path.GetFileName(testAssembly.AssemblyFilename)) -// ); -// } - -// public override bool ClassFailed(TestClass testClass, string exceptionType, string message, string stackTrace) -// { -// Console.WriteLine( -// "##teamcity[buildStatus status='FAILURE' text='Class failed: {0}: {1}|r|n{2}']", -// Escape(testClass.TypeName), -// Escape(message), -// Escape(stackTrace) -// ); - -// return true; -// } - -// protected override void TestFailed(TestMethod method, TestFailedResult result) -// { -// Console.WriteLine( -// "##teamcity[testFailed name='{0}' details='{1}|r|n{2}']", -// Escape(method.DisplayName), -// Escape(result.ExceptionMessage), -// Escape(result.ExceptionStackTrace) -// ); - -// WriteOutput(result.DisplayName, result.Output); -// } - -// protected override bool TestFinished(TestMethod method, TestResult result) -// { -// WriteFinished(method.DisplayName, result.Duration); -// return true; -// } - -// protected override void TestPassed(TestMethod method, TestPassedResult result) -// { -// WriteOutput(method.DisplayName, result.Output); -// } - -// protected override void TestSkipped(TestMethod method, TestSkippedResult result) -// { -// Console.WriteLine( -// "##teamcity[testIgnored name='{0}' message='{1}']", -// Escape(method.DisplayName), -// Escape(result.Reason) -// ); -// } - -// public override bool TestStart(TestMethod method) -// { -// Console.WriteLine( -// "##teamcity[testStarted name='{0}']", -// Escape(method.DisplayName) -// ); - -// return true; -// } - -// // Helpers - -// static string Escape(string value) -// { -// if (value == null) -// return String.Empty; - -// return value.Replace("|", "||") -// .Replace("'", "|'") -// .Replace("\r", "|r") -// .Replace("\n", "|n") -// .Replace("]", "|]"); -// } - -// static void WriteFinished(string name, double duration) -// { -// Console.WriteLine("##teamcity[testFinished name='{0}' duration='{1}']", -// Escape(name), (int)(duration * 1000D)); -// } - -// static void WriteOutput(string name, string output) -// { -// if (output != null) -// Console.WriteLine("##teamcity[testStdOut name='{0}' out='{1}']", Escape(name), Escape(output)); -// } -// } -//} \ No newline at end of file diff --git a/src/xunit.runner.kre/Utility/StackFrameTransformer.cs b/src/xunit.runner.kre/Utility/StackFrameTransformer.cs deleted file mode 100644 index ff907e891ee..00000000000 --- a/src/xunit.runner.kre/Utility/StackFrameTransformer.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text.RegularExpressions; - -namespace Xunit.ConsoleClient -{ - /// - /// Transforms stack frames and stack traces into compiler-like output - /// so they can be double-clicked in Visual Studio. - /// - public static class StackFrameTransformer - { - static Regex regex; - - static StackFrameTransformer() - { - regex = new Regex(@"^\s*at (?.*) in (?.*):(line )?(?\d+)$"); - } - - /// - public static string TransformFrame(string stackFrame, string defaultDirectory) - { - if (stackFrame == null) - return null; - - var match = regex.Match(stackFrame); - if (match == Match.Empty) - return stackFrame; - - var file = match.Groups["file"].Value; - if (file.StartsWith(defaultDirectory, StringComparison.OrdinalIgnoreCase)) - file = file.Substring(defaultDirectory.Length); - - return String.Format("{0}({1},0): at {2}", - file, - match.Groups["line"].Value, - match.Groups["method"].Value); - } - - /// - public static string TransformStack(string stack, string defaultDirectory) - { - if (stack == null) - return null; - - List results = new List(); - - foreach (string frame in stack.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) - results.Add(TransformFrame(frame, defaultDirectory)); - - return String.Join(Environment.NewLine, results.ToArray()); - } - } -} diff --git a/src/xunit.runner.kre/Utility/Transform.cs b/src/xunit.runner.kre/Utility/Transform.cs deleted file mode 100644 index 5b4541a0f8f..00000000000 --- a/src/xunit.runner.kre/Utility/Transform.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Xml.Linq; - -namespace Xunit.ConsoleClient -{ - public class Transform - { - public string CommandLine; - public string Description; - public Action OutputHandler; - } -} diff --git a/src/xunit.runner.kre/Utility/TransformFactory.cs b/src/xunit.runner.kre/Utility/TransformFactory.cs deleted file mode 100644 index 4b24644b5b0..00000000000 --- a/src/xunit.runner.kre/Utility/TransformFactory.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Reflection; -using System.Xml; -using System.Xml.Linq; - -namespace Xunit.ConsoleClient -{ - public class TransformFactory - { - static readonly TransformFactory instance = new TransformFactory(); - - readonly Dictionary availableTransforms = new Dictionary(StringComparer.OrdinalIgnoreCase); - - protected TransformFactory() - { - availableTransforms.Add("xml", new Transform { CommandLine = "xml", Description = "output results to xUnit.net v2 style XML file", OutputHandler = Handler_DirectWrite }); - } - - public static List AvailableTransforms - { - get { return instance.availableTransforms.Values.ToList(); } - } - - public static List> GetXmlTransformers(XunitProject project) - { - return project.Output.Select(output => new Action(xml => instance.availableTransforms[output.Key].OutputHandler(xml, output.Value))).ToList(); - } - - static void Handler_DirectWrite(XElement xml, string outputFileName) - { - using (var stream = File.OpenWrite(outputFileName)) - xml.Save(stream); - } - } -} diff --git a/src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs b/src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs deleted file mode 100644 index a1f5f74cc58..00000000000 --- a/src/xunit.runner.kre/Visitors/StandardOutputVisitor.cs +++ /dev/null @@ -1,174 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.IO; -using System.Xml.Linq; -using Xunit.Abstractions; - -namespace Xunit.ConsoleClient -{ - public class StandardOutputVisitor : XmlTestExecutionVisitor - { - string assemblyFileName; - readonly object consoleLock; - readonly ConcurrentDictionary completionMessages; - readonly string defaultDirectory; - - public StandardOutputVisitor(object consoleLock, - string defaultDirectory, - XElement assemblyElement, - Func cancelThunk, - ConcurrentDictionary completionMessages = null) - : base(assemblyElement, cancelThunk) - { - this.consoleLock = consoleLock; - this.defaultDirectory = defaultDirectory; - this.completionMessages = completionMessages; - } - - protected override bool Visit(ITestAssemblyStarting assemblyStarting) - { - assemblyFileName = Path.GetFileName(assemblyStarting.TestAssembly.Assembly.AssemblyPath); - - lock (consoleLock) - Console.WriteLine("Starting: {0}", Path.GetFileNameWithoutExtension(assemblyFileName)); - - return base.Visit(assemblyStarting); - } - - protected override bool Visit(ITestAssemblyFinished assemblyFinished) - { - // Base class does computation of results, so call it first. - var result = base.Visit(assemblyFinished); - - lock (consoleLock) - Console.WriteLine("Finished: {0}", Path.GetFileNameWithoutExtension(assemblyFileName)); - - if (completionMessages != null) - completionMessages.TryAdd(Path.GetFileNameWithoutExtension(assemblyFileName), new ExecutionSummary - { - Total = assemblyFinished.TestsRun, - Failed = assemblyFinished.TestsFailed, - Skipped = assemblyFinished.TestsSkipped, - Time = assemblyFinished.ExecutionTime, - Errors = Errors - }); - - return result; - } - - protected override bool Visit(ITestFailed testFailed) - { - lock (consoleLock) - { - // TODO: Thread-safe way to figure out the default foreground color - Console.ForegroundColor = ConsoleColor.Red; - Console.Error.WriteLine(" {0} [FAIL]", Escape(testFailed.Test.DisplayName)); - Console.ForegroundColor = ConsoleColor.Gray; - Console.Error.WriteLine(" {0}", ExceptionUtility.CombineMessages(testFailed).Replace(Environment.NewLine, Environment.NewLine + " ")); - - WriteStackTrace(ExceptionUtility.CombineStackTraces(testFailed)); - } - - return base.Visit(testFailed); - } - - protected override bool Visit(ITestPassed testPassed) - { - return base.Visit(testPassed); - } - - protected override bool Visit(ITestSkipped testSkipped) - { - lock (consoleLock) - { - // TODO: Thread-safe way to figure out the default foreground color - Console.ForegroundColor = ConsoleColor.Yellow; - Console.Error.WriteLine(" {0} [SKIP]", Escape(testSkipped.Test.DisplayName)); - Console.ForegroundColor = ConsoleColor.Gray; - Console.Error.WriteLine(" {0}", Escape(testSkipped.Reason)); - } - - return base.Visit(testSkipped); - } - - protected override bool Visit(ITestStarting testStarting) - { - return base.Visit(testStarting); - } - - protected override bool Visit(IErrorMessage error) - { - WriteError("FATAL", error); - - return base.Visit(error); - } - - protected override bool Visit(ITestAssemblyCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Assembly Cleanup Failure ({0})", cleanupFailure.TestAssembly.Assembly.AssemblyPath), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCaseCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Case Cleanup Failure ({0})", cleanupFailure.TestCase.DisplayName), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestClassCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Class Cleanup Failure ({0})", cleanupFailure.TestClass.Class.Name), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCollectionCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Collection Cleanup Failure ({0})", cleanupFailure.TestCollection.DisplayName), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Cleanup Failure ({0})", cleanupFailure.Test.DisplayName), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestMethodCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Method Cleanup Failure ({0})", cleanupFailure.TestMethod.Method.Name), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected void WriteError(string failureName, IFailureInformation failureInfo) - { - lock (consoleLock) - { - Console.ForegroundColor = ConsoleColor.Red; - Console.Error.WriteLine(" [{0}] {1}", failureName, Escape(failureInfo.ExceptionTypes[0])); - Console.ForegroundColor = ConsoleColor.Gray; - Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(failureInfo))); - - WriteStackTrace(ExceptionUtility.CombineStackTraces(failureInfo)); - } - } - - void WriteStackTrace(string stackTrace) - { - if (String.IsNullOrWhiteSpace(stackTrace)) - return; - - Console.ForegroundColor = ConsoleColor.DarkGray; - Console.Error.WriteLine(" Stack Trace:"); - - Console.ForegroundColor = ConsoleColor.Gray; - foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) - Console.Error.WriteLine(" {0}", StackFrameTransformer.TransformFrame(stackFrame, defaultDirectory)); - } - } -} \ No newline at end of file diff --git a/src/xunit.runner.kre/Visitors/TeamCityVisitor.cs b/src/xunit.runner.kre/Visitors/TeamCityVisitor.cs deleted file mode 100644 index 01a3ac294c3..00000000000 --- a/src/xunit.runner.kre/Visitors/TeamCityVisitor.cs +++ /dev/null @@ -1,168 +0,0 @@ -using System; -using System.Collections.Concurrent; -using System.Xml.Linq; -using Xunit.Abstractions; - -namespace Xunit.ConsoleClient -{ - public class TeamCityVisitor : XmlTestExecutionVisitor - { - readonly ConcurrentDictionary flowMappings = new ConcurrentDictionary(); - readonly Func flowIdMapper; - - public TeamCityVisitor(XElement assembliesElement, Func cancelThunk) - : this(assembliesElement, cancelThunk, _ => Guid.NewGuid().ToString("N")) { } - - public TeamCityVisitor(XElement assembliesElement, Func cancelThunk, Func flowIdMapper) - : base(assembliesElement, cancelThunk) - { - this.flowIdMapper = flowIdMapper; - } - - void LogFinish(ITestResultMessage testResult) - { - Console.WriteLine("##teamcity[testFinished name='{0}' duration='{1}' flowId='{2}']", - TeamCityEscape(testResult.Test.DisplayName), - (int)(testResult.ExecutionTime * 1000M), - ToFlowId(testResult.TestCollection.DisplayName)); - } - - protected override bool Visit(ITestCollectionFinished testCollectionFinished) - { - // Base class does computation of results, so call it first. - var result = base.Visit(testCollectionFinished); - - Console.WriteLine("##teamcity[testSuiteFinished name='{0}' flowId='{1}']", - TeamCityEscape(testCollectionFinished.TestCollection.DisplayName), - ToFlowId(testCollectionFinished.TestCollection.DisplayName)); - - return result; - } - - protected override bool Visit(ITestCollectionStarting testCollectionStarting) - { - Console.WriteLine("##teamcity[testSuiteStarted name='{0}' flowId='{1}']", - TeamCityEscape(testCollectionStarting.TestCollection.DisplayName), - ToFlowId(testCollectionStarting.TestCollection.DisplayName)); - - return base.Visit(testCollectionStarting); - } - - protected override bool Visit(ITestFailed testFailed) - { - Console.WriteLine("##teamcity[testFailed name='{0}' details='{1}|r|n{2}' flowId='{3}']", - TeamCityEscape(testFailed.Test.DisplayName), - TeamCityEscape(ExceptionUtility.CombineMessages(testFailed)), - TeamCityEscape(ExceptionUtility.CombineStackTraces(testFailed)), - ToFlowId(testFailed.TestCollection.DisplayName)); - LogFinish(testFailed); - - return base.Visit(testFailed); - } - - protected override bool Visit(ITestPassed testPassed) - { - LogFinish(testPassed); - - return base.Visit(testPassed); - } - - protected override bool Visit(ITestSkipped testSkipped) - { - Console.WriteLine("##teamcity[testIgnored name='{0}' message='{1}' flowId='{2}']", - TeamCityEscape(testSkipped.Test.DisplayName), - TeamCityEscape(testSkipped.Reason), - ToFlowId(testSkipped.TestCollection.DisplayName)); - LogFinish(testSkipped); - - return base.Visit(testSkipped); - } - - protected override bool Visit(ITestStarting testStarting) - { - Console.WriteLine("##teamcity[testStarted name='{0}' flowId='{1}']", - TeamCityEscape(testStarting.Test.DisplayName), - ToFlowId(testStarting.TestCollection.DisplayName)); - - return base.Visit(testStarting); - } - - protected override bool Visit(IErrorMessage error) - { - WriteError("FATAL", error); - - return base.Visit(error); - } - - protected override bool Visit(ITestAssemblyCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Assembly Cleanup Failure ({0})", cleanupFailure.TestAssembly.Assembly.AssemblyPath), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCaseCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Case Cleanup Failure ({0})", cleanupFailure.TestCase.DisplayName), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestClassCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Class Cleanup Failure ({0})", cleanupFailure.TestClass.Class.Name), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCollectionCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Collection Cleanup Failure ({0})", cleanupFailure.TestCollection.DisplayName), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Cleanup Failure ({0})", cleanupFailure.Test.DisplayName), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - protected override bool Visit(ITestMethodCleanupFailure cleanupFailure) - { - WriteError(String.Format("Test Method Cleanup Failure ({0})", cleanupFailure.TestMethod.Method.Name), cleanupFailure); - - return base.Visit(cleanupFailure); - } - - static string TeamCityEscape(string value) - { - if (value == null) - return String.Empty; - - return value.Replace("|", "||") - .Replace("'", "|'") - .Replace("\r", "|r") - .Replace("\n", "|n") - .Replace("]", "|]") - .Replace("[", "|[") - .Replace("\u0085", "|x") - .Replace("\u2028", "|l") - .Replace("\u2029", "|p"); - } - - string ToFlowId(string testCollectionName) - { - return flowMappings.GetOrAdd(testCollectionName, flowIdMapper); - } - - static void WriteError(string messageType, IFailureInformation failureInfo) - { - var message = String.Format("[{0}] {1}: {2}", messageType, failureInfo.ExceptionTypes[0], ExceptionUtility.CombineMessages(failureInfo)); - var stack = ExceptionUtility.CombineStackTraces(failureInfo); - - Console.WriteLine("##teamcity[message text='{0}' errorDetails='{1}' status='ERROR']", TeamCityEscape(message), TeamCityEscape(stack)); - } - } -} \ No newline at end of file diff --git a/src/xunit.runner.kre/project.json b/src/xunit.runner.kre/project.json deleted file mode 100644 index 9854d7345a1..00000000000 --- a/src/xunit.runner.kre/project.json +++ /dev/null @@ -1,47 +0,0 @@ -{ - "version": "1.0.0-*", - "frameworks": { - "aspnet50": { - "frameworkAssemblies": { - "System.Configuration": "", - "System.Reflection": "", - "System.Runtime": "", - "System.Threading.Tasks": "", - "System.Web": "", - "System.Web.Extensions": "", - "System.XML": "", - "System.Xml.Linq": "" - } - }, - "aspnetcore50": { - "dependencies": { - "System.Collections": "4.0.10-beta-*", - "System.Collections.Concurrent": "4.0.0-beta-*", - "System.Console": "4.0.0-beta-*", - "System.Diagnostics.Debug": "4.0.10-beta-*", - "System.Diagnostics.Tools": "4.0.0-beta-*", - "System.Globalization": "4.0.10-beta-*", - "System.IO.FileSystem": "4.0.0-beta-*", - "System.Linq": "4.0.0-beta-*", - "System.Reflection": "4.0.10-beta-*", - "System.Reflection.Extensions": "4.0.0-beta-*", - "System.Runtime.Extensions": "4.0.10-beta-*", - "System.Security.Cryptography.Hashing": "4.0.0-beta-*", - "System.Security.Cryptography.Hashing.Algorithms": "4.0.0-beta-*", - "System.Text.RegularExpressions": "4.0.0-beta-*", - "System.Threading": "4.0.0-beta-*", - "System.Threading.ExecutionContext": "4.0.0-beta-*", - "System.Threading.Thread": "4.0.0-beta-*", - "System.Threading.ThreadPool": "4.0.10-beta-*", - "System.Xml.XDocument": "4.0.0-beta-*" - } - } - }, - "dependencies": { - "Microsoft.Framework.TestAdapter": "1.0.0-*", - "Microsoft.Framework.TestHost": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", - "xunit.execution": "2.0.0-beta5-build2785", - "xunit.runner.utility": "2.0.0-beta5-build2785" - } -} diff --git a/src/xunit.runner.kre/xunit.runner.kre.kproj b/src/xunit.runner.kre/xunit.runner.kre.kproj deleted file mode 100644 index 2916d7acb7b..00000000000 --- a/src/xunit.runner.kre/xunit.runner.kre.kproj +++ /dev/null @@ -1,21 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - 002d321e-170e-4e55-bdd1-77c6353a6eb5 - Library - - - - - - - - 2.0 - - - \ No newline at end of file diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 6081f8ca185..e1fd82cf556 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,11 +1,10 @@ { "version": "1.0.0-*", "dependencies": { - "xunit": "2.0.0-beta5-build2785", - "xunit.runner.kre": "1.0.0-*" + "Xunit.KRunner": "1.0.0-*" }, "commands": { - "test": "xunit.runner.kre" + "test": "Xunit.KRunner" }, "frameworks": { "aspnet50": { }, From cffdc41e86f36a064c9e323da8b76477a85f04f3 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 11 Dec 2014 13:20:37 -0800 Subject: [PATCH 089/463] Remove Xunit.KRunner --- Testing.sln | 9 +- src/Microsoft.AspNet.Testing/project.json | 3 +- src/Xunit.KRunner/CommandLine.cs | 128 ------- src/Xunit.KRunner/Common/Guard.cs | 17 - .../Common/TestDiscoveryVisitor.cs | 31 -- src/Xunit.KRunner/Common/TestOptionsNames.cs | 15 - .../DesignTime/DesignTimeExecutionVisitor.cs | 68 ---- .../DesignTime/TestCaseExtensions.cs | 28 -- .../Frameworks/TestFrameworkOptions.cs | 43 --- .../Frameworks/v2/XunitDiscoveryOptions.cs | 13 - .../Frameworks/v2/XunitExecutionOptions.cs | 30 -- src/Xunit.KRunner/ParallelismOption.cs | 12 - src/Xunit.KRunner/Program.cs | 278 -------------- src/Xunit.KRunner/Utility/ExceptionUtility.cs | 137 ------- src/Xunit.KRunner/Utility/ExecutionSummary.cs | 31 -- .../Visitors/StandardOutputVisitor.cs | 139 ------- src/Xunit.KRunner/Visitors/TeamCityVisitor.cs | 121 ------ .../Visitors/TestMessageVisitor.cs | 362 ------------------ .../Visitors/XmlTestExecutionVisitor.cs | 57 --- src/Xunit.KRunner/Xunit.KRunner.kproj | 17 - src/Xunit.KRunner/project.json | 20 - .../TestHostTest.cs | 72 ++-- .../project.json | 5 +- test/Sample.Tests/project.json | 4 +- 24 files changed, 42 insertions(+), 1598 deletions(-) delete mode 100644 src/Xunit.KRunner/CommandLine.cs delete mode 100644 src/Xunit.KRunner/Common/Guard.cs delete mode 100644 src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs delete mode 100644 src/Xunit.KRunner/Common/TestOptionsNames.cs delete mode 100644 src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs delete mode 100644 src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs delete mode 100644 src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs delete mode 100644 src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs delete mode 100644 src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs delete mode 100644 src/Xunit.KRunner/ParallelismOption.cs delete mode 100644 src/Xunit.KRunner/Program.cs delete mode 100644 src/Xunit.KRunner/Utility/ExceptionUtility.cs delete mode 100644 src/Xunit.KRunner/Utility/ExecutionSummary.cs delete mode 100644 src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs delete mode 100644 src/Xunit.KRunner/Visitors/TeamCityVisitor.cs delete mode 100644 src/Xunit.KRunner/Visitors/TestMessageVisitor.cs delete mode 100644 src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs delete mode 100644 src/Xunit.KRunner/Xunit.KRunner.kproj delete mode 100644 src/Xunit.KRunner/project.json diff --git a/Testing.sln b/Testing.sln index 7a62f70b6e6..3bafb8e42a6 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,14 +1,12 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22201.0 +VisualStudioVersion = 14.0.22310.1 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{09F799F3-E521-466F-B155-B89E2746C8C9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Xunit.KRunner", "src\Xunit.KRunner\Xunit.KRunner.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B7061}" -EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.kproj", "{09BE5203-8042-4338-9713-E44169342E72}" EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample.Tests", "test\Sample.Tests\Sample.Tests.kproj", "{25D18D0B-119C-4AB4-BCA6-AC06179335FA}" @@ -29,10 +27,6 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {F003F228-2AE2-4E9D-877B-93EB773B7061}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F003F228-2AE2-4E9D-877B-93EB773B7061}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F003F228-2AE2-4E9D-877B-93EB773B7061}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F003F228-2AE2-4E9D-877B-93EB773B7061}.Release|Any CPU.Build.0 = Release|Any CPU {09BE5203-8042-4338-9713-E44169342E72}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {09BE5203-8042-4338-9713-E44169342E72}.Debug|Any CPU.Build.0 = Debug|Any CPU {09BE5203-8042-4338-9713-E44169342E72}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -66,7 +60,6 @@ Global HideSolutionNode = FALSE EndGlobalSection GlobalSection(NestedProjects) = preSolution - {F003F228-2AE2-4E9D-877B-93EB773B7061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {09BE5203-8042-4338-9713-E44169342E72} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0B-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} {62BE2FA4-6B9D-4296-9178-5FC2F66372AB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 9f10539e85d..2838779decd 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,8 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*" + "xunit.runner.kre": "1.0.0-*" }, "frameworks": { "aspnet50": { diff --git a/src/Xunit.KRunner/CommandLine.cs b/src/Xunit.KRunner/CommandLine.cs deleted file mode 100644 index 1b0a51b91ae..00000000000 --- a/src/Xunit.KRunner/CommandLine.cs +++ /dev/null @@ -1,128 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; - -namespace Xunit.ConsoleClient -{ - public class CommandLine - { - readonly Stack arguments = new Stack(); - - protected CommandLine(string[] args) - { - for (int i = args.Length - 1; i >= 0; i--) - arguments.Push(args[i]); - - TeamCity = Environment.GetEnvironmentVariable("TEAMCITY_PROJECT_NAME") != null; - ParallelizeTestCollections = true; - Tests = new List(); - Parse(); - } - - public bool DesignTime { get; set; } - - public bool List { get; set; } - - public int MaxParallelThreads { get; set; } - - public bool ParallelizeTestCollections { get; set; } - - public bool TeamCity { get; protected set; } - - public List Tests { get; private set; } - - static void GuardNoOptionValue(KeyValuePair option) - { - if (option.Value != null) - throw new ArgumentException(String.Format("error: unknown command line option: {0}", option.Value)); - } - - public static CommandLine Parse(params string[] args) - { - return new CommandLine(args); - } - - protected virtual void Parse() - { - while (arguments.Count > 0) - { - var option = PopOption(arguments); - var optionName = option.Key.ToLowerInvariant(); - - if (!optionName.StartsWith("-")) - throw new ArgumentException(String.Format("unknown command line option: {0}", option.Key)); - - if (optionName == "-maxthreads") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -maxthreads"); - - int threadValue; - if (!Int32.TryParse(option.Value, out threadValue) || threadValue < 0) - throw new ArgumentException("incorrect argument value for -maxthreads"); - - MaxParallelThreads = threadValue; - } - else if (optionName == "-parallel") - { - if (option.Value == null) - throw new ArgumentException("missing argument for -parallel"); - - ParallelismOption parallelismOption; - if (!Enum.TryParse(option.Value, out parallelismOption)) - throw new ArgumentException("incorrect argument value for -parallel"); - - switch (parallelismOption) - { - case ParallelismOption.all: - case ParallelismOption.collections: - ParallelizeTestCollections = true; - break; - - case ParallelismOption.none: - default: - ParallelizeTestCollections = false; - break; - } - } - else if (optionName == "--test") - { - if (option.Value == null) - { - throw new ArgumentException("missing argument for --test"); - } - - Tests.AddRange(option.Value.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)); - } - else if (optionName == "-teamcity") - { - GuardNoOptionValue(option); - TeamCity = true; - } - else if (optionName == "--list") - { - GuardNoOptionValue(option); - List = true; - } - else if (optionName == "--designtime") - { - GuardNoOptionValue(option); - DesignTime = true; - } - } - } - - static KeyValuePair PopOption(Stack arguments) - { - string option = arguments.Pop(); - string value = null; - - if (arguments.Count > 0 && !arguments.Peek().StartsWith("-")) - value = arguments.Pop(); - - return new KeyValuePair(option, value); - } - } -} diff --git a/src/Xunit.KRunner/Common/Guard.cs b/src/Xunit.KRunner/Common/Guard.cs deleted file mode 100644 index 34bd8667f81..00000000000 --- a/src/Xunit.KRunner/Common/Guard.cs +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; - -/// -/// Guard class, used for guard clauses and argument validation -/// -internal static class Guard -{ - /// - public static void ArgumentNotNull(string argName, object argValue) - { - if (argValue == null) - throw new ArgumentNullException(argName); - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs b/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs deleted file mode 100644 index 69e67f2abac..00000000000 --- a/src/Xunit.KRunner/Common/TestDiscoveryVisitor.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; -using Xunit.Abstractions; - -namespace Xunit -{ - internal class TestDiscoveryVisitor : TestMessageVisitor - { - public TestDiscoveryVisitor() - { - TestCases = new List(); - } - - public List TestCases { get; private set; } - - public override void Dispose() - { - foreach (var testCase in TestCases) testCase.Dispose(); - TestCases = null; - } - - protected override bool Visit(ITestCaseDiscoveryMessage discovery) - { - TestCases.Add(discovery.TestCase); - - return true; - } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Common/TestOptionsNames.cs b/src/Xunit.KRunner/Common/TestOptionsNames.cs deleted file mode 100644 index c998c8c4bd7..00000000000 --- a/src/Xunit.KRunner/Common/TestOptionsNames.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -internal static class TestOptionsNames -{ - internal static class Discovery - { - } - - internal static class Execution - { - public static readonly string DisableParallelization = "xunit.DisableParallelization"; - public static readonly string MaxParallelThreads = "xunit.MaxParallelThreads"; - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs b/src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs deleted file mode 100644 index 689f8ee3e9b..00000000000 --- a/src/Xunit.KRunner/DesignTime/DesignTimeExecutionVisitor.cs +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Microsoft.Framework.TestAdapter; -using Xunit.Abstractions; - -namespace Xunit.KRunner -{ - public class DesignTimeExecutionVisitor : TestMessageVisitor - { - private readonly ITestExecutionSink _sink; - - public DesignTimeExecutionVisitor(ITestExecutionSink sink) - { - _sink = sink; - } - - protected override bool Visit(ITestStarting testStarting) - { - _sink.RecordStart(testStarting.TestCase.ToDesignTimeTest()); - return base.Visit(testStarting); - } - - protected override bool Visit(ITestSkipped testSkipped) - { - var test = testSkipped.TestCase.ToDesignTimeTest(); - _sink.RecordResult(new TestResult(test) - { - Outcome = TestOutcome.Skipped, - }); - - return base.Visit(testSkipped); - } - - protected override bool Visit(ITestFailed testFailed) - { - var test = testFailed.TestCase.ToDesignTimeTest(); - var result = new TestResult(test) - { - Outcome = TestOutcome.Failed, - - Duration = TimeSpan.FromSeconds((double)testFailed.ExecutionTime), - ErrorMessage = string.Join(Environment.NewLine, testFailed.Messages), - ErrorStackTrace = string.Join(Environment.NewLine, testFailed.StackTraces), - }; - - result.Messages.Add(testFailed.Output); - - _sink.RecordResult(result); - - return base.Visit(testFailed); - } - - protected override bool Visit(ITestPassed testPassed) - { - var test = testPassed.TestCase.ToDesignTimeTest(); - _sink.RecordResult(new TestResult(test) - { - Outcome = TestOutcome.Passed, - - Duration = TimeSpan.FromSeconds((double)testPassed.ExecutionTime), - }); - - return base.Visit(testPassed); - } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs b/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs deleted file mode 100644 index 97b9d8c91c0..00000000000 --- a/src/Xunit.KRunner/DesignTime/TestCaseExtensions.cs +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using Microsoft.Framework.TestAdapter; -using Xunit.Abstractions; - -namespace Xunit.KRunner -{ - public static class TestCaseExtensions - { - public static Test ToDesignTimeTest(this ITestCase testCase) - { - var test = new Test() - { - DisplayName = testCase.DisplayName, - FullyQualifiedName = testCase.UniqueID, - }; - - if (testCase.SourceInformation != null) - { - test.CodeFilePath = testCase.SourceInformation.FileName; - test.LineNumber = testCase.SourceInformation.LineNumber; - } - - return test; - } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs b/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs deleted file mode 100644 index fd40c9410f8..00000000000 --- a/src/Xunit.KRunner/Frameworks/TestFrameworkOptions.cs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; -using Xunit.Abstractions; - -namespace Xunit -{ - /// - /// Represents options passed to a test framework for discovery or execution. - /// - public class TestFrameworkOptions : ITestFrameworkOptions - { - readonly Dictionary properties = new Dictionary(); - - /// - /// Gets a value from the options collection. - /// - /// The type of the value. - /// The name of the value. - /// The default value to use if the value is not present. - /// Returns the value. - public TValue GetValue(string name, TValue defaultValue) - { - object result; - if (properties.TryGetValue(name, out result)) - return (TValue)result; - - return defaultValue; - } - - /// - /// Sets a value into the options collection. - /// - /// The type of the value. - /// The name of the value. - /// The value. - public void SetValue(string name, TValue value) - { - properties[name] = value; - } - } -} diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs deleted file mode 100644 index a866b24b565..00000000000 --- a/src/Xunit.KRunner/Frameworks/v2/XunitDiscoveryOptions.cs +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Xunit -{ - /// - /// Represents discovery options for xUnit.net v2 tests. - /// - // TODO: Need to figure out what might go here - public class XunitDiscoveryOptions : TestFrameworkOptions - { - } -} diff --git a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs b/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs deleted file mode 100644 index 96721a30509..00000000000 --- a/src/Xunit.KRunner/Frameworks/v2/XunitExecutionOptions.cs +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Xunit -{ - /// - /// Represents execution options for xUnit.net v2 tests. - /// - public class XunitExecutionOptions : TestFrameworkOptions - { - /// - /// Gets or sets a flag to disable parallelization. - /// - public bool DisableParallelization - { - get { return GetValue(TestOptionsNames.Execution.DisableParallelization, false); } - set { SetValue(TestOptionsNames.Execution.DisableParallelization, value); } - } - - /// - /// Gets or sets the maximum number of threads to use when running tests in parallel. - /// If set to 0 (the default value), does not limit the number of threads. - /// - public int MaxParallelThreads - { - get { return GetValue(TestOptionsNames.Execution.MaxParallelThreads, 0); } - set { SetValue(TestOptionsNames.Execution.MaxParallelThreads, value); } - } - } -} diff --git a/src/Xunit.KRunner/ParallelismOption.cs b/src/Xunit.KRunner/ParallelismOption.cs deleted file mode 100644 index 5a5152bb45c..00000000000 --- a/src/Xunit.KRunner/ParallelismOption.cs +++ /dev/null @@ -1,12 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Xunit.ConsoleClient -{ - public enum ParallelismOption - { - none, - collections, - all - } -} diff --git a/src/Xunit.KRunner/Program.cs b/src/Xunit.KRunner/Program.cs deleted file mode 100644 index 792358d26cc..00000000000 --- a/src/Xunit.KRunner/Program.cs +++ /dev/null @@ -1,278 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Concurrent; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using Microsoft.Framework.Runtime; -using Microsoft.Framework.TestAdapter; -using Xunit.Abstractions; -using Xunit.ConsoleClient; -using Xunit.Sdk; -#if !ASPNET50 -using System.Diagnostics; -#endif - -namespace Xunit.KRunner -{ - public class Program - { - volatile bool cancel; - bool failed; - readonly ConcurrentDictionary completionMessages = new ConcurrentDictionary(); - private readonly IApplicationEnvironment _environment; - private readonly IFileMonitor _fileMonitor; - private readonly IServiceProvider _services; - - public Program(IServiceProvider services, IApplicationEnvironment environment, IFileMonitor fileMonitor) - { - _services = services; - _environment = environment; - _fileMonitor = fileMonitor; - } - - public int Main(string[] args) - { - Console.WriteLine("xUnit.net Project K test runner ({0}-bit {1})", IntPtr.Size * 8, _environment.RuntimeFramework); - Console.WriteLine("Copyright (C) 2014 Outercurve Foundation, Microsoft Open Technologies, Inc."); - Console.WriteLine(); - - if (args.Length > 0 && args[0] == "-?") - { - PrintUsage(); - return 1; - } - -#if ASPNET50 - AppDomain.CurrentDomain.UnhandledException += OnUnhandledException; - - Console.CancelKeyPress += (sender, e) => - { - if (!cancel) - { - Console.WriteLine("Canceling... (Press Ctrl+C again to terminate)"); - cancel = true; - e.Cancel = true; - } - }; - _fileMonitor.OnChanged += _ => Environment.Exit(-409); -#else - _fileMonitor.OnChanged += _ => Process.GetCurrentProcess().Kill(); -#endif - - try - { - var commandLine = CommandLine.Parse(args); - - int failCount = RunProject(commandLine); - - return failCount; - } - catch (ArgumentException ex) - { - Console.WriteLine("error: {0}", ex.Message); - Console.WriteLine(ex); - return 1; - } - catch (BadImageFormatException ex) - { - Console.WriteLine("{0}", ex.Message); - Console.WriteLine(ex); - return 1; - } - } - -#if ASPNET50 - static void OnUnhandledException(object sender, UnhandledExceptionEventArgs e) - { - var ex = e.ExceptionObject as Exception; - - if (ex != null) - Console.WriteLine(ex.ToString()); - else - Console.WriteLine("Error of unknown type thrown in application domain"); - - - Environment.Exit(1); - } -#endif - - static void PrintUsage() - { - Console.WriteLine("usage: Xunit.KRunner [options]"); - Console.WriteLine(); - Console.WriteLine("Valid options:"); - Console.WriteLine(" -parallel option : set parallelization based on option"); - Console.WriteLine(" : none - turn off all parallelization"); - Console.WriteLine(" : collections - only parallelize collections"); - Console.WriteLine(" : all - parallelize collections"); - Console.WriteLine(" -maxthreads count : maximum thread count for collection parallelization"); - Console.WriteLine(" : 0 - run with unbounded thread count"); - Console.WriteLine(" : >0 - limit task thread pool size to 'count'"); - Console.WriteLine(" -teamcity : forces TeamCity mode (normally auto-detected)"); - } - - int RunProject(CommandLine options) - { - var consoleLock = new object(); - - ExecuteAssembly(consoleLock, _environment.ApplicationName, options); - - if (completionMessages.Count > 0) - { - Console.WriteLine(); - Console.WriteLine("=== TEST EXECUTION SUMMARY ==="); - int longestAssemblyName = completionMessages.Keys.Max(key => key.Length); - int longestTotal = completionMessages.Values.Max(summary => summary.Total.ToString().Length); - int longestFailed = completionMessages.Values.Max(summary => summary.Failed.ToString().Length); - int longestSkipped = completionMessages.Values.Max(summary => summary.Skipped.ToString().Length); - int longestTime = completionMessages.Values.Max(summary => summary.Time.ToString("0.000s").Length); - - foreach (var message in completionMessages.OrderBy(m => m.Key)) - Console.WriteLine(" {0} Total: {1}, Failed: {2}, Skipped: {3}, Time: {4}", - message.Key.PadRight(longestAssemblyName), - message.Value.Total.ToString().PadLeft(longestTotal), - message.Value.Failed.ToString().PadLeft(longestFailed), - message.Value.Skipped.ToString().PadLeft(longestSkipped), - message.Value.Time.ToString("0.000s").PadLeft(longestTime)); - } - - return failed ? 1 : completionMessages.Values.Sum(summary => summary.Failed); - } - - TestMessageVisitor CreateVisitor(object consoleLock, CommandLine options) - { - if (options.TeamCity) - { - return new TeamCityVisitor(() => cancel); - } - - if (options.DesignTime) - { - var executionSink = (ITestExecutionSink)_services.GetService(typeof(ITestExecutionSink)); - if (executionSink != null) - { - return new DesignTimeExecutionVisitor(executionSink); - } - } - - return new StandardOutputVisitor(consoleLock, () => cancel, completionMessages); - } - - void ExecuteAssembly(object consoleLock, string assemblyName, CommandLine options) - { - if (cancel) - return; - - try - { - var name = new AssemblyName(assemblyName); - var assembly = Reflector.Wrap(Assembly.Load(name)); - var framework = GetFramework(assembly); - var discoverer = framework.GetDiscoverer(assembly); - var executor = framework.GetExecutor(name); - var discoveryVisitor = new TestDiscoveryVisitor(); - - discoverer.Find(includeSourceInformation: true, messageSink: discoveryVisitor, options: new TestFrameworkOptions()); - discoveryVisitor.Finished.WaitOne(); - - if (options.List) - { - ITestDiscoverySink discoverySink = null; - if (options.DesignTime) - { - discoverySink = (ITestDiscoverySink)_services.GetService(typeof(ITestDiscoverySink)); - } - - lock (consoleLock) - { - foreach (var test in discoveryVisitor.TestCases) - { - if (discoverySink != null) - { - discoverySink.SendTest(test.ToDesignTimeTest()); - } - - Console.WriteLine(test.DisplayName); - } - } - - return; - } - - var executionOptions = new XunitExecutionOptions { DisableParallelization = !options.ParallelizeTestCollections, MaxParallelThreads = options.MaxParallelThreads }; - var resultsVisitor = CreateVisitor(consoleLock, options); - - var tests = discoveryVisitor.TestCases; - if (options.Tests != null && options.Tests.Count > 0) - { - tests = tests.Where(t => IsTestNameMatch(t, options.Tests)).ToList(); - } - - executor.RunTests(tests, resultsVisitor, executionOptions); - resultsVisitor.Finished.WaitOne(); - - // When executing under TeamCity, we record the results in a format TeamCity understands, but do not return an error code. - // This causes TeamCity to treat the step as completed, but the build as failed. We'll work around this by special casing the TeamCityVisitor - var teamCityVisitor = resultsVisitor as TeamCityVisitor; - if (teamCityVisitor != null) - { - failed = teamCityVisitor.Failed > 0; - } - } - catch (Exception ex) - { - Console.WriteLine("{0}: {1}", ex.GetType().FullName, ex.Message); - Console.WriteLine(ex); - - failed = true; - } - } - - ITestFramework GetFramework(IAssemblyInfo assemblyInfo) - { - var frameworkAttribute = assemblyInfo.GetCustomAttributes(typeof(TestFrameworkAttribute)).FirstOrDefault(); - if (frameworkAttribute == null) - { - return new XunitTestFramework(); - } - var ctorArgs = frameworkAttribute.GetConstructorArguments().Cast().ToArray(); - var testFrameworkType = Reflector.GetType(ctorArgs[1], ctorArgs[0]); - var framework = Activator.CreateInstance(testFrameworkType) as ITestFramework; - return framework ?? new XunitTestFramework(); - } - - // Performs fuzzy matching for test names specified at the commandline. - // - test name specified at the command line might be a test uniqueId (guid) OR - // - test name might be a full test display name (including parameters) - // - test name might be the test class + method name - private bool IsTestNameMatch(ITestCase test, IList testNames) - { - foreach (var testName in testNames) - { - if (string.Equals(testName, test.UniqueID, StringComparison.Ordinal)) - { - return true; - } - else if (string.Equals(testName, test.DisplayName, StringComparison.Ordinal)) - { - return true; - } - else if (!testName.Contains('(') && test.DisplayName.Contains('(')) - { - // No parameters in testName, and parameters in the displayname, it might be - // the 'short' display name (without parameters). - var shortName = test.DisplayName.Substring(0, test.DisplayName.IndexOf('(')); - if (string.Equals(testName, shortName, StringComparison.Ordinal)) - { - return true; - } - } - } - - return false; - } - } -} diff --git a/src/Xunit.KRunner/Utility/ExceptionUtility.cs b/src/Xunit.KRunner/Utility/ExceptionUtility.cs deleted file mode 100644 index b64b71369ee..00000000000 --- a/src/Xunit.KRunner/Utility/ExceptionUtility.cs +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Generic; -using Xunit.Abstractions; - -namespace Xunit -{ - /// - /// Utility classes for dealing with Exception objects. - /// - public static class ExceptionUtility - { - /// - /// Combines multiple levels of messages into a single message. - /// - /// The failure information from which to get the messages. - /// The combined string. - public static string CombineMessages(IFailureInformation failureInfo) - { - return GetMessage(failureInfo, 0, 0); - } - - /// - /// Combines multiple levels of stack traces into a single stack trace. - /// - /// The failure information from which to get the stack traces. - /// The combined string. - public static string CombineStackTraces(IFailureInformation failureInfo) - { - return GetStackTrace(failureInfo, 0); - } - - static bool ExcludeStackFrame(string stackFrame) - { - Guard.ArgumentNotNull("stackFrame", stackFrame); - - return stackFrame.StartsWith("at Xunit.", StringComparison.Ordinal); - } - - static string FilterStackTrace(string stack) - { - if (stack == null) - return null; - - var results = new List(); - - foreach (string line in SplitLines(stack)) - { - string trimmedLine = line.TrimStart(); - if (!ExcludeStackFrame(trimmedLine)) - results.Add(line); - } - - return string.Join(Environment.NewLine, results.ToArray()); - } - - static string GetMessage(IFailureInformation failureInfo, int index, int level) - { - string result = ""; - - if (level > 0) - { - for (int idx = 0; idx < level; idx++) - result += "----"; - - result += " "; - } - - var exceptionType = failureInfo.ExceptionTypes[index]; - if (GetNamespace(exceptionType) != "Xunit.Sdk") - result += exceptionType + " : "; - - result += failureInfo.Messages[index]; - - for (int subIndex = index + 1; subIndex < failureInfo.ExceptionParentIndices.Length; ++subIndex) - if (failureInfo.ExceptionParentIndices[subIndex] == index) - result += Environment.NewLine + GetMessage(failureInfo, subIndex, level + 1); - - return result; - } - - private static string GetNamespace(string exceptionType) - { - var nsIndex = exceptionType.LastIndexOf('.'); - if (nsIndex > 0) - return exceptionType.Substring(0, nsIndex); - - return ""; - } - - static string GetStackTrace(IFailureInformation failureInfo, int index) - { - string result = FilterStackTrace(failureInfo.StackTraces[index]); - - var children = new List(); - for (int subIndex = index + 1; subIndex < failureInfo.ExceptionParentIndices.Length; ++subIndex) - if (failureInfo.ExceptionParentIndices[subIndex] == index) - children.Add(subIndex); - - if (children.Count > 1) - { - for (int idx = 0; idx < children.Count; ++idx) - result += String.Format("{0}----- Inner Stack Trace #{1} ({2}) -----{0}{3}", - Environment.NewLine, - idx + 1, - failureInfo.ExceptionTypes[children[idx]], - GetStackTrace(failureInfo, children[idx])); - } - else if (children.Count == 1) - result += Environment.NewLine + - "----- Inner Stack Trace -----" + Environment.NewLine + - GetStackTrace(failureInfo, children[0]); - - return result; - } - - // Our own custom String.Split because Silverlight/CoreCLR doesn't support the version we were using - static IEnumerable SplitLines(string input) - { - while (true) - { - int idx = input.IndexOf(Environment.NewLine); - - if (idx < 0) - { - yield return input; - break; - } - - yield return input.Substring(0, idx); - input = input.Substring(idx + Environment.NewLine.Length); - } - } - } -} diff --git a/src/Xunit.KRunner/Utility/ExecutionSummary.cs b/src/Xunit.KRunner/Utility/ExecutionSummary.cs deleted file mode 100644 index 94be1c2b559..00000000000 --- a/src/Xunit.KRunner/Utility/ExecutionSummary.cs +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -namespace Xunit -{ - /// - /// Collects execution totals for a group of test cases. - /// - public class ExecutionSummary - { - /// - /// Gets or set the total number of tests run. - /// - public int Total { get; set; } - - /// - /// Gets or sets the number of failed tests. - /// - public int Failed { get; set; } - - /// - /// Gets or sets the number of skipped tests. - /// - public int Skipped { get; set; } - - /// - /// Gets or sets the total execution time for the tests. - /// - public decimal Time { get; set; } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs b/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs deleted file mode 100644 index bacd7fd6eb3..00000000000 --- a/src/Xunit.KRunner/Visitors/StandardOutputVisitor.cs +++ /dev/null @@ -1,139 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Concurrent; -using Xunit.Abstractions; - -namespace Xunit.ConsoleClient -{ - public class StandardOutputVisitor : XmlTestExecutionVisitor - { - string assemblyName; - readonly object consoleLock; - readonly ConcurrentDictionary completionMessages; - - public StandardOutputVisitor(object consoleLock, - Func cancelThunk, - ConcurrentDictionary completionMessages = null) - : base(cancelThunk) - { - this.consoleLock = consoleLock; - this.completionMessages = completionMessages; - } - - protected override bool Visit(ITestAssemblyStarting assemblyStarting) - { - assemblyName = assemblyStarting.AssemblyFileName; - - lock (consoleLock) - Console.WriteLine("Starting: {0}", assemblyName); - - return base.Visit(assemblyStarting); - } - - protected override bool Visit(ITestAssemblyFinished assemblyFinished) - { - // Base class does computation of results, so call it first. - var result = base.Visit(assemblyFinished); - - lock (consoleLock) - Console.WriteLine("Finished: {0}", assemblyName); - - if (completionMessages != null) - completionMessages.TryAdd(assemblyName, new ExecutionSummary - { - Total = assemblyFinished.TestsRun, - Failed = assemblyFinished.TestsFailed, - Skipped = assemblyFinished.TestsSkipped, - Time = assemblyFinished.ExecutionTime - }); - - return result; - } - - protected override bool Visit(IErrorMessage error) - { - lock (consoleLock) - { -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Red; -#endif - Console.Error.WriteLine(" {0} [FATAL]", Escape(error.ExceptionTypes[0])); -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Gray; -#endif - Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(error))); - - WriteStackTrace(ExceptionUtility.CombineStackTraces(error)); - } - - return base.Visit(error); - } - - protected override bool Visit(ITestFailed testFailed) - { - lock (consoleLock) - { - // TODO: Thread-safe way to figure out the default foreground color -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Red; -#endif - Console.Error.WriteLine(" {0} [FAIL]", Escape(testFailed.TestDisplayName)); -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Gray; -#endif - Console.Error.WriteLine(" {0}", Escape(ExceptionUtility.CombineMessages(testFailed))); - - WriteStackTrace(ExceptionUtility.CombineStackTraces(testFailed)); - } - - return base.Visit(testFailed); - } - - protected override bool Visit(ITestPassed testPassed) - { - return base.Visit(testPassed); - } - - protected override bool Visit(ITestSkipped testSkipped) - { - lock (consoleLock) - { - // TODO: Thread-safe way to figure out the default foreground color -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Yellow; -#endif - Console.Error.WriteLine(" {0} [SKIP]", Escape(testSkipped.TestDisplayName)); -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Gray; -#endif - Console.Error.WriteLine(" {0}", Escape(testSkipped.Reason)); - } - - return base.Visit(testSkipped); - } - - protected override bool Visit(ITestStarting testStarting) - { - return base.Visit(testStarting); - } - - void WriteStackTrace(string stackTrace) - { - if (String.IsNullOrWhiteSpace(stackTrace)) - return; - -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.DarkGray; -#endif - Console.Error.WriteLine(" Stack Trace:"); - -#if ASPNET50 - Console.ForegroundColor = ConsoleColor.Gray; -#endif - foreach (var stackFrame in stackTrace.Split(new[] { Environment.NewLine }, StringSplitOptions.None)) - Console.Error.WriteLine(" {0}", stackFrame); - } - } -} diff --git a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs b/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs deleted file mode 100644 index 5412b33f1e2..00000000000 --- a/src/Xunit.KRunner/Visitors/TeamCityVisitor.cs +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Collections.Concurrent; -using Xunit.Abstractions; - -namespace Xunit.ConsoleClient -{ - public class TeamCityVisitor : XmlTestExecutionVisitor - { - readonly ConcurrentDictionary flowMappings = new ConcurrentDictionary(); - readonly Func flowIdMapper; - - public TeamCityVisitor(Func cancelThunk) - : this(cancelThunk, _ => Guid.NewGuid().ToString("N")) { } - - public TeamCityVisitor(Func cancelThunk, Func flowIdMapper) - : base(cancelThunk) - { - this.flowIdMapper = flowIdMapper; - } - - void LogFinish(ITestResultMessage testResult) - { - Console.WriteLine("##teamcity[testFinished name='{0}' duration='{1}' flowId='{2}']", - TeamCityEscape(testResult.TestDisplayName), - (int)(testResult.ExecutionTime * 1000M), - ToFlowId(testResult.TestCollection.DisplayName)); - } - - protected override bool Visit(IErrorMessage error) - { - Console.Error.WriteLine("{0}: {1}", error.ExceptionTypes[0], Escape(ExceptionUtility.CombineMessages(error))); - Console.Error.WriteLine(ExceptionUtility.CombineStackTraces(error)); - - return base.Visit(error); - } - - protected override bool Visit(ITestCollectionFinished testCollectionFinished) - { - // Base class does computation of results, so call it first. - var result = base.Visit(testCollectionFinished); - - Console.WriteLine("##teamcity[testSuiteFinished name='{0}' flowId='{1}']", - TeamCityEscape(testCollectionFinished.TestCollection.DisplayName), - ToFlowId(testCollectionFinished.TestCollection.DisplayName)); - - return result; - } - - protected override bool Visit(ITestCollectionStarting testCollectionStarting) - { - Console.WriteLine("##teamcity[testSuiteStarted name='{0}' flowId='{1}']", - TeamCityEscape(testCollectionStarting.TestCollection.DisplayName), - ToFlowId(testCollectionStarting.TestCollection.DisplayName)); - - return base.Visit(testCollectionStarting); - } - - protected override bool Visit(ITestFailed testFailed) - { - Console.WriteLine("##teamcity[testFailed name='{0}' details='{1}|r|n{2}' flowId='{3}']", - TeamCityEscape(testFailed.TestDisplayName), - TeamCityEscape(ExceptionUtility.CombineMessages(testFailed)), - TeamCityEscape(ExceptionUtility.CombineStackTraces(testFailed)), - ToFlowId(testFailed.TestCollection.DisplayName)); - LogFinish(testFailed); - - return base.Visit(testFailed); - } - - protected override bool Visit(ITestPassed testPassed) - { - LogFinish(testPassed); - - return base.Visit(testPassed); - } - - protected override bool Visit(ITestSkipped testSkipped) - { - Console.WriteLine("##teamcity[testIgnored name='{0}' message='{1}' flowId='{2}']", - TeamCityEscape(testSkipped.TestDisplayName), - TeamCityEscape(testSkipped.Reason), - ToFlowId(testSkipped.TestCollection.DisplayName)); - LogFinish(testSkipped); - - return base.Visit(testSkipped); - } - - protected override bool Visit(ITestStarting testStarting) - { - Console.WriteLine("##teamcity[testStarted name='{0}' flowId='{1}']", - TeamCityEscape(testStarting.TestDisplayName), - ToFlowId(testStarting.TestCollection.DisplayName)); - - return base.Visit(testStarting); - } - - static string TeamCityEscape(string value) - { - if (value == null) - return String.Empty; - - return value.Replace("|", "||") - .Replace("'", "|'") - .Replace("\r", "|r") - .Replace("\n", "|n") - .Replace("]", "|]") - .Replace("[", "|[") - .Replace("\u0085", "|x") - .Replace("\u2028", "|l") - .Replace("\u2029", "|p"); - } - - string ToFlowId(string testCollectionName) - { - return flowMappings.GetOrAdd(testCollectionName, flowIdMapper); - } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs b/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs deleted file mode 100644 index 04a7e474d68..00000000000 --- a/src/Xunit.KRunner/Visitors/TestMessageVisitor.cs +++ /dev/null @@ -1,362 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using System.Threading; -using Xunit.Abstractions; - -namespace Xunit -{ - /// - /// An implementation of that provides several Visit methods that - /// can provide access to specific message types without the burden of casting. - /// - public class TestMessageVisitor : IMessageSink - { - bool DoVisit(IMessageSinkMessage message, Func callback) - where TMessage : class, IMessageSinkMessage - { - TMessage castMessage = message as TMessage; - if (castMessage != null) - return callback(castMessage); - - return true; - } - - /// - public virtual bool OnMessage(IMessageSinkMessage message) - { - return - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit) && - DoVisit(message, Visit); - } - - public virtual void Dispose() - { - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(IAfterTestFinished afterTestFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(IAfterTestStarting afterTestStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(IBeforeTestFinished beforeTestFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(IBeforeTestStarting beforeTestStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue discovering tests; false otherwise. - protected virtual bool Visit(IDiscoveryCompleteMessage discoveryComplete) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(IErrorMessage error) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestAssemblyFinished assemblyFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestAssemblyStarting assemblyStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue discovering tests; false otherwise. - protected virtual bool Visit(ITestCaseDiscoveryMessage testCaseDiscovered) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestCaseFinished testCaseFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestCaseStarting testCaseStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestClassConstructionFinished testClassConstructionFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestClassConstructionStarting testClassConstructionStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestClassDisposeFinished testClassDisposedFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestClassDisposeStarting testClassDisposeStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestClassFinished testClassFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestClassStarting testClassStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestCollectionFinished testCollectionFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestCollectionStarting testCollectionStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestFailed testFailed) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestFinished testFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestMethodFinished testMethodFinished) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestMethodStarting testMethodStarting) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestPassed testPassed) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestSkipped testSkipped) - { - return true; - } - - /// - /// Called when an instance of is sent to the message sink. - /// - /// The message. - /// Return true to continue executing tests; false otherwise. - protected virtual bool Visit(ITestStarting testStarting) - { - return true; - } - } - - /// - /// An implementation of that provides several Visit methods that - /// can provide access to specific message types without the burden of casting. It also record - /// when it sees a completion message, and sets the event appropriately. - /// - /// The type of the completion message. - public class TestMessageVisitor : TestMessageVisitor - where TCompleteMessage : IMessageSinkMessage - { - /// - /// Initializes a new instance of the class. - /// - public TestMessageVisitor() - { - Finished = new ManualResetEvent(initialState: false); - } - - /// - /// This event is trigged when the completion message has been seen. - /// - public ManualResetEvent Finished { get; private set; } - - /// - public override void Dispose() - { - ((IDisposable)Finished).Dispose(); - } - - /// - public override bool OnMessage(IMessageSinkMessage message) - { - var result = base.OnMessage(message); - - if (message is TCompleteMessage) - Finished.Set(); - - return result; - } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs b/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs deleted file mode 100644 index 07bcc264143..00000000000 --- a/src/Xunit.KRunner/Visitors/XmlTestExecutionVisitor.cs +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System; -using Xunit.Abstractions; - -namespace Xunit -{ - public class XmlTestExecutionVisitor : TestMessageVisitor - { - public XmlTestExecutionVisitor(Func cancelThunk) - { - CancelThunk = cancelThunk ?? (() => false); - } - - public readonly Func CancelThunk; - public int Failed; - public int Skipped; - public decimal Time; - public int Total; - - public override bool OnMessage(IMessageSinkMessage message) - { - var result = base.OnMessage(message); - if (result) - result = !CancelThunk(); - - return result; - } - - protected override bool Visit(ITestAssemblyFinished assemblyFinished) - { - Total += assemblyFinished.TestsRun; - Failed += assemblyFinished.TestsFailed; - Skipped += assemblyFinished.TestsSkipped; - Time += assemblyFinished.ExecutionTime; - - return base.Visit(assemblyFinished); - } - - protected static string Escape(string value) - { - if (value == null) - return String.Empty; - - return value.Replace("\r", "\\r").Replace("\n", "\\n").Replace("\t", "\\t").Replace("\0", "\\0"); - } - - protected static string XmlEscape(string value) - { - if (value == null) - return String.Empty; - - return value.Replace("\0", "\\0"); - } - } -} \ No newline at end of file diff --git a/src/Xunit.KRunner/Xunit.KRunner.kproj b/src/Xunit.KRunner/Xunit.KRunner.kproj deleted file mode 100644 index 2a511152d41..00000000000 --- a/src/Xunit.KRunner/Xunit.KRunner.kproj +++ /dev/null @@ -1,17 +0,0 @@ - - - - 14.0 - $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - - - - f003f228-2ae2-4e9d-877b-93eb773b7061 - ..\..\artifacts\obj\$(MSBuildProjectName) - ..\..\artifacts\bin\$(MSBuildProjectName)\ - - - 2.0 - - - diff --git a/src/Xunit.KRunner/project.json b/src/Xunit.KRunner/project.json deleted file mode 100644 index 674017a9755..00000000000 --- a/src/Xunit.KRunner/project.json +++ /dev/null @@ -1,20 +0,0 @@ -{ - "version": "1.0.0-*", - "dependencies": { - "Microsoft.Framework.TestAdapter": "1.0.0-*", - "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.TestHost": "1.0.0-*", - "xunit.abstractions": "2.0.0-aspnet-*", - "xunit.assert": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" - }, - "frameworks": { - "aspnet50": { }, - "aspnetcore50": { - "dependencies": { - "System.Console": "4.0.0-beta-*", - "System.Diagnostics.Process": "4.0.0-beta-*" - } - } - } -} diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index f47ab7cc4c6..3e51287f5fe 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -37,17 +37,17 @@ public async Task ListTest() Assert.Equal(0, result); Assert.Equal(8, host.Output.Count); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.True_is_true")); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); - Assert.Single(host.Output, m => TestFound(m, "Sample.Tests.SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.True_is_true")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); + Assert.Single(host.Output, m => TestFound(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "diagnosing ci failures")] + [Fact] public async Task RunTest_All() { // Arrange @@ -60,20 +60,20 @@ public async Task RunTest_All() Assert.Equal(0, result); Assert.Equal(15, host.Output.Count); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.True_is_true")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.True_is_true")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.True_is_true")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.True_is_true")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest2(x: 1, s: \"Hi\")")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest2(x: 2, s: \"Hi\")")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest2(x: 3, s: \"Hi\")")); Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } @@ -86,17 +86,17 @@ public async Task RunTest_ByDisplayName() // Act var result = await host.RunTestsAsync( _testProject, - "Sample.Tests.SampleTest.TheoryTest1(x: 1)", - "Sample.Tests.SampleTest.TheoryTest1(x: 2)"); + "SampleTest.TheoryTest1(x: 1)", + "SampleTest.TheoryTest1(x: 2)"); // Assert Assert.Equal(0, result); Assert.Equal(5, host.Output.Count); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 2)")); Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } @@ -107,22 +107,22 @@ public async Task RunTest_ByDisplayName_Short() var host = new TestHostWrapper(); // Act - var result = await host.RunTestsAsync(_testProject, "Sample.Tests.SampleTest.TheoryTest1"); + var result = await host.RunTestsAsync(_testProject, "SampleTest.TheoryTest1"); // Assert Assert.Equal(0, result); Assert.Equal(7, host.Output.Count); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 1)")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 2)")); - Assert.Single(host.Output, m => TestStarted(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); - Assert.Single(host.Output, m => TestPassed(m, "Sample.Tests.SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 1)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 2)")); + Assert.Single(host.Output, m => TestStarted(m, "SampleTest.TheoryTest1(x: 3)")); + Assert.Single(host.Output, m => TestPassed(m, "SampleTest.TheoryTest1(x: 3)")); Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "diagnosing ci failures")] + [Fact] public async Task RunTest_ByUniqueName() { // Arrange diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index 43ee263679d..3c85d72291c 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -1,11 +1,10 @@ { "version": "1.0.0-*", "dependencies": { - "Sample.Tests": "1.0.0-*", - "Xunit.KRunner": "1.0.0-*" + "Sample.Tests": "1.0.0-*" }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { } diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index e1fd82cf556..e1543593968 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,10 +1,10 @@ { "version": "1.0.0-*", "dependencies": { - "Xunit.KRunner": "1.0.0-*" + "xunit.runner.kre": "1.0.0-*" }, "commands": { - "test": "Xunit.KRunner" + "test": "xunit.runner.kre" }, "frameworks": { "aspnet50": { }, From defad52b95c6b0bcad109fe8d1eebf5ba6347435 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 11 Dec 2014 14:18:36 -0800 Subject: [PATCH 090/463] Revert change to Microsoft.AspNet.Testing --- src/Microsoft.AspNet.Testing/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 2838779decd..9f10539e85d 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,7 +1,8 @@ { "version": "1.0.0-*", "dependencies": { - "xunit.runner.kre": "1.0.0-*" + "xunit.assert": "2.0.0-aspnet-*", + "xunit.core": "2.0.0-aspnet-*" }, "frameworks": { "aspnet50": { From b76b6158892af58ed9b0177d394d161d7e313778 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Thu, 11 Dec 2014 17:12:58 -0800 Subject: [PATCH 091/463] Conditional run attributes --- src/Microsoft.AspNet.Testing/WindowsApis.cs | 31 +++++++ src/Microsoft.AspNet.Testing/project.json | 4 +- .../xunit/ConditionalAttributeDiscoverer.cs | 51 ++++++++++++ .../xunit/ConditionalFactAttribute.cs | 15 ++++ .../xunit/ConditionalTheoryAttribute.cs | 15 ++++ .../xunit/FrameworkConditionAttribute.cs | 50 ++++++++++++ .../xunit/ITestCondition.cs | 12 +++ .../xunit/OSSkipConditionAttribute.cs | 80 +++++++++++++++++++ .../xunit/OperatingSystems.cs | 18 +++++ .../xunit/RuntimeFrameworks.cs | 14 ++++ .../xunit/SkipReasonAttributeInfo.cs | 50 ++++++++++++ 11 files changed, 339 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.Testing/WindowsApis.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/ConditionalFactAttribute.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/ConditionalTheoryAttribute.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/ITestCondition.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs create mode 100644 src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs diff --git a/src/Microsoft.AspNet.Testing/WindowsApis.cs b/src/Microsoft.AspNet.Testing/WindowsApis.cs new file mode 100644 index 00000000000..fbbe55fec2e --- /dev/null +++ b/src/Microsoft.AspNet.Testing/WindowsApis.cs @@ -0,0 +1,31 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +#if ASPNETCORE50 + +using System; +using System.Runtime.InteropServices; + +namespace Microsoft.AspNet.Testing +{ + internal static class WindowsApis + { + public static Version OSVersion + { + get + { + uint dwVersion = GetVersion(); + + int major = (int)(dwVersion & 0xFF); + int minor = (int)((dwVersion >> 8) & 0xFF); + + return new Version(major, minor); + } + } + + [DllImport("kernel32.dll")] + private static extern uint GetVersion(); + } +} + +#endif \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 9f10539e85d..b2048a8f101 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -2,7 +2,8 @@ "version": "1.0.0-*", "dependencies": { "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*" + "xunit.core": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*", }, "frameworks": { "aspnet50": { @@ -15,6 +16,7 @@ "aspnetcore50": { "dependencies": { "System.Runtime": "4.0.20-beta-*", + "System.Runtime.InteropServices": "4.0.20-beta-", "System.Globalization": "4.0.10-beta-*", "System.Threading.Tasks": "4.0.10-beta-*", "System.Reflection": "4.0.10-beta-*", diff --git a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs new file mode 100644 index 00000000000..7f751861f8b --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using System.Linq; +using Xunit; +using Xunit.Abstractions; +using Xunit.Sdk; + +namespace Microsoft.AspNet.Testing.xunit +{ + internal class ConditionalAttributeDiscoverer : IXunitTestCaseDiscoverer + { + public IEnumerable Discover(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo testClass, IMethodInfo testMethod, IAttributeInfo factAttribute) + { + var skipReason = EvaluateSkipConditions(testMethod); + var wrapperAttributeInfo = new SkipReasonAttributeInfo(skipReason, factAttribute); + + IXunitTestCaseDiscoverer innerDiscoverer; + if (testMethod.GetCustomAttributes(typeof(TheoryAttribute)).Any()) + { + innerDiscoverer = new TheoryDiscoverer(); + } + else + { + innerDiscoverer = new FactDiscoverer(); + } + + var res = innerDiscoverer.Discover(testCollection, assembly, testClass, testMethod, wrapperAttributeInfo); + return res; + } + + private string EvaluateSkipConditions(IMethodInfo testMethod) + { + var conditionAttributes = testMethod + .GetCustomAttributes(typeof(ITestCondition)) + .OfType() + .Select(attributeInfo => attributeInfo.Attribute); + + foreach (ITestCondition condition in conditionAttributes) + { + if (!condition.IsMet) + { + return condition.SkipReason; + } + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/ConditionalFactAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/ConditionalFactAttribute.cs new file mode 100644 index 00000000000..ced24c2a76e --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/ConditionalFactAttribute.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; +using Xunit.Sdk; + +namespace Microsoft.AspNet.Testing.xunit +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + [XunitTestCaseDiscoverer("Microsoft.AspNet.Testing.xunit.ConditionalAttributeDiscoverer", "Microsoft.AspNet.Testing")] + public class ConditionalFactAttribute : FactAttribute + { + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/ConditionalTheoryAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/ConditionalTheoryAttribute.cs new file mode 100644 index 00000000000..637e40c9281 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/ConditionalTheoryAttribute.cs @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Xunit; +using Xunit.Sdk; + +namespace Microsoft.AspNet.Testing.xunit +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + [XunitTestCaseDiscoverer("Microsoft.AspNet.Testing.xunit.ConditionalAttributeDiscoverer", "Microsoft.AspNet.Testing")] + public class ConditionalTheoryAttribute : TheoryAttribute + { + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs new file mode 100644 index 00000000000..63ccc2265d4 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Testing.xunit +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class FrameworkSkipConditionAttribute : Attribute, ITestCondition + { + private RuntimeFrameworks _excludedFrameworks; + + public FrameworkSkipConditionAttribute(RuntimeFrameworks excludedFrameworks) + { + _excludedFrameworks = excludedFrameworks; + } + + public bool IsMet + { + get + { + return CanRunOnThisFramework(_excludedFrameworks); + } + } + + public string SkipReason + { + get + { + return "Test cannot run on this runtime framework."; + } + } + + private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) + { + if (excludedFrameworks == RuntimeFrameworks.None) + { + return true; + } + + if (excludedFrameworks.HasFlag(RuntimeFrameworks.Mono) && + TestPlatformHelper.IsMono) + { + return false; + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/ITestCondition.cs b/src/Microsoft.AspNet.Testing/xunit/ITestCondition.cs new file mode 100644 index 00000000000..94bc7807e1d --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/ITestCondition.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.Testing.xunit +{ + public interface ITestCondition + { + bool IsMet { get; } + + string SkipReason { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs new file mode 100644 index 00000000000..6488b22f018 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Testing.xunit +{ + [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] + public class OSSkipConditionAttribute : Attribute, ITestCondition + { + private OperatingSystems _excludedOS; + + public OSSkipConditionAttribute(OperatingSystems excludedOperatingSystems) + { + _excludedOS = excludedOperatingSystems; + } + + public bool IsMet + { + get + { + return CanRunOnThisOS(_excludedOS); + } + } + + public string SkipReason + { + get + { + return "Test cannot run on this operating system."; + } + } + + private static bool CanRunOnThisOS(OperatingSystems excludedOperatingSystems) + { + if (excludedOperatingSystems == OperatingSystems.None) + { + return true; + } + + bool isWindows = false; +#if ASPNETCORE50 + Version osVersion = WindowsApis.OSVersion; + + // No platform check because it is always Windows + isWindows = true; +#else + Version osVersion = Environment.OSVersion.Version; + + switch (Environment.OSVersion.Platform) + { + case PlatformID.Win32NT: + isWindows = true; + break; + case PlatformID.Unix: + if (excludedOperatingSystems.HasFlag(OperatingSystems.Unix)) + { + return false; + } + break; + } +#endif + + if (isWindows) + { + if (osVersion.Major == 6) + { + if (osVersion.Minor == 1 && + (excludedOperatingSystems.HasFlag(OperatingSystems.Win7) || + excludedOperatingSystems.HasFlag(OperatingSystems.Win2008R2))) + { + return false; + } + } + } + + return true; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs b/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs new file mode 100644 index 00000000000..419640b1cc0 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Testing.xunit +{ + [Flags] + public enum OperatingSystems + { + None = 0, + Win7 = 1 << 0, + Win2008R2 = 1 << 1, + Unix = 1 << 2, + + Win7And2008R2 = Win7 | Win2008R2, + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs b/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs new file mode 100644 index 00000000000..9756d230a50 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; + +namespace Microsoft.AspNet.Testing.xunit +{ + [Flags] + public enum RuntimeFrameworks + { + None = 0, + Mono = 1 << 0, + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs new file mode 100644 index 00000000000..1154a2a3a38 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs @@ -0,0 +1,50 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; +using Xunit.Abstractions; + +namespace Microsoft.AspNet.Testing.xunit +{ + internal class SkipReasonAttributeInfo : IAttributeInfo + { + private IAttributeInfo _wrappedAttribute; + private string _skipReason; + + public SkipReasonAttributeInfo(string skipReason, IAttributeInfo wrappedAttribute) + { + _wrappedAttribute = wrappedAttribute; + _skipReason = skipReason; + } + + public TValue GetNamedArgument(string argumentName) + { + var argumentValue = _wrappedAttribute.GetNamedArgument(argumentName); + + // Override the skip reason if we have one and there + // was not already one specified by the user + if (_skipReason != null && + typeof(TValue) == typeof(string) && + argumentName == "Skip") + { + string stringValue = (string)(object)argumentValue; + if (stringValue == null) + { + return (TValue)(object)_skipReason; + } + } + + return argumentValue; + } + + public IEnumerable GetConstructorArguments() + { + return _wrappedAttribute.GetConstructorArguments(); + } + + public IEnumerable GetCustomAttributes(string assemblyQualifiedAttributeTypeName) + { + return _wrappedAttribute.GetCustomAttributes(assemblyQualifiedAttributeTypeName); + } + } +} \ No newline at end of file From 896c87fd3ed98115fdf0037b8bc515fd036d6989 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Mon, 15 Dec 2014 17:24:25 -0800 Subject: [PATCH 092/463] Fixing InteropServices version --- src/Microsoft.AspNet.Testing/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index b2048a8f101..2154134654c 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -16,7 +16,7 @@ "aspnetcore50": { "dependencies": { "System.Runtime": "4.0.20-beta-*", - "System.Runtime.InteropServices": "4.0.20-beta-", + "System.Runtime.InteropServices": "4.0.20-beta-*", "System.Globalization": "4.0.10-beta-*", "System.Threading.Tasks": "4.0.10-beta-*", "System.Reflection": "4.0.10-beta-*", From 6132a4e5cd84c7d1dd7e7bb41377443d5f078c18 Mon Sep 17 00:00:00 2001 From: Victor Hurdugaci Date: Tue, 16 Dec 2014 08:58:21 -0800 Subject: [PATCH 093/463] Minor fixes for the testing attributes --- src/Microsoft.AspNet.Testing/project.json | 2 +- ....cs => FrameworkSkipConditionAttribute.cs} | 2 +- .../xunit/OSSkipConditionAttribute.cs | 23 +++++++++++-------- .../xunit/SkipReasonAttributeInfo.cs | 4 ++-- 4 files changed, 17 insertions(+), 14 deletions(-) rename src/Microsoft.AspNet.Testing/xunit/{FrameworkConditionAttribute.cs => FrameworkSkipConditionAttribute.cs} (95%) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 2154134654c..d6f1de50831 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -3,7 +3,7 @@ "dependencies": { "xunit.assert": "2.0.0-aspnet-*", "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*", + "xunit.execution": "2.0.0-aspnet-*" }, "frameworks": { "aspnet50": { diff --git a/src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs similarity index 95% rename from src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs rename to src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs index 63ccc2265d4..591a29ef543 100644 --- a/src/Microsoft.AspNet.Testing/xunit/FrameworkConditionAttribute.cs +++ b/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Testing.xunit [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class FrameworkSkipConditionAttribute : Attribute, ITestCondition { - private RuntimeFrameworks _excludedFrameworks; + private readonly RuntimeFrameworks _excludedFrameworks; public FrameworkSkipConditionAttribute(RuntimeFrameworks excludedFrameworks) { diff --git a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs index 6488b22f018..3f43b9465d1 100644 --- a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs +++ b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs @@ -8,7 +8,7 @@ namespace Microsoft.AspNet.Testing.xunit [AttributeUsage(AttributeTargets.Method, AllowMultiple = false)] public class OSSkipConditionAttribute : Attribute, ITestCondition { - private OperatingSystems _excludedOS; + private readonly OperatingSystems _excludedOS; public OSSkipConditionAttribute(OperatingSystems excludedOperatingSystems) { @@ -49,20 +49,23 @@ private static bool CanRunOnThisOS(OperatingSystems excludedOperatingSystems) switch (Environment.OSVersion.Platform) { - case PlatformID.Win32NT: - isWindows = true; - break; - case PlatformID.Unix: - if (excludedOperatingSystems.HasFlag(OperatingSystems.Unix)) - { - return false; - } - break; + case PlatformID.Win32NT: + isWindows = true; + break; + case PlatformID.Unix: + if (excludedOperatingSystems.HasFlag(OperatingSystems.Unix)) + { + return false; + } + break; } #endif if (isWindows) { + // The GetVersion API has a back compat feature: for apps that are not manifested + // and run on Windows 8.1, it returns version 6.2 rather than 6.3. See this: + // http://msdn.microsoft.com/en-us/library/windows/desktop/ms724439(v=vs.85).aspx if (osVersion.Major == 6) { if (osVersion.Minor == 1 && diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs index 1154a2a3a38..50396085d7e 100644 --- a/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs +++ b/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs @@ -8,8 +8,8 @@ namespace Microsoft.AspNet.Testing.xunit { internal class SkipReasonAttributeInfo : IAttributeInfo { - private IAttributeInfo _wrappedAttribute; - private string _skipReason; + private readonly IAttributeInfo _wrappedAttribute; + private readonly string _skipReason; public SkipReasonAttributeInfo(string skipReason, IAttributeInfo wrappedAttribute) { From 0d05284bf6297d3a5d5bb11bf661cd6befb5f324 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Tue, 16 Dec 2014 14:09:05 -0800 Subject: [PATCH 094/463] Adding ability to exclude MacOSX for test runs --- .../xunit/OSSkipConditionAttribute.cs | 6 ++++++ src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs index 3f43b9465d1..6b0788981e8 100644 --- a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs +++ b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs @@ -58,6 +58,12 @@ private static bool CanRunOnThisOS(OperatingSystems excludedOperatingSystems) return false; } break; + case PlatformID.MacOSX: + if (excludedOperatingSystems.HasFlag(OperatingSystems.MacOSX)) + { + return false; + } + break; } #endif diff --git a/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs b/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs index 419640b1cc0..4e7959b38ec 100644 --- a/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs +++ b/src/Microsoft.AspNet.Testing/xunit/OperatingSystems.cs @@ -12,6 +12,7 @@ public enum OperatingSystems Win7 = 1 << 0, Win2008R2 = 1 << 1, Unix = 1 << 2, + MacOSX = 1 << 3, Win7And2008R2 = Win7 | Win2008R2, } From acc3d987ac85fc596990bb40e79449d23f127bc5 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Tue, 16 Dec 2014 14:52:04 -0800 Subject: [PATCH 095/463] Add ability to skip a test on .net --- .../xunit/FrameworkSkipConditionAttribute.cs | 6 ++++++ src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs | 1 + 2 files changed, 7 insertions(+) diff --git a/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs index 591a29ef543..f63c6e158a1 100644 --- a/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs +++ b/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs @@ -44,6 +44,12 @@ private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) return false; } + if (excludedFrameworks.HasFlag(RuntimeFrameworks.Dotnet) && + !TestPlatformHelper.IsMono) + { + return false; + } + return true; } } diff --git a/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs b/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs index 9756d230a50..86ec0892b27 100644 --- a/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs +++ b/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs @@ -10,5 +10,6 @@ public enum RuntimeFrameworks { None = 0, Mono = 1 << 0, + Dotnet = 1 << 1 } } \ No newline at end of file From 2070b6fcd7f1833c4742120e74a3bbbcae8ec5cb Mon Sep 17 00:00:00 2001 From: Praburaj Date: Wed, 17 Dec 2014 09:35:37 -0800 Subject: [PATCH 096/463] PR comment. Fixing Dotnet -> DotNet --- .../xunit/FrameworkSkipConditionAttribute.cs | 2 +- src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs index f63c6e158a1..6b5aa42e07b 100644 --- a/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs +++ b/src/Microsoft.AspNet.Testing/xunit/FrameworkSkipConditionAttribute.cs @@ -44,7 +44,7 @@ private static bool CanRunOnThisFramework(RuntimeFrameworks excludedFrameworks) return false; } - if (excludedFrameworks.HasFlag(RuntimeFrameworks.Dotnet) && + if (excludedFrameworks.HasFlag(RuntimeFrameworks.DotNet) && !TestPlatformHelper.IsMono) { return false; diff --git a/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs b/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs index 86ec0892b27..c3f59ae26b3 100644 --- a/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs +++ b/src/Microsoft.AspNet.Testing/xunit/RuntimeFrameworks.cs @@ -10,6 +10,6 @@ public enum RuntimeFrameworks { None = 0, Mono = 1 << 0, - Dotnet = 1 << 1 + DotNet = 1 << 1 } } \ No newline at end of file From 7984b2be2b27e2de5aacf91271ed8ce278dec599 Mon Sep 17 00:00:00 2001 From: Brennan Date: Tue, 16 Dec 2014 16:50:02 -0800 Subject: [PATCH 097/463] Updating to new xunit --- src/Microsoft.AspNet.Testing/project.json | 4 +--- .../xunit/ConditionalAttributeDiscoverer.cs | 11 +++++------ 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index d6f1de50831..f0b1b13ad1d 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,9 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "xunit.assert": "2.0.0-aspnet-*", - "xunit.core": "2.0.0-aspnet-*", - "xunit.execution": "2.0.0-aspnet-*" + "xunit.runner.kre": "1.0.0-*" }, "frameworks": { "aspnet50": { diff --git a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs index 7f751861f8b..b08def346e4 100644 --- a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs +++ b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs @@ -11,13 +11,12 @@ namespace Microsoft.AspNet.Testing.xunit { internal class ConditionalAttributeDiscoverer : IXunitTestCaseDiscoverer { - public IEnumerable Discover(ITestCollection testCollection, IAssemblyInfo assembly, ITypeInfo testClass, IMethodInfo testMethod, IAttributeInfo factAttribute) + public IEnumerable Discover(ITestMethod testMethod, IAttributeInfo factAttribute) { var skipReason = EvaluateSkipConditions(testMethod); - var wrapperAttributeInfo = new SkipReasonAttributeInfo(skipReason, factAttribute); IXunitTestCaseDiscoverer innerDiscoverer; - if (testMethod.GetCustomAttributes(typeof(TheoryAttribute)).Any()) + if (testMethod.Method.GetCustomAttributes(typeof(TheoryAttribute)).Any()) { innerDiscoverer = new TheoryDiscoverer(); } @@ -26,13 +25,13 @@ public IEnumerable Discover(ITestCollection testCollection, IAss innerDiscoverer = new FactDiscoverer(); } - var res = innerDiscoverer.Discover(testCollection, assembly, testClass, testMethod, wrapperAttributeInfo); + var res = innerDiscoverer.Discover(testMethod, factAttribute).Select(s => new SkipReasonTestCase(skipReason, s)); return res; } - private string EvaluateSkipConditions(IMethodInfo testMethod) + private string EvaluateSkipConditions(ITestMethod testMethod) { - var conditionAttributes = testMethod + var conditionAttributes = testMethod.Method .GetCustomAttributes(typeof(ITestCondition)) .OfType() .Select(attributeInfo => attributeInfo.Attribute); From acffef6c8af41e4cc4c92b5b9ed0d7f54cfdeeed Mon Sep 17 00:00:00 2001 From: Brennan Date: Tue, 16 Dec 2014 16:51:20 -0800 Subject: [PATCH 098/463] Missed file --- .../xunit/SkipReasonTestCase.cs | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs new file mode 100644 index 00000000000..89693dbac74 --- /dev/null +++ b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs @@ -0,0 +1,91 @@ +using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using Xunit.Abstractions; +using Xunit.Sdk; + +internal class SkipReasonTestCase : IXunitTestCase +{ + private readonly string _skipReason; + private readonly IXunitTestCase _wrappedTestCase; + + public SkipReasonTestCase(string skipReason, IXunitTestCase wrappedBase) + { + _skipReason = wrappedBase.SkipReason ?? skipReason; + _wrappedTestCase = wrappedBase; + } + + public string DisplayName + { + get + { + return _wrappedTestCase.DisplayName; + } + } + + public IMethodInfo Method + { + get + { + return _wrappedTestCase.Method; + } + } + + public string SkipReason + { + get + { + return _skipReason; + } + } + + public ISourceInformation SourceInformation + { + get + { + return _wrappedTestCase.SourceInformation; + } + + set + { + _wrappedTestCase.SourceInformation = value; + } + } + + public ITestMethod TestMethod + { + get + { + return _wrappedTestCase.TestMethod; + } + } + + public object[] TestMethodArguments + { + get + { + return _wrappedTestCase.TestMethodArguments; + } + } + + public Dictionary> Traits + { + get + { + return _wrappedTestCase.Traits; + } + } + + public string UniqueID + { + get + { + return _wrappedTestCase.UniqueID; + } + } + + public Task RunAsync(IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) + { + return new XunitTestCaseRunner(this, DisplayName, _skipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync(); + } +} \ No newline at end of file From d0b86c38bd3e83cd3f61f3c1df9de4fc873a0c34 Mon Sep 17 00:00:00 2001 From: Brennan Date: Tue, 16 Dec 2014 17:24:55 -0800 Subject: [PATCH 099/463] Made changes based on comments and added a test --- .../xunit/ConditionalAttributeDiscoverer.cs | 3 +- .../xunit/SkipReasonAttributeInfo.cs | 50 ------------------- .../xunit/SkipReasonTestCase.cs | 12 +++-- .../TestHostTest.cs | 14 ++++++ .../project.json | 3 +- 5 files changed, 25 insertions(+), 57 deletions(-) delete mode 100644 src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs diff --git a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs index b08def346e4..6b1e93491d9 100644 --- a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs +++ b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs @@ -25,7 +25,8 @@ public IEnumerable Discover(ITestMethod testMethod, IAttributeIn innerDiscoverer = new FactDiscoverer(); } - var res = innerDiscoverer.Discover(testMethod, factAttribute).Select(s => new SkipReasonTestCase(skipReason, s)); + var res = innerDiscoverer.Discover(testMethod, factAttribute) + .Select(testCase => new SkipReasonTestCase(skipReason, testCase)); return res; } diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs deleted file mode 100644 index 50396085d7e..00000000000 --- a/src/Microsoft.AspNet.Testing/xunit/SkipReasonAttributeInfo.cs +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. -// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. - -using System.Collections.Generic; -using Xunit.Abstractions; - -namespace Microsoft.AspNet.Testing.xunit -{ - internal class SkipReasonAttributeInfo : IAttributeInfo - { - private readonly IAttributeInfo _wrappedAttribute; - private readonly string _skipReason; - - public SkipReasonAttributeInfo(string skipReason, IAttributeInfo wrappedAttribute) - { - _wrappedAttribute = wrappedAttribute; - _skipReason = skipReason; - } - - public TValue GetNamedArgument(string argumentName) - { - var argumentValue = _wrappedAttribute.GetNamedArgument(argumentName); - - // Override the skip reason if we have one and there - // was not already one specified by the user - if (_skipReason != null && - typeof(TValue) == typeof(string) && - argumentName == "Skip") - { - string stringValue = (string)(object)argumentValue; - if (stringValue == null) - { - return (TValue)(object)_skipReason; - } - } - - return argumentValue; - } - - public IEnumerable GetConstructorArguments() - { - return _wrappedAttribute.GetConstructorArguments(); - } - - public IEnumerable GetCustomAttributes(string assemblyQualifiedAttributeTypeName) - { - return _wrappedAttribute.GetCustomAttributes(assemblyQualifiedAttributeTypeName); - } - } -} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs index 89693dbac74..1a0818771c8 100644 --- a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs +++ b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs @@ -1,4 +1,7 @@ -using System.Collections.Generic; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using Xunit.Abstractions; @@ -9,10 +12,10 @@ internal class SkipReasonTestCase : IXunitTestCase private readonly string _skipReason; private readonly IXunitTestCase _wrappedTestCase; - public SkipReasonTestCase(string skipReason, IXunitTestCase wrappedBase) + public SkipReasonTestCase(string skipReason, IXunitTestCase wrappedTestCase) { - _skipReason = wrappedBase.SkipReason ?? skipReason; - _wrappedTestCase = wrappedBase; + _skipReason = wrappedTestCase.SkipReason ?? skipReason; + _wrappedTestCase = wrappedTestCase; } public string DisplayName @@ -45,7 +48,6 @@ public ISourceInformation SourceInformation { return _wrappedTestCase.SourceInformation; } - set { _wrappedTestCase.SourceInformation = value; diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index 3e51287f5fe..acdf1b71cad 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -9,6 +9,7 @@ using Microsoft.Framework.Runtime.Infrastructure; using Microsoft.Framework.TestAdapter; using Xunit; +using Microsoft.AspNet.Testing.xunit; namespace Microsoft.Framework.TestHost { @@ -149,6 +150,19 @@ public async Task RunTest_ByUniqueName() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } + [ConditionalFact] + [OSSkipCondition(OperatingSystems.Win7And2008R2)] + public void RunTest_DoesNotRunOnWin7() + { + Version osVersion = Environment.OSVersion.Version; + + if (Environment.OSVersion.Platform == PlatformID.Win32NT + && osVersion.Major == 6 && osVersion.Minor == 1) + { + throw new SystemException("Test should not be running on Win7"); + } + } + private static bool TestFound(Message message, string name) { if (!string.Equals("TestDiscovery.TestFound", message.MessageType)) diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index 3c85d72291c..be9e510c261 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -1,7 +1,8 @@ { "version": "1.0.0-*", "dependencies": { - "Sample.Tests": "1.0.0-*" + "Sample.Tests": "1.0.0-*", + "Microsoft.AspNet.Testing": "" }, "commands": { "test": "xunit.runner.kre" From 1a37210d20d10398cfff5039b5aaf5e5a4d38435 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 17 Dec 2014 09:47:52 -0800 Subject: [PATCH 100/463] Minor changes --- .../xunit/SkipReasonTestCase.cs | 109 +++++++++--------- .../TestHostTest.cs | 8 +- .../project.json | 2 +- 3 files changed, 61 insertions(+), 58 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs index 1a0818771c8..2b6a306b3cd 100644 --- a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs +++ b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs @@ -7,87 +7,90 @@ using Xunit.Abstractions; using Xunit.Sdk; -internal class SkipReasonTestCase : IXunitTestCase +namespace Microsoft.AspNet.Testing.xunit { - private readonly string _skipReason; - private readonly IXunitTestCase _wrappedTestCase; - - public SkipReasonTestCase(string skipReason, IXunitTestCase wrappedTestCase) + internal class SkipReasonTestCase : IXunitTestCase { - _skipReason = wrappedTestCase.SkipReason ?? skipReason; - _wrappedTestCase = wrappedTestCase; - } + private readonly string _skipReason; + private readonly IXunitTestCase _wrappedTestCase; - public string DisplayName - { - get + public SkipReasonTestCase(string skipReason, IXunitTestCase wrappedTestCase) { - return _wrappedTestCase.DisplayName; + _skipReason = wrappedTestCase.SkipReason ?? skipReason; + _wrappedTestCase = wrappedTestCase; } - } - public IMethodInfo Method - { - get + public string DisplayName { - return _wrappedTestCase.Method; + get + { + return _wrappedTestCase.DisplayName; + } } - } - public string SkipReason - { - get + public IMethodInfo Method { - return _skipReason; + get + { + return _wrappedTestCase.Method; + } } - } - public ISourceInformation SourceInformation - { - get + public string SkipReason { - return _wrappedTestCase.SourceInformation; + get + { + return _skipReason; + } } - set + + public ISourceInformation SourceInformation { - _wrappedTestCase.SourceInformation = value; + get + { + return _wrappedTestCase.SourceInformation; + } + set + { + _wrappedTestCase.SourceInformation = value; + } } - } - public ITestMethod TestMethod - { - get + public ITestMethod TestMethod { - return _wrappedTestCase.TestMethod; + get + { + return _wrappedTestCase.TestMethod; + } } - } - public object[] TestMethodArguments - { - get + public object[] TestMethodArguments { - return _wrappedTestCase.TestMethodArguments; + get + { + return _wrappedTestCase.TestMethodArguments; + } } - } - public Dictionary> Traits - { - get + public Dictionary> Traits { - return _wrappedTestCase.Traits; + get + { + return _wrappedTestCase.Traits; + } } - } - public string UniqueID - { - get + public string UniqueID { - return _wrappedTestCase.UniqueID; + get + { + return _wrappedTestCase.UniqueID; + } } - } - public Task RunAsync(IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) - { - return new XunitTestCaseRunner(this, DisplayName, _skipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync(); + public Task RunAsync(IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) + { + return new XunitTestCaseRunner(this, DisplayName, _skipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync(); + } } } \ No newline at end of file diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index acdf1b71cad..fdceb28bfb8 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -1,15 +1,15 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Infrastructure; +using Microsoft.Framework.TestAdapter; +using Microsoft.AspNet.Testing.xunit; using System; using System.IO; using System.Linq; using System.Threading.Tasks; -using Microsoft.Framework.Runtime; -using Microsoft.Framework.Runtime.Infrastructure; -using Microsoft.Framework.TestAdapter; using Xunit; -using Microsoft.AspNet.Testing.xunit; namespace Microsoft.Framework.TestHost { diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index be9e510c261..2c766708a4d 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -2,7 +2,7 @@ "version": "1.0.0-*", "dependencies": { "Sample.Tests": "1.0.0-*", - "Microsoft.AspNet.Testing": "" + "Microsoft.AspNet.Testing": "1.0.0-*" }, "commands": { "test": "xunit.runner.kre" From 8840c60de7b51fb516e6c7e078328cfaf12a1cf2 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 17 Dec 2014 10:05:44 -0800 Subject: [PATCH 101/463] System before others --- test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index fdceb28bfb8..4ab26e139ad 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -1,14 +1,14 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.Runtime; -using Microsoft.Framework.Runtime.Infrastructure; -using Microsoft.Framework.TestAdapter; -using Microsoft.AspNet.Testing.xunit; using System; using System.IO; using System.Linq; using System.Threading.Tasks; +using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Infrastructure; +using Microsoft.Framework.TestAdapter; +using Microsoft.AspNet.Testing.xunit; using Xunit; namespace Microsoft.Framework.TestHost From e542e0722c363fd7bf01f02a69244ac1a0a4da35 Mon Sep 17 00:00:00 2001 From: Brice Lambson Date: Thu, 18 Dec 2014 14:05:20 -0800 Subject: [PATCH 102/463] Update Microsoft.AspNet.Testing dependencies --- src/Microsoft.AspNet.Testing/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index f0b1b13ad1d..87180de60a0 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,7 +1,8 @@ { "version": "1.0.0-*", "dependencies": { - "xunit.runner.kre": "1.0.0-*" + "xunit.assert": "2.0.0-beta5-*", + "xunit.execution": "2.0.0-aspnet-*" }, "frameworks": { "aspnet50": { From cdb54f2c56d833354bf13f74e751616dd7dd0907 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 01:37:05 -0800 Subject: [PATCH 103/463] Updating build.cmd and build.sh to use dotnetsdk --- build.cmd | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbbf14..c8041fdd9d3 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_KRE_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef58ec..350d7e389a6 100644 --- a/build.sh +++ b/build.sh @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source packages/KoreBuild/build/dotnetsdk.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dotnetsdk upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 063d0562900f01ede21c97cbf5b56aef31041b48 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Tue, 20 Jan 2015 17:19:33 -0800 Subject: [PATCH 104/463] Updating NuGet.config --- NuGet.Config | 1 - 1 file changed, 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index 2d3b0cb857e..53454b20004 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,6 @@  - From a20bceceec95f8f3903bd7b1ffdbbaf38b971e41 Mon Sep 17 00:00:00 2001 From: Pranav K Date: Tue, 20 Jan 2015 18:09:54 -0800 Subject: [PATCH 105/463] Updating to release NuGet.config --- NuGet.Config | 1 + 1 file changed, 1 insertion(+) diff --git a/NuGet.Config b/NuGet.Config index 53454b20004..2d3b0cb857e 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,6 +1,7 @@  + From df01eed4403db27d81644bfdb54213d6f4859d08 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 20 Jan 2015 18:39:48 -0800 Subject: [PATCH 106/463] Rename SKIP_KRE_INSTALL to SKIP_DOTNET_INSTALL --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index c8041fdd9d3..220a1ff561d 100644 --- a/build.cmd +++ b/build.cmd @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DOTNET_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 From 10e6eee987555215783cac7a7425fd1aeeed7196 Mon Sep 17 00:00:00 2001 From: Suhas Joshi Date: Wed, 21 Jan 2015 15:46:49 -0800 Subject: [PATCH 107/463] Updating to release NuGet.config --- NuGet.Config | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631de..2d3b0cb857e 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + From e1cf92fb04b10669aa0cd052e179f671033c81eb Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 28 Jan 2015 18:45:55 -0800 Subject: [PATCH 108/463] Update build.cmd and build.sh to use kvm --- build.cmd | 6 +++--- build.sh | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cmd b/build.cmd index 220a1ff561d..5885abe3881 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DOTNET_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dotnetsdk upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\dotnetsdk install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\dotnetsdk use default -runtime CLR -x86 +CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index 350d7e389a6..c7873ef58ec 100644 --- a/build.sh +++ b/build.sh @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/dotnetsdk.sh + source packages/KoreBuild/build/kvm.sh fi if ! type k > /dev/null 2>&1; then - dotnetsdk upgrade + kvm upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From 5ecf6557438ab55118c928411c00c44753ed3cfa Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Wed, 28 Jan 2015 18:46:09 -0800 Subject: [PATCH 109/463] Change SKIP_DOTNET_INSTALL to SKIP_KRE_INSTALL --- build.cmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.cmd b/build.cmd index 5885abe3881..86ca5bbbf14 100644 --- a/build.cmd +++ b/build.cmd @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_DOTNET_INSTALL%"=="1" goto run +IF "%SKIP_KRE_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 From ca7a1054bf393f6364cb8991dae83d05cc32b312 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Fri, 6 Feb 2015 14:27:23 -0800 Subject: [PATCH 110/463] Adding System.Diagnostics.TraceSource to fix build errors AspnetCore50 builds fail with a "The name 'Trace' does not exist in the current context" error. --- src/Microsoft.Framework.TestHost/project.json | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index 2887cd22e32..c4c2e34cb4f 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -20,8 +20,9 @@ "aspnetcore50": { "dependencies": { "System.Console": "4.0.0-beta-*", - "System.Diagnostics.Process": "4.0.0-beta-*" + "System.Diagnostics.Process": "4.0.0-beta-*", + "System.Diagnostics.TraceSource": "4.0.0-beta-*" } } } -} +} \ No newline at end of file From 45af27aca08ea396e0e9e750506607e05364db03 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Tue, 10 Feb 2015 11:13:51 -0800 Subject: [PATCH 111/463] Removed build time dependency on Runtime.Interfaces --- src/Microsoft.Framework.TestHost/project.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index c4c2e34cb4f..d9a31ac4120 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -9,7 +9,7 @@ "Microsoft.Framework.CommandLineUtils": "1.0.0-*", "Microsoft.Framework.Runtime": "1.0.0-*", "Microsoft.Framework.Runtime.Common": { "version": "1.0.0-*", "type": "build" }, - "Microsoft.Framework.Runtime.Interfaces": { "version": "1.0.0-*", "type": "build" }, + "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", "Newtonsoft.Json": "6.0.6" }, "commands": { From 9539e88efa59bfc2a5409882e157b2ac05394c18 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Mon, 16 Feb 2015 14:15:04 -0800 Subject: [PATCH 112/463] Add project.lock.json to .gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 9274ba2c888..8a9a4c3b2e4 100644 --- a/.gitignore +++ b/.gitignore @@ -24,4 +24,5 @@ nuget.exe *.ncrunchsolution *.*sdf *.ipch -*.sln.ide \ No newline at end of file +*.sln.ide +project.lock.json From 02e49ddbec32dfa6889b8c735ba44f0f13e9069d Mon Sep 17 00:00:00 2001 From: Brennan Date: Tue, 24 Feb 2015 11:39:10 -0800 Subject: [PATCH 113/463] Adding Testing.Logging project --- Testing.sln | 9 ++- .../Microsoft.AspNet.Testing.Logging.kproj | 17 ++++++ .../TestLogger.cs | 57 +++++++++++++++++++ .../TestLoggerFactory.cs | 29 ++++++++++ .../TestSink.cs | 57 +++++++++++++++++++ .../project.json | 11 ++++ 6 files changed, 179 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj create mode 100644 src/Microsoft.AspNet.Testing.Logging/TestLogger.cs create mode 100644 src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs create mode 100644 src/Microsoft.AspNet.Testing.Logging/TestSink.cs create mode 100644 src/Microsoft.AspNet.Testing.Logging/project.json diff --git a/Testing.sln b/Testing.sln index 3bafb8e42a6..c86a7be5d83 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22310.1 +VisualStudioVersion = 14.0.22613.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -21,6 +21,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAda EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.kproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing.Logging", "src\Microsoft.AspNet.Testing.Logging\Microsoft.AspNet.Testing.Logging.kproj", "{379AA56B-E1A6-4133-9A45-7F70385F39FB}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -55,6 +57,10 @@ Global {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Debug|Any CPU.Build.0 = Debug|Any CPU {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.ActiveCfg = Release|Any CPU {25D18D0C-119C-4AB4-BCA6-AC06179335FA}.Release|Any CPU.Build.0 = Release|Any CPU + {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Debug|Any CPU.Build.0 = Debug|Any CPU + {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Release|Any CPU.ActiveCfg = Release|Any CPU + {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -67,5 +73,6 @@ Global {F003F228-2AE2-4E9D-877B-93EB773B5061} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} + {379AA56B-E1A6-4133-9A45-7F70385F39FB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj b/src/Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj new file mode 100644 index 00000000000..111516a7e6b --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj @@ -0,0 +1,17 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 379aa56b-e1a6-4133-9a45-7f70385f39fb + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + + + diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs b/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs new file mode 100644 index 00000000000..42dad0c9f8e --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Framework.Logging; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class TestLogger : ILogger + { + private object _scope; + private readonly TestSink _sink; + private readonly string _name; + private readonly bool _enabled; + + public TestLogger(string name, TestSink sink, bool enabled) + { + _sink = sink; + _name = name; + _enabled = enabled; + } + + public string Name { get; set; } + + public IDisposable BeginScope(object state) + { + _scope = state; + + _sink.Begin(new BeginScopeContext() + { + LoggerName = _name, + Scope = state, + }); + + return NullDisposable.Instance; + } + + public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) + { + _sink.Write(new WriteContext() + { + LogLevel = logLevel, + EventId = eventId, + State = state, + Exception = exception, + Formatter = formatter, + LoggerName = _name, + Scope = _scope + }); + } + + public bool IsEnabled(LogLevel logLevel) + { + return _enabled; + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs b/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs new file mode 100644 index 00000000000..f0beec9d26e --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +using Microsoft.Framework.Logging; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class TestLoggerFactory : ILoggerFactory + { + private readonly TestSink _sink; + private readonly bool _enabled; + + public TestLoggerFactory(TestSink sink, bool enabled) + { + _sink = sink; + _enabled = enabled; + } + + public LogLevel MinimumLevel { get; set; } = LogLevel.Verbose; + + public ILogger Create(string name) + { + return new TestLogger(name, _sink, _enabled); + } + + public void AddProvider(ILoggerProvider provider) + { + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing.Logging/TestSink.cs b/src/Microsoft.AspNet.Testing.Logging/TestSink.cs new file mode 100644 index 00000000000..e73627c9d16 --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/TestSink.cs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using Microsoft.Framework.Logging; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class TestSink + { + public TestSink( + Func writeEnabled = null, + Func beginEnabled = null) + { + WriteEnabled = writeEnabled; + BeginEnabled = beginEnabled; + + Scopes = new List(); + Writes = new List(); + } + + public Func WriteEnabled { get; set; } + + public Func BeginEnabled { get; set; } + + public List Scopes { get; set; } + + public List Writes { get; set; } + + public void Write(WriteContext context) + { + if (WriteEnabled == null || WriteEnabled(context)) + { + Writes.Add(context); + } + } + + public void Begin(BeginScopeContext context) + { + if (BeginEnabled == null || BeginEnabled(context)) + { + Scopes.Add(context); + } + } + + public static bool EnableWithTypeName(WriteContext context) + { + return context.LoggerName.Equals(typeof(T).FullName); + } + + public static bool EnableWithTypeName(BeginScopeContext context) + { + return context.LoggerName.Equals(typeof(T).FullName); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing.Logging/project.json b/src/Microsoft.AspNet.Testing.Logging/project.json new file mode 100644 index 00000000000..858b5bdf615 --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/project.json @@ -0,0 +1,11 @@ +{ + "version": "1.0.0-*", + "dependencies": { + "Microsoft.Framework.Logging": "1.0.0-*" + }, + "frameworks": { + "net45": { }, + "aspnet50": { }, + "aspnetcore50": { } + } +} From f7d29bff65c782e74b393cef0fdc291ca9ff3d7f Mon Sep 17 00:00:00 2001 From: Brennan Date: Tue, 24 Feb 2015 14:20:06 -0800 Subject: [PATCH 114/463] Adding BeginScopeContext --- .../BeginScopeContext.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs diff --git a/src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs b/src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs new file mode 100644 index 00000000000..5560988effd --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs @@ -0,0 +1,12 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.AspNet.Testing.Logging +{ + public class BeginScopeContext + { + public object Scope { get; set; } + + public string LoggerName { get; set; } + } +} \ No newline at end of file From 50d04de4c44269fe8bce973596b71069e4070585 Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 26 Feb 2015 10:04:39 -0800 Subject: [PATCH 115/463] NullDisposable is being removed from Logging repo --- src/Microsoft.AspNet.Testing.Logging/TestLogger.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs b/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs index 42dad0c9f8e..864f549ae81 100644 --- a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs +++ b/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs @@ -32,7 +32,7 @@ public IDisposable BeginScope(object state) Scope = state, }); - return NullDisposable.Instance; + return null; } public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) From 7165b2252a58349908bf16c9eb8201d9b95b8f99 Mon Sep 17 00:00:00 2001 From: Brennan Date: Thu, 26 Feb 2015 18:10:11 -0800 Subject: [PATCH 116/463] Adding NullLogger and NullLoggerFactory --- Testing.sln | 7 +++ .../NullLogger.cs | 37 +++++++++++++ .../NullLoggerFactory.cs | 23 ++++++++ ...crosoft.AspNet.Testing.Logging.Tests.kproj | 17 ++++++ .../NullLoggerFactoryTest.cs | 33 ++++++++++++ .../NullLoggerTest.cs | 52 +++++++++++++++++++ .../project.json | 18 +++++++ 7 files changed, 187 insertions(+) create mode 100644 src/Microsoft.AspNet.Testing.Logging/NullLogger.cs create mode 100644 src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs create mode 100644 test/Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj create mode 100644 test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs create mode 100644 test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs create mode 100644 test/Microsoft.AspNet.Testing.Logging.Tests/project.json diff --git a/Testing.sln b/Testing.sln index c86a7be5d83..70b80cd35e0 100644 --- a/Testing.sln +++ b/Testing.sln @@ -23,6 +23,8 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHos EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing.Logging", "src\Microsoft.AspNet.Testing.Logging\Microsoft.AspNet.Testing.Logging.kproj", "{379AA56B-E1A6-4133-9A45-7F70385F39FB}" EndProject +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing.Logging.Tests", "test\Microsoft.AspNet.Testing.Logging.Tests\Microsoft.AspNet.Testing.Logging.Tests.kproj", "{6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -61,6 +63,10 @@ Global {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Debug|Any CPU.Build.0 = Debug|Any CPU {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Release|Any CPU.ActiveCfg = Release|Any CPU {379AA56B-E1A6-4133-9A45-7F70385F39FB}.Release|Any CPU.Build.0 = Release|Any CPU + {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -74,5 +80,6 @@ Global {71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} {379AA56B-E1A6-4133-9A45-7F70385F39FB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} + {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F} = {09F799F3-E521-466F-B155-B89E2746C8C9} EndGlobalSection EndGlobal diff --git a/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs b/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs new file mode 100644 index 00000000000..4ae78820dbd --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs @@ -0,0 +1,37 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Framework.Logging; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class NullLogger : ILogger + { + public static readonly NullLogger Instance = new NullLogger(); + + public IDisposable BeginScope(object state) + { + return NullDisposable.Instance; + } + + public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) + { + } + + public bool IsEnabled(LogLevel logLevel) + { + return false; + } + + private class NullDisposable : IDisposable + { + public static readonly NullDisposable Instance = new NullDisposable(); + + public void Dispose() + { + // intentionally does nothing + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs b/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs new file mode 100644 index 00000000000..89ae975d76c --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.Logging; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class NullLoggerFactory : ILoggerFactory + { + public static readonly NullLoggerFactory Instance = new NullLoggerFactory(); + + public LogLevel MinimumLevel { get; set; } = LogLevel.Verbose; + + public ILogger Create(string name) + { + return NullLogger.Instance; + } + + public void AddProvider(ILoggerProvider provider) + { + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj b/test/Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj new file mode 100644 index 00000000000..01906e6559e --- /dev/null +++ b/test/Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj @@ -0,0 +1,17 @@ + + + + 14.0 + $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) + + + + 6fa3efae-2dbc-4532-a5a0-c2ebd8dd672f + ..\..\artifacts\obj\$(MSBuildProjectName) + ..\..\artifacts\bin\$(MSBuildProjectName)\ + + + 2.0 + + + diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs new file mode 100644 index 00000000000..f48cb69e6fc --- /dev/null +++ b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using Microsoft.Framework.Logging; +using Xunit; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class NullLoggerFactoryTest + { + [Fact] + public void MinimumLevelIsVerbose() + { + // Act & Assert + Assert.True(LogLevel.Verbose == NullLoggerFactory.Instance.MinimumLevel); + } + + [Fact] + public void Create_GivesSameLogger() + { + // Arrange + var factory = NullLoggerFactory.Instance; + + // Act + var logger1 = factory.Create("Logger1"); + var logger2 = factory.Create("Logger2"); + + // Assert + Assert.Same(logger1, logger2); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs new file mode 100644 index 00000000000..6ce2ee20f4e --- /dev/null +++ b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using Microsoft.Framework.Logging; +using Xunit; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class NullLoggerTest + { + [Fact] + public void BeginScope_CanDispose() + { + // Arrange + var logger = NullLogger.Instance; + + // Act & Assert + using (logger.BeginScope(null)) + { + } + } + + [Fact] + public void IsEnabled_AlwaysFalse() + { + // Arrange + var logger = NullLogger.Instance; + + // Act & Assert + Assert.False(logger.IsEnabled(LogLevel.Debug)); + Assert.False(logger.IsEnabled(LogLevel.Verbose)); + Assert.False(logger.IsEnabled(LogLevel.Information)); + Assert.False(logger.IsEnabled(LogLevel.Warning)); + Assert.False(logger.IsEnabled(LogLevel.Error)); + Assert.False(logger.IsEnabled(LogLevel.Critical)); + } + + [Fact] + public void Write_Does_Nothing() + { + // Arrange + var logger = NullLogger.Instance; + bool isCalled = false; + + // Act + logger.Write(LogLevel.Verbose, eventId: 0, state: null, exception: null, formatter: (ex, message) => { isCalled = true; return string.Empty; }); + + // Assert + Assert.False(isCalled); + } + } +} \ No newline at end of file diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/project.json b/test/Microsoft.AspNet.Testing.Logging.Tests/project.json new file mode 100644 index 00000000000..6493663e1a8 --- /dev/null +++ b/test/Microsoft.AspNet.Testing.Logging.Tests/project.json @@ -0,0 +1,18 @@ +{ + "version": "1.0.0-*", + "dependencies": { + "Microsoft.AspNet.Testing.Logging": "1.0.0-*", + "xunit.runner.kre": "1.0.0-*" + }, + "commands": { + "test": "xunit.runner.kre" + }, + "frameworks" : { + "aspnet50" : { }, + "aspnetcore50" : { + "dependencies": { + "System.Runtime": "4.0.20-*" + } + } + } +} From 58985cfaab02e430ad616954b596bb6cc1ebe1d4 Mon Sep 17 00:00:00 2001 From: Brennan Date: Wed, 4 Mar 2015 17:02:50 -0800 Subject: [PATCH 117/463] Logging API changes --- src/Microsoft.AspNet.Testing.Logging/NullLogger.cs | 2 +- src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs | 2 +- src/Microsoft.AspNet.Testing.Logging/TestLogger.cs | 2 +- src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs | 2 +- .../NullLoggerFactoryTest.cs | 4 ++-- test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs b/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs index 4ae78820dbd..ecf525d919b 100644 --- a/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs +++ b/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs @@ -15,7 +15,7 @@ public IDisposable BeginScope(object state) return NullDisposable.Instance; } - public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) + public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) { } diff --git a/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs b/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs index 89ae975d76c..ce49af4d354 100644 --- a/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs +++ b/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs @@ -11,7 +11,7 @@ public class NullLoggerFactory : ILoggerFactory public LogLevel MinimumLevel { get; set; } = LogLevel.Verbose; - public ILogger Create(string name) + public ILogger CreateLogger(string name) { return NullLogger.Instance; } diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs b/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs index 864f549ae81..beb48760886 100644 --- a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs +++ b/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs @@ -35,7 +35,7 @@ public IDisposable BeginScope(object state) return null; } - public void Write(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) + public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) { _sink.Write(new WriteContext() { diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs b/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs index f0beec9d26e..0203ce6a167 100644 --- a/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs +++ b/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs @@ -17,7 +17,7 @@ public TestLoggerFactory(TestSink sink, bool enabled) public LogLevel MinimumLevel { get; set; } = LogLevel.Verbose; - public ILogger Create(string name) + public ILogger CreateLogger(string name) { return new TestLogger(name, _sink, _enabled); } diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs index f48cb69e6fc..9a0c8a82119 100644 --- a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs +++ b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs @@ -23,8 +23,8 @@ public void Create_GivesSameLogger() var factory = NullLoggerFactory.Instance; // Act - var logger1 = factory.Create("Logger1"); - var logger2 = factory.Create("Logger2"); + var logger1 = factory.CreateLogger("Logger1"); + var logger2 = factory.CreateLogger("Logger2"); // Assert Assert.Same(logger1, logger2); diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs index 6ce2ee20f4e..df8a3457e7e 100644 --- a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs +++ b/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs @@ -43,7 +43,7 @@ public void Write_Does_Nothing() bool isCalled = false; // Act - logger.Write(LogLevel.Verbose, eventId: 0, state: null, exception: null, formatter: (ex, message) => { isCalled = true; return string.Empty; }); + logger.Log(LogLevel.Verbose, eventId: 0, state: null, exception: null, formatter: (ex, message) => { isCalled = true; return string.Empty; }); // Assert Assert.False(isCalled); From 46d82417c04e6ffee7c07d8a508f43ed216bd162 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Thu, 5 Mar 2015 02:57:10 -0800 Subject: [PATCH 118/463] React to Logging refactoring - Added WriteContext - Depend on Logging.Interfaces only --- .../WriteContext.cs | 22 +++++++++++++++++++ .../project.json | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) create mode 100644 src/Microsoft.AspNet.Testing.Logging/WriteContext.cs diff --git a/src/Microsoft.AspNet.Testing.Logging/WriteContext.cs b/src/Microsoft.AspNet.Testing.Logging/WriteContext.cs new file mode 100644 index 00000000000..651596c4d6f --- /dev/null +++ b/src/Microsoft.AspNet.Testing.Logging/WriteContext.cs @@ -0,0 +1,22 @@ +using System; +using Microsoft.Framework.Logging; + +namespace Microsoft.AspNet.Testing.Logging +{ + public class WriteContext + { + public LogLevel LogLevel { get; set; } + + public int EventId { get; set; } + + public object State { get; set; } + + public Exception Exception { get; set; } + + public Func Formatter { get; set; } + + public object Scope { get; set; } + + public string LoggerName { get; set; } + } +} \ No newline at end of file diff --git a/src/Microsoft.AspNet.Testing.Logging/project.json b/src/Microsoft.AspNet.Testing.Logging/project.json index 858b5bdf615..9b75828aaa4 100644 --- a/src/Microsoft.AspNet.Testing.Logging/project.json +++ b/src/Microsoft.AspNet.Testing.Logging/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.Framework.Logging": "1.0.0-*" + "Microsoft.Framework.Logging.Interfaces": "1.0.0-*" }, "frameworks": { "net45": { }, From e69d6ed6f811d515bf4857eca2b225408064a20a Mon Sep 17 00:00:00 2001 From: Brennan Date: Fri, 6 Mar 2015 09:10:18 -0800 Subject: [PATCH 119/463] Logging in .Framework not .AspNet --- Testing.sln | 4 ++-- .../BeginScopeContext.cs | 2 +- .../Microsoft.Framework.Logging.Testing.kproj} | 0 .../NullLogger.cs | 3 +-- .../NullLoggerFactory.cs | 4 +--- .../TestLogger.cs | 3 +-- .../TestLoggerFactory.cs | 3 +-- .../TestSink.cs | 3 +-- .../WriteContext.cs | 8 +++++--- .../project.json | 0 .../Microsoft.Framework.Logging.Testing.Tests.kproj} | 0 .../NullLoggerFactoryTest.cs | 3 +-- .../NullLoggerTest.cs | 3 +-- .../project.json | 2 +- 14 files changed, 16 insertions(+), 22 deletions(-) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/BeginScopeContext.cs (87%) rename src/{Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj => Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.kproj} (100%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/NullLogger.cs (92%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/NullLoggerFactory.cs (88%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/TestLogger.cs (94%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/TestLoggerFactory.cs (90%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/TestSink.cs (95%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/WriteContext.cs (61%) rename src/{Microsoft.AspNet.Testing.Logging => Microsoft.Framework.Logging.Testing}/project.json (100%) rename test/{Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj => Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.kproj} (100%) rename test/{Microsoft.AspNet.Testing.Logging.Tests => Microsoft.Framework.Logging.Testing.Tests}/NullLoggerFactoryTest.cs (91%) rename test/{Microsoft.AspNet.Testing.Logging.Tests => Microsoft.Framework.Logging.Testing.Tests}/NullLoggerTest.cs (94%) rename test/{Microsoft.AspNet.Testing.Logging.Tests => Microsoft.Framework.Logging.Testing.Tests}/project.json (85%) diff --git a/Testing.sln b/Testing.sln index 70b80cd35e0..4c47912580f 100644 --- a/Testing.sln +++ b/Testing.sln @@ -21,9 +21,9 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAda EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.kproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing.Logging", "src\Microsoft.AspNet.Testing.Logging\Microsoft.AspNet.Testing.Logging.kproj", "{379AA56B-E1A6-4133-9A45-7F70385F39FB}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing", "src\Microsoft.Framework.Logging.Testing\Microsoft.Framework.Logging.Testing.kproj", "{379AA56B-E1A6-4133-9A45-7F70385F39FB}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing.Logging.Tests", "test\Microsoft.AspNet.Testing.Logging.Tests\Microsoft.AspNet.Testing.Logging.Tests.kproj", "{6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing.Tests", "test\Microsoft.Framework.Logging.Testing.Tests\Microsoft.Framework.Logging.Testing.Tests.kproj", "{6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs b/src/Microsoft.Framework.Logging.Testing/BeginScopeContext.cs similarity index 87% rename from src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs rename to src/Microsoft.Framework.Logging.Testing/BeginScopeContext.cs index 5560988effd..d4f00211f8a 100644 --- a/src/Microsoft.AspNet.Testing.Logging/BeginScopeContext.cs +++ b/src/Microsoft.Framework.Logging.Testing/BeginScopeContext.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class BeginScopeContext { diff --git a/src/Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj b/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.kproj similarity index 100% rename from src/Microsoft.AspNet.Testing.Logging/Microsoft.AspNet.Testing.Logging.kproj rename to src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.kproj diff --git a/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs b/src/Microsoft.Framework.Logging.Testing/NullLogger.cs similarity index 92% rename from src/Microsoft.AspNet.Testing.Logging/NullLogger.cs rename to src/Microsoft.Framework.Logging.Testing/NullLogger.cs index ecf525d919b..f7ea6b310aa 100644 --- a/src/Microsoft.AspNet.Testing.Logging/NullLogger.cs +++ b/src/Microsoft.Framework.Logging.Testing/NullLogger.cs @@ -2,9 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Framework.Logging; -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class NullLogger : ILogger { diff --git a/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs b/src/Microsoft.Framework.Logging.Testing/NullLoggerFactory.cs similarity index 88% rename from src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs rename to src/Microsoft.Framework.Logging.Testing/NullLoggerFactory.cs index ce49af4d354..327918a061e 100644 --- a/src/Microsoft.AspNet.Testing.Logging/NullLoggerFactory.cs +++ b/src/Microsoft.Framework.Logging.Testing/NullLoggerFactory.cs @@ -1,9 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.Logging; - -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class NullLoggerFactory : ILoggerFactory { diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs b/src/Microsoft.Framework.Logging.Testing/TestLogger.cs similarity index 94% rename from src/Microsoft.AspNet.Testing.Logging/TestLogger.cs rename to src/Microsoft.Framework.Logging.Testing/TestLogger.cs index beb48760886..f268483e993 100644 --- a/src/Microsoft.AspNet.Testing.Logging/TestLogger.cs +++ b/src/Microsoft.Framework.Logging.Testing/TestLogger.cs @@ -2,9 +2,8 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Framework.Logging; -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class TestLogger : ILogger { diff --git a/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs b/src/Microsoft.Framework.Logging.Testing/TestLoggerFactory.cs similarity index 90% rename from src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs rename to src/Microsoft.Framework.Logging.Testing/TestLoggerFactory.cs index 0203ce6a167..d4b333e2599 100644 --- a/src/Microsoft.AspNet.Testing.Logging/TestLoggerFactory.cs +++ b/src/Microsoft.Framework.Logging.Testing/TestLoggerFactory.cs @@ -1,8 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.Logging; -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class TestLoggerFactory : ILoggerFactory { diff --git a/src/Microsoft.AspNet.Testing.Logging/TestSink.cs b/src/Microsoft.Framework.Logging.Testing/TestSink.cs similarity index 95% rename from src/Microsoft.AspNet.Testing.Logging/TestSink.cs rename to src/Microsoft.Framework.Logging.Testing/TestSink.cs index e73627c9d16..96ad385f0ae 100644 --- a/src/Microsoft.AspNet.Testing.Logging/TestSink.cs +++ b/src/Microsoft.Framework.Logging.Testing/TestSink.cs @@ -3,9 +3,8 @@ using System; using System.Collections.Generic; -using Microsoft.Framework.Logging; -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class TestSink { diff --git a/src/Microsoft.AspNet.Testing.Logging/WriteContext.cs b/src/Microsoft.Framework.Logging.Testing/WriteContext.cs similarity index 61% rename from src/Microsoft.AspNet.Testing.Logging/WriteContext.cs rename to src/Microsoft.Framework.Logging.Testing/WriteContext.cs index 651596c4d6f..8c0645aefd3 100644 --- a/src/Microsoft.AspNet.Testing.Logging/WriteContext.cs +++ b/src/Microsoft.Framework.Logging.Testing/WriteContext.cs @@ -1,7 +1,9 @@ -using System; -using Microsoft.Framework.Logging; +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -namespace Microsoft.AspNet.Testing.Logging +using System; + +namespace Microsoft.Framework.Logging.Testing { public class WriteContext { diff --git a/src/Microsoft.AspNet.Testing.Logging/project.json b/src/Microsoft.Framework.Logging.Testing/project.json similarity index 100% rename from src/Microsoft.AspNet.Testing.Logging/project.json rename to src/Microsoft.Framework.Logging.Testing/project.json diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj b/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.kproj similarity index 100% rename from test/Microsoft.AspNet.Testing.Logging.Tests/Microsoft.AspNet.Testing.Logging.Tests.kproj rename to test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.kproj diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs b/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerFactoryTest.cs similarity index 91% rename from test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs rename to test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerFactoryTest.cs index 9a0c8a82119..c89c8f8d892 100644 --- a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerFactoryTest.cs +++ b/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerFactoryTest.cs @@ -2,10 +2,9 @@ // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; -using Microsoft.Framework.Logging; using Xunit; -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class NullLoggerFactoryTest { diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs b/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs similarity index 94% rename from test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs rename to test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs index df8a3457e7e..9571e038cfb 100644 --- a/test/Microsoft.AspNet.Testing.Logging.Tests/NullLoggerTest.cs +++ b/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs @@ -1,10 +1,9 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -using Microsoft.Framework.Logging; using Xunit; -namespace Microsoft.AspNet.Testing.Logging +namespace Microsoft.Framework.Logging.Testing { public class NullLoggerTest { diff --git a/test/Microsoft.AspNet.Testing.Logging.Tests/project.json b/test/Microsoft.Framework.Logging.Testing.Tests/project.json similarity index 85% rename from test/Microsoft.AspNet.Testing.Logging.Tests/project.json rename to test/Microsoft.Framework.Logging.Testing.Tests/project.json index 6493663e1a8..671bbf4b5fa 100644 --- a/test/Microsoft.AspNet.Testing.Logging.Tests/project.json +++ b/test/Microsoft.Framework.Logging.Testing.Tests/project.json @@ -1,7 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "Microsoft.AspNet.Testing.Logging": "1.0.0-*", + "Microsoft.Framework.Logging.Testing": "1.0.0-*", "xunit.runner.kre": "1.0.0-*" }, "commands": { From 343cd83060d6a686287ad556078c460556bab8c2 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:17 -0700 Subject: [PATCH 120/463] Update aspnet50/aspnetcore50 => dnx451/dnxcore50. --- src/Microsoft.AspNet.Testing/CultureReplacer.cs | 6 +++--- src/Microsoft.AspNet.Testing/ReplaceCulture.cs | 6 +++--- src/Microsoft.AspNet.Testing/WindowsApis.cs | 4 ++-- src/Microsoft.AspNet.Testing/project.json | 6 +++--- .../xunit/OSSkipConditionAttribute.cs | 4 ++-- src/Microsoft.Framework.Logging.Testing/project.json | 4 ++-- src/Microsoft.Framework.TestAdapter/project.json | 6 +++--- src/Microsoft.Framework.TestHost/project.json | 8 ++++---- src/StyleCop.KRules/project.json | 4 ++-- .../project.json | 4 ++-- test/Microsoft.Framework.TestHost.Tests/project.json | 4 ++-- test/Sample.Tests/project.json | 6 +++--- 12 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/CultureReplacer.cs b/src/Microsoft.AspNet.Testing/CultureReplacer.cs index 4716558bb5c..af50cc550f5 100644 --- a/src/Microsoft.AspNet.Testing/CultureReplacer.cs +++ b/src/Microsoft.AspNet.Testing/CultureReplacer.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -26,7 +26,7 @@ public CultureReplacer(string culture = _defaultCultureName, string uiCulture = _originalCulture = CultureInfo.CurrentCulture; _originalUICulture = CultureInfo.CurrentUICulture; _threadId = Thread.CurrentThread.ManagedThreadId; -#if ASPNET50 +#if DNX451 Thread.CurrentThread.CurrentCulture = new CultureInfo(culture); Thread.CurrentThread.CurrentUICulture = new CultureInfo(uiCulture); #else @@ -71,7 +71,7 @@ private void Dispose(bool disposing) { Assert.True(Thread.CurrentThread.ManagedThreadId == _threadId, "The current thread is not the same as the thread invoking the constructor. This should never happen."); -#if ASPNET50 +#if DNX451 Thread.CurrentThread.CurrentCulture = _originalCulture; Thread.CurrentThread.CurrentUICulture = _originalUICulture; #else diff --git a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs index 1719a1d87dc..1379960a91c 100644 --- a/src/Microsoft.AspNet.Testing/ReplaceCulture.cs +++ b/src/Microsoft.AspNet.Testing/ReplaceCulture.cs @@ -1,4 +1,4 @@ -// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; @@ -47,7 +47,7 @@ public override void Before(MethodInfo methodUnderTest) _originalCulture = CultureInfo.CurrentCulture; _originalUICulture = CultureInfo.CurrentUICulture; -#if ASPNET50 +#if DNX451 Thread.CurrentThread.CurrentCulture = Culture; Thread.CurrentThread.CurrentUICulture = UICulture; #else @@ -59,7 +59,7 @@ public override void Before(MethodInfo methodUnderTest) public override void After(MethodInfo methodUnderTest) { -#if ASPNET50 +#if DNX451 Thread.CurrentThread.CurrentCulture = _originalCulture; Thread.CurrentThread.CurrentUICulture = _originalUICulture; #else diff --git a/src/Microsoft.AspNet.Testing/WindowsApis.cs b/src/Microsoft.AspNet.Testing/WindowsApis.cs index fbbe55fec2e..9eb0afd28b7 100644 --- a/src/Microsoft.AspNet.Testing/WindowsApis.cs +++ b/src/Microsoft.AspNet.Testing/WindowsApis.cs @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -#if ASPNETCORE50 +#if DNXCORE50 using System; using System.Runtime.InteropServices; @@ -28,4 +28,4 @@ public static Version OSVersion } } -#endif \ No newline at end of file +#endif diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 87180de60a0..1b9ffdb8c45 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,18 +1,18 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "xunit.assert": "2.0.0-beta5-*", "xunit.execution": "2.0.0-aspnet-*" }, "frameworks": { - "aspnet50": { + "dnx451": { "frameworkAssemblies": { "System.Runtime": "", "System.Reflection": "", "System.Threading.Tasks": "" } }, - "aspnetcore50": { + "dnxcore50": { "dependencies": { "System.Runtime": "4.0.20-beta-*", "System.Runtime.InteropServices": "4.0.20-beta-*", diff --git a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs index 6b0788981e8..424bd8ec11a 100644 --- a/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs +++ b/src/Microsoft.AspNet.Testing/xunit/OSSkipConditionAttribute.cs @@ -39,7 +39,7 @@ private static bool CanRunOnThisOS(OperatingSystems excludedOperatingSystems) } bool isWindows = false; -#if ASPNETCORE50 +#if DNXCORE50 Version osVersion = WindowsApis.OSVersion; // No platform check because it is always Windows @@ -86,4 +86,4 @@ private static bool CanRunOnThisOS(OperatingSystems excludedOperatingSystems) return true; } } -} \ No newline at end of file +} diff --git a/src/Microsoft.Framework.Logging.Testing/project.json b/src/Microsoft.Framework.Logging.Testing/project.json index 9b75828aaa4..0918be92119 100644 --- a/src/Microsoft.Framework.Logging.Testing/project.json +++ b/src/Microsoft.Framework.Logging.Testing/project.json @@ -5,7 +5,7 @@ }, "frameworks": { "net45": { }, - "aspnet50": { }, - "aspnetcore50": { } + "dnx451": { }, + "dnxcore50": { } } } diff --git a/src/Microsoft.Framework.TestAdapter/project.json b/src/Microsoft.Framework.TestAdapter/project.json index 993ec4d4ca4..e468003abf1 100644 --- a/src/Microsoft.Framework.TestAdapter/project.json +++ b/src/Microsoft.Framework.TestAdapter/project.json @@ -1,9 +1,9 @@ -{ +{ "version": "1.0.0-*", "dependencies": { }, "frameworks": { - "aspnet50": { }, - "aspnetcore50": { + "dnx451": { }, + "dnxcore50": { "dependencies": { "System.Collections": "4.0.10-beta-*", "System.Runtime": "4.0.20-beta-*", diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index d9a31ac4120..db45e96a82d 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "compilationOptions": { "warningsAsErrors": true @@ -16,8 +16,8 @@ "run": "run" }, "frameworks": { - "aspnet50": { }, - "aspnetcore50": { + "dnx451": { }, + "dnxcore50": { "dependencies": { "System.Console": "4.0.0-beta-*", "System.Diagnostics.Process": "4.0.0-beta-*", @@ -25,4 +25,4 @@ } } } -} \ No newline at end of file +} diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index 60d6c06425f..6edbe2cc880 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -1,11 +1,11 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "StyleCop": "4.7.10.0" }, "resources": [ "*.xml" ], "frameworks" : { - "aspnet50" : { + "dnx451" : { "dependencies": { } } diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/project.json b/test/Microsoft.Framework.Logging.Testing.Tests/project.json index 671bbf4b5fa..d623f1c968c 100644 --- a/test/Microsoft.Framework.Logging.Testing.Tests/project.json +++ b/test/Microsoft.Framework.Logging.Testing.Tests/project.json @@ -8,8 +8,8 @@ "test": "xunit.runner.kre" }, "frameworks" : { - "aspnet50" : { }, - "aspnetcore50" : { + "dnx451" : { }, + "dnxcore50" : { "dependencies": { "System.Runtime": "4.0.20-*" } diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index 2c766708a4d..38c29f804b3 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Sample.Tests": "1.0.0-*", @@ -8,6 +8,6 @@ "test": "xunit.runner.kre" }, "frameworks": { - "aspnet50": { } + "dnx451": { } } } diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index e1543593968..d537971bf2d 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "xunit.runner.kre": "1.0.0-*" @@ -7,7 +7,7 @@ "test": "xunit.runner.kre" }, "frameworks": { - "aspnet50": { }, - "aspnetcore50": { } + "dnx451": { }, + "dnxcore50": { } } } From 641d3eff5d79cf21448e66c9090a3e612b9b06cd Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:18 -0700 Subject: [PATCH 121/463] Update K_BUILD_VERSION/kre/KRE/.k => DNX_BUILD_VERSION/dnx/DNX/.dnx. --- build.cmd | 4 ++-- .../Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 86ca5bbbf14..49ba0692dee 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ -@echo off +@echo off cd %~dp0 SETLOCAL @@ -19,7 +19,7 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install KoreBuild -ExcludeVersion -o packages -nocache -pre .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion -IF "%SKIP_KRE_INSTALL%"=="1" goto run +IF "%SKIP_DNX_INSTALL%"=="1" goto run CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs index ed83f9ded6c..34c615adcb3 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs @@ -35,7 +35,7 @@ public async Task RunListAsync(string project) // This will block until the test host opens the port var listener = Task.Run(() => GetMessage(port, "TestDiscovery.Response")); - var process = RunKRE(project, arguments); + var process = RunDNX(project, arguments); process.WaitForExit(); await listener; @@ -66,7 +66,7 @@ public async Task RunTestsAsync(string project, params string[] tests) // This will block until the test host opens the port var listener = Task.Run(() => GetMessage(port, "TestExecution.Response")); - var process = RunKRE(project, arguments); + var process = RunDNX(project, arguments); process.WaitForExit(); await listener; @@ -74,7 +74,7 @@ public async Task RunTestsAsync(string project, params string[] tests) return process.ExitCode; } - private static Process RunKRE(string projectDirectory, IEnumerable args) + private static Process RunDNX(string projectDirectory, IEnumerable args) { // TODO: Mono? @@ -151,4 +151,4 @@ private int FindFreePort() } } } -} \ No newline at end of file +} From ae3565e1443bcda428cadc3d85b568ece4f50832 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:19 -0700 Subject: [PATCH 122/463] Update kvm/KVM/Kvm => dnvm/DNVM/Dnvm. --- build.cmd | 6 +++--- build.sh | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/build.cmd b/build.cmd index 49ba0692dee..77be0a66275 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\kvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\kvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -x86 :run -CALL packages\KoreBuild\build\kvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm use default -runtime CLR -x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* diff --git a/build.sh b/build.sh index c7873ef58ec..74cb3421e60 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild @@ -28,11 +28,11 @@ if test ! -d packages/KoreBuild; then fi if ! type k > /dev/null 2>&1; then - source packages/KoreBuild/build/kvm.sh + source packages/KoreBuild/build/dnvm.sh fi if ! type k > /dev/null 2>&1; then - kvm upgrade + dnvm upgrade fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" From d6cd03884c4780181a7b123c08c192bbef2028d7 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Sun, 8 Mar 2015 13:00:19 -0700 Subject: [PATCH 123/463] Update build.sh to use dnvm correctly. --- build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/build.sh b/build.sh index 74cb3421e60..a9ce06d0872 100644 --- a/build.sh +++ b/build.sh @@ -27,7 +27,7 @@ if test ! -d packages/KoreBuild; then mono .nuget/nuget.exe install Sake -version 0.2 -o packages -ExcludeVersion fi -if ! type k > /dev/null 2>&1; then +if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi @@ -36,3 +36,4 @@ if ! type k > /dev/null 2>&1; then fi mono packages/Sake/tools/Sake.exe -I packages/KoreBuild/build -f makefile.shade "$@" + From 8cdba941f8e2ec8f0397267d11d6428eb1777752 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Mon, 9 Mar 2015 13:01:33 -0700 Subject: [PATCH 124/463] Remove BOM from project.json, *.cmd, *.sh and *.shade files. --- build.cmd | 2 +- build.sh | 2 +- src/Microsoft.AspNet.Testing/project.json | 2 +- src/Microsoft.Framework.Logging.Testing/project.json | 2 +- src/Microsoft.Framework.TestAdapter/project.json | 2 +- src/Microsoft.Framework.TestHost/project.json | 2 +- src/StyleCop.KRules/project.json | 2 +- test/Microsoft.Framework.Logging.Testing.Tests/project.json | 2 +- test/Microsoft.Framework.TestHost.Tests/project.json | 2 +- test/Sample.Tests/project.json | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/build.cmd b/build.cmd index 77be0a66275..68a732c182d 100644 --- a/build.cmd +++ b/build.cmd @@ -1,4 +1,4 @@ -@echo off +@echo off cd %~dp0 SETLOCAL diff --git a/build.sh b/build.sh index a9ce06d0872..ec3263114a3 100644 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash if test `uname` = Darwin; then cachedir=~/Library/Caches/KBuild diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 1b9ffdb8c45..9b24f2c90fc 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "xunit.assert": "2.0.0-beta5-*", diff --git a/src/Microsoft.Framework.Logging.Testing/project.json b/src/Microsoft.Framework.Logging.Testing/project.json index 0918be92119..1254091cb99 100644 --- a/src/Microsoft.Framework.Logging.Testing/project.json +++ b/src/Microsoft.Framework.Logging.Testing/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Microsoft.Framework.Logging.Interfaces": "1.0.0-*" diff --git a/src/Microsoft.Framework.TestAdapter/project.json b/src/Microsoft.Framework.TestAdapter/project.json index e468003abf1..c295bf05a97 100644 --- a/src/Microsoft.Framework.TestAdapter/project.json +++ b/src/Microsoft.Framework.TestAdapter/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { }, "frameworks": { diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index db45e96a82d..9f08494854d 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "compilationOptions": { "warningsAsErrors": true diff --git a/src/StyleCop.KRules/project.json b/src/StyleCop.KRules/project.json index 6edbe2cc880..26c715436de 100644 --- a/src/StyleCop.KRules/project.json +++ b/src/StyleCop.KRules/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "StyleCop": "4.7.10.0" diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/project.json b/test/Microsoft.Framework.Logging.Testing.Tests/project.json index d623f1c968c..7136f2a06e3 100644 --- a/test/Microsoft.Framework.Logging.Testing.Tests/project.json +++ b/test/Microsoft.Framework.Logging.Testing.Tests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Microsoft.Framework.Logging.Testing": "1.0.0-*", diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index 38c29f804b3..bf8833cca0a 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "Sample.Tests": "1.0.0-*", diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index d537971bf2d..9aa8fb8a52a 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,4 +1,4 @@ -{ +{ "version": "1.0.0-*", "dependencies": { "xunit.runner.kre": "1.0.0-*" From 536468d453dbaced51a1268b75438b27bcda5fe4 Mon Sep 17 00:00:00 2001 From: Praburaj Date: Tue, 10 Mar 2015 11:47:06 -0700 Subject: [PATCH 125/463] Renaming Nuget.org feed key name to Nuget. fixes https://github.com/aspnet/Universe/issues/174 --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index f41e9c631de..da57d47267e 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -2,6 +2,6 @@ - + - + \ No newline at end of file From cdf4abe3ca6faa4813777c0c00f737ce339918a3 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 11 Mar 2015 14:08:09 -0700 Subject: [PATCH 126/463] Update .kproj => .xproj. --- Testing.sln | 16 ++++++++-------- ...ting.kproj => Microsoft.AspNet.Testing.xproj} | 0 ...=> Microsoft.Framework.Logging.Testing.xproj} | 0 ...roj => Microsoft.Framework.TestAdapter.xproj} | 0 ....kproj => Microsoft.Framework.TestHost.xproj} | 0 ...yleCop.KRules.kproj => StyleCop.KRules.xproj} | 0 ...rosoft.Framework.Logging.Testing.Tests.xproj} | 0 ... => Microsoft.Framework.TestHost.Tests.xproj} | 0 .../{Sample.Tests.kproj => Sample.Tests.xproj} | 0 9 files changed, 8 insertions(+), 8 deletions(-) rename src/Microsoft.AspNet.Testing/{Microsoft.AspNet.Testing.kproj => Microsoft.AspNet.Testing.xproj} (100%) rename src/Microsoft.Framework.Logging.Testing/{Microsoft.Framework.Logging.Testing.kproj => Microsoft.Framework.Logging.Testing.xproj} (100%) rename src/Microsoft.Framework.TestAdapter/{Microsoft.Framework.TestAdapter.kproj => Microsoft.Framework.TestAdapter.xproj} (100%) rename src/Microsoft.Framework.TestHost/{Microsoft.Framework.TestHost.kproj => Microsoft.Framework.TestHost.xproj} (100%) rename src/StyleCop.KRules/{StyleCop.KRules.kproj => StyleCop.KRules.xproj} (100%) rename test/Microsoft.Framework.Logging.Testing.Tests/{Microsoft.Framework.Logging.Testing.Tests.kproj => Microsoft.Framework.Logging.Testing.Tests.xproj} (100%) rename test/Microsoft.Framework.TestHost.Tests/{Microsoft.Framework.TestHost.Tests.kproj => Microsoft.Framework.TestHost.Tests.xproj} (100%) rename test/Sample.Tests/{Sample.Tests.kproj => Sample.Tests.xproj} (100%) diff --git a/Testing.sln b/Testing.sln index 4c47912580f..6d62a03d590 100644 --- a/Testing.sln +++ b/Testing.sln @@ -7,23 +7,23 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BB EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{09F799F3-E521-466F-B155-B89E2746C8C9}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.kproj", "{09BE5203-8042-4338-9713-E44169342E72}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.AspNet.Testing", "src\Microsoft.AspNet.Testing\Microsoft.AspNet.Testing.xproj", "{09BE5203-8042-4338-9713-E44169342E72}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample.Tests", "test\Sample.Tests\Sample.Tests.kproj", "{25D18D0B-119C-4AB4-BCA6-AC06179335FA}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Sample.Tests", "test\Sample.Tests\Sample.Tests.xproj", "{25D18D0B-119C-4AB4-BCA6-AC06179335FA}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KCop.Runner", "src\StyleCop.KRunner\KCop.Runner.csproj", "{62BE2FA4-6B9D-4296-9178-5FC2F66372AB}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StyleCop.KRules", "src\StyleCop.KRules\StyleCop.KRules.kproj", "{657EB507-EE7A-451F-90A4-196F6FCD66E5}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "StyleCop.KRules", "src\StyleCop.KRules\StyleCop.KRules.xproj", "{657EB507-EE7A-451F-90A4-196F6FCD66E5}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost", "src\Microsoft.Framework.TestHost\Microsoft.Framework.TestHost.kproj", "{F003F228-2AE2-4E9D-877B-93EB773B5061}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost", "src\Microsoft.Framework.TestHost\Microsoft.Framework.TestHost.xproj", "{F003F228-2AE2-4E9D-877B-93EB773B5061}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAdapter", "src\Microsoft.Framework.TestAdapter\Microsoft.Framework.TestAdapter.kproj", "{71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestAdapter", "src\Microsoft.Framework.TestAdapter\Microsoft.Framework.TestAdapter.xproj", "{71C2F8AA-05E6-47DB-9A1A-D2760CEF7DC1}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.kproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.TestHost.Tests", "test\Microsoft.Framework.TestHost.Tests\Microsoft.Framework.TestHost.Tests.xproj", "{25D18D0C-119C-4AB4-BCA6-AC06179335FA}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing", "src\Microsoft.Framework.Logging.Testing\Microsoft.Framework.Logging.Testing.kproj", "{379AA56B-E1A6-4133-9A45-7F70385F39FB}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing", "src\Microsoft.Framework.Logging.Testing\Microsoft.Framework.Logging.Testing.xproj", "{379AA56B-E1A6-4133-9A45-7F70385F39FB}" EndProject -Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing.Tests", "test\Microsoft.Framework.Logging.Testing.Tests\Microsoft.Framework.Logging.Testing.Tests.kproj", "{6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}" +Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing.Tests", "test\Microsoft.Framework.Logging.Testing.Tests\Microsoft.Framework.Logging.Testing.Tests.xproj", "{6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.xproj similarity index 100% rename from src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.kproj rename to src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.xproj diff --git a/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.kproj b/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.xproj similarity index 100% rename from src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.kproj rename to src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.xproj diff --git a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.xproj similarity index 100% rename from src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.kproj rename to src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.xproj diff --git a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.xproj similarity index 100% rename from src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.kproj rename to src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.xproj diff --git a/src/StyleCop.KRules/StyleCop.KRules.kproj b/src/StyleCop.KRules/StyleCop.KRules.xproj similarity index 100% rename from src/StyleCop.KRules/StyleCop.KRules.kproj rename to src/StyleCop.KRules/StyleCop.KRules.xproj diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.kproj b/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj similarity index 100% rename from test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.kproj rename to test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj diff --git a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.xproj similarity index 100% rename from test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.kproj rename to test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.xproj diff --git a/test/Sample.Tests/Sample.Tests.kproj b/test/Sample.Tests/Sample.Tests.xproj similarity index 100% rename from test/Sample.Tests/Sample.Tests.kproj rename to test/Sample.Tests/Sample.Tests.xproj From d2414fe01d2629746855fe7690e642458a399166 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Wed, 11 Mar 2015 16:58:35 -0700 Subject: [PATCH 127/463] Do not use deprecated `dnvm -x86` switch --- build.cmd | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.cmd b/build.cmd index 68a732c182d..41025afb267 100644 --- a/build.cmd +++ b/build.cmd @@ -20,9 +20,9 @@ IF EXIST packages\KoreBuild goto run .nuget\NuGet.exe install Sake -version 0.2 -o packages -ExcludeVersion IF "%SKIP_DNX_INSTALL%"=="1" goto run -CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -x86 -CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -x86 +CALL packages\KoreBuild\build\dnvm upgrade -runtime CLR -arch x86 +CALL packages\KoreBuild\build\dnvm install default -runtime CoreCLR -arch x86 :run -CALL packages\KoreBuild\build\dnvm use default -runtime CLR -x86 +CALL packages\KoreBuild\build\dnvm use default -runtime CLR -arch x86 packages\Sake\tools\Sake.exe -I packages\KoreBuild\build -f makefile.shade %* From bbe8e33b4f878969ee3ac9ce6742602b57226aba Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 12 Mar 2015 16:37:11 -0700 Subject: [PATCH 128/463] Update xunit.runner.kre => xunit.runner.aspnet. --- test/Microsoft.Framework.Logging.Testing.Tests/project.json | 4 ++-- test/Microsoft.Framework.TestHost.Tests/project.json | 2 +- test/Sample.Tests/project.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/project.json b/test/Microsoft.Framework.Logging.Testing.Tests/project.json index 7136f2a06e3..dfae84d3bfc 100644 --- a/test/Microsoft.Framework.Logging.Testing.Tests/project.json +++ b/test/Microsoft.Framework.Logging.Testing.Tests/project.json @@ -2,10 +2,10 @@ "version": "1.0.0-*", "dependencies": { "Microsoft.Framework.Logging.Testing": "1.0.0-*", - "xunit.runner.kre": "1.0.0-*" + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "commands": { - "test": "xunit.runner.kre" + "test": "xunit.runner.aspnet" }, "frameworks" : { "dnx451" : { }, diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index bf8833cca0a..17317d495c4 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -5,7 +5,7 @@ "Microsoft.AspNet.Testing": "1.0.0-*" }, "commands": { - "test": "xunit.runner.kre" + "test": "xunit.runner.aspnet" }, "frameworks": { "dnx451": { } diff --git a/test/Sample.Tests/project.json b/test/Sample.Tests/project.json index 9aa8fb8a52a..3fe7bd46dfa 100644 --- a/test/Sample.Tests/project.json +++ b/test/Sample.Tests/project.json @@ -1,10 +1,10 @@ { "version": "1.0.0-*", "dependencies": { - "xunit.runner.kre": "1.0.0-*" + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "commands": { - "test": "xunit.runner.kre" + "test": "xunit.runner.aspnet" }, "frameworks": { "dnx451": { }, From d703a585df05d137f45527b71b2ede98a8ae0d5a Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 12 Mar 2015 17:09:23 -0700 Subject: [PATCH 129/463] Update TestHostTests project.json --- test/Microsoft.Framework.TestHost.Tests/project.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/project.json b/test/Microsoft.Framework.TestHost.Tests/project.json index 17317d495c4..351c5d85951 100644 --- a/test/Microsoft.Framework.TestHost.Tests/project.json +++ b/test/Microsoft.Framework.TestHost.Tests/project.json @@ -2,7 +2,9 @@ "version": "1.0.0-*", "dependencies": { "Sample.Tests": "1.0.0-*", - "Microsoft.AspNet.Testing": "1.0.0-*" + "Microsoft.AspNet.Testing": "1.0.0-*", + "Microsoft.Framework.TestHost": "1.0.0-*", + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "commands": { "test": "xunit.runner.aspnet" From e9fdafb88e3bbd180fcc9dca60855c2d8ec5df1c Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Thu, 12 Mar 2015 23:30:54 -0700 Subject: [PATCH 130/463] Skip TestHost tests until xunit.runner.aspnet supports designtime. --- test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index 4ab26e139ad..72973468b9b 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -25,7 +25,7 @@ public TestHostTest() _testProject = Path.GetDirectoryName(libraryManager.GetLibraryInformation("Sample.Tests").Path); } - [Fact] + [Fact(Skip = "Waiting for xunit.runner.aspnet designtime support.")] public async Task ListTest() { // Arrange @@ -48,7 +48,7 @@ public async Task ListTest() Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "Waiting for xunit.runner.aspnet designtime support.")] public async Task RunTest_All() { // Arrange @@ -123,7 +123,7 @@ public async Task RunTest_ByDisplayName_Short() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact] + [Fact(Skip = "Waiting for xunit.runner.aspnet designtime support.")] public async Task RunTest_ByUniqueName() { // Arrange From d479387fe6a5a387abdf01981942efb8ecc8440e Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 12 Mar 2015 22:15:11 -0700 Subject: [PATCH 131/463] Change Microsoft.AspNet.Tooling to use the same `xunit` as everything else - adjust to core interface changes - likely some expectations still are not met --- src/Microsoft.AspNet.Testing/project.json | 3 +-- .../xunit/ConditionalAttributeDiscoverer.cs | 18 ++++++++++++++---- .../xunit/SkipReasonTestCase.cs | 17 ++++++++++++++++- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/project.json b/src/Microsoft.AspNet.Testing/project.json index 9b24f2c90fc..d33bbe8654d 100644 --- a/src/Microsoft.AspNet.Testing/project.json +++ b/src/Microsoft.AspNet.Testing/project.json @@ -1,8 +1,7 @@ { "version": "1.0.0-*", "dependencies": { - "xunit.assert": "2.0.0-beta5-*", - "xunit.execution": "2.0.0-aspnet-*" + "xunit.runner.aspnet": "2.0.0-aspnet-*" }, "frameworks": { "dnx451": { diff --git a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs index 6b1e93491d9..04a1700a93f 100644 --- a/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs +++ b/src/Microsoft.AspNet.Testing/xunit/ConditionalAttributeDiscoverer.cs @@ -11,21 +11,31 @@ namespace Microsoft.AspNet.Testing.xunit { internal class ConditionalAttributeDiscoverer : IXunitTestCaseDiscoverer { - public IEnumerable Discover(ITestMethod testMethod, IAttributeInfo factAttribute) + private readonly IMessageSink _diagnosticMessageSink; + + public ConditionalAttributeDiscoverer(IMessageSink diagnosticMessageSink) + { + _diagnosticMessageSink = diagnosticMessageSink; + } + + public IEnumerable Discover( + ITestFrameworkDiscoveryOptions discoveryOptions, + ITestMethod testMethod, + IAttributeInfo factAttribute) { var skipReason = EvaluateSkipConditions(testMethod); IXunitTestCaseDiscoverer innerDiscoverer; if (testMethod.Method.GetCustomAttributes(typeof(TheoryAttribute)).Any()) { - innerDiscoverer = new TheoryDiscoverer(); + innerDiscoverer = new TheoryDiscoverer(_diagnosticMessageSink); } else { - innerDiscoverer = new FactDiscoverer(); + innerDiscoverer = new FactDiscoverer(_diagnosticMessageSink); } - var res = innerDiscoverer.Discover(testMethod, factAttribute) + var res = innerDiscoverer.Discover(discoveryOptions, testMethod, factAttribute) .Select(testCase => new SkipReasonTestCase(skipReason, testCase)); return res; } diff --git a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs index 2b6a306b3cd..482ed2df79b 100644 --- a/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs +++ b/src/Microsoft.AspNet.Testing/xunit/SkipReasonTestCase.cs @@ -88,9 +88,24 @@ public string UniqueID } } - public Task RunAsync(IMessageBus messageBus, object[] constructorArguments, ExceptionAggregator aggregator, CancellationTokenSource cancellationTokenSource) + public void Deserialize(IXunitSerializationInfo info) + { + _wrappedTestCase.Deserialize(info); + } + + public Task RunAsync( + IMessageSink diagnosticMessageSink, + IMessageBus messageBus, + object[] constructorArguments, + ExceptionAggregator aggregator, + CancellationTokenSource cancellationTokenSource) { return new XunitTestCaseRunner(this, DisplayName, _skipReason, constructorArguments, TestMethodArguments, messageBus, aggregator, cancellationTokenSource).RunAsync(); } + + public void Serialize(IXunitSerializationInfo info) + { + _wrappedTestCase.Serialize(info); + } } } \ No newline at end of file From 7ae4f5f63c3a9f681552feff0f6eea1ad803363e Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Fri, 13 Mar 2015 11:29:54 -0700 Subject: [PATCH 132/463] Revert "Skip TestHost tests until xunit.runner.aspnet supports designtime." This reverts commit e9fdafb88e3bbd180fcc9dca60855c2d8ec5df1c. --- test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs index 72973468b9b..4ab26e139ad 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostTest.cs @@ -25,7 +25,7 @@ public TestHostTest() _testProject = Path.GetDirectoryName(libraryManager.GetLibraryInformation("Sample.Tests").Path); } - [Fact(Skip = "Waiting for xunit.runner.aspnet designtime support.")] + [Fact] public async Task ListTest() { // Arrange @@ -48,7 +48,7 @@ public async Task ListTest() Assert.Equal("TestDiscovery.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "Waiting for xunit.runner.aspnet designtime support.")] + [Fact] public async Task RunTest_All() { // Arrange @@ -123,7 +123,7 @@ public async Task RunTest_ByDisplayName_Short() Assert.Equal("TestExecution.Response", host.Output[host.Output.Count - 1].MessageType); } - [Fact(Skip = "Waiting for xunit.runner.aspnet designtime support.")] + [Fact] public async Task RunTest_ByUniqueName() { // Arrange From 684fdf91ec5b7322021f48aeb46ee9909aa45664 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 22 Mar 2015 18:28:27 -0700 Subject: [PATCH 133/463] Adding support for discovering source information to tests --- .../ISourceInformationProvider.cs | 10 + .../SourceInformation.cs | 18 + .../DIA/DataKind.cs | 19 + .../DIA/DiaDataSource.cs | 14 + .../DIA/IDiaDataSource.cs | 35 + .../DIA/IDiaEnumDebugStreamData.cs | 41 + .../DIA/IDiaEnumDebugStreams.cs | 36 + .../DIA/IDiaEnumInjectedSources.cs | 35 + .../DIA/IDiaEnumInputAssemblyFiles.cs | 35 + .../DIA/IDiaEnumLineNumbers.cs | 35 + .../DIA/IDiaEnumSourceFiles.cs | 35 + .../DIA/IDiaEnumSymbols.cs | 35 + .../DIA/IDiaEnumSymbolsByAddr.cs | 29 + .../DIA/IDiaEnumTables.cs | 35 + .../DIA/IDiaInjectedSource.cs | 55 + .../DIA/IDiaInputAssemblyFile.cs | 47 + .../DIA/IDiaLineNumber.cs | 100 ++ .../DIA/IDiaSession.cs | 130 ++ .../DIA/IDiaSourceFile.cs | 43 + .../DIA/IDiaSymbol.cs | 1269 +++++++++++++++++ .../DIA/IDiaTable.cs | 41 + .../DIA/IEnumUnknown.cs | 21 + .../DIA/ISequentialStream.cs | 18 + .../DIA/IStream.cs | 35 + .../DIA/StreamWrapper.cs | 80 ++ .../DIA/Structs.cs | 44 + .../DIA/SymTagEnum.cs | 51 + src/Microsoft.Framework.TestHost/Program.cs | 6 +- .../TestAdapter/SourceInformationProvider.cs | 311 ++++ .../TestServices.cs | 55 + src/Microsoft.Framework.TestHost/project.json | 1 + 31 files changed, 2715 insertions(+), 4 deletions(-) create mode 100644 src/Microsoft.Framework.TestAdapter/ISourceInformationProvider.cs create mode 100644 src/Microsoft.Framework.TestAdapter/SourceInformation.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/DataKind.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/DiaDataSource.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaDataSource.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreamData.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreams.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumInjectedSources.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumInputAssemblyFiles.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumLineNumbers.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumSourceFiles.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbols.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbolsByAddr.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaEnumTables.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaInjectedSource.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaInputAssemblyFile.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaLineNumber.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaSession.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaSourceFile.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IDiaTable.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/ISequentialStream.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/IStream.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/StreamWrapper.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/Structs.cs create mode 100644 src/Microsoft.Framework.TestHost/DIA/SymTagEnum.cs create mode 100644 src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs create mode 100644 src/Microsoft.Framework.TestHost/TestServices.cs diff --git a/src/Microsoft.Framework.TestAdapter/ISourceInformationProvider.cs b/src/Microsoft.Framework.TestAdapter/ISourceInformationProvider.cs new file mode 100644 index 00000000000..d45f9f0b898 --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/ISourceInformationProvider.cs @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.Framework.TestAdapter +{ + public interface ISourceInformationProvider + { + SourceInformation GetSourceInformation(string className, string methodName); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/SourceInformation.cs b/src/Microsoft.Framework.TestAdapter/SourceInformation.cs new file mode 100644 index 00000000000..e8c2f8732cd --- /dev/null +++ b/src/Microsoft.Framework.TestAdapter/SourceInformation.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Microsoft.Framework.TestAdapter +{ + public class SourceInformation + { + public SourceInformation(string filename, int lineNumber) + { + Filename = filename; + LineNumber = lineNumber; + } + + public string Filename { get; } + + public int LineNumber { get; } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/DataKind.cs b/src/Microsoft.Framework.TestHost/DIA/DataKind.cs new file mode 100644 index 00000000000..9b74dd03ade --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/DataKind.cs @@ -0,0 +1,19 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace dia2 +{ + public enum DataKind + { + DataIsUnknown, + DataIsLocal, + DataIsStaticLocal, + DataIsParam, + DataIsObjectPtr, + DataIsFileStatic, + DataIsGlobal, + DataIsMember, + DataIsStaticMember, + DataIsConstant + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/DiaDataSource.cs b/src/Microsoft.Framework.TestHost/DIA/DiaDataSource.cs new file mode 100644 index 00000000000..8cb2829b808 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/DiaDataSource.cs @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [ComImport] + [Guid("E6756135-1E65-4D17-8576-610761398C3C")] + public class DiaDataSource + { + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaDataSource.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaDataSource.cs new file mode 100644 index 00000000000..23e25459b8a --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaDataSource.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("79F1BB5F-B66E-48E5-B6A9-1545C323CA3D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaDataSource + { + [DispId(1)] + string lastError + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + + void loadDataFromPdb([MarshalAs(UnmanagedType.LPWStr)] [In] string pdbPath); + + void loadAndValidateDataFromPdb([MarshalAs(UnmanagedType.LPWStr)] [In] string pdbPath, [In] ref Guid pcsig70, [In] uint sig, [In] uint age); + + void loadDataForExe([MarshalAs(UnmanagedType.LPWStr)] [In] string executable, [MarshalAs(UnmanagedType.LPWStr)] [In] string searchPath, [MarshalAs(UnmanagedType.IUnknown)] [In] object pCallback); + + void loadDataFromIStream([MarshalAs(UnmanagedType.Interface)] [In] IStream pIStream); + + void openSession([MarshalAs(UnmanagedType.Interface)] out IDiaSession ppSession); + + void loadDataFromCodeViewInfo([MarshalAs(UnmanagedType.LPWStr)] [In] string executable, [MarshalAs(UnmanagedType.LPWStr)] [In] string searchPath, [In] uint cbCvInfo, [In] ref byte pbCvInfo, [MarshalAs(UnmanagedType.IUnknown)] [In] object pCallback); + + void loadDataFromMiscInfo([MarshalAs(UnmanagedType.LPWStr)] [In] string executable, [MarshalAs(UnmanagedType.LPWStr)] [In] string searchPath, [In] uint timeStampExe, [In] uint timeStampDbg, [In] uint sizeOfExe, [In] uint cbMiscInfo, [In] ref byte pbMiscInfo, [MarshalAs(UnmanagedType.IUnknown)] [In] object pCallback); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreamData.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreamData.cs new file mode 100644 index 00000000000..4d26b09f417 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreamData.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("486943E8-D187-4A6B-A3C4-291259FFF60D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumDebugStreamData + { + [DispId(1)] + int count + { + + get; + } + [DispId(2)] + string name + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + + IEnumerator GetEnumerator(); + + void Item([In] uint index, [In] uint cbData, out uint pcbData, out byte pbData); + + void Next([In] uint celt, [In] uint cbData, out uint pcbData, out byte pbData, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumDebugStreamData ppenum); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreams.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreams.cs new file mode 100644 index 00000000000..07913e1f51f --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumDebugStreams.cs @@ -0,0 +1,36 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("08CBB41E-47A6-4F87-92F1-1C9C87CED044"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumDebugStreams + { + [DispId(1)] + int count + { + + get; + } + + [return: MarshalAs(UnmanagedType.Interface)] + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaEnumDebugStreamData Item([In] object index); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumDebugStreamData rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumDebugStreams ppenum); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumInjectedSources.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumInjectedSources.cs new file mode 100644 index 00000000000..a186054300e --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumInjectedSources.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("D5612573-6925-4468-8883-98CDEC8C384A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumInjectedSources + { + [DispId(1)] + int count + { + + get; + } + + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaInjectedSource Item([In] uint index); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaInjectedSource rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumInjectedSources ppenum); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumInputAssemblyFiles.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumInputAssemblyFiles.cs new file mode 100644 index 00000000000..43dd31d3c77 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumInputAssemblyFiles.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("1C7FF653-51F7-457E-8419-B20F57EF7E4D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumInputAssemblyFiles + { + [DispId(1)] + int count + { + + get; + } + + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaInputAssemblyFile Item([In] uint index); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaInputAssemblyFile rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumInputAssemblyFiles ppenum); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumLineNumbers.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumLineNumbers.cs new file mode 100644 index 00000000000..10e59250e0b --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumLineNumbers.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("FE30E878-54AC-44F1-81BA-39DE940F6052"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumLineNumbers + { + [DispId(1)] + int count + { + + get; + } + + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaLineNumber Item([In] uint index); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaLineNumber rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppenum); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSourceFiles.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSourceFiles.cs new file mode 100644 index 00000000000..573785ee3e1 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSourceFiles.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("10F3DBD9-664F-4469-B808-9471C7A50538"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumSourceFiles + { + [DispId(1)] + int count + { + + get; + } + + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaSourceFile Item([In] uint index); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaSourceFile rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumSourceFiles ppenum); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbols.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbols.cs new file mode 100644 index 00000000000..1dbcf3748e9 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbols.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("CAB72C48-443B-48F5-9B0B-42F0820AB29A"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumSymbols + { + [DispId(1)] + int count + { + + get; + } + + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaSymbol Item([In] uint index); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppenum); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbolsByAddr.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbolsByAddr.cs new file mode 100644 index 00000000000..b8e611e079c --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumSymbolsByAddr.cs @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("624B7D9C-24EA-4421-9D06-3B577471C1FA"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumSymbolsByAddr + { + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaSymbol symbolByAddr([In] uint isect, [In] uint offset); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaSymbol symbolByRVA([In] uint relativeVirtualAddress); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaSymbol symbolByVA([In] ulong virtualAddress); + + void Next([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol rgelt, out uint pceltFetched); + + void Prev([In] uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol rgelt, out uint pceltFetched); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbolsByAddr ppenum); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaEnumTables.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumTables.cs new file mode 100644 index 00000000000..12b45b0ef95 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaEnumTables.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("Item"), Guid("C65C2B0A-1150-4D7A-AFCC-E05BF3DEE81E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaEnumTables + { + [DispId(1)] + int count + { + + get; + } + + IEnumerator GetEnumerator(); + + [return: MarshalAs(UnmanagedType.Interface)] + IDiaTable Item([In] object index); + + void Next(uint celt, [MarshalAs(UnmanagedType.Interface)] out IDiaTable rgelt, ref uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IDiaEnumTables ppenum); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaInjectedSource.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaInjectedSource.cs new file mode 100644 index 00000000000..dea4dab79dd --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaInjectedSource.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("AE605CDC-8105-4A23-B710-3259F1E26112"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaInjectedSource + { + [DispId(1)] + uint crc + { + + get; + } + [DispId(2)] + ulong length + { + + get; + } + [DispId(3)] + string fileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(4)] + string objectFileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(5)] + string virtualFilename + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(6)] + uint sourceCompression + { + + get; + } + + void get_source([In] uint cbData, out uint pcbData, out byte pbData); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaInputAssemblyFile.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaInputAssemblyFile.cs new file mode 100644 index 00000000000..cb7df30cf34 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaInputAssemblyFile.cs @@ -0,0 +1,47 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("3BFE56B0-390C-4863-9430-1F3D083B7684"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaInputAssemblyFile + { + [DispId(1)] + uint uniqueId + { + + get; + } + [DispId(2)] + uint index + { + + get; + } + [DispId(3)] + uint timeStamp + { + + get; + } + [DispId(4)] + int pdbAvailableAtILMerge + { + + get; + } + [DispId(5)] + string fileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + + void get_version([In] uint cbData, out uint pcbData, out byte pbData); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaLineNumber.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaLineNumber.cs new file mode 100644 index 00000000000..48393743bfe --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaLineNumber.cs @@ -0,0 +1,100 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("B388EB14-BE4D-421D-A8A1-6CF7AB057086"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaLineNumber + { + [DispId(1)] + IDiaSymbol compiland + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(2)] + IDiaSourceFile sourceFile + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(3)] + uint lineNumber + { + + get; + } + [DispId(4)] + uint lineNumberEnd + { + + get; + } + [DispId(5)] + uint columnNumber + { + + get; + } + [DispId(6)] + uint columnNumberEnd + { + + get; + } + [DispId(7)] + uint addressSection + { + + get; + } + [DispId(8)] + uint addressOffset + { + + get; + } + [DispId(9)] + uint relativeVirtualAddress + { + + get; + } + [DispId(10)] + ulong virtualAddress + { + + get; + } + [DispId(11)] + uint length + { + + get; + } + [DispId(12)] + uint sourceFileId + { + + get; + } + [DispId(13)] + int statement + { + + get; + } + [DispId(14)] + uint compilandId + { + + get; + } + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaSession.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaSession.cs new file mode 100644 index 00000000000..212c8b69f38 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaSession.cs @@ -0,0 +1,130 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; +namespace dia2 +{ + [Guid("2F609EE1-D1C8-4E24-8288-3326BADCD211"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaSession + { + [DispId(1)] + ulong loadAddress + { + + get; + + set; + } + [DispId(2)] + IDiaSymbol globalScope + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + + void getEnumTables([MarshalAs(UnmanagedType.Interface)] out IDiaEnumTables ppEnumTables); + + void getSymbolsByAddr([MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbolsByAddr ppEnumbyAddr); + + void findChildren([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findChildrenEx([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findChildrenExByAddr([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findChildrenExByVA([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findChildrenExByRVA([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findSymbolByAddr([In] uint isect, [In] uint offset, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol); + + void findSymbolByRVA([In] uint rva, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol); + + void findSymbolByVA([In] ulong va, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol); + + void findSymbolByToken([In] uint token, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol); + + void symsAreEquiv([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol symbolA, [MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol symbolB); + + void symbolById([In] uint id, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol); + + void findSymbolByRVAEx([In] uint rva, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol, out int displacement); + + void findSymbolByVAEx([In] ulong va, [In] SymTagEnum symTag, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol ppSymbol, out int displacement); + + void findFile([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol pCompiland, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSourceFiles ppResult); + + void findFileById([In] uint uniqueId, [MarshalAs(UnmanagedType.Interface)] out IDiaSourceFile ppResult); + + void findLines([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol compiland, [MarshalAs(UnmanagedType.Interface)] [In] IDiaSourceFile file, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findLinesByAddr([In] uint seg, [In] uint offset, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findLinesByRVA([In] uint rva, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findLinesByVA([In] ulong va, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findLinesByLinenum([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol compiland, [MarshalAs(UnmanagedType.Interface)] [In] IDiaSourceFile file, [In] uint linenum, [In] uint column, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInjectedSource([MarshalAs(UnmanagedType.LPWStr)] [In] string srcFile, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumInjectedSources ppResult); + + void getEnumDebugStreams([MarshalAs(UnmanagedType.Interface)] out IDiaEnumDebugStreams ppEnumDebugStreams); + + void findInlineFramesByAddr([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findInlineFramesByRVA([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findInlineFramesByVA([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void findInlineeLines([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInlineeLinesByAddr([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] uint isect, [In] uint offset, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInlineeLinesByRVA([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] uint rva, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInlineeLinesByVA([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol parent, [In] ulong va, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInlineeLinesByLinenum([MarshalAs(UnmanagedType.Interface)] [In] IDiaSymbol compiland, [MarshalAs(UnmanagedType.Interface)] [In] IDiaSourceFile file, [In] uint linenum, [In] uint column, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInlineesByName([MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint option, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void addressForVA([In] ulong va, out uint pISect, out uint pOffset); + + void addressForRVA([In] uint rva, out uint pISect, out uint pOffset); + + void findILOffsetsByAddr([In] uint isect, [In] uint offset, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findILOffsetsByRVA([In] uint rva, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findILOffsetsByVA([In] ulong va, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + void findInputAssemblyFiles([MarshalAs(UnmanagedType.Interface)] out IDiaEnumInputAssemblyFiles ppResult); + + void findInputAssembly([In] uint index, [MarshalAs(UnmanagedType.Interface)] out IDiaInputAssemblyFile ppResult); + + void findInputAssemblyById([In] uint uniqueId, [MarshalAs(UnmanagedType.Interface)] out IDiaInputAssemblyFile ppResult); + + void getFuncMDTokenMapSize(out uint pcb); + + void getFuncMDTokenMap([In] uint cb, out uint pcb, out byte pb); + + void getTypeMDTokenMapSize(out uint pcb); + + void getTypeMDTokenMap([In] uint cb, out uint pcb, out byte pb); + + void getNumberOfFunctionFragments_VA([In] ulong vaFunc, [In] uint cbFunc, out uint pNumFragments); + + void getNumberOfFunctionFragments_RVA([In] uint rvaFunc, [In] uint cbFunc, out uint pNumFragments); + + void getFunctionFragments_VA([In] ulong vaFunc, [In] uint cbFunc, [In] uint cFragments, out ulong pVaFragment, out uint pLenFragment); + + void getFunctionFragments_RVA([In] uint rvaFunc, [In] uint cbFunc, [In] uint cFragments, out uint pRvaFragment, out uint pLenFragment); + + void getExports([MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + void getHeapAllocationSites([MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaSourceFile.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaSourceFile.cs new file mode 100644 index 00000000000..5f57d3517ff --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaSourceFile.cs @@ -0,0 +1,43 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("A2EF5353-F5A8-4EB3-90D2-CB526ACB3CDD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaSourceFile + { + [DispId(2)] + uint uniqueId + { + + get; + } + [DispId(3)] + string fileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(4)] + uint checksumType + { + + get; + } + [DispId(5)] + IDiaEnumSymbols compilands + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + + + void get_checksum([In] uint cbData, out uint pcbData, out byte pbData); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs new file mode 100644 index 00000000000..a47421f11c2 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs @@ -0,0 +1,1269 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Reflection; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [DefaultMember("symIndexId"), Guid("CB787B2F-BD6C-4635-BA52-933126BD2DCD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaSymbol + { + [DispId(0)] + uint symIndexId + { + + get; + } + [DispId(1)] + uint symTag + { + + get; + } + [DispId(2)] + string name + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(3)] + IDiaSymbol lexicalParent + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(4)] + IDiaSymbol classParent + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(5)] + IDiaSymbol type + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(6)] + uint dataKind + { + + get; + } + [DispId(7)] + uint locationType + { + + get; + } + [DispId(8)] + uint addressSection + { + + get; + } + [DispId(9)] + uint addressOffset + { + + get; + } + [DispId(10)] + uint relativeVirtualAddress + { + + get; + } + [DispId(11)] + ulong virtualAddress + { + + get; + } + [DispId(12)] + uint registerId + { + + get; + } + [DispId(13)] + int offset + { + + get; + } + [DispId(14)] + ulong length + { + + get; + } + [DispId(15)] + uint slot + { + + get; + } + [DispId(16)] + int volatileType + { + + get; + } + [DispId(17)] + int constType + { + + get; + } + [DispId(18)] + int unalignedType + { + + get; + } + [DispId(19)] + uint access + { + + get; + } + [DispId(20)] + string libraryName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(21)] + uint platform + { + + get; + } + [DispId(22)] + uint language + { + + get; + } + [DispId(23)] + int editAndContinueEnabled + { + + get; + } + [DispId(24)] + uint frontEndMajor + { + + get; + } + [DispId(25)] + uint frontEndMinor + { + + get; + } + [DispId(26)] + uint frontEndBuild + { + + get; + } + [DispId(27)] + uint backEndMajor + { + + get; + } + [DispId(28)] + uint backEndMinor + { + + get; + } + [DispId(29)] + uint backEndBuild + { + + get; + } + [DispId(30)] + string sourceFileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(31)] + string unused + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(32)] + uint thunkOrdinal + { + + get; + } + [DispId(33)] + int thisAdjust + { + + get; + } + [DispId(34)] + uint virtualBaseOffset + { + + get; + } + [DispId(35)] + int @virtual + { + + get; + } + [DispId(36)] + int intro + { + + get; + } + [DispId(37)] + int pure + { + + get; + } + [DispId(38)] + uint callingConvention + { + + get; + } + [DispId(39)] + object value + { + + get; + } + [DispId(40)] + uint baseType + { + + get; + } + [DispId(41)] + uint token + { + + get; + } + [DispId(42)] + uint timeStamp + { + + get; + } + [DispId(43)] + Guid guid + { + + get; + } + [DispId(44)] + string symbolsFileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(46)] + int reference + { + + get; + } + [DispId(47)] + uint count + { + + get; + } + [DispId(49)] + uint bitPosition + { + + get; + } + [DispId(50)] + IDiaSymbol arrayIndexType + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(51)] + int packed + { + + get; + } + [DispId(52)] + int constructor + { + + get; + } + [DispId(53)] + int overloadedOperator + { + + get; + } + [DispId(54)] + int nested + { + + get; + } + [DispId(55)] + int hasNestedTypes + { + + get; + } + [DispId(56)] + int hasAssignmentOperator + { + + get; + } + [DispId(57)] + int hasCastOperator + { + + get; + } + [DispId(58)] + int scoped + { + + get; + } + [DispId(59)] + int virtualBaseClass + { + + get; + } + [DispId(60)] + int indirectVirtualBaseClass + { + + get; + } + [DispId(61)] + int virtualBasePointerOffset + { + + get; + } + [DispId(62)] + IDiaSymbol virtualTableShape + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(64)] + uint lexicalParentId + { + + get; + } + [DispId(65)] + uint classParentId + { + + get; + } + [DispId(66)] + uint typeId + { + + get; + } + [DispId(67)] + uint arrayIndexTypeId + { + + get; + } + [DispId(68)] + uint virtualTableShapeId + { + + get; + } + [DispId(69)] + int code + { + + get; + } + [DispId(70)] + int function + { + + get; + } + [DispId(71)] + int managed + { + + get; + } + [DispId(72)] + int msil + { + + get; + } + [DispId(73)] + uint virtualBaseDispIndex + { + + get; + } + [DispId(74)] + string undecoratedName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(75)] + uint age + { + + get; + } + [DispId(76)] + uint signature + { + + get; + } + [DispId(77)] + int compilerGenerated + { + + get; + } + [DispId(78)] + int addressTaken + { + + get; + } + [DispId(79)] + uint rank + { + + get; + } + [DispId(80)] + IDiaSymbol lowerBound + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(81)] + IDiaSymbol upperBound + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(82)] + uint lowerBoundId + { + + get; + } + [DispId(83)] + uint upperBoundId + { + + get; + } + [DispId(84)] + uint targetSection + { + + get; + } + [DispId(85)] + uint targetOffset + { + + get; + } + [DispId(86)] + uint targetRelativeVirtualAddress + { + + get; + } + [DispId(87)] + ulong targetVirtualAddress + { + + get; + } + [DispId(88)] + uint machineType + { + + get; + } + [DispId(89)] + uint oemId + { + + get; + } + [DispId(90)] + uint oemSymbolId + { + + get; + } + [DispId(91)] + IDiaSymbol objectPointerType + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(92)] + uint udtKind + { + + get; + } + [DispId(93)] + int noReturn + { + + get; + } + [DispId(94)] + int customCallingConvention + { + + get; + } + [DispId(95)] + int noInline + { + + get; + } + [DispId(96)] + int optimizedCodeDebugInfo + { + + get; + } + [DispId(97)] + int notReached + { + + get; + } + [DispId(98)] + int interruptReturn + { + + get; + } + [DispId(99)] + int farReturn + { + + get; + } + [DispId(100)] + int isStatic + { + + get; + } + [DispId(101)] + int hasDebugInfo + { + + get; + } + [DispId(102)] + int isLTCG + { + + get; + } + [DispId(103)] + int isDataAligned + { + + get; + } + [DispId(104)] + int hasSecurityChecks + { + + get; + } + [DispId(105)] + string compilerName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(106)] + int hasAlloca + { + + get; + } + [DispId(107)] + int hasSetJump + { + + get; + } + [DispId(108)] + int hasLongJump + { + + get; + } + [DispId(109)] + int hasInlAsm + { + + get; + } + [DispId(110)] + int hasEH + { + + get; + } + [DispId(111)] + int hasSEH + { + + get; + } + [DispId(112)] + int hasEHa + { + + get; + } + [DispId(113)] + int isNaked + { + + get; + } + [DispId(114)] + int isAggregated + { + + get; + } + [DispId(115)] + int isSplitted + { + + get; + } + [DispId(116)] + IDiaSymbol container + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(117)] + int inlSpec + { + + get; + } + [DispId(118)] + int noStackOrdering + { + + get; + } + [DispId(119)] + IDiaSymbol virtualBaseTableType + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(120)] + int hasManagedCode + { + + get; + } + [DispId(121)] + int isHotpatchable + { + + get; + } + [DispId(122)] + int isCVTCIL + { + + get; + } + [DispId(123)] + int isMSILNetmodule + { + + get; + } + [DispId(124)] + int isCTypes + { + + get; + } + [DispId(125)] + int isStripped + { + + get; + } + [DispId(126)] + uint frontEndQFE + { + + get; + } + [DispId(127)] + uint backEndQFE + { + + get; + } + [DispId(128)] + int wasInlined + { + + get; + } + [DispId(129)] + int strictGSCheck + { + + get; + } + [DispId(130)] + int isCxxReturnUdt + { + + get; + } + [DispId(131)] + int isConstructorVirtualBase + { + + get; + } + [DispId(132)] + int RValueReference + { + + get; + } + [DispId(133)] + IDiaSymbol unmodifiedType + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(134)] + int framePointerPresent + { + + get; + } + [DispId(135)] + int isSafeBuffers + { + + get; + } + [DispId(136)] + int intrinsic + { + + get; + } + [DispId(137)] + int @sealed + { + + get; + } + [DispId(138)] + int hfaFloat + { + + get; + } + [DispId(139)] + int hfaDouble + { + + get; + } + [DispId(140)] + uint liveRangeStartAddressSection + { + + get; + } + [DispId(141)] + uint liveRangeStartAddressOffset + { + + get; + } + [DispId(142)] + uint liveRangeStartRelativeVirtualAddress + { + + get; + } + [DispId(143)] + uint countLiveRanges + { + + get; + } + [DispId(144)] + ulong liveRangeLength + { + + get; + } + [DispId(145)] + uint offsetInUdt + { + + get; + } + [DispId(146)] + uint paramBasePointerRegisterId + { + + get; + } + [DispId(147)] + uint localBasePointerRegisterId + { + + get; + } + [DispId(148)] + int isLocationControlFlowDependent + { + + get; + } + [DispId(149)] + uint stride + { + + get; + } + [DispId(150)] + uint numberOfRows + { + + get; + } + [DispId(151)] + uint numberOfColumns + { + + get; + } + [DispId(152)] + int isMatrixRowMajor + { + + get; + } + [DispId(153)] + int isReturnValue + { + + get; + } + [DispId(154)] + int isOptimizedAway + { + + get; + } + [DispId(155)] + uint builtInKind + { + + get; + } + [DispId(156)] + uint registerType + { + + get; + } + [DispId(157)] + uint baseDataSlot + { + + get; + } + [DispId(158)] + uint baseDataOffset + { + + get; + } + [DispId(159)] + uint textureSlot + { + + get; + } + [DispId(160)] + uint samplerSlot + { + + get; + } + [DispId(161)] + uint uavSlot + { + + get; + } + [DispId(162)] + uint sizeInUdt + { + + get; + } + [DispId(163)] + uint memorySpaceKind + { + + get; + } + [DispId(164)] + uint unmodifiedTypeId + { + + get; + } + [DispId(165)] + uint subTypeId + { + + get; + } + [DispId(166)] + IDiaSymbol subType + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(167)] + uint numberOfModifiers + { + + get; + } + [DispId(168)] + uint numberOfRegisterIndices + { + + get; + } + [DispId(169)] + int isHLSLData + { + + get; + } + [DispId(170)] + int isPointerToDataMember + { + + get; + } + [DispId(171)] + int isPointerToMemberFunction + { + + get; + } + [DispId(172)] + int isSingleInheritance + { + + get; + } + [DispId(173)] + int isMultipleInheritance + { + + get; + } + [DispId(174)] + int isVirtualInheritance + { + + get; + } + [DispId(175)] + int restrictedType + { + + get; + } + [DispId(176)] + int isPointerBasedOnSymbolValue + { + + get; + } + [DispId(177)] + IDiaSymbol baseSymbol + { + + [return: MarshalAs(UnmanagedType.Interface)] + get; + } + [DispId(178)] + uint baseSymbolId + { + + get; + } + [DispId(179)] + string objectFileName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(184)] + int isSdl + { + + get; + } + [DispId(185)] + int isWinRTPointer + { + + get; + } + [DispId(186)] + int isRefUdt + { + + get; + } + [DispId(187)] + int isValueUdt + { + + get; + } + [DispId(188)] + int isInterfaceUdt + { + + get; + } + [DispId(189)] + int isPGO + { + + get; + } + [DispId(190)] + int hasValidPGOCounts + { + + get; + } + [DispId(191)] + int isOptimizedForSpeed + { + + get; + } + [DispId(192)] + uint PGOEntryCount + { + + get; + } + [DispId(193)] + uint PGOEdgeCount + { + + get; + } + [DispId(194)] + ulong PGODynamicInstructionCount + { + + get; + } + [DispId(195)] + uint staticSize + { + + get; + } + [DispId(196)] + uint finalLiveStaticSize + { + + get; + } + [DispId(197)] + string phaseName + { + + [return: MarshalAs(UnmanagedType.BStr)] + get; + } + [DispId(198)] + int hasControlFlowCheck + { + + get; + } + [DispId(199)] + int constantExport + { + + get; + } + [DispId(200)] + int dataExport + { + + get; + } + [DispId(201)] + int privateExport + { + + get; + } + [DispId(202)] + int noNameExport + { + + get; + } + [DispId(203)] + int exportHasExplicitlyAssignedOrdinal + { + + get; + } + [DispId(204)] + int exportIsForwarder + { + + get; + } + [DispId(205)] + uint ordinal + { + + get; + } + + //void get_dataBytes([In] uint cbData, out uint pcbData, out byte pbData); + + //void findChildren([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findChildrenEx([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findChildrenExByAddr([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findChildrenExByVA([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findChildrenExByRVA([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void get_types([In] uint cTypes, out uint pcTypes, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol pTypes); + + //void get_typeIds([In] uint cTypeIds, out uint pcTypeIds, out uint pdwTypeIds); + + //void get_undecoratedNameEx([In] uint undecorateOptions, [MarshalAs(UnmanagedType.BStr)] out string name); + + //void get_numericProperties([In] uint cnt, out uint pcnt, out uint pProperties); + + //void get_modifierValues([In] uint cnt, out uint pcnt, out ushort pModifiers); + + //void findInlineFramesByAddr([In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findInlineFramesByRVA([In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findInlineFramesByVA([In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + + //void findInlineeLines([MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + //void findInlineeLinesByAddr([In] uint isect, [In] uint offset, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + //void findInlineeLinesByRVA([In] uint rva, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + //void findInlineeLinesByVA([In] ulong va, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + + //void getSrcLineOnTypeDefn([MarshalAs(UnmanagedType.Interface)] out IDiaLineNumber ppResult); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaTable.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaTable.cs new file mode 100644 index 00000000000..e21c604d34f --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaTable.cs @@ -0,0 +1,41 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [TypeIdentifier] + [CompilerGenerated] + [DefaultMember("Item"), Guid("4A59FB77-ABAC-469B-A30B-9ECC85BFEF14"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IDiaTable : IEnumUnknown + { + string name { get; } + + [DispId(2)] + int count + { + get; + } + + new void RemoteNext([In] uint celt, [MarshalAs(UnmanagedType.IUnknown)] out object rgelt, out uint pceltFetched); + + new void Skip([In] uint celt); + + new void Reset(); + + new void Clone([MarshalAs(UnmanagedType.Interface)] out IEnumUnknown ppenum); + + [return: MarshalAs(UnmanagedType.IUnknown, MarshalType = "System.Runtime.InteropServices.CustomMarshalers.EnumeratorToEnumVariantMarshaler")] + IEnumerator GetEnumerator(); + + + [return: MarshalAs(UnmanagedType.IUnknown)] + object Item([In] uint index); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs b/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs new file mode 100644 index 00000000000..097a2c1df3c --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("00000100-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IEnumUnknown + { + void RemoteNext([In] uint celt, [MarshalAs(UnmanagedType.IUnknown)] out object rgelt, out uint pceltFetched); + + void Skip([In] uint celt); + + void Reset(); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IEnumUnknown ppenum); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/ISequentialStream.cs b/src/Microsoft.Framework.TestHost/DIA/ISequentialStream.cs new file mode 100644 index 00000000000..a25530ee6f1 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/ISequentialStream.cs @@ -0,0 +1,18 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("0C733A30-2A1C-11CE-ADE5-00AA0044773D"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface ISequentialStream + { + + void RemoteRead([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, int cb, out uint pcbRead); + + void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/IStream.cs b/src/Microsoft.Framework.TestHost/DIA/IStream.cs new file mode 100644 index 00000000000..611b1656332 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/IStream.cs @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [Guid("0000000C-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IStream : ISequentialStream + { + new void RemoteRead([Out, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] byte[] pv, int cb, out uint pcbRead); + + new void RemoteWrite([In] ref byte pv, [In] uint cb, out uint pcbWritten); + + void RemoteSeek([In] _LARGE_INTEGER dlibMove, [In] uint dwOrigin, out _ULARGE_INTEGER plibNewPosition); + + void SetSize([In] _ULARGE_INTEGER libNewSize); + + void RemoteCopyTo([MarshalAs(UnmanagedType.Interface)] [In] IStream pstm, [In] _ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten); + + void Commit([In] uint grfCommitFlags); + + void Revert(); + + void LockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); + + void UnlockRegion([In] _ULARGE_INTEGER libOffset, [In] _ULARGE_INTEGER cb, [In] uint dwLockType); + + void Stat(out tagSTATSTG pstatstg, [In] uint grfStatFlag); + + void Clone([MarshalAs(UnmanagedType.Interface)] out IStream ppstm); + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/StreamWrapper.cs b/src/Microsoft.Framework.TestHost/DIA/StreamWrapper.cs new file mode 100644 index 00000000000..4f03a3a7658 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/StreamWrapper.cs @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.IO; +using System.Runtime.InteropServices; + +namespace dia2 +{ + public class StreamWrapper : IStream + { + private Stream _stream; + + public StreamWrapper(Stream stream) + { + _stream = stream; + } + + public void RemoteRead(byte[] pv, int cb, out uint pcbRead) + { + pcbRead = (uint)_stream.Read(pv, 0, cb); + } + + public void Stat(out tagSTATSTG pstatstg, [In]uint grfStatFlag) + { + pstatstg = new tagSTATSTG(); + pstatstg.cbSize.QuadPart = (ulong)_stream.Length; + } + + public void RemoteSeek([In]_LARGE_INTEGER dlibMove, [In]uint dwOrigin, out _ULARGE_INTEGER plibNewPosition) + { + plibNewPosition.QuadPart = (ulong)_stream.Seek(dlibMove.QuadPart, (SeekOrigin)dwOrigin); + } + + public void RemoteRead(byte[] pv, [In]uint cb, out uint pcbRead) + { + pcbRead = (uint)_stream.Read(pv, offset: 0, count: (int)cb); + } + + public void SetSize([In]_ULARGE_INTEGER libNewSize) + { + throw new NotImplementedException(); + } + + public void RemoteCopyTo([In, MarshalAs(UnmanagedType.Interface)]IStream pstm, [In]_ULARGE_INTEGER cb, out _ULARGE_INTEGER pcbRead, out _ULARGE_INTEGER pcbWritten) + { + throw new NotImplementedException(); + } + + public void Commit([In]uint grfCommitFlags) + { + throw new NotImplementedException(); + } + + public void Revert() + { + throw new NotImplementedException(); + } + + public void LockRegion([In]_ULARGE_INTEGER libOffset, [In]_ULARGE_INTEGER cb, [In]uint dwLockType) + { + throw new NotImplementedException(); + } + + public void UnlockRegion([In]_ULARGE_INTEGER libOffset, [In]_ULARGE_INTEGER cb, [In]uint dwLockType) + { + throw new NotImplementedException(); + } + + public void Clone([MarshalAs(UnmanagedType.Interface)]out IStream ppstm) + { + throw new NotImplementedException(); + } + + public void RemoteWrite([In]ref byte pv, [In]uint cb, out uint pcbWritten) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/DIA/Structs.cs b/src/Microsoft.Framework.TestHost/DIA/Structs.cs new file mode 100644 index 00000000000..f7b30b7039b --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/Structs.cs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Runtime.InteropServices; + +namespace dia2 +{ + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct _LARGE_INTEGER + { + public long QuadPart; + } + + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct _ULARGE_INTEGER + { + public ulong QuadPart; + } + + [StructLayout(LayoutKind.Sequential, Pack = 8)] + public struct tagSTATSTG + { + [MarshalAs(UnmanagedType.LPWStr)] + public string pwcsName; + public uint type; + public _ULARGE_INTEGER cbSize; + public _FILETIME mtime; + public _FILETIME ctime; + public _FILETIME atime; + public uint grfMode; + public uint grfLocksSupported; + public Guid clsid; + public uint grfStateBits; + public uint reserved; + } + + [StructLayout(LayoutKind.Sequential, Pack = 4)] + public struct _FILETIME + { + public uint dwLowDateTime; + public uint dwHighDateTime; + } +} diff --git a/src/Microsoft.Framework.TestHost/DIA/SymTagEnum.cs b/src/Microsoft.Framework.TestHost/DIA/SymTagEnum.cs new file mode 100644 index 00000000000..9205adfec13 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/DIA/SymTagEnum.cs @@ -0,0 +1,51 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace dia2 +{ + public enum SymTagEnum + { + SymTagNull, + SymTagExe, + SymTagCompiland, + SymTagCompilandDetails, + SymTagCompilandEnv, + SymTagFunction, + SymTagBlock, + SymTagData, + SymTagAnnotation, + SymTagLabel, + SymTagPublicSymbol, + SymTagUDT, + SymTagEnum, + SymTagFunctionType, + SymTagPointerType, + SymTagArrayType, + SymTagBaseType, + SymTagTypedef, + SymTagBaseClass, + SymTagFriend, + SymTagFunctionArgType, + SymTagFuncDebugStart, + SymTagFuncDebugEnd, + SymTagUsingNamespace, + SymTagVTableShape, + SymTagVTable, + SymTagCustom, + SymTagThunk, + SymTagCustomType, + SymTagManagedType, + SymTagDimension, + SymTagCallSite, + SymTagInlineSite, + SymTagBaseInterface, + SymTagVectorType, + SymTagMatrixType, + SymTagHLSLType, + SymTagCaller, + SymTagCallee, + SymTagExport, + SymTagHeapAllocationSite, + SymTagMax + } +} diff --git a/src/Microsoft.Framework.TestHost/Program.cs b/src/Microsoft.Framework.TestHost/Program.cs index a0d66f01491..5ff4fba4571 100644 --- a/src/Microsoft.Framework.TestHost/Program.cs +++ b/src/Microsoft.Framework.TestHost/Program.cs @@ -4,11 +4,9 @@ using System; using System.Collections.Generic; using System.Diagnostics; -using System.Linq; using System.Threading.Tasks; using Microsoft.Framework.Runtime; using Microsoft.Framework.Runtime.Common.CommandLine; -using Microsoft.Framework.Runtime.Common.DependencyInjection; using Microsoft.Framework.TestAdapter; namespace Microsoft.Framework.TestHost @@ -102,7 +100,7 @@ private async Task ExecuteTests(int port, string projectPath, IList test return; } - var testServices = new ServiceProvider(_services); + var testServices = TestServices.CreateTestServices(_services, project); testServices.Add(typeof(ITestExecutionSink), new TestExecutionSink(channel)); var args = new List() @@ -164,7 +162,7 @@ private async Task DiscoverTests(int port, string projectPath) return; } - var testServices = new ServiceProvider(_services); + var testServices = TestServices.CreateTestServices(_services, project); testServices.Add(typeof(ITestDiscoverySink), new TestDiscoverySink(channel)); var args = new string[] { "test", "--list", "--designtime" }; diff --git a/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs b/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs new file mode 100644 index 00000000000..91e88df2324 --- /dev/null +++ b/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs @@ -0,0 +1,311 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.IO; +using System.Reflection; +using dia2; +using Microsoft.Framework.Logging; +using Microsoft.Framework.Runtime; +using Microsoft.Framework.TestAdapter; + +namespace Microsoft.Framework.TestHost.TestAdapter +{ + public class SourceInformationProvider : ISourceInformationProvider + { + private readonly IMetadataProjectReference _project; + private readonly ILogger _logger; + + private bool? _isInitialized; + private IDiaDataSource _diaDataSource; + private IDiaSession _diaSession; + private AssemblyData _assemblyData; + + public SourceInformationProvider( + IMetadataProjectReference project, + ILogger logger) + { + _project = project; + _logger = logger; + } + + public SourceInformation GetSourceInformation(string className, string methodName) + { + if (!EnsureInitialized()) + { + // Unable to load DIA or we had a failure reading the symbols. + return null; + } + + Debug.Assert(_diaSession != null); + Debug.Assert(_assemblyData != null); + + // The DIA code doesn't include a + for nested classes, just a dot. + var symbolId = FindMethodSymbolId(className.Replace('+', '.'), methodName); + if (symbolId == null) + { + // No matching method in the symbol. + return null; + } + + try + { + return GetSourceInformation(symbolId.Value); + } + catch (Exception ex) + { + _logger.LogWarning("Failed to access source information in symbol.", ex); + return null; + } + } + + private uint? FindMethodSymbolId(string className, string methodName) + { + Debug.Assert(_isInitialized == true); + + ClassData classData; + if (_assemblyData.Classes.TryGetValue(className, out classData)) + { + MethodData methodData; + if (classData.Methods.TryGetValue(methodName, out methodData)) + { + return methodData.SymbolId; + } + } + + return null; + } + + private SourceInformation GetSourceInformation(uint symbolId) + { + Debug.Assert(_isInitialized == true); + + string filename = null; + int? lineNumber = null; + + IDiaSymbol diaSymbol; + _diaSession.symbolById(symbolId, out diaSymbol); + if (diaSymbol == null) + { + // Doesn't seem like this should happen, since DIA gave us the id. + return null; + } + + IDiaEnumLineNumbers diaLineNumbers; + _diaSession.findLinesByAddr( + diaSymbol.addressSection, + diaSymbol.addressOffset, + (uint)diaSymbol.length, + out diaLineNumbers); + + // Resist the user to use foreach here. It doesn't work well with these APIs. + IDiaLineNumber diaLineNumber; + var lineNumbersFetched = 0u; + + diaLineNumbers.Next(1u, out diaLineNumber, out lineNumbersFetched); + while (lineNumbersFetched == 1 && diaLineNumber != null) + { + if (filename == null) + { + var diaFile = diaLineNumber.sourceFile; + if (diaFile != null) + { + filename = diaFile.fileName; + } + } + + if (diaLineNumber.lineNumber != 16707566u) + { + // We'll see multiple line numbers for the same method, but we just want the first one. + lineNumber = Math.Min(lineNumber ?? Int32.MaxValue, (int)diaLineNumber.lineNumber); + } + + diaLineNumbers.Next(1u, out diaLineNumber, out lineNumbersFetched); + } + + if (filename == null || lineNumber == null) + { + return null; + } + else + { + return new SourceInformation(filename, lineNumber.Value); + } + } + + private bool EnsureInitialized() + { + if (_isInitialized.HasValue) + { + return _isInitialized.Value; + } + + if (_project == null) + { + _logger.LogWarning("No project information. No source information will be available."); + _isInitialized = false; + return _isInitialized.Value; + } + + try + { + _diaDataSource = (IDiaDataSource)new DiaDataSource(); + _isInitialized = true; + } + catch (Exception ex) + { + _logger.LogWarning("Failed to create DIA DataSource. No source information will be available.", ex); + _isInitialized = false; + return _isInitialized.Value; + } + + // We have a project, and we successfully loaded DIA, so let's capture the symbols + // and create a session. + try + { + var context = new CapturingLoadContext(); + _project.Load(context); + + _diaDataSource.loadDataFromIStream(new StreamWrapper(context.Symbols)); + _diaDataSource.openSession(out _diaSession); + } + catch (Exception ex) + { + _logger.LogWarning("Failed to load symbols. No source information will be available.", ex); + _isInitialized = false; + return _isInitialized.Value; + } + + try + { + _assemblyData = FetchSymbolData(_diaSession); + } + catch (Exception ex) + { + _logger.LogWarning("Failed to read symbols. No source information will be available.", ex); + _isInitialized = false; + return _isInitialized.Value; + } + + _isInitialized = true; + return _isInitialized.Value; + } + + // Builds a lookup table of class+method name. + // + // It's easier to build it at once by enumerating, once we have the table, we + // can use the symbolIds to look up the sources when we need them. + private static AssemblyData FetchSymbolData(IDiaSession session) + { + // This will be a *flat* enumerator of all classes. + // + // A nested class will not contain a '+' in it's name, just a '.' separating the parent class name from + // the child class name. + IDiaEnumSymbols diaClasses; + + session.findChildren( + session.globalScope, // Search at the top-level. + SymTagEnum.SymTagCompiland, // Just find classes. + name: null, // Don't filter by name. + compareFlags: 0u, // doesn't matter because name is null. + ppResult: out diaClasses); + + var assemblyData = new AssemblyData(); + + // Resist the urge to use foreach here. It doesn't work well with these APIs. + var classesFetched = 0u; + IDiaSymbol diaClass; + + diaClasses.Next(1u, out diaClass, out classesFetched); + while (classesFetched == 1 && diaClass != null) + { + var classData = new ClassData() + { + Name = diaClass.name, + SymbolId = diaClass.symIndexId, + }; + assemblyData.Classes.Add(diaClass.name, classData); + + IDiaEnumSymbols diaMethods; + session.findChildren( + diaClass, + SymTagEnum.SymTagFunction, + name: null, // Don't filter by name. + compareFlags: 0u, // doesn't matter because name is null. + ppResult: out diaMethods); + + // Resist the urge to use foreach here. It doesn't work well with these APIs. + var methodsFetched = 0u; + IDiaSymbol diaMethod; + + diaMethods.Next(1u, out diaMethod, out methodsFetched); + while (methodsFetched == 1 && diaMethod != null) + { + classData.Methods[diaMethod.name] = new MethodData() + { + Name = diaMethod.name, + SymbolId = diaMethod.symIndexId, + }; + + diaMethods.Next(1u, out diaMethod, out methodsFetched); + } + + diaClasses.Next(1u, out diaClass, out classesFetched); + } + + return assemblyData; + } + + private class AssemblyData + { + public IDictionary Classes { get; } = new Dictionary(); + } + + private class ClassData + { + public string Name { get; set; } + + public uint SymbolId { get; set; } + + public IDictionary Methods { get; } = new Dictionary(); + } + + private class MethodData + { + public string Name { get; set; } + + public uint SymbolId { get; set; } + } + + private class CapturingLoadContext : IAssemblyLoadContext + { + public Stream Symbols { get; set; } + + public void Dispose() + { + } + + public Assembly Load(string name) + { + throw new NotImplementedException(); + } + + public Assembly LoadFile(string path) + { + throw new NotImplementedException(); + } + + public Assembly LoadStream(Stream assemblyStream, Stream assemblySymbols) + { + // The stream that's passed to us will get disposed, so we need to make + // a copy. + Symbols = new MemoryStream((int)assemblySymbols.Length); + assemblySymbols.CopyTo(Symbols); + + return null; + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/TestServices.cs b/src/Microsoft.Framework.TestHost/TestServices.cs new file mode 100644 index 00000000000..5d9ed967a1c --- /dev/null +++ b/src/Microsoft.Framework.TestHost/TestServices.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +using System; +using System.Linq; +using Microsoft.Framework.DependencyInjection; +using Microsoft.Framework.Logging; +using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Common.DependencyInjection; +using Microsoft.Framework.TestAdapter; +using Microsoft.Framework.TestHost.TestAdapter; + +namespace Microsoft.Framework.TestHost +{ + internal static class TestServices + { + public static ServiceProvider CreateTestServices( + IServiceProvider applicationServices, + Project project) + { + var services = new ServiceProvider(applicationServices); + + var libraryManager = applicationServices.GetRequiredService(); + var export = libraryManager.GetLibraryExport(project.Name); + + var projectReference = export.MetadataReferences + .OfType() + .Where(r => r.Name == project.Name) + .FirstOrDefault(); + + services.Add( + typeof(ISourceInformationProvider), + new SourceInformationProvider(projectReference, new NullLogger())); + + return services; + } + + private class NullLogger : ILogger + { + public IDisposable BeginScope(object state) + { + return null; + } + + public bool IsEnabled(LogLevel logLevel) + { + return false; + } + + public void Log(LogLevel logLevel, int eventId, object state, Exception exception, Func formatter) + { + } + } + } +} \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index 9f08494854d..a5d74544652 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -7,6 +7,7 @@ "Microsoft.Framework.TestAdapter": "1.0.0-*", "Microsoft.Framework.ApplicationHost": "1.0.0-*", "Microsoft.Framework.CommandLineUtils": "1.0.0-*", + "Microsoft.Framework.Logging": "1.0.0-*", "Microsoft.Framework.Runtime": "1.0.0-*", "Microsoft.Framework.Runtime.Common": { "version": "1.0.0-*", "type": "build" }, "Microsoft.Framework.Runtime.Interfaces": "1.0.0-*", From de4bd3c518de69b7b26f607ea5028ef712423bc5 Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Sun, 22 Mar 2015 20:22:56 -0700 Subject: [PATCH 134/463] CR feedback bro --- .../DIA/IDiaSymbol.cs | 38 +++++++++---------- .../DIA/IEnumUnknown.cs | 18 ++++----- src/Microsoft.Framework.TestHost/Program.cs | 9 +---- .../TestServices.cs | 6 ++- 4 files changed, 35 insertions(+), 36 deletions(-) diff --git a/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs b/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs index a47421f11c2..46bb782ab03 100644 --- a/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs +++ b/src/Microsoft.Framework.TestHost/DIA/IDiaSymbol.cs @@ -1228,42 +1228,42 @@ uint ordinal get; } - //void get_dataBytes([In] uint cbData, out uint pcbData, out byte pbData); + void get_dataBytes([In] uint cbData, out uint pcbData, out byte pbData); - //void findChildren([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findChildren([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findChildrenEx([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findChildrenEx([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findChildrenExByAddr([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findChildrenExByAddr([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findChildrenExByVA([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findChildrenExByVA([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findChildrenExByRVA([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findChildrenExByRVA([In] SymTagEnum symTag, [MarshalAs(UnmanagedType.LPWStr)] [In] string name, [In] uint compareFlags, [In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void get_types([In] uint cTypes, out uint pcTypes, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol pTypes); + void get_types([In] uint cTypes, out uint pcTypes, [MarshalAs(UnmanagedType.Interface)] out IDiaSymbol pTypes); - //void get_typeIds([In] uint cTypeIds, out uint pcTypeIds, out uint pdwTypeIds); + void get_typeIds([In] uint cTypeIds, out uint pcTypeIds, out uint pdwTypeIds); - //void get_undecoratedNameEx([In] uint undecorateOptions, [MarshalAs(UnmanagedType.BStr)] out string name); + void get_undecoratedNameEx([In] uint undecorateOptions, [MarshalAs(UnmanagedType.BStr)] out string name); - //void get_numericProperties([In] uint cnt, out uint pcnt, out uint pProperties); + void get_numericProperties([In] uint cnt, out uint pcnt, out uint pProperties); - //void get_modifierValues([In] uint cnt, out uint pcnt, out ushort pModifiers); + void get_modifierValues([In] uint cnt, out uint pcnt, out ushort pModifiers); - //void findInlineFramesByAddr([In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findInlineFramesByAddr([In] uint isect, [In] uint offset, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findInlineFramesByRVA([In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findInlineFramesByRVA([In] uint rva, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findInlineFramesByVA([In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); + void findInlineFramesByVA([In] ulong va, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumSymbols ppResult); - //void findInlineeLines([MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + void findInlineeLines([MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); - //void findInlineeLinesByAddr([In] uint isect, [In] uint offset, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + void findInlineeLinesByAddr([In] uint isect, [In] uint offset, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); - //void findInlineeLinesByRVA([In] uint rva, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + void findInlineeLinesByRVA([In] uint rva, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); - //void findInlineeLinesByVA([In] ulong va, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); + void findInlineeLinesByVA([In] ulong va, [In] uint length, [MarshalAs(UnmanagedType.Interface)] out IDiaEnumLineNumbers ppResult); - //void getSrcLineOnTypeDefn([MarshalAs(UnmanagedType.Interface)] out IDiaLineNumber ppResult); + void getSrcLineOnTypeDefn([MarshalAs(UnmanagedType.Interface)] out IDiaLineNumber ppResult); } } diff --git a/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs b/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs index 097a2c1df3c..570b5763015 100644 --- a/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs +++ b/src/Microsoft.Framework.TestHost/DIA/IEnumUnknown.cs @@ -6,16 +6,16 @@ namespace dia2 { - [Guid("00000100-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [ComImport] - public interface IEnumUnknown - { - void RemoteNext([In] uint celt, [MarshalAs(UnmanagedType.IUnknown)] out object rgelt, out uint pceltFetched); + [Guid("00000100-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [ComImport] + public interface IEnumUnknown + { + void RemoteNext([In] uint celt, [MarshalAs(UnmanagedType.IUnknown)] out object rgelt, out uint pceltFetched); - void Skip([In] uint celt); + void Skip([In] uint celt); - void Reset(); + void Reset(); - void Clone([MarshalAs(UnmanagedType.Interface)] out IEnumUnknown ppenum); - } + void Clone([MarshalAs(UnmanagedType.Interface)] out IEnumUnknown ppenum); + } } diff --git a/src/Microsoft.Framework.TestHost/Program.cs b/src/Microsoft.Framework.TestHost/Program.cs index 5ff4fba4571..35c81fc7183 100644 --- a/src/Microsoft.Framework.TestHost/Program.cs +++ b/src/Microsoft.Framework.TestHost/Program.cs @@ -7,7 +7,6 @@ using System.Threading.Tasks; using Microsoft.Framework.Runtime; using Microsoft.Framework.Runtime.Common.CommandLine; -using Microsoft.Framework.TestAdapter; namespace Microsoft.Framework.TestHost { @@ -100,9 +99,6 @@ private async Task ExecuteTests(int port, string projectPath, IList test return; } - var testServices = TestServices.CreateTestServices(_services, project); - testServices.Add(typeof(ITestExecutionSink), new TestExecutionSink(channel)); - var args = new List() { "test", @@ -120,6 +116,7 @@ private async Task ExecuteTests(int port, string projectPath, IList test try { + var testServices = TestServices.CreateTestServices(_services, project, channel); await ProjectCommand.Execute(testServices, project, args.ToArray()); } catch @@ -162,13 +159,11 @@ private async Task DiscoverTests(int port, string projectPath) return; } - var testServices = TestServices.CreateTestServices(_services, project); - testServices.Add(typeof(ITestDiscoverySink), new TestDiscoverySink(channel)); - var args = new string[] { "test", "--list", "--designtime" }; try { + var testServices = TestServices.CreateTestServices(_services, project, channel); await ProjectCommand.Execute(testServices, project, args); } catch diff --git a/src/Microsoft.Framework.TestHost/TestServices.cs b/src/Microsoft.Framework.TestHost/TestServices.cs index 5d9ed967a1c..2afc296a86a 100644 --- a/src/Microsoft.Framework.TestHost/TestServices.cs +++ b/src/Microsoft.Framework.TestHost/TestServices.cs @@ -16,7 +16,8 @@ internal static class TestServices { public static ServiceProvider CreateTestServices( IServiceProvider applicationServices, - Project project) + Project project, + ReportingChannel channel) { var services = new ServiceProvider(applicationServices); @@ -32,6 +33,9 @@ public static ServiceProvider CreateTestServices( typeof(ISourceInformationProvider), new SourceInformationProvider(projectReference, new NullLogger())); + services.Add(typeof(ITestDiscoverySink), new TestDiscoverySink(channel)); + services.Add(typeof(ITestExecutionSink), new TestExecutionSink(channel)); + return services; } From 0e8d3aaa34db4482b0407d73e0280aada18d9805 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Tue, 24 Mar 2015 22:38:31 -0700 Subject: [PATCH 135/463] Remove k command and use dnx instead --- build.sh | 2 +- test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index ec3263114a3..d81164353c6 100644 --- a/build.sh +++ b/build.sh @@ -31,7 +31,7 @@ if ! type dnvm > /dev/null 2>&1; then source packages/KoreBuild/build/dnvm.sh fi -if ! type k > /dev/null 2>&1; then +if ! type dnx > /dev/null 2>&1; then dnvm upgrade fi diff --git a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs index 34c615adcb3..cf65d005c9a 100644 --- a/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs +++ b/test/Microsoft.Framework.TestHost.Tests/TestHostWrapper.cs @@ -78,7 +78,7 @@ private static Process RunDNX(string projectDirectory, IEnumerable args) { // TODO: Mono? - var allArgs = "/c k Microsoft.Framework.TestHost " + string.Join(" ", args.Select(Quote)); + var allArgs = "/c dnx . Microsoft.Framework.TestHost " + string.Join(" ", args.Select(Quote)); return Process.Start(new ProcessStartInfo { FileName = "cmd", From 0daf3bb23f620a0d0ddbfbe3be761a8707614e0b Mon Sep 17 00:00:00 2001 From: suhasj Date: Wed, 25 Mar 2015 11:46:08 -0700 Subject: [PATCH 136/463] Updating to release NuGet.config --- NuGet.Config | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/NuGet.Config b/NuGet.Config index da57d47267e..1978dc065a9 100644 --- a/NuGet.Config +++ b/NuGet.Config @@ -1,7 +1,7 @@  - + - \ No newline at end of file + From f9810ad0761f3216b0c7277f1913466068e9045a Mon Sep 17 00:00:00 2001 From: Pranav K Date: Thu, 26 Mar 2015 20:30:23 -0700 Subject: [PATCH 137/463] Reacting to DNX namespace changes --- .../TestAdapter/SourceInformationProvider.cs | 1 + src/Microsoft.Framework.TestHost/TestServices.cs | 1 + 2 files changed, 2 insertions(+) diff --git a/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs b/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs index 91e88df2324..5a3c5ac1ee6 100644 --- a/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs +++ b/src/Microsoft.Framework.TestHost/TestAdapter/SourceInformationProvider.cs @@ -9,6 +9,7 @@ using dia2; using Microsoft.Framework.Logging; using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Compilation; using Microsoft.Framework.TestAdapter; namespace Microsoft.Framework.TestHost.TestAdapter diff --git a/src/Microsoft.Framework.TestHost/TestServices.cs b/src/Microsoft.Framework.TestHost/TestServices.cs index 2afc296a86a..28cd4141a55 100644 --- a/src/Microsoft.Framework.TestHost/TestServices.cs +++ b/src/Microsoft.Framework.TestHost/TestServices.cs @@ -6,6 +6,7 @@ using Microsoft.Framework.DependencyInjection; using Microsoft.Framework.Logging; using Microsoft.Framework.Runtime; +using Microsoft.Framework.Runtime.Compilation; using Microsoft.Framework.Runtime.Common.DependencyInjection; using Microsoft.Framework.TestAdapter; using Microsoft.Framework.TestHost.TestAdapter; From cf5b8e935320c1ab5125ac21f8bb0ddbcf66d680 Mon Sep 17 00:00:00 2001 From: David Fowler Date: Sat, 28 Mar 2015 01:26:56 -0700 Subject: [PATCH 138/463] Added sockets as an explicit dependency --- src/Microsoft.Framework.TestHost/project.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Microsoft.Framework.TestHost/project.json b/src/Microsoft.Framework.TestHost/project.json index a5d74544652..a958cc5d773 100644 --- a/src/Microsoft.Framework.TestHost/project.json +++ b/src/Microsoft.Framework.TestHost/project.json @@ -22,7 +22,8 @@ "dependencies": { "System.Console": "4.0.0-beta-*", "System.Diagnostics.Process": "4.0.0-beta-*", - "System.Diagnostics.TraceSource": "4.0.0-beta-*" + "System.Diagnostics.TraceSource": "4.0.0-beta-*", + "System.Net.Sockets": "4.0.0-beta-*" } } } From c28308b7cc3b463785a7987a4d465bcec819569f Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 1 Apr 2015 15:57:38 -0700 Subject: [PATCH 139/463] Add travis and appveyor CI support. --- .travis.yml | 3 +++ appveyor.yml | 5 +++++ build.sh | 0 3 files changed, 8 insertions(+) create mode 100644 .travis.yml create mode 100644 appveyor.yml mode change 100644 => 100755 build.sh diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000000..0f4cb93e59f --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: csharp +script: + - ./build.sh verify \ No newline at end of file diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000000..88cb9ef145a --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,5 @@ +build_script: + - build.cmd verify +clone_depth: 1 +test: off +deploy: off \ No newline at end of file diff --git a/build.sh b/build.sh old mode 100644 new mode 100755 From fb82bc7408c183ce5c697049067875c784831060 Mon Sep 17 00:00:00 2001 From: "N. Taylor Mullen" Date: Wed, 1 Apr 2015 17:09:13 -0700 Subject: [PATCH 140/463] Turn off sudo for .travis.yml. --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 0f4cb93e59f..5939a529e51 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,4 @@ language: csharp +sudo: false script: - ./build.sh verify \ No newline at end of file From d47dca2be8055bc1a5145369afd0ec12f764d175 Mon Sep 17 00:00:00 2001 From: Troy Dai Date: Thu, 2 Apr 2015 09:20:42 -0700 Subject: [PATCH 141/463] Update global.json, sources=>projects --- global.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/global.json b/global.json index 840c36f6ade..983ba0401e3 100644 --- a/global.json +++ b/global.json @@ -1,3 +1,3 @@ { - "sources": ["src"] -} \ No newline at end of file + "projects": ["src"] +} From f42f07dd84ee238df61dd072af0e937da663dde6 Mon Sep 17 00:00:00 2001 From: Doug Bunting Date: Thu, 2 Apr 2015 13:49:30 -0700 Subject: [PATCH 142/463] Update .xproj files for Microsoft.Web.AspNet.* -> Microsoft.DNX.* rename --- .../Microsoft.AspNet.Testing.xproj | 8 ++++---- .../Microsoft.Framework.Logging.Testing.xproj | 6 +++--- .../Microsoft.Framework.TestAdapter.xproj | 8 ++++---- .../Microsoft.Framework.TestHost.xproj | 8 ++++---- src/StyleCop.KRules/StyleCop.KRules.xproj | 8 ++++---- .../Microsoft.Framework.Logging.Testing.Tests.xproj | 6 +++--- .../Microsoft.Framework.TestHost.Tests.xproj | 8 ++++---- test/Sample.Tests/Sample.Tests.xproj | 8 ++++---- 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.xproj b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.xproj index 3583805ddbf..2a426cb8427 100644 --- a/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.xproj +++ b/src/Microsoft.AspNet.Testing/Microsoft.AspNet.Testing.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 09be5203-8042-4338-9713-e44169342e72 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.xproj b/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.xproj index 111516a7e6b..0d0fa2d24f8 100644 --- a/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.xproj +++ b/src/Microsoft.Framework.Logging.Testing/Microsoft.Framework.Logging.Testing.xproj @@ -4,7 +4,7 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 379aa56b-e1a6-4133-9a45-7f70385f39fb ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.xproj b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.xproj index d3a44ce9b12..56d469c7c9f 100644 --- a/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.xproj +++ b/src/Microsoft.Framework.TestAdapter/Microsoft.Framework.TestAdapter.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 71c2f8aa-05e6-47db-9a1a-d2760cef7dc1 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.xproj b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.xproj index 72646b7e308..31b3cc5b710 100644 --- a/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.xproj +++ b/src/Microsoft.Framework.TestHost/Microsoft.Framework.TestHost.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + f003f228-2ae2-4e9d-877b-93eb773b5061 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/src/StyleCop.KRules/StyleCop.KRules.xproj b/src/StyleCop.KRules/StyleCop.KRules.xproj index 19565bcba8d..9392d9794b2 100644 --- a/src/StyleCop.KRules/StyleCop.KRules.xproj +++ b/src/StyleCop.KRules/StyleCop.KRules.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 657eb507-ee7a-451f-90a4-196f6fcd66e5 ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj b/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj index 01906e6559e..018078c757b 100644 --- a/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj +++ b/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj @@ -4,7 +4,7 @@ 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 6fa3efae-2dbc-4532-a5a0-c2ebd8dd672f ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.xproj b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.xproj index a869473eb63..3afc94ac2e5 100644 --- a/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.xproj +++ b/test/Microsoft.Framework.TestHost.Tests/Microsoft.Framework.TestHost.Tests.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 25d18d0c-119c-4ab4-bca6-ac06179335fa ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file diff --git a/test/Sample.Tests/Sample.Tests.xproj b/test/Sample.Tests/Sample.Tests.xproj index 7a7ca46e92f..a8f96d17c98 100644 --- a/test/Sample.Tests/Sample.Tests.xproj +++ b/test/Sample.Tests/Sample.Tests.xproj @@ -1,10 +1,10 @@ - + 14.0 $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion) - + 25d18d0b-119c-4ab4-bca6-ac06179335fa ..\..\artifacts\obj\$(MSBuildProjectName) @@ -13,5 +13,5 @@ 2.0 - - + + \ No newline at end of file From 11f54613b4bbb50923c875cba06585dc43ee7940 Mon Sep 17 00:00:00 2001 From: Wei Wang Date: Fri, 3 Apr 2015 17:30:20 -0700 Subject: [PATCH 143/463] Fix AppVeyor git line ending config --- appveyor.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 88cb9ef145a..3fab83e134e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,3 +1,5 @@ +init: + - git config --global core.autocrlf true build_script: - build.cmd verify clone_depth: 1 From 32ddd44538c685f67b3e90b769758f34d1c898ea Mon Sep 17 00:00:00 2001 From: Kiran Challa Date: Sat, 4 Apr 2015 02:53:15 -0700 Subject: [PATCH 144/463] Reacting to ILogger api changes --- src/Microsoft.Framework.Logging.Testing/NullLogger.cs | 2 +- src/Microsoft.Framework.Logging.Testing/TestLogger.cs | 2 +- src/Microsoft.Framework.TestHost/TestServices.cs | 2 +- .../Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Microsoft.Framework.Logging.Testing/NullLogger.cs b/src/Microsoft.Framework.Logging.Testing/NullLogger.cs index f7ea6b310aa..0ad379edfcd 100644 --- a/src/Microsoft.Framework.Logging.Testing/NullLogger.cs +++ b/src/Microsoft.Framework.Logging.Testing/NullLogger.cs @@ -9,7 +9,7 @@ public class NullLogger : ILogger { public static readonly NullLogger Instance = new NullLogger(); - public IDisposable BeginScope(object state) + public IDisposable BeginScopeImpl(object state) { return NullDisposable.Instance; } diff --git a/src/Microsoft.Framework.Logging.Testing/TestLogger.cs b/src/Microsoft.Framework.Logging.Testing/TestLogger.cs index f268483e993..2a40ea15c2f 100644 --- a/src/Microsoft.Framework.Logging.Testing/TestLogger.cs +++ b/src/Microsoft.Framework.Logging.Testing/TestLogger.cs @@ -21,7 +21,7 @@ public TestLogger(string name, TestSink sink, bool enabled) public string Name { get; set; } - public IDisposable BeginScope(object state) + public IDisposable BeginScopeImpl(object state) { _scope = state; diff --git a/src/Microsoft.Framework.TestHost/TestServices.cs b/src/Microsoft.Framework.TestHost/TestServices.cs index 28cd4141a55..8e96176cab6 100644 --- a/src/Microsoft.Framework.TestHost/TestServices.cs +++ b/src/Microsoft.Framework.TestHost/TestServices.cs @@ -42,7 +42,7 @@ public static ServiceProvider CreateTestServices( private class NullLogger : ILogger { - public IDisposable BeginScope(object state) + public IDisposable BeginScopeImpl(object state) { return null; } diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs b/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs index 9571e038cfb..e5a391ed19e 100644 --- a/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs +++ b/test/Microsoft.Framework.Logging.Testing.Tests/NullLoggerTest.cs @@ -14,7 +14,7 @@ public void BeginScope_CanDispose() var logger = NullLogger.Instance; // Act & Assert - using (logger.BeginScope(null)) + using (logger.BeginScopeImpl(null)) { } } From 1cf76c40bb645bd8b70e1e3c47dd4412054db6ef Mon Sep 17 00:00:00 2001 From: Ryan Nowak Date: Thu, 2 Apr 2015 17:31:05 -0700 Subject: [PATCH 145/463] Add testing UI for TestHost --- Testing.sln | 11 +- src/Microsoft.Framework.TestHost/Program.cs | 16 +- ...soft.Framework.Logging.Testing.Tests.xproj | 5 +- test/Sample.Tests/Sample.Tests.xproj | 5 +- .../Microsoft.Framework.TestHost.UI/App.xaml | 9 + .../App.xaml.cs | 17 ++ tools/Microsoft.Framework.TestHost.UI/DNX.cs | 29 ++ .../MainWindow.xaml | 199 +++++++++++++ .../MainWindow.xaml.cs | 28 ++ .../MainWindowViewModel.cs | 265 ++++++++++++++++++ .../Message.cs | 20 ++ .../Microsoft.Framework.TestHost.UI.csproj | 94 +++++++ .../Properties/AssemblyInfo.cs | 55 ++++ .../RelayCommand.cs | 38 +++ .../TestHostWrapper.cs | 206 ++++++++++++++ .../packages.config | 4 + 16 files changed, 996 insertions(+), 5 deletions(-) create mode 100644 tools/Microsoft.Framework.TestHost.UI/App.xaml create mode 100644 tools/Microsoft.Framework.TestHost.UI/App.xaml.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/DNX.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/MainWindow.xaml create mode 100644 tools/Microsoft.Framework.TestHost.UI/MainWindow.xaml.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/MainWindowViewModel.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/Message.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/Microsoft.Framework.TestHost.UI.csproj create mode 100644 tools/Microsoft.Framework.TestHost.UI/Properties/AssemblyInfo.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/RelayCommand.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/TestHostWrapper.cs create mode 100644 tools/Microsoft.Framework.TestHost.UI/packages.config diff --git a/Testing.sln b/Testing.sln index 6d62a03d590..bf59aa51706 100644 --- a/Testing.sln +++ b/Testing.sln @@ -1,7 +1,7 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22613.0 +VisualStudioVersion = 14.0.22727.0 MinimumVisualStudioVersion = 10.0.40219.1 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{5525B6EA-8BBB-4437-BD09-419AE380BBA8}" EndProject @@ -25,6 +25,10 @@ Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging EndProject Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "Microsoft.Framework.Logging.Testing.Tests", "test\Microsoft.Framework.Logging.Testing.Tests\Microsoft.Framework.Logging.Testing.Tests.xproj", "{6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{57A90243-F8A5-4115-BA05-A1CEEBD8A5CD}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microsoft.Framework.TestHost.UI", "tools\Microsoft.Framework.TestHost.UI\Microsoft.Framework.TestHost.UI.csproj", "{2A16C1BE-8777-473A-A581-02E10D82C49D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -67,6 +71,10 @@ Global {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Debug|Any CPU.Build.0 = Debug|Any CPU {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Release|Any CPU.ActiveCfg = Release|Any CPU {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F}.Release|Any CPU.Build.0 = Release|Any CPU + {2A16C1BE-8777-473A-A581-02E10D82C49D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {2A16C1BE-8777-473A-A581-02E10D82C49D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {2A16C1BE-8777-473A-A581-02E10D82C49D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {2A16C1BE-8777-473A-A581-02E10D82C49D}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -81,5 +89,6 @@ Global {25D18D0C-119C-4AB4-BCA6-AC06179335FA} = {09F799F3-E521-466F-B155-B89E2746C8C9} {379AA56B-E1A6-4133-9A45-7F70385F39FB} = {5525B6EA-8BBB-4437-BD09-419AE380BBA8} {6FA3EFAE-2DBC-4532-A5A0-C2EBD8DD672F} = {09F799F3-E521-466F-B155-B89E2746C8C9} + {2A16C1BE-8777-473A-A581-02E10D82C49D} = {57A90243-F8A5-4115-BA05-A1CEEBD8A5CD} EndGlobalSection EndGlobal diff --git a/src/Microsoft.Framework.TestHost/Program.cs b/src/Microsoft.Framework.TestHost/Program.cs index 35c81fc7183..e5bcbe4e668 100644 --- a/src/Microsoft.Framework.TestHost/Program.cs +++ b/src/Microsoft.Framework.TestHost/Program.cs @@ -29,6 +29,8 @@ public int Main(string[] args) var portOption = application.Option("--port", "Port number to listen for a connection.", CommandOptionType.SingleValue); var projectOption = application.Option("--project", "Path to a project file.", CommandOptionType.SingleValue); + var debugOption = application.Option("--debug", "Launch the debugger", CommandOptionType.NoValue); + // Show help information if no subcommand was specified application.OnExecute(() => { @@ -43,6 +45,11 @@ public int Main(string[] args) command.OnExecute(async () => { + if (debugOption.HasValue()) + { + Debugger.Launch(); + } + var projectPath = projectOption.Value() ?? env.ApplicationBasePath; var port = int.Parse(portOption.Value()); @@ -60,6 +67,11 @@ public int Main(string[] args) command.OnExecute(async () => { + if (debugOption.HasValue()) + { + Debugger.Launch(); + } + var projectPath = projectOption.Value() ?? env.ApplicationBasePath; var port = int.Parse(portOption.Value()); @@ -82,7 +94,7 @@ private async Task ExecuteTests(int port, string projectPath, IList test string testCommand = null; Project project = null; - if (Project.TryGetProject(projectPath, out project)) + if (Project.TryGetProject(projectPath, out project, diagnostics: null)) { project.Commands.TryGetValue("test", out testCommand); } @@ -142,7 +154,7 @@ private async Task DiscoverTests(int port, string projectPath) string testCommand = null; Project project = null; - if (Project.TryGetProject(projectPath, out project)) + if (Project.TryGetProject(projectPath, out project, diagnostics: null)) { project.Commands.TryGetValue("test", out testCommand); } diff --git a/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj b/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj index 018078c757b..40d6faf35b7 100644 --- a/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj +++ b/test/Microsoft.Framework.Logging.Testing.Tests/Microsoft.Framework.Logging.Testing.Tests.xproj @@ -14,4 +14,7 @@ 2.0 - \ No newline at end of file + + + + diff --git a/test/Sample.Tests/Sample.Tests.xproj b/test/Sample.Tests/Sample.Tests.xproj index a8f96d17c98..a1abc6891c4 100644 --- a/test/Sample.Tests/Sample.Tests.xproj +++ b/test/Sample.Tests/Sample.Tests.xproj @@ -14,4 +14,7 @@ 2.0 - \ No newline at end of file + + + + diff --git a/tools/Microsoft.Framework.TestHost.UI/App.xaml b/tools/Microsoft.Framework.TestHost.UI/App.xaml new file mode 100644 index 00000000000..3e53d7821b7 --- /dev/null +++ b/tools/Microsoft.Framework.TestHost.UI/App.xaml @@ -0,0 +1,9 @@ + + + + + diff --git a/tools/Microsoft.Framework.TestHost.UI/App.xaml.cs b/tools/Microsoft.Framework.TestHost.UI/App.xaml.cs new file mode 100644 index 00000000000..7ccb4ed3654 --- /dev/null +++ b/tools/Microsoft.Framework.TestHost.UI/App.xaml.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Configuration; +using System.Data; +using System.Linq; +using System.Threading.Tasks; +using System.Windows; + +namespace Microsoft.Framework.TestHost.UI +{ + /// + /// Interaction logic for App.xaml + /// + public partial class App : Application + { + } +} diff --git a/tools/Microsoft.Framework.TestHost.UI/DNX.cs b/tools/Microsoft.Framework.TestHost.UI/DNX.cs new file mode 100644 index 00000000000..0d6bf63093d --- /dev/null +++ b/tools/Microsoft.Framework.TestHost.UI/DNX.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Microsoft.Framework.TestHost.UI +{ + public static class DNX + { + public static string FindDnx() + { + var process = new Process(); + process.StartInfo = new ProcessStartInfo() + { + FileName = "cmd", + Arguments = "/c where dnx", + UseShellExecute = false, + RedirectStandardOutput = true, + CreateNoWindow = true, + }; + + process.Start(); + process.WaitForExit(); + return process.StandardOutput.ReadToEnd().TrimEnd('\r', '\n'); + } + } +} diff --git a/tools/Microsoft.Framework.TestHost.UI/MainWindow.xaml b/tools/Microsoft.Framework.TestHost.UI/MainWindow.xaml new file mode 100644 index 00000000000..f2cf0e00a32 --- /dev/null +++ b/tools/Microsoft.Framework.TestHost.UI/MainWindow.xaml @@ -0,0 +1,199 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +