From 1163d0e204b52c48db2f6c02922c46ca5a07cbc2 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Wed, 16 May 2018 22:09:00 -0400 Subject: [PATCH 01/29] nunit.engine.api now supports .NET Standard 1.3 and 2.0 --- src/CommonAssemblyInfo.cs | 4 -- .../DefaultOptionsProviderTests.cs | 4 +- .../OutputSpecificationTests.cs | 4 +- src/NUnitConsole/nunit3-console/Options.cs | 46 +------------------ .../Exceptions/NUnitEngineException.cs | 6 +-- .../NUnitEngineNotFoundException.cs | 2 + .../Exceptions/NUnitEngineUnloadException.cs | 6 +-- .../Extensibility/IDriverFactory.cs | 10 ++++ .../nunit.engine.api/TestEngineActivator.cs | 15 +++++- .../nunit.engine.api/TestFilter.cs | 2 +- .../nunit.engine.api/TestPackage.cs | 2 +- .../TestSelectionParserException.cs | 8 ++-- .../nunit.engine.api/nunit.engine.api.csproj | 11 +++-- 13 files changed, 48 insertions(+), 72 deletions(-) diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index da5b7310f..a4b4b7f7d 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -31,10 +31,6 @@ [assembly: AssemblyCompany("NUnit Software")] [assembly: AssemblyCopyright("Copyright (c) 2018 Charlie Poole, Rob Prouse")] -#if PORTABLE -[assembly: AssemblyMetadata("PCL", "True")] -#endif - #if DEBUG #if NET_4_5 [assembly: AssemblyConfiguration(".NET 4.5 Debug")] diff --git a/src/NUnitConsole/nunit3-console.tests/DefaultOptionsProviderTests.cs b/src/NUnitConsole/nunit3-console.tests/DefaultOptionsProviderTests.cs index 2b7217b83..45ee74412 100644 --- a/src/NUnitConsole/nunit3-console.tests/DefaultOptionsProviderTests.cs +++ b/src/NUnitConsole/nunit3-console.tests/DefaultOptionsProviderTests.cs @@ -25,7 +25,6 @@ using NUnit.Common; using NUnit.Framework; -#if !SILVERLIGHT && !NETCF && !PORTABLE namespace NUnit.ConsoleRunner.Tests { [TestFixture] @@ -70,5 +69,4 @@ private static DefaultOptionsProvider CreateInstance() return new DefaultOptionsProvider(); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/NUnitConsole/nunit3-console.tests/OutputSpecificationTests.cs b/src/NUnitConsole/nunit3-console.tests/OutputSpecificationTests.cs index b3ebc2146..9aef2d662 100644 --- a/src/NUnitConsole/nunit3-console.tests/OutputSpecificationTests.cs +++ b/src/NUnitConsole/nunit3-console.tests/OutputSpecificationTests.cs @@ -20,7 +20,6 @@ // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !PORTABLE using System; using System.IO; using NUnit.Framework; @@ -139,5 +138,4 @@ public void TransformFolderIsUsedToSpecifyTransform(string transformFolder) Assert.That(spec.Transform, Is.EqualTo(expectedTransform)); } } -} -#endif \ No newline at end of file +} \ No newline at end of file diff --git a/src/NUnitConsole/nunit3-console/Options.cs b/src/NUnitConsole/nunit3-console/Options.cs index ce0136405..71cdb46ce 100644 --- a/src/NUnitConsole/nunit3-console/Options.cs +++ b/src/NUnitConsole/nunit3-console/Options.cs @@ -144,20 +144,12 @@ // Missing XML Docs #pragma warning disable 1591 -#if PORTABLE -using NUnit.Compatibility; -#else using System.Security.Permissions; -#endif #if LINQ using System.Linq; #endif -#if TEST -using NDesk.Options; -#endif - namespace NUnit.Options { public class OptionValueCollection : IList, IList { @@ -357,29 +349,17 @@ public string[] GetValueSeparators () protected static T Parse (string value, OptionContext c) { Type tt = typeof (T); -#if PORTABLE - bool nullable = tt.GetTypeInfo().IsValueType && tt.GetTypeInfo().IsGenericType && - !tt.GetTypeInfo().IsGenericTypeDefinition && - tt.GetGenericTypeDefinition () == typeof (Nullable<>); - Type targetType = nullable ? tt.GetGenericArguments () [0] : typeof (T); -#else bool nullable = tt.IsValueType && tt.IsGenericType && !tt.IsGenericTypeDefinition && tt.GetGenericTypeDefinition () == typeof (Nullable<>); Type targetType = nullable ? tt.GetGenericArguments () [0] : typeof (T); -#endif -#if !NETCF && !SILVERLIGHT && !PORTABLE TypeConverter conv = TypeDescriptor.GetConverter (targetType); -#endif + T t = default (T); try { if (value != null) -#if NETCF || SILVERLIGHT || PORTABLE - t = (T)Convert.ChangeType(value, tt, CultureInfo.InvariantCulture); -#else t = (T) conv.ConvertFromString (value); -#endif } catch (Exception e) { throw new OptionException ( @@ -485,9 +465,7 @@ public override string ToString () } } -#if !PORTABLE [Serializable] -#endif public class OptionException : Exception { private string option; @@ -508,49 +486,28 @@ public OptionException (string message, string optionName, Exception innerExcept this.option = optionName; } -#if !NETCF && !SILVERLIGHT && !PORTABLE protected OptionException (SerializationInfo info, StreamingContext context) : base (info, context) { this.option = info.GetString ("OptionName"); } -#endif public string OptionName { get {return this.option;} } -#if !NETCF && !SILVERLIGHT && !PORTABLE [SecurityPermission (SecurityAction.LinkDemand, SerializationFormatter = true)] public override void GetObjectData (SerializationInfo info, StreamingContext context) { base.GetObjectData (info, context); info.AddValue ("OptionName", option); } -#endif } public delegate void OptionAction (TKey key, TValue value); public class OptionSet : KeyedCollection { -#if !PORTABLE - public OptionSet () - : this (delegate (string f) {return f;}) - { - } - - public OptionSet (Converter localizer) - { - this.localizer = localizer; - } - - Converter localizer; - - public Converter MessageLocalizer { - get {return localizer;} - } -#else string localizer(string msg) { return msg; @@ -560,7 +517,6 @@ public string MessageLocalizer(string msg) { return msg; } -#endif protected override string GetKeyForItem (Option item) { diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs index aa1812835..1a7ab85d5 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs @@ -22,7 +22,7 @@ // *********************************************************************** using System; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 using System.Runtime.Serialization; #endif @@ -33,7 +33,7 @@ namespace NUnit.Engine /// called with improper values or when a particular facility /// is not available. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 [Serializable] #endif public class NUnitEngineException : Exception @@ -52,7 +52,7 @@ public NUnitEngineException(string message, Exception innerException) : base(mes { } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 /// /// Serialization constructor /// diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs index b23bf9275..35e93d7a3 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs @@ -28,7 +28,9 @@ namespace NUnit.Engine /// /// The exception that is thrown if a valid test engine is not found /// +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 [Serializable] +#endif public class NUnitEngineNotFoundException : Exception { /// diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs index f0bae47d1..7d024051a 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 using System.Runtime.Serialization; #endif @@ -35,7 +35,7 @@ namespace NUnit.Engine /// but one or more errors were encountered when attempting to unload /// and shut down the test run cleanly. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 [Serializable] #endif public class NUnitEngineUnloadException : NUnitEngineException //Inherits from NUnitEngineException for backwards compatibility of calling runners @@ -66,7 +66,7 @@ public NUnitEngineUnloadException(ICollection aggregatedExceptions) : AggregatedExceptions = aggregatedExceptions; } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 /// /// Serialization constructor. /// diff --git a/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs b/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs index 4f544cd34..bc3b9fb00 100644 --- a/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs +++ b/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs @@ -40,6 +40,15 @@ public interface IDriverFactory /// An AssemblyName referring to the possible test framework. bool IsSupportedTestFramework(AssemblyName reference); +#if NETSTANDARD1_3 || NETSTANDARD2_0 + /// + /// Gets a driver for a given test assembly and a framework + /// which the assembly is already known to reference. + /// + /// An AssemblyName referring to the test framework. + /// + IFrameworkDriver GetDriver(AssemblyName reference); +#else /// /// Gets a driver for a given test assembly and a framework /// which the assembly is already known to reference. @@ -48,5 +57,6 @@ public interface IDriverFactory /// An AssemblyName referring to the test framework. /// IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference); +#endif } } diff --git a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs index c95e012bf..7bfdef62b 100644 --- a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs +++ b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs @@ -39,6 +39,19 @@ public static class TestEngineActivator private const string DefaultAssemblyName = "nunit.engine.dll"; internal const string DefaultTypeName = "NUnit.Engine.TestEngine"; +#if NETSTANDARD1_3 || NETSTANDARD2_0 + /// + /// Create an instance of the test engine. + /// + /// An + public static ITestEngine CreateInstance() + { + var assemblyName = new AssemblyName(DefaultAssemblyName); + var assembly = Assembly.Load(assemblyName); + var engineType = assembly.GetType(DefaultTypeName); + return Activator.CreateInstance(engineType) as ITestEngine; + } +#else #region Public Methods /// @@ -190,7 +203,7 @@ private static string FindEngineInRegistry(RegistryKey rootKey, string subKey) catch (Exception) { } return null; } - #endregion +#endif } } diff --git a/src/NUnitEngine/nunit.engine.api/TestFilter.cs b/src/NUnitEngine/nunit.engine.api/TestFilter.cs index c3d120f3f..961ece551 100644 --- a/src/NUnitEngine/nunit.engine.api/TestFilter.cs +++ b/src/NUnitEngine/nunit.engine.api/TestFilter.cs @@ -32,7 +32,7 @@ namespace NUnit.Engine /// In the console runner, filters serve only to carry this /// XML representation, as all filtering is done by the engine. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 [Serializable] #endif public class TestFilter diff --git a/src/NUnitEngine/nunit.engine.api/TestPackage.cs b/src/NUnitEngine/nunit.engine.api/TestPackage.cs index c8fc22847..496bc3f81 100644 --- a/src/NUnitEngine/nunit.engine.api/TestPackage.cs +++ b/src/NUnitEngine/nunit.engine.api/TestPackage.cs @@ -33,7 +33,7 @@ namespace NUnit.Engine /// tests for one or more test files. TestPackages may be named /// or anonymous, depending on how they are constructed. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 [Serializable] #endif public class TestPackage diff --git a/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs b/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs index ac824d37b..9650fa06a 100644 --- a/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs +++ b/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs @@ -22,7 +22,7 @@ // *********************************************************************** using System; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 using System.Runtime.Serialization; #endif @@ -32,7 +32,7 @@ namespace NUnit.Engine /// TestSelectionParserException is thrown when an error /// is found while parsing the selection expression. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 [Serializable] #endif public class TestSelectionParserException : Exception @@ -48,8 +48,8 @@ public TestSelectionParserException(string message) : base(message) { } /// /// public TestSelectionParserException(string message, Exception innerException) : base(message, innerException) { } - -#if !NETSTANDARD1_3 + +#if !NETSTANDARD1_3 && !NETSTANDARD1_6 /// /// Serialization constructor /// diff --git a/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj b/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj index e3dd974a5..3819ad8d4 100644 --- a/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj +++ b/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj @@ -2,7 +2,7 @@ NUnit.Engine nunit.engine.api - net20 + net20;netstandard1.3;netstandard2.0 false ..\..\..\bin\$(Configuration)\ true @@ -11,11 +11,14 @@ true 7 - - - + + + + + + \ No newline at end of file From 49945d4c03ed36b4989e92281c2da34e2b761100 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Mon, 4 Jun 2018 21:11:26 -0400 Subject: [PATCH 02/29] NUnit.Engine is now compiling .NET Standard 1.3 and 2.0 --- src/CommonAssemblyInfo.cs | 12 +- .../Exceptions/NUnitEngineException.cs | 6 +- .../NUnitEngineNotFoundException.cs | 2 +- .../Exceptions/NUnitEngineUnloadException.cs | 6 +- .../Extensibility/IDriverFactory.cs | 4 +- .../nunit.engine.api/ITestEngine.cs | 16 +- .../nunit.engine.api/TestFilter.cs | 2 +- .../nunit.engine.api/TestPackage.cs | 2 +- .../TestSelectionParserException.cs | 12 +- .../nunit.engine.api/nunit.engine.api.csproj | 8 +- .../Services/DriverService.cs | 6 +- .../nunit.engine/Agents/RemoteTestAgent.cs | 2 + .../Agents/RemoteTestAgentProxy.cs | 8 +- .../nunit.engine/Agents/TestAgent.cs | 6 +- .../nunit.engine/AsyncTestEngineResult.cs | 6 +- .../nunit.engine/CallbackHandler.cs | 6 +- .../Drivers/NUnit2DriverFactory.cs | 6 +- .../Drivers/NUnit3DriverFactory.cs | 20 +- .../Drivers/NUnit3FrameworkDriver.cs | 6 +- .../Drivers/NUnitNetStandardDriver.cs | 205 ++++++++++++++++++ .../Extensibility/ExtensionNode.cs | 23 +- .../Extensibility/ExtensionPoint.cs | 10 +- .../nunit.engine/IDriverService.cs | 14 +- .../nunit.engine/Internal/AssemblyHelper.cs | 2 + .../Internal/DomainDetailsBuilder.cs | 8 +- .../nunit.engine/Internal/DomainUsage.cs | 8 +- .../nunit.engine/Internal/Logging/Logger.cs | 16 +- .../Internal/NUnitConfiguration.cs | 13 +- .../nunit.engine/Internal/ProcessModel.cs | 6 +- .../Internal/ProvidedPathsAssemblyResolver.cs | 6 +- .../nunit.engine/Internal/ServerBase.cs | 6 +- .../nunit.engine/Internal/SettingsGroup.cs | 7 +- .../Internal/TargetFrameworkHelper.cs | 13 +- ...ils.ObservableServerChannelSinkProvider.cs | 27 ++- .../nunit.engine/Internal/TcpChannelUtils.cs | 2 + .../nunit.engine/RunTestsCallbackHandler.cs | 6 +- .../Runners/AbstractTestRunner.cs | 18 +- .../Runners/AggregatingTestRunner.cs | 12 +- .../nunit.engine/Runners/DirectTestRunner.cs | 48 ++-- .../nunit.engine/Runners/LocalTestRunner.cs | 6 +- .../nunit.engine/Runners/MasterTestRunner.cs | 30 ++- .../Runners/MultipleTestDomainRunner.cs | 2 + .../Runners/MultipleTestProcessRunner.cs | 6 +- .../Runners/ParallelTaskWorkerPool.cs | 2 + .../nunit.engine/Runners/ProcessRunner.cs | 14 +- .../nunit.engine/Runners/TestDomainRunner.cs | 8 +- .../nunit.engine/RuntimeFramework.cs | 20 +- .../nunit.engine/Services/AgentDataBase.cs | 2 + .../Services/DefaultTestRunnerFactory.cs | 24 +- .../nunit.engine/Services/DomainManager.cs | 14 +- .../nunit.engine/Services/DriverService.cs | 20 +- .../Services/ExtensionAssembly.cs | 8 +- .../nunit.engine/Services/ExtensionService.cs | 26 ++- .../Services/InProcessTestRunnerFactory.cs | 10 +- .../nunit.engine/Services/ProjectService.cs | 8 +- .../nunit.engine/Services/ResultService.cs | 6 +- .../ResultWriters/XmlTransformResultWriter.cs | 8 +- .../Services/RuntimeFrameworkService.cs | 10 +- .../nunit.engine/Services/ServiceManager.cs | 17 +- .../nunit.engine/Services/TestAgency.cs | 10 +- .../Services/TestFilterService.cs | 6 +- src/NUnitEngine/nunit.engine/TestEngine.cs | 31 ++- .../nunit.engine/nunit.engine.csproj | 10 +- 63 files changed, 642 insertions(+), 242 deletions(-) create mode 100644 src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index a4b4b7f7d..d5a893d89 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -40,8 +40,10 @@ [assembly: AssemblyConfiguration(".NET 2.0 Debug")] #elif PORTABLE [assembly: AssemblyConfiguration("Portable Debug")] -#elif NETSTANDARD1_3 || NETSTANDARD1_6 || NETCOREAPP1_0 -[assembly: AssemblyConfiguration(".NET Standard Debug")] +#elif NETSTANDARD1_3 || NETCOREAPP1_0 +[assembly: AssemblyConfiguration(".NET Standard 1.3 Debug")] +#elif NETSTANDARD2_0 || NETCOREAPP2_0 +[assembly: AssemblyConfiguration(".NET Standard 2.0 Debug")] #else [assembly: AssemblyConfiguration("Debug")] #endif @@ -54,8 +56,10 @@ [assembly: AssemblyConfiguration(".NET 2.0")] #elif PORTABLE [assembly: AssemblyConfiguration("Portable")] -#elif NETSTANDARD1_3 || NETSTANDARD1_6 || NETCOREAPP1_0 -[assembly: AssemblyConfiguration(".NET Standard")] +#elif NETSTANDARD1_3 || NETCOREAPP1_0 +[assembly: AssemblyConfiguration(".NET Standard 1.3")] +#elif NETSTANDARD2_0 || NETCOREAPP2_0 +[assembly: AssemblyConfiguration(".NET Standard 2.0")] #else [assembly: AssemblyConfiguration("")] #endif diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs index 1a7ab85d5..aa1812835 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs @@ -22,7 +22,7 @@ // *********************************************************************** using System; -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 using System.Runtime.Serialization; #endif @@ -33,7 +33,7 @@ namespace NUnit.Engine /// called with improper values or when a particular facility /// is not available. /// -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 [Serializable] #endif public class NUnitEngineException : Exception @@ -52,7 +52,7 @@ public NUnitEngineException(string message, Exception innerException) : base(mes { } -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 /// /// Serialization constructor /// diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs index 35e93d7a3..5d81b536d 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs @@ -28,7 +28,7 @@ namespace NUnit.Engine /// /// The exception that is thrown if a valid test engine is not found /// -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 [Serializable] #endif public class NUnitEngineNotFoundException : Exception diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs index 7d024051a..f0bae47d1 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 using System.Runtime.Serialization; #endif @@ -35,7 +35,7 @@ namespace NUnit.Engine /// but one or more errors were encountered when attempting to unload /// and shut down the test run cleanly. /// -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 [Serializable] #endif public class NUnitEngineUnloadException : NUnitEngineException //Inherits from NUnitEngineException for backwards compatibility of calling runners @@ -66,7 +66,7 @@ public NUnitEngineUnloadException(ICollection aggregatedExceptions) : AggregatedExceptions = aggregatedExceptions; } -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 /// /// Serialization constructor. /// diff --git a/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs b/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs index bc3b9fb00..e308c6245 100644 --- a/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs +++ b/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND diff --git a/src/NUnitEngine/nunit.engine.api/ITestEngine.cs b/src/NUnitEngine/nunit.engine.api/ITestEngine.cs index 869b0a570..d5c2b1987 100644 --- a/src/NUnitEngine/nunit.engine.api/ITestEngine.cs +++ b/src/NUnitEngine/nunit.engine.api/ITestEngine.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -29,18 +29,16 @@ namespace NUnit.Engine /// /// ITestEngine represents an instance of the test engine. /// Clients wanting to discover, explore or run tests start - /// require an instance of the engine, which is generally + /// require an instance of the engine, which is generally /// acquired from the TestEngineActivator class. /// public interface ITestEngine : IDisposable { -#if !NETSTANDARD1_3 /// /// Gets the IServiceLocator interface, which gives access to /// certain services provided by the engine. /// IServiceLocator Services { get; } -#endif /// /// Gets and sets the directory path used by the engine for saving files. @@ -58,12 +56,12 @@ public interface ITestEngine : IDisposable /// /// Initialize the engine. This includes initializing mono addins, - /// setting the trace level and creating the standard set of services + /// setting the trace level and creating the standard set of services /// used in the Engine. - /// - /// This interface is not normally called by user code. Programs linking + /// + /// This interface is not normally called by user code. Programs linking /// only to the nunit.engine.api assembly are given a - /// pre-initialized instance of TestEngine. Programs + /// pre-initialized instance of TestEngine. Programs /// that link directly to nunit.engine usually do so /// in order to perform custom initialization. /// diff --git a/src/NUnitEngine/nunit.engine.api/TestFilter.cs b/src/NUnitEngine/nunit.engine.api/TestFilter.cs index 961ece551..c3d120f3f 100644 --- a/src/NUnitEngine/nunit.engine.api/TestFilter.cs +++ b/src/NUnitEngine/nunit.engine.api/TestFilter.cs @@ -32,7 +32,7 @@ namespace NUnit.Engine /// In the console runner, filters serve only to carry this /// XML representation, as all filtering is done by the engine. /// -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 [Serializable] #endif public class TestFilter diff --git a/src/NUnitEngine/nunit.engine.api/TestPackage.cs b/src/NUnitEngine/nunit.engine.api/TestPackage.cs index 496bc3f81..c8fc22847 100644 --- a/src/NUnitEngine/nunit.engine.api/TestPackage.cs +++ b/src/NUnitEngine/nunit.engine.api/TestPackage.cs @@ -33,7 +33,7 @@ namespace NUnit.Engine /// tests for one or more test files. TestPackages may be named /// or anonymous, depending on how they are constructed. /// -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 [Serializable] #endif public class TestPackage diff --git a/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs b/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs index 9650fa06a..284189ad7 100644 --- a/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs +++ b/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -22,17 +22,17 @@ // *********************************************************************** using System; -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 using System.Runtime.Serialization; #endif namespace NUnit.Engine { /// - /// TestSelectionParserException is thrown when an error + /// TestSelectionParserException is thrown when an error /// is found while parsing the selection expression. /// -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 [Serializable] #endif public class TestSelectionParserException : Exception @@ -49,7 +49,7 @@ public TestSelectionParserException(string message) : base(message) { } /// public TestSelectionParserException(string message, Exception innerException) : base(message, innerException) { } -#if !NETSTANDARD1_3 && !NETSTANDARD1_6 +#if !NETSTANDARD1_3 /// /// Serialization constructor /// diff --git a/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj b/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj index 3819ad8d4..f8ec3a0ad 100644 --- a/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj +++ b/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj @@ -11,14 +11,14 @@ true 7 - - - - + + + + \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs b/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs index f403d9d1b..53f4deb12 100644 --- a/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs +++ b/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -42,9 +42,7 @@ public class DriverService /// /// Get a driver suitable for use with a particular test assembly. /// - /// The AppDomain to use for the tests /// The full path to the test assembly - /// The value of any TargetFrameworkAttribute on the assembly, or null /// True if non-test assemblies should simply be skipped rather than reporting an error /// public IFrameworkDriver GetDriver(string assemblyPath, bool skipNonTestAssemblies) diff --git a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs index da838862e..77a93bd76 100644 --- a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs +++ b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; @@ -230,3 +231,4 @@ public void StopRun(bool force) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs index afe3142fc..c4dadf707 100644 --- a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs +++ b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Text; @@ -28,7 +29,7 @@ namespace NUnit.Engine.Agents { /// - /// RemoteTestAgentProxy wraps a RemoteTestAgent so that certain + /// RemoteTestAgentProxy wraps a RemoteTestAgent so that certain /// of its properties may be accessed without remoting. /// internal class RemoteTestAgentProxy : ITestAgent @@ -60,3 +61,4 @@ public void Stop() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs b/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs index 6db1a9a25..e26657960 100644 --- a/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs +++ b/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; namespace NUnit.Engine.Agents @@ -131,3 +132,4 @@ public override object InitializeLifetimeService() #endregion } } +#endif diff --git a/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs b/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs index 34ae1d87f..1a01d1e6e 100644 --- a/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs +++ b/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs @@ -31,7 +31,9 @@ namespace NUnit.Engine /// /// The TestRun class encapsulates an ongoing test run. /// +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 [Serializable] +#endif public class AsyncTestEngineResult : ITestRun { private volatile TestEngineResult _result; @@ -81,7 +83,7 @@ public bool Wait(int timeout) /// public bool IsComplete { get { return _result != null; } } - #region ITestRun Members +#region ITestRun Members XmlNode ITestRun.Result { @@ -93,6 +95,6 @@ bool ITestRun.Wait(int timeout) return Wait(timeout); } - #endregion +#endregion } } diff --git a/src/NUnitEngine/nunit.engine/CallbackHandler.cs b/src/NUnitEngine/nunit.engine/CallbackHandler.cs index f74f2c28d..f64acede1 100644 --- a/src/NUnitEngine/nunit.engine/CallbackHandler.cs +++ b/src/NUnitEngine/nunit.engine/CallbackHandler.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Web.UI; @@ -59,3 +60,4 @@ public void RaiseCallbackEvent(string eventArgument) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs index 82b860eef..ef7224d43 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Reflection; @@ -79,3 +80,4 @@ public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference) } } } +#endif diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs index 6433e8d9f..64fc6ad9d 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -42,6 +42,7 @@ public bool IsSupportedTestFramework(AssemblyName reference) return NUNIT_FRAMEWORK.Equals(reference.Name, StringComparison.OrdinalIgnoreCase) && reference.Version.Major == 3; } +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 /// /// Gets a driver for a given test assembly and a framework /// which the assembly is already known to reference. @@ -55,5 +56,20 @@ public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference) return new NUnit3FrameworkDriver(domain, reference); } +#else + /// + /// Gets a driver for a given test assembly and a framework + /// which the assembly is already known to reference. + /// + /// The domain in which the assembly will be loaded + /// An AssemblyName referring to the test framework. + /// + public IFrameworkDriver GetDriver(AssemblyName reference) + { + Guard.ArgumentValid(IsSupportedTestFramework(reference), "Invalid framework", "reference"); + + return new NUnitNetStandardDriver(); + } +#endif } } diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs index 1a4703bf9..9b6f72d7e 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.IO; @@ -184,3 +185,4 @@ private object CreateObject(string typeName, params object[] args) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs new file mode 100644 index 000000000..7141087d9 --- /dev/null +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs @@ -0,0 +1,205 @@ +// *********************************************************************** +// Copyright (c) 2016 Charlie Poole +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN METHOD +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// *********************************************************************** + +#if NETSTANDARD1_3 || NETSTANDARD2_0 +using System; +using System.Linq; +using System.Collections.Generic; +using NUnit.Engine.Internal; +using System.Reflection; +using NUnit.Engine.Extensibility; +using Mono.Cecil; + +namespace NUnit.Engine.Drivers +{ + /// + /// NUnitNetStandardDriver is used by the test-runner to load and run + /// tests using the NUnit framework assembly. + /// + public class NUnitNetStandardDriver : IFrameworkDriver + { + const string LOAD_MESSAGE = "Method called without calling Load first"; + const string INVALID_FRAMEWORK_MESSAGE = "Running tests against this version of the framework using this driver is not supported. Please update NUnit.Framework to the latest version."; + const string FAILED_TO_LOAD_TEST_ASSEMBLY = "Failed to load the test assembly {0}"; + const string FAILED_TO_LOAD_NUNIT = "Failed to load the NUnit Framework in the test assembly"; + + static readonly string CONTROLLER_TYPE = "NUnit.Framework.Api.FrameworkController"; + static readonly string LOAD_METHOD = "LoadTests"; + static readonly string EXPLORE_METHOD = "ExploreTests"; + static readonly string COUNT_METHOD = "CountTests"; + static readonly string RUN_METHOD = "RunTests"; + static readonly string RUN_ASYNC_METHOD = "RunTests"; + static readonly string STOP_RUN_METHOD = "StopRun"; + + static ILogger log = InternalTrace.GetLogger(nameof(NUnitNetStandardDriver)); + + Assembly _testAssembly; + Assembly _frameworkAssembly; + object _frameworkController; + Type _frameworkControllerType; + + /// + /// An id prefix that will be passed to the test framework and used as part of the + /// test ids created. + /// + public string ID { get; set; } + + /// + /// Loads the tests in an assembly. + /// + /// The NUnit Framework that the tests reference + /// The test assembly + /// The test settings + /// An Xml string representing the loaded test + public string Load(string testAssembly, IDictionary settings) + { + var idPrefix = string.IsNullOrEmpty(ID) ? "" : ID + "-"; + + var assemblyRef = AssemblyDefinition.ReadAssembly(testAssembly); + _testAssembly = Assembly.Load(new AssemblyName(assemblyRef.FullName)); + if(_testAssembly == null) + throw new NUnitEngineException(string.Format(FAILED_TO_LOAD_TEST_ASSEMBLY, assemblyRef.FullName)); + + var nunitRef = assemblyRef.MainModule.AssemblyReferences.Where(reference => reference.Name.Equals("nunit.framework", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); + if (nunitRef == null) + throw new NUnitEngineException(FAILED_TO_LOAD_NUNIT); + + var nunit = Assembly.Load(new AssemblyName(nunitRef.FullName)); + if (nunit == null) + throw new NUnitEngineException(FAILED_TO_LOAD_NUNIT); + + _frameworkAssembly = nunit; + + _frameworkController = CreateObject(CONTROLLER_TYPE, _testAssembly, idPrefix, settings); + if (_frameworkController == null) + throw new NUnitEngineException(INVALID_FRAMEWORK_MESSAGE); + + _frameworkControllerType = _frameworkController.GetType(); + + log.Info("Loading {0} - see separate log file", _testAssembly.FullName); + return ExecuteMethod(LOAD_METHOD) as string; + } + + /// + /// Counts the number of test cases for the loaded test assembly + /// + /// The XML test filter + /// The number of test cases + public int CountTestCases(string filter) + { + CheckLoadWasCalled(); + object count = ExecuteMethod(COUNT_METHOD, filter); + return count != null ? (int)count : 0; + } + + /// + /// Executes the tests in an assembly. + /// + /// An ITestEventHandler that receives progress notices + /// A filter that controls which tests are executed + /// An Xml string representing the result + public string Run(ITestEventListener listener, string filter) + { + CheckLoadWasCalled(); + log.Info("Running {0} - see separate log file", _testAssembly.FullName); + Action callback = listener != null ? listener.OnTestEvent : (Action)null; + return ExecuteMethod(RUN_METHOD, new[] { typeof(Action), typeof(string) }, callback, filter) as string; + } + + /// + /// Executes the tests in an assembly asyncronously. + /// + /// A callback that receives XML progress notices + /// A filter that controls which tests are executed + public void RunAsync(Action callback, string filter) + { + CheckLoadWasCalled(); + log.Info("Running {0} - see separate log file", _testAssembly.FullName); + ExecuteMethod(RUN_ASYNC_METHOD, new[] { typeof(Action), typeof(string) }, callback, filter); + } + + /// + /// Cancel the ongoing test run. If no test is running, the call is ignored. + /// + /// If true, cancel any ongoing test threads, otherwise wait for them to complete. + public void StopRun(bool force) + { + ExecuteMethod(STOP_RUN_METHOD, force); + } + + /// + /// Returns information about the tests in an assembly. + /// + /// A filter indicating which tests to include + /// An Xml string representing the tests + public string Explore(string filter) + { + CheckLoadWasCalled(); + + log.Info("Exploring {0} - see separate log file", _testAssembly.FullName); + return ExecuteMethod(EXPLORE_METHOD, filter) as string; + } + + #region Helper Methods + + void CheckLoadWasCalled() + { + if (_frameworkController == null) + throw new InvalidOperationException(LOAD_MESSAGE); + } + + object CreateObject(string typeName, params object[] args) + { + var typeinfo = _frameworkAssembly.DefinedTypes.FirstOrDefault(t => t.FullName == typeName); + if (typeinfo == null) + { + log.Error("Could not find type {0}", typeName); + } + return Activator.CreateInstance(typeinfo.AsType(), args); + } + + object ExecuteMethod(string methodName, params object[] args) + { + var method = _frameworkControllerType.GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance); + return ExecuteMethod(method, args); + } + + object ExecuteMethod(string methodName, Type[] ptypes, params object[] args) + { + var method = _frameworkControllerType.GetMethod(methodName, ptypes); + return ExecuteMethod(method, args); + } + + object ExecuteMethod(MethodInfo method, params object[] args) + { + if (method == null) + { + throw new NUnitEngineException(INVALID_FRAMEWORK_MESSAGE); + } + return method.Invoke(_frameworkController, args); + } + + #endregion + } +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs index d758eb768..e31ad6197 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,8 +21,14 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.Collections.Generic; +using System.Reflection; + +#if NETSTANDARD2_0 +using System.Linq; +#endif namespace NUnit.Engine.Extensibility { @@ -63,7 +69,7 @@ public ExtensionNode(string assemblyPath, string typeName) public bool Enabled { get; set; } /// - /// Gets and sets the unique string identifying the ExtensionPoint for which + /// Gets and sets the unique string identifying the ExtensionPoint for which /// this Extension is intended. This identifier may be supplied by the attribute /// marking the extension or deduced by NUnit from the Type of the extension class. /// @@ -131,7 +137,17 @@ public object ExtensionObject /// public object CreateExtensionObject(params object[] args) { +#if NETSTANDARD2_0 + var assembly = Assembly.LoadFrom(AssemblyPath); + var typeinfo = assembly.DefinedTypes.FirstOrDefault(t => t.FullName == TypeName); + if (typeinfo == null) + { + return null; + } + return Activator.CreateInstance(typeinfo.AsType(), args); +#else return AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(AssemblyPath, TypeName, false, 0, null, args, null, null, null); +#endif } public void AddProperty(string name, string val) @@ -149,3 +165,4 @@ public void AddProperty(string name, string val) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs index 7c9d49444..1f7c08d34 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.Collections.Generic; @@ -95,8 +96,8 @@ public void Install(ExtensionNode node) throw new NUnitEngineException(msg); } - // TODO: Verify that the type is correct using Cecil or Reflection - // depending on whether the assembly is pre-loaded. For now, it's not + // TODO: Verify that the type is correct using Cecil or Reflection + // depending on whether the assembly is pre-loaded. For now, it's not // simple to verify the type without loading the extension, so we // let it throw at the time the object is accessed. @@ -116,3 +117,4 @@ public void Remove(ExtensionNode extension) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/IDriverService.cs b/src/NUnitEngine/nunit.engine/IDriverService.cs index 5c2f0dddf..a943e63eb 100644 --- a/src/NUnitEngine/nunit.engine/IDriverService.cs +++ b/src/NUnitEngine/nunit.engine/IDriverService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -32,6 +32,15 @@ namespace NUnit.Engine /// public interface IDriverService { +#if NETSTANDARD1_3 + /// + /// Get a driver suitable for use with a particular test assembly. + /// + /// The full path to the test assembly + /// True if non-test assemblies should simply be skipped rather than reporting an error + /// + IFrameworkDriver GetDriver(string assemblyPath, bool skipNonTestAssemblies); +#else /// /// Get a driver suitable for loading and running tests in the specified assembly. /// @@ -41,5 +50,6 @@ public interface IDriverService /// True if non-test assemblies should simply be skipped rather than reporting an error /// IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string targetFramework, bool skipNonTestAssemblies); +#endif } } diff --git a/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs b/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs index 9e25e286a..35445f467 100644 --- a/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs +++ b/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.IO; using System.Reflection; @@ -104,3 +105,4 @@ public static string GetAssemblyPathFromCodeBase(string codeBase) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs b/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs index e8a9e7d34..485bb0833 100644 --- a/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs +++ b/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Reflection; @@ -30,7 +31,7 @@ namespace NUnit.Engine.Internal { /// - /// DomainDetailsBuilder provides human readable information on + /// DomainDetailsBuilder provides human readable information on /// an application domain, to assist with debugging. /// internal static class DomainDetailsBuilder @@ -83,3 +84,4 @@ private static void WriteAssemblyInformation(StringBuilder sb, Assembly assembly } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs b/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs index c9232b6b6..25b92b51b 100644 --- a/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs +++ b/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 namespace NUnit.Engine.Internal { /// @@ -49,4 +50,5 @@ public enum DomainUsage /// Multiple } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs b/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs index 45eec1dff..e105c97a3 100644 --- a/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs +++ b/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -32,7 +32,11 @@ namespace NUnit.Engine.Internal public class Logger : ILogger { private readonly static string TIME_FMT = "HH:mm:ss.fff"; +#if NETSTANDARD1_3 + private readonly static string TRACE_FMT = "{0} {1,-5} {2}: {3}"; +#else private readonly static string TRACE_FMT = "{0} {1,-5} [{2,2}] {3}: {4}"; +#endif private string name; private string fullname; @@ -148,6 +152,7 @@ public void Debug(string message, params object[] args) #endregion #region Helper Methods + private void Log(InternalTraceLevel level, string message) { if (writer != null && this.maxLevel >= level) @@ -165,9 +170,12 @@ private void WriteLog(InternalTraceLevel level, string message) writer.WriteLine(TRACE_FMT, DateTime.Now.ToString(TIME_FMT), level == InternalTraceLevel.Verbose ? "Debug" : level.ToString(), - System.Threading.Thread.CurrentThread.ManagedThreadId, name, message); +#if !NETSTANDARD1_3 + System.Threading.Thread.CurrentThread.ManagedThreadId, +#endif + name, message); } -#endregion + #endregion } } diff --git a/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs b/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs index afe49ddf0..f574ebc88 100644 --- a/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs +++ b/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -24,6 +24,7 @@ using System; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using Microsoft.Win32; namespace NUnit.Engine.Internal @@ -35,6 +36,7 @@ public static class NUnitConfiguration { #region Public Properties +#if !NETSTANDARD1_3 #region EngineDirectory private static string _engineDirectory; @@ -51,6 +53,7 @@ public static string EngineDirectory } #endregion +#endif #region ApplicationDataDirectory @@ -62,7 +65,11 @@ public static string ApplicationDirectory if (_applicationDirectory == null) { _applicationDirectory = Path.Combine( - Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), +#if NETSTANDARD1_3 + Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "Home"), +#else + Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), +#endif "NUnit"); } diff --git a/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs b/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs index 9147e5ef7..fc61460fc 100644 --- a/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs +++ b/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; namespace NUnit.Engine.Internal @@ -55,3 +56,4 @@ public enum ProcessModel Multiple } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs b/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs index 2442d9b2e..12b77c327 100644 --- a/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs +++ b/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.Collections.Generic; using System.Reflection; @@ -95,3 +96,4 @@ Assembly AssemblyResolve(object sender, ResolveEventArgs args) List _resolutionPaths; } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs b/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs index 37538d22f..5842781af 100644 --- a/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs +++ b/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Threading; using System.Runtime.Remoting; @@ -149,3 +150,4 @@ public override object InitializeLifetimeService() #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/SettingsGroup.cs b/src/NUnitEngine/nunit.engine/Internal/SettingsGroup.cs index 435b75b5b..91b06a6a4 100644 --- a/src/NUnitEngine/nunit.engine/Internal/SettingsGroup.cs +++ b/src/NUnitEngine/nunit.engine/Internal/SettingsGroup.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -80,7 +80,6 @@ public T GetSetting(string settingName, T defaultValue) } catch(Exception ex) { - log.Error("Unable to convert setting {0} to {1}", settingName, typeof(T).Name); log.Error(ex.Message); return defaultValue; @@ -146,4 +145,4 @@ public void SaveSetting(string settingName, object settingValue) #endregion } -} +} \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/TargetFrameworkHelper.cs b/src/NUnitEngine/nunit.engine/Internal/TargetFrameworkHelper.cs index 4d7504378..2835c27f6 100644 --- a/src/NUnitEngine/nunit.engine/Internal/TargetFrameworkHelper.cs +++ b/src/NUnitEngine/nunit.engine/Internal/TargetFrameworkHelper.cs @@ -64,7 +64,7 @@ public Version TargetRuntimeVersion { var runtimeVersion = _module.RuntimeVersion; - if (runtimeVersion.StartsWith("v", StringComparison.InvariantCultureIgnoreCase)) + if (runtimeVersion.StartsWith("v", StringComparison.OrdinalIgnoreCase)) runtimeVersion = runtimeVersion.Remove(0, 1); return new Version(runtimeVersion); @@ -86,17 +86,6 @@ public string FrameworkName break; } - foreach (var reference in _module.AssemblyReferences) - if (reference.Name == "mscorlib" && - BitConverter.ToUInt64(reference.PublicKeyToken, 0) == 0xac22333d05b89d96) - { - // We assume 3.5, since that's all we are supporting - // Could be extended to other versions if necessary - // Format for FrameworkName is invented - it is not - // known if any compilers supporting CF use the attribute - return ".NETCompactFramework,Version=3.5"; - } - return null; } } diff --git a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs index 655069d27..47e3f9c68 100644 --- a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs +++ b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs @@ -1,3 +1,27 @@ +// *********************************************************************** +// Copyright (c) 2018 Charlie Poole, Rob Prouse +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// *********************************************************************** + +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections; using System.IO; @@ -88,4 +112,5 @@ public Stream GetResponseStream(IServerResponseChannelSinkStack sinkStack, objec } } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs index 7b42df334..226187ec2 100644 --- a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs +++ b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Runtime.Remoting; @@ -130,3 +131,4 @@ public static TcpChannel GetTcpChannel(string name, int port, int limit, Current } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs b/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs index 2ac37da21..647282cd3 100644 --- a/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs +++ b/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Diagnostics; using System.IO; @@ -53,3 +54,4 @@ public void OnTestEvent(string report) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs index 4ec978860..e5288c815 100644 --- a/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -36,13 +36,6 @@ namespace NUnit.Engine.Runners /// public abstract class AbstractTestRunner : ITestEngineRunner { -#if NETSTANDARD1_3 - public AbstractTestRunner(TestPackage package) - { - TestRunnerFactory = new DefaultTestRunnerFactory(); - TestPackage = package; - } -#else public AbstractTestRunner(IServiceLocator services, TestPackage package) { Services = services; @@ -50,18 +43,15 @@ public AbstractTestRunner(IServiceLocator services, TestPackage package) ProjectService = Services.GetService(); TestPackage = package; } -#endif #region Properties -#if !NETSTANDARD1_3 /// /// Our Service Context /// protected IServiceLocator Services { get; private set; } protected IProjectService ProjectService { get; private set; } -#endif protected ITestRunnerFactory TestRunnerFactory { get; private set; } @@ -118,11 +108,11 @@ public virtual void UnloadPackage() /// A TestFilter used to select tests /// A TestEngineResult giving the result of the test execution protected abstract TestEngineResult RunTests(ITestEventListener listener, TestFilter filter); - + #if !NETSTANDARD1_3 /// /// Start a run of the tests in the loaded TestPackage, returning immediately. - /// The tests are run asynchronously and the listener interface is notified + /// The tests are run asynchronously and the listener interface is notified /// as it progresses. /// /// An ITestEventHandler to receive events diff --git a/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs index 9d1dc6706..13cda0159 100644 --- a/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs @@ -25,9 +25,7 @@ using System.Collections.Generic; using NUnit.Engine.Internal; -#if !NETSTANDARD1_3 using NUnit.Common; -#endif namespace NUnit.Engine.Runners { @@ -73,17 +71,11 @@ public IList Runners } } -#if NETSTANDARD1_3 - public AggregatingTestRunner(TestPackage package) : base(package) - { - } -#else public AggregatingTestRunner(IServiceLocator services, TestPackage package) : base(services, package) { } -#endif -#region AbstractTestRunner Overrides + #region AbstractTestRunner Overrides /// /// Explore a TestPackage and return information about @@ -247,7 +239,7 @@ protected override void Dispose(bool disposing) throw new NUnitEngineUnloadException(_unloadExceptions); } -#endregion + #endregion protected virtual ITestEngineRunner CreateRunner(TestPackage package) { diff --git a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs index 162c7b816..3379ba5e3 100644 --- a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -30,16 +30,22 @@ namespace NUnit.Engine.Runners { /// - /// DirectTestRunner is the abstract base for runners + /// DirectTestRunner is the abstract base for runners /// that deal directly with a framework driver. /// public abstract class DirectTestRunner : AbstractTestRunner { private readonly List _drivers = new List(); + +#if !NETSTANDARD1_3 private ProvidedPathsAssemblyResolver _assemblyResolver; + protected AppDomain TestDomain { get; set; } +#endif + public DirectTestRunner(IServiceLocator services, TestPackage package) : base(services, package) { +#if !NETSTANDARD1_3 // Bypass the resolver if not in the default AppDomain. This prevents trying to use the resolver within // NUnit's own automated tests (in a test AppDomain) which does not make sense anyway. if (AppDomain.CurrentDomain.IsDefaultAppDomain()) @@ -47,14 +53,9 @@ public DirectTestRunner(IServiceLocator services, TestPackage package) : base(se _assemblyResolver = new ProvidedPathsAssemblyResolver(); _assemblyResolver.Install(); } +#endif } - #region Properties - - protected AppDomain TestDomain { get; set; } - - #endregion - #region AbstractTestRunner Overrides /// @@ -96,6 +97,8 @@ public override TestEngineResult Explore(TestFilter filter) /// A TestEngineResult. protected override TestEngineResult LoadPackage() { + EnsurePackageIsLoaded(); + var result = new TestEngineResult(); // DirectRunner may be called with a single-assembly package @@ -104,32 +107,44 @@ protected override TestEngineResult LoadPackage() if (packages.Count == 0) packages.Add(TestPackage); - var driverService = Services.GetService(); + var driverService = GetDriverService(); foreach (var subPackage in packages) { var testFile = subPackage.FullName; + string targetFramework = subPackage.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, (string)null); + bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false); + +#if !NETSTANDARD1_3 if (_assemblyResolver != null && !TestDomain.IsDefaultAppDomain() && subPackage.GetSetting(InternalEnginePackageSettings.ImageRequiresDefaultAppDomainAssemblyResolver, false)) { - // It's OK to do this in the loop because the Add method + // It's OK to do this in the loop because the Add method // checks to see if the path is already present. _assemblyResolver.AddPathFromFile(testFile); } - string targetFramework = subPackage.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, (string)null); - bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false); - IFrameworkDriver driver = driverService.GetDriver(TestDomain, testFile, targetFramework, skipNonTestAssemblies); +#else + IFrameworkDriver driver = driverService.GetDriver(testFile, skipNonTestAssemblies); +#endif driver.ID = TestPackage.ID; result.Add(LoadDriver(driver, testFile, subPackage)); _drivers.Add(driver); } - return result; } + private IDriverService GetDriverService() + { +#if NETSTANDARD1_3 + return new Services.DriverService(); +#else + return Services.GetService(); +#endif + } + private static string LoadDriver(IFrameworkDriver driver, string testFile, TestPackage subPackage) { try @@ -200,6 +215,7 @@ protected override TestEngineResult RunTests(ITestEventListener listener, TestFi result.Add(driverResult); } +#if !NETSTANDARD1_3 if (_assemblyResolver != null) { var packages = TestPackage.SubPackages; @@ -210,7 +226,7 @@ protected override TestEngineResult RunTests(ITestEventListener listener, TestFi foreach (var package in packages) _assemblyResolver.RemovePathFromFile(package.FullName); } - +#endif return result; } diff --git a/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs index 528d8271a..1e38ea0a5 100644 --- a/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -32,7 +32,9 @@ public class LocalTestRunner : DirectTestRunner { public LocalTestRunner(IServiceLocator services, TestPackage package) : base(services, package) { +#if !NETSTANDARD1_3 this.TestDomain = AppDomain.CurrentDomain; +#endif } } } diff --git a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs index ce7fe13d6..8fd9bb093 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -39,7 +39,9 @@ public class MasterTestRunner : ITestRunner private readonly ITestEngineRunner _engineRunner; private readonly IServiceLocator _services; private readonly IRuntimeFrameworkService _runtimeService; +#if !NETSTANDARD1_3 private readonly ExtensionService _extensionService; +#endif private readonly IProjectService _projectService; private bool _disposed; @@ -54,7 +56,9 @@ public MasterTestRunner(IServiceLocator services, TestPackage package) // Get references to the services we use _projectService = _services.GetService(); _runtimeService = _services.GetService(); +#if !NETSTANDARD1_3 _extensionService = _services.GetService(); +#endif _engineRunner = _services.GetService().MakeTestRunner(package); InitializePackage(); @@ -90,7 +94,7 @@ protected bool IsPackageLoaded public bool IsTestRunning { get; private set; } /// - /// Load a TestPackage for possible execution. The + /// Load a TestPackage for possible execution. The /// explicit implementation returns an ITestEngineResult /// for consumption by clients. /// @@ -145,6 +149,8 @@ public XmlNode Run(ITestEventListener listener, TestFilter filter) return PrepareResult(RunTests(listener, filter)).Xml; } + +#if !NETSTANDARD1_3 /// /// Start a run of the tests in the loaded TestPackage. The tests are run /// asynchronously and the listener interface is notified as it progresses. @@ -156,6 +162,7 @@ public ITestRun RunAsync(ITestEventListener listener, TestFilter filter) { return RunTestsAsync(listener, filter); } +#endif /// /// Cancel the ongoing test run. If no test is running, the call is ignored. @@ -269,7 +276,7 @@ private bool IsProjectPackage(TestPackage package) { if (package == null) throw new ArgumentNullException("package"); - return + return _projectService != null && !string.IsNullOrEmpty(package.FullName) && _projectService.CanLoadFrom(package.FullName); @@ -290,6 +297,7 @@ private void ExpandProjects(TestPackage package) // runner is putting invalid values into the package. private void ValidatePackageSettings() { +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 var frameworkSetting = TestPackage.GetSetting(EnginePackageSettings.RuntimeFramework, ""); if (frameworkSetting.Length > 0) { @@ -313,6 +321,7 @@ private void ValidatePackageSettings() "Cannot run {0} framework in process already running {1}.", frameworkSetting, currentFramework)); } } +#endif } /// @@ -351,8 +360,10 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter var eventDispatcher = new TestEventDispatcher(); if (listener != null) eventDispatcher.Listeners.Add(listener); +#if !NETSTANDARD1_3 foreach (var extension in _extensionService.GetExtensions()) eventDispatcher.Listeners.Add(extension); +#endif IsTestRunning = true; @@ -365,10 +376,15 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter // These are inserted in reverse order, since each is added as the first child. InsertFilterElement(result.Xml, filter); - InsertCommandLineElement(result.Xml); +#if !NETSTANDARD1_3 + InsertCommandLineElement(result.Xml); result.Xml.AddAttribute("engine-version", Assembly.GetExecutingAssembly().GetName().Version.ToString()); result.Xml.AddAttribute("clr-version", Environment.Version.ToString()); +#else + result.Xml.AddAttribute("engine-version", typeof(MasterTestRunner).GetTypeInfo().Assembly.GetName().Version.ToString()); + result.Xml.AddAttribute("clr-version", Microsoft.DotNet.InternalAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()); +#endif double duration = (double)(Stopwatch.GetTimestamp() - startTicks) / Stopwatch.Frequency; result.Xml.AddAttribute("start-time", XmlConvert.ToString(startTime, "u")); @@ -382,6 +398,7 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter return result; } +#if !NETSTANDARD1_3 private AsyncTestEngineResult RunTestsAsync(ITestEventListener listener, TestFilter filter) { var testRun = new AsyncTestEngineResult(); @@ -415,6 +432,7 @@ private static void InsertCommandLineElement(XmlNode resultNode) var cdata = doc.CreateCDataSection(Environment.CommandLine); cmd.AppendChild(cdata); } +#endif private static void InsertFilterElement(XmlNode resultNode, TestFilter filter) { @@ -437,6 +455,6 @@ private static void InsertFilterElement(XmlNode resultNode, TestFilter filter) resultNode.InsertAfter(filterElement, null); } - #endregion +#endregion } } diff --git a/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs index d146b32d2..de2a70662 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 namespace NUnit.Engine.Runners { /// @@ -46,3 +47,4 @@ protected override ITestEngineRunner CreateRunner(TestPackage package) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs index f2f97ef95..03d5e3003 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; namespace NUnit.Engine.Runners @@ -59,3 +60,4 @@ protected override ITestEngineRunner CreateRunner(TestPackage package) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs b/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs index a59c1ed28..ad572614b 100644 --- a/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs +++ b/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.Collections.Generic; using System.Diagnostics; @@ -111,3 +112,4 @@ public void WaitAll() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs b/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs index c4c4c5005..6c759022d 100644 --- a/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Net.Sockets; using NUnit.Common; @@ -171,7 +172,7 @@ protected override TestEngineResult RunTests(ITestEventListener listener, TestFi /// /// Start a run of the tests in the loaded TestPackage, returning immediately. - /// The tests are run asynchronously and the listener interface is notified + /// The tests are run asynchronously and the listener interface is notified /// as it progresses. /// /// An ITestEventHandler to receive events @@ -291,9 +292,9 @@ protected override void Dispose(bool disposing) } } -#endregion + #endregion -#region Helper Methods + #region Helper Methods private void CreateAgentAndRunner() { @@ -341,6 +342,7 @@ TestEngineResult CreateFailedResult(Exception e) return new TestEngineResult(suite); } -#endregion + #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs b/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs index cc4fa8112..141c69333 100644 --- a/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using NUnit.Engine.Services; namespace NUnit.Engine.Runners @@ -33,7 +34,7 @@ public class TestDomainRunner : DirectTestRunner { private DomainManager _domainManager; - public TestDomainRunner(IServiceLocator services, TestPackage package) : base(services, package) + public TestDomainRunner(IServiceLocator services, TestPackage package) : base(services, package) { _domainManager = Services.GetService(); } @@ -62,3 +63,4 @@ public override void UnloadPackage() #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/RuntimeFramework.cs b/src/NUnitEngine/nunit.engine/RuntimeFramework.cs index 4af14718c..fa229bd85 100644 --- a/src/NUnitEngine/nunit.engine/RuntimeFramework.cs +++ b/src/NUnitEngine/nunit.engine/RuntimeFramework.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Diagnostics; @@ -36,7 +37,7 @@ namespace NUnit.Engine /// [Serializable] public sealed class RuntimeFramework : IRuntimeFramework - { + { // TODO: RuntimeFramework was originally created for use in // a single-threaded environment. The introduction of parallel // execution and especially parallel loading of tests has @@ -44,7 +45,7 @@ public sealed class RuntimeFramework : IRuntimeFramework // // Ideally, we should remove all knowledge of the environment // from RuntimeFramework. An instance of RuntimeFramework does - // not need to know, for example, if it is available on the + // not need to know, for example, if it is available on the // current system. In the present architecture, that's really // the job of the RuntimeFrameworkService. Other functions // may actually belong in TestAgency. @@ -68,7 +69,7 @@ public sealed class RuntimeFramework : IRuntimeFramework private static RuntimeFramework _currentFramework; private static List _availableFrameworks; - private static readonly string DEFAULT_WINDOWS_MONO_DIR = + private static readonly string DEFAULT_WINDOWS_MONO_DIR = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles), "Mono"); #endregion @@ -379,7 +380,7 @@ public bool IsAvailable /// /// The Profile for this framework, where relevant. - /// May be null and will have different sets of + /// May be null and will have different sets of /// values for each Runtime. /// public string Profile { get; private set; } @@ -554,7 +555,7 @@ private static void FindDefaultMonoFramework() { if (CurrentFramework.Runtime == RuntimeType.Mono) UseCurrentMonoFramework(); - else + else if (Environment.OSVersion.Platform == PlatformID.Win32NT) FindBestMonoFrameworkOnWindows(); } @@ -615,7 +616,7 @@ private static void FindBestMonoFrameworkOnWindows() AddMonoFramework(new Version(4, 5), null); return; } - + // Look in the Software\Novell key for older versions key = Registry.LocalMachine.OpenSubKey(@"Software\Novell\Mono"); if (key != null) @@ -735,7 +736,7 @@ private static void AddDotNetFourFrameworkVersions(RegistryKey versionKey) { var profileKey = versionKey.OpenSubKey(profile); if (profileKey == null) continue; - + if (CheckInstallDword(profileKey)) { AddDotNetFramework(new Version(4, 0), profile); @@ -767,3 +768,4 @@ private static bool CheckInstallDword(RegistryKey key) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs b/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs index b93ccab72..d9c6ca4cc 100644 --- a/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs +++ b/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Diagnostics; @@ -157,3 +158,4 @@ public Snapshot(IEnumerable data) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs index 0618890be..92a28c07e 100644 --- a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -27,9 +27,9 @@ namespace NUnit.Engine.Services { /// - /// DefaultTestRunnerFactory handles creation of a suitable test - /// runner for a given package to be loaded and run either in a - /// separate process or within the same process. + /// DefaultTestRunnerFactory handles creation of a suitable test + /// runner for a given package to be loaded and run either in a + /// separate process or within the same process. /// public class DefaultTestRunnerFactory : InProcessTestRunnerFactory, ITestRunnerFactory { @@ -50,8 +50,6 @@ public override void StartService() #endregion - #region InProcessTestRunnerFactory Overrides - /// /// Returns a test runner based on the settings in a TestPackage. /// Any setting that is "consumed" by the factory is removed, so @@ -62,7 +60,6 @@ public override void StartService() /// A TestRunner public override ITestEngineRunner MakeTestRunner(TestPackage package) { - int assemblyCount = 0; int projectCount = 0; @@ -75,7 +72,14 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) else if (_projectService.CanLoadFrom(testFile)) projectCount++; } +#if NETSTANDARD1_3 || NETSTANDARD2_0 + + if (assemblyCount > 0) + return new AggregatingTestRunner(ServiceContext, package); + return new LocalTestRunner(ServiceContext, package); + } +#else // If we have multiple projects or a project plus assemblies // then defer to the AggregatingTestRunner, which will make // the decision on a file by file basis so that each project @@ -126,8 +130,6 @@ public override bool CanReuse(ITestEngineRunner runner, TestPackage package) } } - #endregion - #region Helper Methods private ProcessModel GetTargetProcessModel(TestPackage package) @@ -138,5 +140,7 @@ private ProcessModel GetTargetProcessModel(TestPackage package) } #endregion + +#endif } } diff --git a/src/NUnitEngine/nunit.engine/Services/DomainManager.cs b/src/NUnitEngine/nunit.engine/Services/DomainManager.cs index 892a7c36d..95b291fb2 100644 --- a/src/NUnitEngine/nunit.engine/Services/DomainManager.cs +++ b/src/NUnitEngine/nunit.engine/Services/DomainManager.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.IO; using System.Collections.Generic; @@ -75,7 +76,7 @@ public AppDomain CreateDomain( TestPackage package ) Hash hash = new Hash(assembly); evidence.AddHost(hash); } - + log.Info("Creating application domain " + domainName); AppDomain runnerDomain = AppDomain.CreateDomain(domainName, evidence, setup); @@ -106,7 +107,7 @@ AppDomainSetup CreateAppDomainSetup(TestPackage package) string appBase = GetApplicationBase(package); setup.ApplicationBase = appBase; setup.ConfigurationFile = GetConfigFile(appBase, package); - setup.PrivateBinPath = GetPrivateBinPath(appBase, package); + setup.PrivateBinPath = GetPrivateBinPath(appBase, package); if (!string.IsNullOrEmpty(package.FullName)) { @@ -240,7 +241,7 @@ public static string GetConfigFile(string appBase, TestPackage package) string configFile = package.GetSetting(EnginePackageSettings.ConfigurationFile, string.Empty); if (configFile != string.Empty) return Path.Combine(appBase, configFile); - + // The ProjectService adds any project config to the settings. // So, at this point, we only want to handle assemblies or an // anonymous package created from the command-line. @@ -330,7 +331,7 @@ public static string GetPrivateBinPath(string basePath, IList assemblies foreach( string assembly in assemblies ) { string dir = PathUtils.RelativePath( - Path.GetFullPath(basePath), + Path.GetFullPath(basePath), Path.GetDirectoryName( Path.GetFullPath(assembly) ) ); if ( dir != null && dir != string.Empty && dir != "." && !dirList.Contains( dir ) ) { @@ -370,3 +371,4 @@ private static void Kill(Thread thread) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/DriverService.cs b/src/NUnitEngine/nunit.engine/Services/DriverService.cs index 999927c15..a9fb3fa08 100644 --- a/src/NUnitEngine/nunit.engine/Services/DriverService.cs +++ b/src/NUnitEngine/nunit.engine/Services/DriverService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -51,7 +51,11 @@ public class DriverService : Service, IDriverService /// The value of any TargetFrameworkAttribute on the assembly, or null /// True if non-test assemblies should simply be skipped rather than reporting an error /// +#if NETSTANDARD1_3 + public IFrameworkDriver GetDriver(string assemblyPath, bool skipNonTestAssemblies) +#else public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string targetFramework, bool skipNonTestAssemblies) +#endif { if (!File.Exists(assemblyPath)) return new InvalidAssemblyFrameworkDriver(assemblyPath, "File not found: " + assemblyPath); @@ -59,9 +63,10 @@ public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string if (!PathUtils.IsAssemblyFileType(assemblyPath)) return new InvalidAssemblyFrameworkDriver(assemblyPath, "File type is not supported"); +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 if (targetFramework != null) { - // This takes care of an issue with Roslyn. It may get fixed, but we still + // This takes care of an issue with Roslyn. It may get fixed, but we still // have to deal with assemblies having this setting. I'm assuming that // any true Portable assembly would have a Profile as part of its name. var platform = targetFramework == ".NETPortable,Version=v5.0" @@ -70,6 +75,7 @@ public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string if (platform == "Silverlight" || platform == ".NETPortable" || platform == ".NETStandard" || platform == ".NETCompactFramework") return new InvalidAssemblyFrameworkDriver(assemblyPath, platform + " test assemblies are not yet supported by the engine"); } +#endif try { @@ -91,7 +97,11 @@ public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string foreach (var reference in references) { if (factory.IsSupportedTestFramework(reference)) +#if NETSTANDARD1_3 || NETSTANDARD2_0 + return factory.GetDriver(reference); +#else return factory.GetDriver(domain, reference); +#endif } } } @@ -117,16 +127,20 @@ public override void StartService() try { +#if !NETSTANDARD1_3 var extensionService = ServiceContext.GetService(); if (extensionService != null) { foreach (IDriverFactory factory in extensionService.GetExtensions()) _factories.Add(factory); +#if !NETSTANDARD2_0 var node = extensionService.GetExtensionNode("/NUnit/Engine/NUnitV2Driver"); if (node != null) _factories.Add(new NUnit2DriverFactory(node)); +#endif } +#endif _factories.Add(new NUnit3DriverFactory()); diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionAssembly.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionAssembly.cs index 3bfbffbc2..b62009892 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionAssembly.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionAssembly.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using Mono.Cecil; namespace NUnit.Engine.Services @@ -72,7 +73,7 @@ public bool IsDuplicateOf(ExtensionAssembly other) { return AssemblyName.Name == other.AssemblyName.Name; } - + /// /// IsBetterVersion determines whether another assembly is /// a better (higher) version than the current assembly. @@ -102,3 +103,4 @@ public bool IsBetterVersionOf(ExtensionAssembly other) } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs index 60e43ed2f..5b931fd6b 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.Collections.Generic; using System.IO; @@ -34,7 +35,7 @@ namespace NUnit.Engine.Services { /// /// The ExtensionService discovers ExtensionPoints and Extensions and - /// maintains them in a database. It can return extension nodes or + /// maintains them in a database. It can return extension nodes or /// actual extension objects on request. /// public class ExtensionService : Service, IExtensionService @@ -177,7 +178,7 @@ public override void StartService() FindExtensionPoints(thisAssembly); FindExtensionPoints(apiAssembly); - // Create the list of possible extension assemblies, + // Create the list of possible extension assemblies, // eliminating duplicates. Start in Engine directory. var startDir = new DirectoryInfo(AssemblyHelper.GetDirectoryName(thisAssembly)); FindExtensionAssemblies(startDir); @@ -256,7 +257,7 @@ public void FindExtensionPoints(Assembly assembly) } /// - /// Deduce the extension point based on the Type of an extension. + /// Deduce the extension point based on the Type of an extension. /// Returns null if no extension point can be found that would /// be satisfied by the provided Type. /// @@ -268,12 +269,22 @@ private ExtensionPoint DeduceExtensionPointFromType(TypeReference typeRef) TypeDefinition typeDef = typeRef.Resolve(); + +#if NETSTANDARD2_0 + foreach (InterfaceImplementation iface in typeDef.Interfaces) + { + ep = DeduceExtensionPointFromType(iface.InterfaceType); + if (ep != null) + return ep; + } +#else foreach (TypeReference iface in typeDef.Interfaces) { ep = DeduceExtensionPointFromType(iface); if (ep != null) return ep; } +#endif TypeReference baseType = typeDef.BaseType; return baseType != null && baseType.FullName != "System.Object" @@ -303,8 +314,8 @@ private void FindExtensionAssemblies(DirectoryInfo startDir) } /// - /// Scans a directory for candidate addin assemblies. Note that assemblies in - /// the directory are only scanned if no file of type .addins is found. If such + /// Scans a directory for candidate addin assemblies. Note that assemblies in + /// the directory are only scanned if no file of type .addins is found. If such /// a file is found, then those assemblies it references are scanned. /// private void ProcessDirectory(DirectoryInfo startDir, bool fromWildCard) @@ -490,3 +501,4 @@ public void FindExtensionsInAssembly(ExtensionAssembly assembly) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs index 73eae1f9a..b0a7293ea 100644 --- a/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -26,7 +26,7 @@ namespace NUnit.Engine.Services { /// - /// InProcessTestRunnerFactory handles creation of a suitable test + /// InProcessTestRunnerFactory handles creation of a suitable test /// runner for a given package to be loaded and run within the /// same process. /// @@ -44,6 +44,9 @@ public class InProcessTestRunnerFactory : Service, ITestRunnerFactory /// An ITestEngineRunner public virtual ITestEngineRunner MakeTestRunner(TestPackage package) { +#if NETSTANDARD1_3 || NETSTANDARD2_0 + return new LocalTestRunner(ServiceContext, package); +#else DomainUsage domainUsage = (DomainUsage)System.Enum.Parse( typeof(DomainUsage), package.GetSetting(EnginePackageSettings.DomainUsage, "Default")); @@ -66,6 +69,7 @@ public virtual ITestEngineRunner MakeTestRunner(TestPackage package) case DomainUsage.Single: return new TestDomainRunner(ServiceContext, package); } +#endif } public virtual bool CanReuse(ITestEngineRunner runner, TestPackage package) diff --git a/src/NUnitEngine/nunit.engine/Services/ProjectService.cs b/src/NUnitEngine/nunit.engine/Services/ProjectService.cs index a68dd62f1..57ab3ceda 100644 --- a/src/NUnitEngine/nunit.engine/Services/ProjectService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ProjectService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System.Collections.Generic; using System.IO; using NUnit.Common; @@ -52,7 +53,7 @@ public bool CanLoadFrom(string path) /// /// Expands a TestPackage based on a known project format, populating it - /// with the project contents and any settings the project provides. + /// with the project contents and any settings the project provides. /// Note that the package file path must be checked to ensure that it is /// a known project format before calling this method. /// @@ -169,3 +170,4 @@ private ExtensionNode GetNodeForPath(string path) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/ResultService.cs b/src/NUnitEngine/nunit.engine/Services/ResultService.cs index 6f3ccd204..4f297ebcb 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultService.cs @@ -27,11 +27,7 @@ namespace NUnit.Engine.Services { - public class ResultService : -#if !NETSTANDARD1_3 - Service, -#endif - IResultService + public class ResultService : Service, IResultService { #if NETSTANDARD1_3 private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases" }; diff --git a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs index 107887e82..279471ab9 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 using System; using System.IO; using System.Text; @@ -65,7 +66,7 @@ public void CheckWritability(string outputPath) { using ( new StreamWriter( outputPath, false ) ) { - // We don't need to check if the XSLT file exists, + // We don't need to check if the XSLT file exists, // that would have thrown in the constructor } } @@ -89,3 +90,4 @@ public void WriteResultFile(XmlNode result, string outputPath) } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs b/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs index a80ecec88..fa8365bb7 100644 --- a/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs +++ b/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.IO; @@ -190,7 +191,7 @@ private static void ApplyImageData(TestPackage package) // We are doing two jobs here: (1) in the else clause (below) // we get information about a single assembly and record it, // (2) in the if clause, we recursively examine all subpackages - // and then apply policies for promulgating each setting to + // and then apply policies for promulgating each setting to // a containing package. We could implement the policy part at // a higher level, but it seems simplest to do it right here. if (package.SubPackages.Count > 0) @@ -203,7 +204,7 @@ private static void ApplyImageData(TestPackage package) Version v = subPackage.GetSetting(InternalEnginePackageSettings.ImageRuntimeVersion, new Version(0, 0)); if (v > targetVersion) targetVersion = v; - // Collect highest framework name + // Collect highest framework name // TODO: This assumes lexical ordering is valid - check it string fn = subPackage.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, ""); if (fn != "") @@ -259,3 +260,4 @@ private static void ApplyImageData(TestPackage package) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs index 8de02a051..c7a0f290e 100644 --- a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs +++ b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -23,6 +23,7 @@ using System; using System.Collections.Generic; +using System.Reflection; using NUnit.Engine.Internal; namespace NUnit.Engine.Services @@ -53,7 +54,11 @@ public IService GetService( Type serviceType ) else foreach( IService service in _services ) { +#if NETSTANDARD1_3 + if( service.GetType().GetTypeInfo().IsAssignableFrom( serviceType.GetTypeInfo() ) ) +#else if( serviceType.IsInstanceOfType( service ) ) +#endif { _serviceIndex[serviceType] = service; theService = service; @@ -65,7 +70,7 @@ public IService GetService( Type serviceType ) log.Error(string.Format("Requested service {0} was not found", serviceType.FullName)); else log.Debug(string.Format("Request for service {0} satisfied by {1}", serviceType.Name, theService.GetType().Name)); - + return theService; } @@ -132,9 +137,9 @@ public void ClearServices() _services.Clear(); } - #endregion +#endregion - #region IDisposable +#region IDisposable private bool _disposed = false; @@ -162,6 +167,6 @@ protected virtual void Dispose(bool disposing) } } - #endregion +#endregion } } diff --git a/src/NUnitEngine/nunit.engine/Services/TestAgency.cs b/src/NUnitEngine/nunit.engine/Services/TestAgency.cs index 7adba5a26..88cb77f11 100644 --- a/src/NUnitEngine/nunit.engine/Services/TestAgency.cs +++ b/src/NUnitEngine/nunit.engine/Services/TestAgency.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.IO; using System.Threading; @@ -238,7 +239,7 @@ private Guid LaunchAgentProcess(TestPackage package) p.StartInfo.Arguments = arglist; break; } - + p.Start(); log.Debug("Launched Agent process {0} - see nunit-agent_{0}.log", p.Id); log.Debug("Command line: \"{0}\" {1}", p.StartInfo.FileName, p.StartInfo.Arguments); @@ -261,7 +262,7 @@ private ITestAgent CreateRemoteAgent(TestPackage package, int waitTime) Thread.Sleep( pollTime ); if ( !infinite ) waitTime -= pollTime; var agentRecord = _agentData[agentId]; - + if ( agentRecord.Agent != null ) { log.Debug( "Returning new agent {0}", agentId.ToString("B") ); @@ -360,3 +361,4 @@ public void StartService() #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/TestFilterService.cs b/src/NUnitEngine/nunit.engine/Services/TestFilterService.cs index 4738e44cc..2fefbde0e 100644 --- a/src/NUnitEngine/nunit.engine/Services/TestFilterService.cs +++ b/src/NUnitEngine/nunit.engine/Services/TestFilterService.cs @@ -23,11 +23,7 @@ namespace NUnit.Engine.Services { - public class TestFilterService : -#if !NETSTANDARD1_3 - Service, -#endif - ITestFilterService + public class TestFilterService : Service, ITestFilterService { public ITestFilterBuilder GetTestFilterBuilder() { diff --git a/src/NUnitEngine/nunit.engine/TestEngine.cs b/src/NUnitEngine/nunit.engine/TestEngine.cs index f5bf586b3..d56f25a9c 100644 --- a/src/NUnitEngine/nunit.engine/TestEngine.cs +++ b/src/NUnitEngine/nunit.engine/TestEngine.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -25,6 +25,7 @@ using System.Diagnostics; using System.IO; using System.Reflection; +using System.Runtime.InteropServices; using NUnit.Engine.Internal; using NUnit.Engine.Services; @@ -40,7 +41,11 @@ public class TestEngine : ITestEngine public TestEngine() { Services = new ServiceContext(); +#if NETSTANDARD1_3 + WorkDirectory = NUnitConfiguration.ApplicationDirectory; +#else WorkDirectory = Environment.CurrentDirectory; +#endif InternalTraceLevel = InternalTraceLevel.Default; } @@ -73,12 +78,12 @@ IServiceLocator ITestEngine.Services /// /// Initialize the engine. This includes initializing mono addins, - /// setting the trace level and creating the standard set of services + /// setting the trace level and creating the standard set of services /// used in the Engine. - /// - /// This interface is not normally called by user code. Programs linking + /// + /// This interface is not normally called by user code. Programs linking /// only to the nunit.engine.api assembly are given a - /// pre-initialized instance of TestEngine. Programs + /// pre-initialized instance of TestEngine. Programs /// that link directly to nunit.engine usually do so /// in order to perform custom initialization. /// @@ -94,16 +99,20 @@ public void Initialize() if (Services.ServiceCount == 0) { Services.Add(new SettingsService(true)); - Services.Add(new DomainManager()); - Services.Add(new ExtensionService()); Services.Add(new DriverService()); Services.Add(new RecentFilesService()); - Services.Add(new ProjectService()); - Services.Add(new RuntimeFrameworkService()); Services.Add(new DefaultTestRunnerFactory()); - Services.Add(new TestAgency()); Services.Add(new ResultService()); Services.Add(new TestFilterService()); +#if !NETSTANDARD1_3 + Services.Add(new ExtensionService()); + Services.Add(new ProjectService()); +#if !NETSTANDARD2_0 + Services.Add(new DomainManager()); + Services.Add(new RuntimeFrameworkService()); + Services.Add(new TestAgency()); +#endif +#endif } Services.ServiceManager.StartServices(); diff --git a/src/NUnitEngine/nunit.engine/nunit.engine.csproj b/src/NUnitEngine/nunit.engine/nunit.engine.csproj index d6e5fa2eb..794fd5e84 100644 --- a/src/NUnitEngine/nunit.engine/nunit.engine.csproj +++ b/src/NUnitEngine/nunit.engine/nunit.engine.csproj @@ -2,7 +2,7 @@ NUnit.Engine nunit.engine - net20 + net20;netstandard1.3;netstandard2.0 false ..\..\..\bin\$(Configuration)\ true @@ -15,6 +15,14 @@ + + + + + + + + From 770f8cdece517d148f543cf691041e1ede389fd1 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Mon, 4 Jun 2018 22:29:35 -0400 Subject: [PATCH 03/29] Checkpointing work getting the tests to compile --- .../nunit3-console.tests.csproj | 2 +- src/NUnitEngine/mock-assembly/MockAssembly.cs | 34 +++++------ .../mock-assembly/mock-assembly.csproj | 4 +- .../notest-assembly/notest-assembly.csproj | 2 +- .../Drivers/NUnit3FrameworkDriverTests.cs | 6 +- .../nunit.engine.tests/DummyExtensions.cs | 4 ++ .../Internal/AssemblyHelperTests.cs | 2 + .../Internal/PathUtilTests.cs | 2 +- .../Internal/SettingsGroupTests.cs | 4 +- .../Internal/SettingsStoreTests.cs | 6 +- .../Internal/TcpChannelUtilsTests.cs | 2 + src/NUnitEngine/nunit.engine.tests/Program.cs | 17 ++++++ .../Runners/DirectTestRunnerTests.cs | 12 +++- .../Runners/MasterTestRunnerTests.cs | 16 ++--- .../Runners/MultipleTestProcessRunnerTests.cs | 6 +- .../Runners/ParallelTaskWorkerPoolTests.cs | 8 ++- .../Runners/TestEngineRunnerTests.cs | 22 +++++-- .../RuntimeFrameworkTests.cs | 60 ++++++++++--------- .../Services/AgentDataBaseTests.cs | 8 ++- .../Services/DefaultTestRunnerFactoryTests.cs | 29 ++++++++- .../Services/DomainManagerStaticTests.cs | 6 +- .../Services/DomainManagerTests.cs | 6 +- .../Services/DriverServiceTests.cs | 18 +++++- .../Services/ExtensionAssemblyTests.cs | 8 ++- .../Services/ExtensionServiceTests.cs | 10 ++-- .../InProcessTestRunnerFactoryTests.cs | 10 +++- .../Services/ProjectServiceTests.cs | 6 +- .../Services/ResultServiceTests.cs | 26 +++----- .../XmlTransformResultWriterTests.cs | 8 ++- .../Services/RuntimeFrameworkServiceTests.cs | 6 +- .../Services/TestAgencyTests.cs | 6 +- .../Services/TestFilteringTests.cs | 4 +- .../nunit.engine.tests/TempResourceFile.cs | 8 ++- .../nunit.engine.tests.csproj | 11 +++- .../Services/DefaultTestRunnerFactory.cs | 13 ++-- 35 files changed, 249 insertions(+), 143 deletions(-) create mode 100644 src/NUnitEngine/nunit.engine.tests/Program.cs diff --git a/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj b/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj index 6d6b794d6..5f8ae0432 100644 --- a/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj +++ b/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/NUnitEngine/mock-assembly/MockAssembly.cs b/src/NUnitEngine/mock-assembly/MockAssembly.cs index 59b9e09e7..6f99dfc3d 100644 --- a/src/NUnitEngine/mock-assembly/MockAssembly.cs +++ b/src/NUnitEngine/mock-assembly/MockAssembly.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -33,7 +33,7 @@ namespace Assemblies /// MockAssembly is intended for those few tests that can only /// be made to work by loading an entire assembly. Please don't /// add any other entries or use it for other purposes. - /// + /// /// Most tests used as data for NUnit's own tests should be /// in the testdata assembly. /// @@ -77,7 +77,7 @@ public class MockAssembly public const int TestOutputEvents = 1; public const int Nodes = Tests + Suites; - + public const int ExplicitFixtures = 1; public const int SuitesRun = Suites - ExplicitFixtures; @@ -184,10 +184,10 @@ namespace Singletons public class OneTestCase { public const int Tests = 1; - public const int Suites = 1; + public const int Suites = 1; [Test] - public virtual void TestCase() + public virtual void TestCase() {} } } @@ -218,7 +218,7 @@ public void Test1() { } [Test] public void Test2() { } - + [Test] public void Test3() { } } @@ -248,27 +248,27 @@ public BadFixture(int val) { } [Test] public void SomeTest() { } } - + [TestFixture] public class FixtureWithTestCases { public const int Tests = 4; public const int Suites = 3; - + [TestCase(2, 2, ExpectedResult=4)] [TestCase(9, 11, ExpectedResult=20)] public int MethodWithParameters(int x, int y) { return x+y; } - + [TestCase(2, 4)] [TestCase(9.2, 11.7)] public void GenericMethod(T x, T y) { } } - + [TestFixture(5)] [TestFixture(42)] public class ParameterizedFixture @@ -277,29 +277,29 @@ public class ParameterizedFixture public const int Suites = 3; public ParameterizedFixture(int num) { } - + [Test] public void Test1() { } - + [Test] public void Test2() { } } - + public class GenericFixtureConstants { public const int Tests = 4; public const int Suites = 3; } - + [TestFixture(5)] [TestFixture(11.5)] public class GenericFixture { public GenericFixture(T num){ } - + [Test] public void Test1() { } - + [Test] public void Test2() { } } diff --git a/src/NUnitEngine/mock-assembly/mock-assembly.csproj b/src/NUnitEngine/mock-assembly/mock-assembly.csproj index 701947c65..b26ced1ca 100644 --- a/src/NUnitEngine/mock-assembly/mock-assembly.csproj +++ b/src/NUnitEngine/mock-assembly/mock-assembly.csproj @@ -2,7 +2,7 @@ mock-assembly NUnit.Tests - net35;netstandard1.6 + net20;netstandard1.6;netstandard2.0 false ..\..\..\bin\$(Configuration)\ true @@ -11,7 +11,7 @@ 7 - + diff --git a/src/NUnitEngine/notest-assembly/notest-assembly.csproj b/src/NUnitEngine/notest-assembly/notest-assembly.csproj index 8f7d8f3b7..e3619f513 100644 --- a/src/NUnitEngine/notest-assembly/notest-assembly.csproj +++ b/src/NUnitEngine/notest-assembly/notest-assembly.csproj @@ -7,6 +7,6 @@ ..\..\..\bin\$(Configuration)\ - + \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Drivers/NUnit3FrameworkDriverTests.cs b/src/NUnitEngine/nunit.engine.tests/Drivers/NUnit3FrameworkDriverTests.cs index 5cfb5e8f8..efee9527c 100644 --- a/src/NUnitEngine/nunit.engine.tests/Drivers/NUnit3FrameworkDriverTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Drivers/NUnit3FrameworkDriverTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 &&!NETCOREAPP2_0 using System; using System.Collections.Generic; using System.Reflection; @@ -199,3 +200,4 @@ public void OnTestEvent(string testEvent) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/DummyExtensions.cs b/src/NUnitEngine/nunit.engine.tests/DummyExtensions.cs index 3645ee25d..5c41ac2c2 100644 --- a/src/NUnitEngine/nunit.engine.tests/DummyExtensions.cs +++ b/src/NUnitEngine/nunit.engine.tests/DummyExtensions.cs @@ -33,7 +33,11 @@ namespace NUnit.Engine.Tests [Extension] public class DummyFrameworkDriverExtension : IDriverFactory { +#if NETCOREAPP1_1 || NETCOREAPP2_0 + public IFrameworkDriver GetDriver(AssemblyName reference) +#else public IFrameworkDriver GetDriver(AppDomain domain, AssemblyName reference) +#endif { throw new NotImplementedException(); } diff --git a/src/NUnitEngine/nunit.engine.tests/Internal/AssemblyHelperTests.cs b/src/NUnitEngine/nunit.engine.tests/Internal/AssemblyHelperTests.cs index 5f5f422d8..eba8ea61a 100644 --- a/src/NUnitEngine/nunit.engine.tests/Internal/AssemblyHelperTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Internal/AssemblyHelperTests.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System.IO; using NUnit.Framework; @@ -73,3 +74,4 @@ public void GetAssemblyPathFromCodeBase(string uri, string expectedPath) } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs b/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs index b941e1191..9188e1163 100644 --- a/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs @@ -86,7 +86,7 @@ public void Canonicalize() PathUtils.Canonicalize( @"folder1\folder2\..\..\..\file.tmp" ) ); } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 [Test] [Platform(Exclude="Linux,UNIX,MacOSX")] public void RelativePath() diff --git a/src/NUnitEngine/nunit.engine.tests/Internal/SettingsGroupTests.cs b/src/NUnitEngine/nunit.engine.tests/Internal/SettingsGroupTests.cs index f320bd144..a131c9bed 100644 --- a/src/NUnitEngine/nunit.engine.tests/Internal/SettingsGroupTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Internal/SettingsGroupTests.cs @@ -24,7 +24,7 @@ using System; using System.ComponentModel; using NUnit.Framework; -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System.Drawing; #endif @@ -101,7 +101,7 @@ public void WhenSettingIsNotValid_DefaultSettingIsReturned() Assert.AreEqual( 42, settings.GetSetting( "X", 42 ) ); } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 [Test] [SetCulture("da-DK")] public void SaveAndGetSettingShouldReturnTheOriginalValue() diff --git a/src/NUnitEngine/nunit.engine.tests/Internal/SettingsStoreTests.cs b/src/NUnitEngine/nunit.engine.tests/Internal/SettingsStoreTests.cs index b7c28fc04..f202cc232 100644 --- a/src/NUnitEngine/nunit.engine.tests/Internal/SettingsStoreTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Internal/SettingsStoreTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System; using System.IO; using System.Xml.Schema; @@ -106,3 +107,4 @@ public void SaveSettingsDoesNotOverwriteExistingFileWhenFailing() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Internal/TcpChannelUtilsTests.cs b/src/NUnitEngine/nunit.engine.tests/Internal/TcpChannelUtilsTests.cs index 543f04a23..cabd03c90 100644 --- a/src/NUnitEngine/nunit.engine.tests/Internal/TcpChannelUtilsTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Internal/TcpChannelUtilsTests.cs @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; @@ -101,3 +102,4 @@ private static IDisposable CleanUpOnDispose(IChannelReceiver channel) => On.Disp }); } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Program.cs b/src/NUnitEngine/nunit.engine.tests/Program.cs new file mode 100644 index 000000000..f07060205 --- /dev/null +++ b/src/NUnitEngine/nunit.engine.tests/Program.cs @@ -0,0 +1,17 @@ +#if !NET35 +using NUnitLite; +using System; +using System.Reflection; + +namespace NUnit.Engine.Tests +{ + class Program + { + static int Main(string[] args) + { + int result = new TextRunner(typeof(Program).GetTypeInfo().Assembly).Execute(args); + return result; + } + } +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs b/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs index d01717ecd..8b3273033 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -43,7 +43,13 @@ public void Initialize() driver = Substitute.For(); var driverService = Substitute.For(); - driverService.GetDriver(AppDomain.CurrentDomain, string.Empty, string.Empty, false).ReturnsForAnyArgs(driver); + driverService.GetDriver( +#if !NETCOREAPP1_1 + AppDomain.CurrentDomain, + string.Empty, +#endif + string.Empty, + false).ReturnsForAnyArgs(driver); var serviceLocator = Substitute.For(); serviceLocator.GetService().Returns(driverService); diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/MasterTestRunnerTests.cs b/src/NUnitEngine/nunit.engine.tests/Runners/MasterTestRunnerTests.cs index a40e9f524..b043f0213 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/MasterTestRunnerTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/MasterTestRunnerTests.cs @@ -35,9 +35,7 @@ namespace NUnit.Engine.Runners.Tests public class MasterTestRunnerTests : ITestEventListener { private TestPackage _package; -#if !NETCOREAPP1_1 private ServiceContext _services; -#endif private MasterTestRunner _runner; private List _events; @@ -46,22 +44,22 @@ public void Initialize() { _package = new TestPackage(Path.Combine(TestContext.CurrentContext.TestDirectory, "mock-assembly.dll")); -#if !NETCOREAPP1_1 // Add all services needed _services = new ServiceContext(); - _services.Add(new Services.DomainManager()); +#if !NETCOREAPP1_1 _services.Add(new Services.ExtensionService()); - _services.Add(new Services.DriverService()); _services.Add(new Services.ProjectService()); +#if !NETCOREAPP2_0 + _services.Add(new Services.DomainManager()); _services.Add(new Services.RuntimeFrameworkService()); +#endif +#endif + _services.Add(new Services.DriverService()); _services.Add(new Services.InProcessTestRunnerFactory()); _services.ServiceManager.StartServices(); _runner = new MasterTestRunner(_services, _package); -#else - _runner = new MasterTestRunner(_package); -#endif _events = new List(); } @@ -71,10 +69,8 @@ public void CleanUp() if (_runner != null) _runner.Dispose(); -#if !NETCOREAPP1_1 if (_services != null) _services.ServiceManager.Dispose(); -#endif } [Test] diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/MultipleTestProcessRunnerTests.cs b/src/NUnitEngine/nunit.engine.tests/Runners/MultipleTestProcessRunnerTests.cs index d51ea7916..11bcfa6ce 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/MultipleTestProcessRunnerTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/MultipleTestProcessRunnerTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.Collections.Generic; using NUnit.Framework; @@ -62,3 +63,4 @@ MultipleTestProcessRunner CreateRunner(int assemblyCount, int maxAgents) } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/ParallelTaskWorkerPoolTests.cs b/src/NUnitEngine/nunit.engine.tests/Runners/ParallelTaskWorkerPoolTests.cs index 46c952279..0d78c4158 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/ParallelTaskWorkerPoolTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/ParallelTaskWorkerPoolTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System; using System.Threading; using NUnit.Framework; @@ -146,7 +147,7 @@ private class BusyTask : ITestExecutionTask public BusyTaskState State { get; private set; } public BusyTask() - { + { _semaphore = new Semaphore(0, 1); State = BusyTaskState.Queued; } @@ -165,3 +166,4 @@ public void MarkTaskAsCompleted() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/TestEngineRunnerTests.cs b/src/NUnitEngine/nunit.engine.tests/Runners/TestEngineRunnerTests.cs index 74bc8c89d..bbf59e27b 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/TestEngineRunnerTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/TestEngineRunnerTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -37,10 +37,12 @@ namespace NUnit.Engine.Runners.Tests // intermittent errors, probably due to the test // fixture rather than the engine. [TestFixture(typeof(LocalTestRunner))] +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 [TestFixture(typeof(TestDomainRunner))] //[TestFixture(typeof(ProcessRunner))] [TestFixture(typeof(MultipleTestDomainRunner), 1)] [TestFixture(typeof(MultipleTestDomainRunner), 3)] +#endif //[TestFixture(typeof(MultipleTestProcessRunner), 1)] //[TestFixture(typeof(MultipleTestProcessRunner), 3)] //[Platform(Exclude = "Mono", Reason = "Currently causing long delays or hangs under Mono")] @@ -65,11 +67,17 @@ public void Initialize() { // Add all services needed by any of our TestEngineRunners _services = new ServiceContext(); - _services.Add(new Services.DriverService()); - _services.Add(new Services.DomainManager()); +#if !NETCOREAPP1_1 + _services.Add(new Services.ExtensionService()); _services.Add(new Services.ProjectService()); - _services.Add(new Services.DefaultTestRunnerFactory()); +#if !NETCOREAPP2_0 + _services.Add(new Services.DomainManager()); + _services.Add(new Services.RuntimeFrameworkService()); _services.Add(new Services.TestAgency("ProcessRunnerTests", 0)); +#endif +#endif + _services.Add(new Services.DriverService()); + _services.Add(new Services.DefaultTestRunnerFactory()); _services.ServiceManager.StartServices(); var mockAssemblyPath = Path.Combine(TestContext.CurrentContext.TestDirectory, "mock-assembly.dll"); @@ -127,11 +135,14 @@ public void Run() CheckPackageLoading(); } +#if !NETCOREAPP1_1 [Test] public void RunAsync() { +#if !NETCOREAPP2_0 if (_runner is ProcessRunner || _runner is MultipleTestProcessRunner) Assert.Ignore("RunAsync is not working for ProcessRunner"); +#endif var asyncResult = _runner.RunAsync(null, TestFilter.Empty); asyncResult.Wait(-1); @@ -140,6 +151,7 @@ public void RunAsync() CheckRunResult(asyncResult.EngineResult); CheckPackageLoading(); } +#endif private void CheckPackageLoading() { diff --git a/src/NUnitEngine/nunit.engine.tests/RuntimeFrameworkTests.cs b/src/NUnitEngine/nunit.engine.tests/RuntimeFrameworkTests.cs index ef6d12b89..b92fd0751 100644 --- a/src/NUnitEngine/nunit.engine.tests/RuntimeFrameworkTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/RuntimeFrameworkTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.Collections.Generic; using NUnit.Framework; @@ -133,48 +134,48 @@ public bool CanMatchRuntimes(RuntimeFramework f1, RuntimeFramework f2) #pragma warning disable 414 static TestCaseData[] matchData = new TestCaseData[] { new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(3,5)), - new RuntimeFramework(RuntimeType.Net, new Version(2,0))) + new RuntimeFramework(RuntimeType.Net, new Version(3,5)), + new RuntimeFramework(RuntimeType.Net, new Version(2,0))) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Net, new Version(3,5))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0)), + new RuntimeFramework(RuntimeType.Net, new Version(3,5))) .Returns(false), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(3,5)), - new RuntimeFramework(RuntimeType.Net, new Version(3,5))) + new RuntimeFramework(RuntimeType.Net, new Version(3,5)), + new RuntimeFramework(RuntimeType.Net, new Version(3,5))) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Net, new Version(2,0))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0)), + new RuntimeFramework(RuntimeType.Net, new Version(2,0))) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0)), + new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727))) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)), - new RuntimeFramework(RuntimeType.Net, new Version(2,0))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)), + new RuntimeFramework(RuntimeType.Net, new Version(2,0))) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)), - new RuntimeFramework(RuntimeType.Net, new Version(2,0))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)), + new RuntimeFramework(RuntimeType.Net, new Version(2,0))) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Mono, new Version(2,0))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0)), + new RuntimeFramework(RuntimeType.Mono, new Version(2,0))) .Returns(false), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Net, new Version(1,1))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0)), + new RuntimeFramework(RuntimeType.Net, new Version(1,1))) .Returns(false), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)), - new RuntimeFramework(RuntimeType.Net, new Version(2,0,40607))) + new RuntimeFramework(RuntimeType.Net, new Version(2,0,50727)), + new RuntimeFramework(RuntimeType.Net, new Version(2,0,40607))) .Returns(false), new TestCaseData( new RuntimeFramework(RuntimeType.Mono, new Version(1,1)), // non-existent version but it works - new RuntimeFramework(RuntimeType.Mono, new Version(1,0))) + new RuntimeFramework(RuntimeType.Mono, new Version(1,0))) .Returns(true), new TestCaseData( new RuntimeFramework(RuntimeType.Mono, new Version(2,0)), @@ -193,20 +194,20 @@ public bool CanMatchRuntimes(RuntimeFramework f1, RuntimeFramework f2) new RuntimeFramework(RuntimeType.Any, new Version(4,0))) .Returns(false), new TestCaseData( - new RuntimeFramework(RuntimeType.Net, RuntimeFramework.DefaultVersion), - new RuntimeFramework(RuntimeType.Net, new Version(2,0))) + new RuntimeFramework(RuntimeType.Net, RuntimeFramework.DefaultVersion), + new RuntimeFramework(RuntimeType.Net, new Version(2,0))) .Returns(true), new TestCaseData( new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Net, RuntimeFramework.DefaultVersion)) + new RuntimeFramework(RuntimeType.Net, RuntimeFramework.DefaultVersion)) .Returns(true), new TestCaseData( - new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion), - new RuntimeFramework(RuntimeType.Net, new Version(2,0))) + new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion), + new RuntimeFramework(RuntimeType.Net, new Version(2,0))) .Returns(true), new TestCaseData( new RuntimeFramework(RuntimeType.Net, new Version(2,0)), - new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion)) + new RuntimeFramework(RuntimeType.Any, RuntimeFramework.DefaultVersion)) .Returns(true) }; #pragma warning restore 414 @@ -265,3 +266,4 @@ public override string ToString() #pragma warning restore 414 } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/AgentDataBaseTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/AgentDataBaseTests.cs index 14e1b37c9..fc500d485 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/AgentDataBaseTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/AgentDataBaseTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.Collections.Generic; using System.Threading; @@ -143,7 +144,7 @@ private void AddRecord(Guid guid) { _data.Add(new AgentRecord(guid, null, null, AgentStatus.Ready)); } - + private void AddRecords(int count) { GenerateGuids(count); @@ -168,3 +169,4 @@ private void RunInParallel(ParameterizedThreadStart start) } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs index aad274e3d..8c9e368a7 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -40,7 +40,9 @@ public class DefaultTestRunnerFactoryTests public void CreateServiceContext() { _services = new ServiceContext(); +#if !NETCOREAPP1_1 _services.Add(new ExtensionService()); +#endif _services.Add(new FakeProjectService()); _factory = new DefaultTestRunnerFactory(); _services.Add(_factory); @@ -52,7 +54,19 @@ public void ServiceIsStarted() { Assert.That(_factory.Status, Is.EqualTo(ServiceStatus.Started)); } - + +#if NETCOREAPP1_1 || NETCOREAPP2_0 + // Single file + [TestCase("x.nunit", null, typeof(AggregatingTestRunner))] + [TestCase("x.dll", null, typeof(LocalTestRunner))] + // Two files + [TestCase("x.nunit y.nunit", null, typeof(AggregatingTestRunner))] + [TestCase("x.nunit y.dll", null, typeof(AggregatingTestRunner))] + [TestCase("x.dll y.dll", null, typeof(AggregatingTestRunner))] + // Three files + [TestCase("x.nunit y.dll z.nunit", null, typeof(AggregatingTestRunner))] + [TestCase("x.dll y.nunit z.dll", null, typeof(AggregatingTestRunner))] +#else // Single file [TestCase("x.nunit", null, typeof(AggregatingTestRunner))] [TestCase("x.dll", null, typeof(ProcessRunner))] @@ -87,6 +101,7 @@ public void ServiceIsStarted() [TestCase("x.nunit y.dll z.nunit", "Multiple", typeof(AggregatingTestRunner))] [TestCase("x.dll y.nunit z.dll", "Multiple", typeof(AggregatingTestRunner))] [TestCase("x.dll y.dll z.dll", "Multiple", typeof(MultipleTestProcessRunner))] +#endif public void CorrectRunnerIsUsed(string files, string processModel, Type expectedType) { var package = new TestPackage(files.Split(new char[] { ' ' })); @@ -98,11 +113,19 @@ public void CorrectRunnerIsUsed(string files, string processModel, Type expected Assert.That(runner, Is.TypeOf(expectedType)); } +#if NETCOREAPP1_1 || NETCOREAPP2_0 + [TestCase("x.junk", typeof(LocalTestRunner))] + [TestCase("x.junk y.dll", typeof(AggregatingTestRunner))] + [TestCase("x.junk y.junk", typeof(AggregatingTestRunner))] + [TestCase("x.dll y.junk z.dll", typeof(AggregatingTestRunner))] + [TestCase("x.dll y.junk z.junk", typeof(AggregatingTestRunner))] +#else [TestCase("x.junk", typeof(ProcessRunner))] [TestCase("x.junk y.dll", typeof(MultipleTestProcessRunner))] [TestCase("x.junk y.junk", typeof(MultipleTestProcessRunner))] [TestCase("x.dll y.junk z.dll", typeof(MultipleTestProcessRunner))] [TestCase("x.dll y.junk z.junk", typeof(MultipleTestProcessRunner))] +#endif public void CorrectRunnerIsUsed_InvalidExtension(string files, Type expectedType) { var package = new TestPackage(files.Split(new char[] {' '})); diff --git a/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerStaticTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerStaticTests.cs index 40fb5963d..091b3a534 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerStaticTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerStaticTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.Collections.Generic; using System.Configuration; @@ -178,3 +179,4 @@ private static IEnumerable AppDomainData() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerTests.cs index 338f42e5e..823fc4888 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/DomainManagerTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.IO; using NUnit.Framework; @@ -133,3 +134,4 @@ private void CheckDomainIsUnloaded(AppDomain domain) #endregion } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/DriverServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/DriverServiceTests.cs index 317dd75fc..082e27420 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/DriverServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/DriverServiceTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -39,7 +39,9 @@ public class DriverServiceTests public void CreateDriverFactory() { var serviceContext = new ServiceContext(); +#if !NETCOREAPP1_1 serviceContext.Add(new ExtensionService()); +#endif _driverService = new DriverService(); serviceContext.Add(_driverService); serviceContext.ServiceManager.StartServices(); @@ -52,22 +54,32 @@ public void ServiceIsStarted() } +#if NETCOREAPP1_1 || NETCOREAPP2_0 + [TestCase("mock-assembly.dll", false, typeof(NUnitNetStandardDriver))] + [TestCase("mock-assembly.dll", true, typeof(NUnitNetStandardDriver))] + [TestCase("notest-assembly.dll", false, typeof(NUnitNetStandardDriver))] +#else [TestCase("mock-assembly.dll", false, typeof(NUnit3FrameworkDriver))] [TestCase("mock-assembly.dll", true, typeof(NUnit3FrameworkDriver))] + [TestCase("notest-assembly.dll", false, typeof(NUnit3FrameworkDriver))] +#endif [TestCase("mock-assembly.pdb", false, typeof(InvalidAssemblyFrameworkDriver))] [TestCase("mock-assembly.pdb", true, typeof(InvalidAssemblyFrameworkDriver))] [TestCase("junk.dll", false, typeof(InvalidAssemblyFrameworkDriver))] [TestCase("junk.dll", true, typeof(InvalidAssemblyFrameworkDriver))] [TestCase("nunit.engine.dll", false, typeof(InvalidAssemblyFrameworkDriver))] [TestCase("nunit.engine.dll", true, typeof(SkippedAssemblyFrameworkDriver))] - [TestCase("notest-assembly.dll", false, typeof(NUnit3FrameworkDriver))] [TestCase("notest-assembly.dll", true, typeof(SkippedAssemblyFrameworkDriver))] public void CorrectDriverIsUsed(string fileName, bool skipNonTestAssemblies, Type expectedType) { var driver = _driverService.GetDriver( +#if !NETCOREAPP1_1 AppDomain.CurrentDomain, +#endif Path.Combine(TestContext.CurrentContext.TestDirectory, fileName), +#if !NETCOREAPP1_1 null, +#endif skipNonTestAssemblies); Assert.That(driver, Is.InstanceOf(expectedType)); diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionAssemblyTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionAssemblyTests.cs index 1ff0aec72..1dae44de7 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionAssemblyTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionAssemblyTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System; using System.Collections.Generic; using System.Reflection; @@ -61,7 +62,7 @@ public void AssemblyDefinition() [Test] public void MainModule() { - Assert.That(_ea.MainModule.Assembly.FullName, Is.EqualTo(THIS_ASSEMBLY_NAME)); + Assert.That(_ea.MainModule.Assembly.FullName, Is.EqualTo(THIS_ASSEMBLY_NAME)); } [Test] @@ -115,3 +116,4 @@ public void IsBetterVersionOf_ThrowsIfNotDuplicates() #endif } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs index a120b2144..f14762893 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System; using System.Reflection; using NUnit.Framework; @@ -42,7 +43,7 @@ public class ExtensionServiceTests #pragma warning disable 414 private static readonly string[] KNOWN_EXTENSION_POINT_PATHS = new string[] { "/NUnit/Engine/TypeExtensions/IDriverFactory", - "/NUnit/Engine/TypeExtensions/IProjectLoader", + "/NUnit/Engine/TypeExtensions/IProjectLoader", "/NUnit/Engine/TypeExtensions/IResultWriter", "/NUnit/Engine/TypeExtensions/ITestEventListener", "/NUnit/Engine/TypeExtensions/IService", @@ -144,7 +145,7 @@ public void CanListExtensions(string typeName) Assert.True(node.Enabled); return; } - + Assert.Fail("Couldn't find known Extension {0}", typeName); } @@ -187,3 +188,4 @@ public void DisabledExtensionMayBeEnabled() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/InProcessTestRunnerFactoryTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/InProcessTestRunnerFactoryTests.cs index 65eea37e1..770f3ea9d 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/InProcessTestRunnerFactoryTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/InProcessTestRunnerFactoryTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -50,6 +50,11 @@ public void ServiceIsStarted() Assert.That(_factory.Status, Is.EqualTo(ServiceStatus.Started), "Failed to start service"); } +#if NETCOREAPP1_1 || NETCOREAPP2_0 + [TestCase("x.dll", null, typeof(LocalTestRunner))] + [TestCase("x.dll y.dll", null, typeof(LocalTestRunner))] + [TestCase("x.dll y.dll z.dll", null, typeof(LocalTestRunner))] +#else // Single file [TestCase("x.dll", null, typeof(TestDomainRunner))] [TestCase("x.dll", "Single", typeof(TestDomainRunner))] @@ -62,6 +67,7 @@ public void ServiceIsStarted() [TestCase("x.dll y.dll z.dll", null, typeof(MultipleTestDomainRunner))] [TestCase("x.dll y.dll z.dll", "Single", typeof(TestDomainRunner))] [TestCase("x.dll y.dll z.dll", "Multiple", typeof(MultipleTestDomainRunner))] +#endif public void CorrectRunnerIsUsed(string files, string domainUsage, Type expectedType) { var package = new TestPackage(files.Split(new char[] { ' ' })); diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ProjectServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ProjectServiceTests.cs index f5c92032b..1f1430a40 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ProjectServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ProjectServiceTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System; using System.Collections.Generic; using System.Text; @@ -49,3 +50,4 @@ public void ServiceIsStarted() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs index f41eee555..774492023 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -32,24 +32,13 @@ public class ResultServiceTests { private ResultService _resultService; -#if NETCOREAPP1_1 - [SetUp] - public void CreateService() - { - _resultService = new ResultService(); - } - - [Test] - public void AvailableFormats() - { - Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases" })); - } -#else [SetUp] public void CreateService() { var services = new ServiceContext(); +#if !NETCOREAPP1_1 services.Add(new ExtensionService()); +#endif _resultService = new ResultService(); services.Add(_resultService); services.ServiceManager.StartServices(); @@ -64,9 +53,12 @@ public void ServiceIsStarted() [Test] public void AvailableFormats() { +#if NETCOREAPP1_1 + Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases" })); +#else Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases", "user" })); - } #endif + } [TestCase("nunit3", null, ExpectedResult = "NUnit3XmlResultWriter")] //[TestCase("nunit2", null, ExpectedResult = "NUnit2XmlResultWriter")] @@ -92,7 +84,7 @@ public void CanGetWriterUser() public void NUnit3Format_NonExistentTransform_ThrowsArgumentException() { Assert.That( - () => _resultService.GetResultWriter("user", new object[] { "junk.xslt" }), + () => _resultService.GetResultWriter("user", new object[] { "junk.xslt" }), Throws.ArgumentException); } diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs index 8bfa2e76c..ca736d27c 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System.IO; using NUnit.Framework; @@ -44,8 +45,9 @@ public void SummaryTransformTest() EngineResult.Xml.Attributes["skipped"].Value); string output = writer.GetStringBuilder().ToString(); - + Assert.That(output, Contains.Substring(summary)); } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/RuntimeFrameworkServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/RuntimeFrameworkServiceTests.cs index 8e91e4242..a038709e7 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/RuntimeFrameworkServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/RuntimeFrameworkServiceTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System; using System.Collections.Generic; using System.IO; @@ -93,3 +94,4 @@ public void EngineOptionPreferredOverImageTarget(string framework, int majorVers } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/TestAgencyTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/TestAgencyTests.cs index 4b574d448..c0d68def9 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/TestAgencyTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/TestAgencyTests.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using NUnit.Framework; namespace NUnit.Engine.Services.Tests @@ -49,3 +50,4 @@ public void ServiceIsStarted() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/TestFilteringTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/TestFilteringTests.cs index 815788555..f9be6392e 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/TestFilteringTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/TestFilteringTests.cs @@ -35,7 +35,7 @@ public class TestFilteringTests { private const string MOCK_ASSEMBLY = "mock-assembly.dll"; -#if NETCOREAPP1_1 +#if NETCOREAPP1_1 || NETCOREAPP2_0 private NUnitNetStandardDriver _driver; #else private NUnit3FrameworkDriver _driver; @@ -45,7 +45,7 @@ public class TestFilteringTests public void LoadAssembly() { var mockAssemblyPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY); -#if NETCOREAPP1_1 +#if NETCOREAPP1_1 || NETCOREAPP2_0 _driver = new NUnitNetStandardDriver(); #else var assemblyName = typeof(NUnit.Framework.TestAttribute).Assembly.GetName(); diff --git a/src/NUnitEngine/nunit.engine.tests/TempResourceFile.cs b/src/NUnitEngine/nunit.engine.tests/TempResourceFile.cs index 9017a79ca..144d1237b 100644 --- a/src/NUnitEngine/nunit.engine.tests/TempResourceFile.cs +++ b/src/NUnitEngine/nunit.engine.tests/TempResourceFile.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 namespace NUnit.Engine.Tests { using System; @@ -61,7 +62,7 @@ public TempResourceFile(Type type, string name, string filePath) public void Dispose() { File.Delete(this.path); - + string path = this.path; while(true) { @@ -84,3 +85,4 @@ public string Path } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj index e5b5238ef..6c2875f65 100644 --- a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj +++ b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj @@ -2,7 +2,8 @@ NUnit.Engine.Tests nunit.engine.tests - net35 + net35;netcoreapp1.1;netcoreapp2.0 + Exe false ..\..\..\bin\$(Configuration)\ true @@ -16,9 +17,13 @@ + + + - + + @@ -45,6 +50,6 @@ - + \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs index 92a28c07e..10284787b 100644 --- a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs @@ -72,14 +72,7 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) else if (_projectService.CanLoadFrom(testFile)) projectCount++; } -#if NETSTANDARD1_3 || NETSTANDARD2_0 - - if (assemblyCount > 0) - return new AggregatingTestRunner(ServiceContext, package); - return new LocalTestRunner(ServiceContext, package); - } -#else // If we have multiple projects or a project plus assemblies // then defer to the AggregatingTestRunner, which will make // the decision on a file by file basis so that each project @@ -89,6 +82,12 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) if (projectCount > 1 || projectCount > 0 && assemblyCount > 0) return new AggregatingTestRunner(ServiceContext, package); +#if NETSTANDARD1_3 || NETSTANDARD2_0 + + return base.MakeTestRunner(package); + } +#else + ProcessModel processModel = GetTargetProcessModel(package); switch (processModel) From 6ada4b3493d37d6c25262e31a55a56138d118350 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Tue, 5 Jun 2018 18:18:58 -0400 Subject: [PATCH 04/29] Engine tests are compiling and running, but not passing. Checkpointing work --- src/NUnitEngine/mock-assembly/MockAssembly.cs | 2 +- src/NUnitEngine/mock-assembly/mock-assembly.csproj | 2 +- src/NUnitEngine/notest-assembly/notest-assembly.csproj | 2 +- .../nunit.engine.tests/Helpers/ShadowCopyUtils.cs | 5 ++++- .../Integration/DirectoryWithNeededAssemblies.cs | 6 ++++-- .../MockAssemblyInDirectoryWithFramework.cs | 6 ++++-- .../nunit.engine.tests/Integration/RemoteAgentTests.cs | 4 +++- .../Integration/RunnerInDirectoryWithoutFramework.cs | 4 +++- .../Services/ResultWriters/XmlOutputTest.cs | 10 ++++++---- 9 files changed, 27 insertions(+), 14 deletions(-) diff --git a/src/NUnitEngine/mock-assembly/MockAssembly.cs b/src/NUnitEngine/mock-assembly/MockAssembly.cs index 6f99dfc3d..359ca3b34 100644 --- a/src/NUnitEngine/mock-assembly/MockAssembly.cs +++ b/src/NUnitEngine/mock-assembly/MockAssembly.cs @@ -102,7 +102,7 @@ public class MockAssembly public const int Inconclusive = MockTestFixture.Inconclusive; -#if !NETSTANDARD1_6 +#if !NETCOREAPP1_1 public static readonly string AssemblyPath = AssemblyHelper.GetAssemblyPath(typeof(MockAssembly).Assembly); #endif } diff --git a/src/NUnitEngine/mock-assembly/mock-assembly.csproj b/src/NUnitEngine/mock-assembly/mock-assembly.csproj index b26ced1ca..b7b576a24 100644 --- a/src/NUnitEngine/mock-assembly/mock-assembly.csproj +++ b/src/NUnitEngine/mock-assembly/mock-assembly.csproj @@ -2,7 +2,7 @@ mock-assembly NUnit.Tests - net20;netstandard1.6;netstandard2.0 + net20;netcoreapp1.1;netcoreapp2.0 false ..\..\..\bin\$(Configuration)\ true diff --git a/src/NUnitEngine/notest-assembly/notest-assembly.csproj b/src/NUnitEngine/notest-assembly/notest-assembly.csproj index e3619f513..7bca6d513 100644 --- a/src/NUnitEngine/notest-assembly/notest-assembly.csproj +++ b/src/NUnitEngine/notest-assembly/notest-assembly.csproj @@ -2,7 +2,7 @@ notest_assembly notest-assembly - net35 + net35;netcoreapp1.1 false ..\..\..\bin\$(Configuration)\ diff --git a/src/NUnitEngine/nunit.engine.tests/Helpers/ShadowCopyUtils.cs b/src/NUnitEngine/nunit.engine.tests/Helpers/ShadowCopyUtils.cs index 097d4a70f..f1db57732 100644 --- a/src/NUnitEngine/nunit.engine.tests/Helpers/ShadowCopyUtils.cs +++ b/src/NUnitEngine/nunit.engine.tests/Helpers/ShadowCopyUtils.cs @@ -1,4 +1,6 @@ -using System; +#if !NETCOREAPP1_1 + +using System; using System.Collections.Generic; using System.IO; using System.Linq; @@ -34,3 +36,4 @@ from assemblyName in assemblyNames } } } +#endif diff --git a/src/NUnitEngine/nunit.engine.tests/Integration/DirectoryWithNeededAssemblies.cs b/src/NUnitEngine/nunit.engine.tests/Integration/DirectoryWithNeededAssemblies.cs index 7cbfa6cd9..b1faade6e 100644 --- a/src/NUnitEngine/nunit.engine.tests/Integration/DirectoryWithNeededAssemblies.cs +++ b/src/NUnitEngine/nunit.engine.tests/Integration/DirectoryWithNeededAssemblies.cs @@ -1,4 +1,5 @@ -using System; +#if !NETCOREAPP1_1 +using System; using System.IO; using NUnit.Engine.Tests.Helpers; @@ -28,4 +29,5 @@ public void Dispose() System.IO.Directory.Delete(Directory, true); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Integration/MockAssemblyInDirectoryWithFramework.cs b/src/NUnitEngine/nunit.engine.tests/Integration/MockAssemblyInDirectoryWithFramework.cs index 068dba825..0e1af5f42 100644 --- a/src/NUnitEngine/nunit.engine.tests/Integration/MockAssemblyInDirectoryWithFramework.cs +++ b/src/NUnitEngine/nunit.engine.tests/Integration/MockAssemblyInDirectoryWithFramework.cs @@ -1,4 +1,5 @@ -using System; +#if !NETCOREAPP1_1 +using System; using System.IO; using NUnit.Framework; @@ -22,4 +23,5 @@ public void Dispose() directory.Dispose(); } } -} \ No newline at end of file +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Integration/RemoteAgentTests.cs b/src/NUnitEngine/nunit.engine.tests/Integration/RemoteAgentTests.cs index a1830bd2d..0818d2e1b 100644 --- a/src/NUnitEngine/nunit.engine.tests/Integration/RemoteAgentTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Integration/RemoteAgentTests.cs @@ -1,4 +1,5 @@ -using System.Diagnostics; +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 +using System.Diagnostics; using NUnit.Engine.Tests.Helpers; using NUnit.Framework; @@ -23,3 +24,4 @@ public void Explore_does_not_throw_SocketException() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Integration/RunnerInDirectoryWithoutFramework.cs b/src/NUnitEngine/nunit.engine.tests/Integration/RunnerInDirectoryWithoutFramework.cs index cb370bc4e..f1d16fd41 100644 --- a/src/NUnitEngine/nunit.engine.tests/Integration/RunnerInDirectoryWithoutFramework.cs +++ b/src/NUnitEngine/nunit.engine.tests/Integration/RunnerInDirectoryWithoutFramework.cs @@ -1,4 +1,5 @@ -using System; +#if !NETCOREAPP1_1 +using System; using System.IO; using System.Threading; using NUnit.Framework; @@ -37,3 +38,4 @@ public void Dispose() } } } +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs index 2696a95da..40c102840 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -21,6 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** +#if !NETCOREAPP1_1 using System; using System.Collections.Generic; using System.IO; @@ -39,7 +40,7 @@ namespace NUnit.Engine.Services.ResultWriters.Tests /// /// This is the abstract base for all XML output tests, - /// which need to work on a TestEngineResult. Creating a + /// which need to work on a TestEngineResult. Creating a /// second level engine in the test domain causes /// problems, so this class uses internal framework /// classes to run the test and then transforms the XML @@ -83,7 +84,7 @@ public void InitializeTestEngineResult() // Make sure the runner loaded the mock assembly. Assert.That( runner.Load(AssemblyPath, settings).RunState.ToString(), - Is.EqualTo("Runnable"), + Is.EqualTo("Runnable"), "Unable to load mock-assembly.dll"); // Run the tests, saving the result as an XML string @@ -96,3 +97,4 @@ public void InitializeTestEngineResult() } } } +#endif \ No newline at end of file From 3bb356580c90ab0050a4a96f82ec2ebaa2fc471a Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Tue, 5 Jun 2018 18:47:23 -0400 Subject: [PATCH 05/29] Checkpointing test fixes --- src/NUnitEngine/nunit.engine.api/TestPackage.cs | 13 +++---------- src/NUnitEngine/nunit.engine.tests/Program.cs | 11 +++++++---- .../nunit.engine.tests/nunit.engine.tests.csproj | 5 +++-- .../nunit.engine/Runners/DirectTestRunner.cs | 2 -- .../nunit.engine/Services/ServiceManager.cs | 3 ++- 5 files changed, 15 insertions(+), 19 deletions(-) diff --git a/src/NUnitEngine/nunit.engine.api/TestPackage.cs b/src/NUnitEngine/nunit.engine.api/TestPackage.cs index c8fc22847..913505479 100644 --- a/src/NUnitEngine/nunit.engine.api/TestPackage.cs +++ b/src/NUnitEngine/nunit.engine.api/TestPackage.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -30,7 +30,7 @@ namespace NUnit.Engine /// /// TestPackage holds information about a set of test files to /// be loaded by a TestRunner. Each TestPackage represents - /// tests for one or more test files. TestPackages may be named + /// tests for one or more test files. TestPackages may be named /// or anonymous, depending on how they are constructed. /// #if !NETSTANDARD1_3 @@ -51,14 +51,7 @@ public TestPackage(string filePath) if (filePath != null) { -#if NETSTANDARD1_3 - if (!Path.IsPathRooted(filePath)) - throw new NUnitEngineException("Paths to test assemblies must not be relative in .NET Standard"); - - FullName = filePath; -#else FullName = Path.GetFullPath(filePath); -#endif Settings = new Dictionary(); SubPackages = new List(); } diff --git a/src/NUnitEngine/nunit.engine.tests/Program.cs b/src/NUnitEngine/nunit.engine.tests/Program.cs index f07060205..2466b2482 100644 --- a/src/NUnitEngine/nunit.engine.tests/Program.cs +++ b/src/NUnitEngine/nunit.engine.tests/Program.cs @@ -1,4 +1,4 @@ -#if !NET35 +//#if !NET35 using NUnitLite; using System; using System.Reflection; @@ -9,9 +9,12 @@ class Program { static int Main(string[] args) { - int result = new TextRunner(typeof(Program).GetTypeInfo().Assembly).Execute(args); - return result; +#if !NET35 + return new TextRunner(typeof(Program).GetTypeInfo().Assembly).Execute(args); +#else + return new TextRunner(typeof(Program).Assembly).Execute(args); +#endif } } } -#endif \ No newline at end of file +//#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj index 6c2875f65..a1bfc1667 100644 --- a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj +++ b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj @@ -3,7 +3,8 @@ NUnit.Engine.Tests nunit.engine.tests net35;netcoreapp1.1;netcoreapp2.0 - Exe + + Exe false ..\..\..\bin\$(Configuration)\ true @@ -50,6 +51,6 @@ - + \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs index 3379ba5e3..6a86c49db 100644 --- a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs @@ -97,8 +97,6 @@ public override TestEngineResult Explore(TestFilter filter) /// A TestEngineResult. protected override TestEngineResult LoadPackage() { - EnsurePackageIsLoaded(); - var result = new TestEngineResult(); // DirectRunner may be called with a single-assembly package diff --git a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs index c7a0f290e..e525e5a4d 100644 --- a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs +++ b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs @@ -55,7 +55,8 @@ public IService GetService( Type serviceType ) foreach( IService service in _services ) { #if NETSTANDARD1_3 - if( service.GetType().GetTypeInfo().IsAssignableFrom( serviceType.GetTypeInfo() ) ) + if (serviceType.GetTypeInfo().IsAssignableFrom(service.GetType().GetTypeInfo())) + //if ( service.GetType().GetTypeInfo().IsAssignableFrom( serviceType.GetTypeInfo() ) ) #else if( serviceType.IsInstanceOfType( service ) ) #endif From 645fd3bdf3d2a7a5527c56a44731d5435dcd98d1 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Tue, 5 Jun 2018 19:47:32 -0400 Subject: [PATCH 06/29] All .NET Standard/Core 2.0 tests passing --- .../notest-assembly/notest-assembly.csproj | 2 +- .../Runners/Fakes/EmptyDirectTestRunner.cs | 7 ++++- .../Services/ResultServiceTests.cs | 4 +-- .../Services/ResultWriters/XmlOutputTest.cs | 2 +- .../XmlTransformResultWriterTests.cs | 2 +- .../nunit.engine/Runners/MasterTestRunner.cs | 8 +++--- .../Services/DefaultTestRunnerFactory.cs | 12 +++++++-- .../nunit.engine/Services/DriverService.cs | 2 +- .../nunit.engine/Services/ResultService.cs | 26 +++++++++---------- .../ResultWriters/XmlTransformResultWriter.cs | 2 +- src/NUnitEngine/nunit.engine/TestEngine.cs | 2 +- 11 files changed, 41 insertions(+), 28 deletions(-) diff --git a/src/NUnitEngine/notest-assembly/notest-assembly.csproj b/src/NUnitEngine/notest-assembly/notest-assembly.csproj index 7bca6d513..a21f76baf 100644 --- a/src/NUnitEngine/notest-assembly/notest-assembly.csproj +++ b/src/NUnitEngine/notest-assembly/notest-assembly.csproj @@ -2,7 +2,7 @@ notest_assembly notest-assembly - net35;netcoreapp1.1 + net35;netcoreapp1.1;netcoreapp2.0 false ..\..\..\bin\$(Configuration)\ diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/Fakes/EmptyDirectTestRunner.cs b/src/NUnitEngine/nunit.engine.tests/Runners/Fakes/EmptyDirectTestRunner.cs index c4d285588..42d9b2bd5 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/Fakes/EmptyDirectTestRunner.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/Fakes/EmptyDirectTestRunner.cs @@ -7,7 +7,12 @@ namespace NUnit.Engine.Tests.Runners.Fakes { internal class EmptyDirectTestRunner : Engine.Runners.DirectTestRunner { - public EmptyDirectTestRunner(IServiceLocator services, TestPackage package) : base(services, package) { } + public EmptyDirectTestRunner(IServiceLocator services, TestPackage package) : base(services, package) + { +#if !NETCOREAPP1_1 + TestDomain = AppDomain.CurrentDomain; +#endif + } public new void LoadPackage() { diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs index 774492023..ede3b1389 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs @@ -53,7 +53,7 @@ public void ServiceIsStarted() [Test] public void AvailableFormats() { -#if NETCOREAPP1_1 +#if NETCOREAPP1_1 || NETCOREAPP2_0 Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases" })); #else Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases", "user" })); @@ -72,7 +72,7 @@ public string CanGetWriter(string format, object[] args) return writer.GetType().Name; } -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 [Test] public void CanGetWriterUser() { diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs index 40c102840..772070702 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_1 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.IO; diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs index ca736d27c..81b69749f 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETCOREAPP1_1 +#if !NETCOREAPP1_1 && !NETCOREAPP2_0 using System.IO; using NUnit.Framework; diff --git a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs index 8fd9bb093..f5705f788 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs @@ -38,8 +38,8 @@ public class MasterTestRunner : ITestRunner private const string TEST_RUN_ELEMENT = "test-run"; private readonly ITestEngineRunner _engineRunner; private readonly IServiceLocator _services; +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 private readonly IRuntimeFrameworkService _runtimeService; -#if !NETSTANDARD1_3 private readonly ExtensionService _extensionService; #endif private readonly IProjectService _projectService; @@ -55,8 +55,8 @@ public MasterTestRunner(IServiceLocator services, TestPackage package) // Get references to the services we use _projectService = _services.GetService(); +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 _runtimeService = _services.GetService(); -#if !NETSTANDARD1_3 _extensionService = _services.GetService(); #endif _engineRunner = _services.GetService().MakeTestRunner(package); @@ -234,7 +234,9 @@ private void InitializePackage() // Info will be left behind in the package about // each contained assembly, which will subsequently // be used to determine how to run the assembly. +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 _runtimeService.SelectRuntimeFramework(TestPackage); +#endif var processModel = TestPackage.GetSetting(EnginePackageSettings.ProcessModel, "").ToLower(); @@ -360,7 +362,7 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter var eventDispatcher = new TestEventDispatcher(); if (listener != null) eventDispatcher.Listeners.Add(listener); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 foreach (var extension in _extensionService.GetExtensions()) eventDispatcher.Listeners.Add(extension); #endif diff --git a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs index 10284787b..9d8172935 100644 --- a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs @@ -33,12 +33,15 @@ namespace NUnit.Engine.Services /// public class DefaultTestRunnerFactory : InProcessTestRunnerFactory, ITestRunnerFactory { +#if !NETSTANDARD1_3 private IProjectService _projectService; +#endif #region Service Overrides public override void StartService() { +#if !NETSTANDARD1_3 // TestRunnerFactory requires the ProjectService _projectService = ServiceContext.GetService(); @@ -46,6 +49,7 @@ public override void StartService() Status = _projectService != null && ((IService)_projectService).Status == ServiceStatus.Started ? ServiceStatus.Started : ServiceStatus.Error; +#endif } #endregion @@ -69,8 +73,10 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) if (PathUtils.IsAssemblyFileType(testFile)) assemblyCount++; +#if !NETSTANDARD1_3 else if (_projectService.CanLoadFrom(testFile)) projectCount++; +#endif } // If we have multiple projects or a project plus assemblies @@ -83,6 +89,8 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) return new AggregatingTestRunner(ServiceContext, package); #if NETSTANDARD1_3 || NETSTANDARD2_0 + if (projectCount > 0 || package.SubPackages.Count > 1) + return new AggregatingTestRunner(ServiceContext, package); return base.MakeTestRunner(package); } @@ -129,7 +137,7 @@ public override bool CanReuse(ITestEngineRunner runner, TestPackage package) } } - #region Helper Methods +#region Helper Methods private ProcessModel GetTargetProcessModel(TestPackage package) { @@ -138,7 +146,7 @@ private ProcessModel GetTargetProcessModel(TestPackage package) package.GetSetting(EnginePackageSettings.ProcessModel, "Default")); } - #endregion +#endregion #endif } diff --git a/src/NUnitEngine/nunit.engine/Services/DriverService.cs b/src/NUnitEngine/nunit.engine/Services/DriverService.cs index a9fb3fa08..965814e62 100644 --- a/src/NUnitEngine/nunit.engine/Services/DriverService.cs +++ b/src/NUnitEngine/nunit.engine/Services/DriverService.cs @@ -73,7 +73,7 @@ public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string ? ".NETStandard" : targetFramework.Split(new char[] { ',' })[0]; if (platform == "Silverlight" || platform == ".NETPortable" || platform == ".NETStandard" || platform == ".NETCompactFramework") - return new InvalidAssemblyFrameworkDriver(assemblyPath, platform + " test assemblies are not yet supported by the engine"); + return new InvalidAssemblyFrameworkDriver(assemblyPath, platform + " test assemblies are not supported by this version of the engine"); } #endif diff --git a/src/NUnitEngine/nunit.engine/Services/ResultService.cs b/src/NUnitEngine/nunit.engine/Services/ResultService.cs index 4f297ebcb..1541cf18d 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultService.cs @@ -8,10 +8,10 @@ // distribute, sublicense, and/or sell copies of the Software, and to // permit persons to whom the Software is furnished to do so, subject to // the following conditions: -// +// // The above copyright notice and this permission notice shall be // included in all copies or substantial portions of the Software. -// +// // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND @@ -29,11 +29,12 @@ namespace NUnit.Engine.Services { public class ResultService : Service, IResultService { -#if NETSTANDARD1_3 +#if NETSTANDARD1_3 || NETSTANDARD2_0 private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases" }; #else private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases", "user" }; - +#endif +#if !NETSTANDARD1_3 private IEnumerable _extensionNodes; #endif @@ -51,7 +52,7 @@ public string[] Formats foreach (var format in node.GetValues("Format")) formatList.Add(format); #endif - + _formats = formatList.ToArray(); } @@ -73,35 +74,33 @@ public IResultWriter GetResultWriter(string format, object[] args) return new NUnit3XmlResultWriter(); case "cases": return new TestCaseResultWriter(); -#if NETSTANDARD1_3 - default: - return null; -#else +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 case "user": return new XmlTransformResultWriter(args); +#endif default: +#if !NETSTANDARD1_3 foreach (var node in _extensionNodes) foreach (var supported in node.GetValues("Format")) if (supported == format) return node.ExtensionObject as IResultWriter; - - return null; #endif + return null; } } -#if !NETSTANDARD1_3 #region IService Members public override void StartService() { try { +#if !NETSTANDARD1_3 var extensionService = ServiceContext.GetService(); if (extensionService != null && extensionService.Status == ServiceStatus.Started) _extensionNodes = extensionService.GetExtensionNodes(); - +#endif // If there is no extension service, we start anyway using builtin writers Status = ServiceStatus.Started; } @@ -113,6 +112,5 @@ public override void StartService() } #endregion -#endif } } diff --git a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs index 279471ab9..fbeab6e81 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 using System; using System.IO; using System.Text; diff --git a/src/NUnitEngine/nunit.engine/TestEngine.cs b/src/NUnitEngine/nunit.engine/TestEngine.cs index d56f25a9c..6635f9f38 100644 --- a/src/NUnitEngine/nunit.engine/TestEngine.cs +++ b/src/NUnitEngine/nunit.engine/TestEngine.cs @@ -101,7 +101,6 @@ public void Initialize() Services.Add(new SettingsService(true)); Services.Add(new DriverService()); Services.Add(new RecentFilesService()); - Services.Add(new DefaultTestRunnerFactory()); Services.Add(new ResultService()); Services.Add(new TestFilterService()); #if !NETSTANDARD1_3 @@ -113,6 +112,7 @@ public void Initialize() Services.Add(new TestAgency()); #endif #endif + Services.Add(new DefaultTestRunnerFactory()); } Services.ServiceManager.StartServices(); From 40e6da253e0a9589b0cd4c9c91e6c06c38f6e7cd Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Sat, 8 Sep 2018 11:38:30 -0400 Subject: [PATCH 07/29] Update the Cake build --- NUnit.Engine.Netstandard.sln | 58 --------------- build.cake | 73 ++++++------------- src/CommonAssemblyInfo.cs | 18 ++--- src/NUnitEngine/nunit.engine.tests/Program.cs | 11 +-- .../nunit.engine.tests.csproj | 8 +- 5 files changed, 35 insertions(+), 133 deletions(-) delete mode 100644 NUnit.Engine.Netstandard.sln diff --git a/NUnit.Engine.Netstandard.sln b/NUnit.Engine.Netstandard.sln deleted file mode 100644 index b88d2b26f..000000000 --- a/NUnit.Engine.Netstandard.sln +++ /dev/null @@ -1,58 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.26228.10 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{49D441DF-39FD-4F4D-AECA-86CF8EFE23AF}" - ProjectSection(SolutionItems) = preProject - .editorconfig = .editorconfig - .gitattributes = .gitattributes - .gitignore = .gitignore - .travis.yml = .travis.yml - appveyor.yml = appveyor.yml - build.cake = build.cake - BUILDING.md = BUILDING.md - CHANGES.txt = CHANGES.txt - CONTRIBUTING.md = CONTRIBUTING.md - LICENSE.txt = LICENSE.txt - NOTICES.txt = NOTICES.txt - NuGet.config = NuGet.config - nunit.ico = nunit.ico - README.md = README.md - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.engine.tests.netstandard", "src\NUnitEngine\nunit.engine.tests.netstandard\nunit.engine.tests.netstandard.csproj", "{BC22F0E4-0862-4F82-A912-C9A447FECBAD}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "mock-assembly.netstandard", "src\NUnitEngine\mock-assembly.netstandard\mock-assembly.netstandard.csproj", "{BC6C8155-2024-4F58-A006-18A15EA22A5C}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "nunit.engine.netstandard", "src\NUnitEngine\nunit.engine.netstandard\nunit.engine.netstandard.csproj", "{C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC22F0E4-0862-4F82-A912-C9A447FECBAD}.Release|Any CPU.Build.0 = Release|Any CPU - {BC6C8155-2024-4F58-A006-18A15EA22A5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {BC6C8155-2024-4F58-A006-18A15EA22A5C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {BC6C8155-2024-4F58-A006-18A15EA22A5C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {BC6C8155-2024-4F58-A006-18A15EA22A5C}.Release|Any CPU.Build.0 = Release|Any CPU - {C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C26FFC46-60CE-4CBA-87BD-8E9B972C0E0D}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(MonoDevelopProperties) = preSolution - StartupItem = src\NUnitFramework\tests\nunitlite.tests-2.0.csproj - {28B605B2-E2E9-417E-8369-49E263F1F31B} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39} - {FFF45826-991F-465B-8A03-0E1DB7E8F38C} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39} - {11640C9F-03A3-456B-848D-9B4A126F9506} = {31B45C4C-206F-4F31-9CC6-33BF11DFEE39} - EndGlobalSection -EndGlobal diff --git a/build.cake b/build.cake index 1e69191e9..f73aec9a2 100644 --- a/build.cake +++ b/build.cake @@ -129,71 +129,48 @@ Task("Clean") // INITIALIZE FOR BUILD ////////////////////////////////////////////////////////////////////// -Task("InitializeBuild") - .Description("Initializes the build") +Task("NuGetRestore") + .Description("Restores NuGet Packages") .Does(() => { - Information("Restoring NuGet packages"); DotNetCoreRestore(SOLUTION_FILE); - - if(IsRunningOnWindows()) - { - Information("Restoring .NET Core packages"); - DotNetCoreRestore(DOTNETCORE_SOLUTION_FILE); - } }); ////////////////////////////////////////////////////////////////////// -// BUILD ENGINE +// BUILD ENGINE AND CONSOLE ////////////////////////////////////////////////////////////////////// -Task("BuildNetFramework") - .Description("Builds the .NET Framework version of the engine and console") - .IsDependentOn("InitializeBuild") +Task("Build") + .Description("Builds the engine and console runner") + .IsDependentOn("NuGetRestore") .Does(() => { // Use MSBuild - MSBuild(SOLUTION_FILE, new MSBuildSettings() - .SetConfiguration(configuration) - .SetMSBuildPlatform(MSBuildPlatform.Automatic) - .SetVerbosity(Verbosity.Minimal) - .SetPlatformTarget(PlatformTarget.MSIL) - ); + MSBuild(SOLUTION_FILE, CreateSettings()); }); -////////////////////////////////////////////////////////////////////// -// BUILD NETSTANDARD ENGINE -////////////////////////////////////////////////////////////////////// +MSBuildSettings CreateSettings() +{ + var settings = new MSBuildSettings { Verbosity = Verbosity.Minimal, Configuration = configuration }; -Task("BuildNetStandardEngine") - .Description("Builds the .NET Standard engine") - .IsDependentOn("InitializeBuild") - .WithCriteria(IsRunningOnWindows()) - .Does(() => - { - if(IsDotNetCoreInstalled) - { - var settings = new DotNetCoreBuildSettings - { - Configuration = configuration, - EnvironmentVariables = new Dictionary() - }; - settings.EnvironmentVariables.Add("PackageVersion", packageVersion); - DotNetCoreBuild(DOTNETCORE_SOLUTION_FILE, settings); - } - else - { - Warning("Skipping .NET Standard build because .NET Core is not installed"); - } - }); + // Only needed when packaging + settings.WithProperty("DebugType", "pdbonly"); + + if (IsRunningOnWindows()) + settings.ToolVersion = MSBuildToolVersion.VS2017; + else + settings.ToolPath = Context.Tools.Resolve("msbuild"); + + return settings; +} ////////////////////////////////////////////////////////////////////// -// BUILD C++ TESTS +// BUILD C++ TESTS ////////////////////////////////////////////////////////////////////// Task("BuildCppTestFiles") .Description("Builds the C++ mock test assemblies") - .IsDependentOn("InitializeBuild") + .IsDependentOn("NuGetRestore") .WithCriteria(IsRunningOnWindows) .Does(() => { @@ -251,7 +228,6 @@ Task("TestConsole") Task("TestNetStandardEngine") .Description("Tests the .NET Standard Engine") - .IsDependentOn("BuildNetStandardEngine") .WithCriteria(IsRunningOnWindows()) .OnError(exception => { ErrorDetail.Add(exception.Message); }) .Does(() => @@ -608,11 +584,6 @@ public void CopyPackageContents(DirectoryPath packageDir, DirectoryPath outDir) // TASK TARGETS ////////////////////////////////////////////////////////////////////// -Task("Build") - .Description("Builds the engine and console runner") - .IsDependentOn("BuildNetFramework") - .IsDependentOn("BuildNetStandardEngine"); - Task("Rebuild") .Description("Rebuilds the engine and console runner") .IsDependentOn("Clean") diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index d5a893d89..df406674d 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -32,14 +32,10 @@ [assembly: AssemblyCopyright("Copyright (c) 2018 Charlie Poole, Rob Prouse")] #if DEBUG -#if NET_4_5 -[assembly: AssemblyConfiguration(".NET 4.5 Debug")] -#elif NET_4_0 -[assembly: AssemblyConfiguration(".NET 4.0 Debug")] -#elif NET_2_0 +#if NET35 +[assembly: AssemblyConfiguration(".NET 3.5 Debug")] +#elif NET20 [assembly: AssemblyConfiguration(".NET 2.0 Debug")] -#elif PORTABLE -[assembly: AssemblyConfiguration("Portable Debug")] #elif NETSTANDARD1_3 || NETCOREAPP1_0 [assembly: AssemblyConfiguration(".NET Standard 1.3 Debug")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 @@ -48,11 +44,9 @@ [assembly: AssemblyConfiguration("Debug")] #endif #else -#if NET_4_5 -[assembly: AssemblyConfiguration(".NET 4.5")] -#elif NET_4_0 -[assembly: AssemblyConfiguration(".NET 4.0")] -#elif NET_2_0 +#if NET35 +[assembly: AssemblyConfiguration(".NET 3.5")] +#elif NET20 [assembly: AssemblyConfiguration(".NET 2.0")] #elif PORTABLE [assembly: AssemblyConfiguration("Portable")] diff --git a/src/NUnitEngine/nunit.engine.tests/Program.cs b/src/NUnitEngine/nunit.engine.tests/Program.cs index 2466b2482..5b93bce97 100644 --- a/src/NUnitEngine/nunit.engine.tests/Program.cs +++ b/src/NUnitEngine/nunit.engine.tests/Program.cs @@ -1,7 +1,6 @@ -//#if !NET35 -using NUnitLite; -using System; +#if !NET35 using System.Reflection; +using NUnitLite; namespace NUnit.Engine.Tests { @@ -9,12 +8,8 @@ class Program { static int Main(string[] args) { -#if !NET35 return new TextRunner(typeof(Program).GetTypeInfo().Assembly).Execute(args); -#else - return new TextRunner(typeof(Program).Assembly).Execute(args); -#endif } } } -//#endif \ No newline at end of file +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj index a1bfc1667..782cd7bbb 100644 --- a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj +++ b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj @@ -3,8 +3,8 @@ NUnit.Engine.Tests nunit.engine.tests net35;netcoreapp1.1;netcoreapp2.0 - - Exe + Exe + false ..\..\..\bin\$(Configuration)\ true @@ -18,13 +18,13 @@ - + + - From 10c247ca264240e9eaca3105a1ad70f842405279 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Fri, 14 Sep 2018 23:53:57 +0100 Subject: [PATCH 08/29] Run .NET Standard 1.3 and 2.0 tests --- build.cake | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/build.cake b/build.cake index d6076d36c..423887b09 100644 --- a/build.cake +++ b/build.cake @@ -27,7 +27,10 @@ var productVersion = version + modifier + dbgSuffix; var PROJECT_DIR = Context.Environment.WorkingDirectory.FullPath + "/"; var PACKAGE_DIR = PROJECT_DIR + "package/"; -var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/net35/"; +var BIN_DIR = PROJECT_DIR + "bin/" + configuration + "/"; +var NET35_BIN_DIR = BIN_DIR + "net35/"; +var NETCOREAPP11_BIN_DIR = BIN_DIR + "netcoreapp1.1/"; +var NETCOREAPP20_BIN_DIR = BIN_DIR + "netcoreapp2.0/"; var CHOCO_DIR = PROJECT_DIR + "choco/"; var TOOLS_DIR = PROJECT_DIR + "tools/"; var IMAGE_DIR = PROJECT_DIR + "images/"; @@ -41,12 +44,11 @@ var SOLUTION_FILE = "NUnitConsole.sln"; var DOTNETCORE_SOLUTION_FILE = "NUnit.Engine.NetStandard.sln"; // Test Runner -var NUNIT3_CONSOLE = BIN_DIR + "nunit3-console.exe"; +var NET20_CONSOLE = BIN_DIR + "net20/" + "nunit3-console.exe"; // Test Assemblies var ENGINE_TESTS = "nunit.engine.tests.dll"; var CONSOLE_TESTS = "nunit3-console.tests.dll"; -var DOTNETCORE_TEST_ASSEMBLY = "src/NUnitEngine/nunit.engine.tests.netstandard/bin/" + configuration + "/netcoreapp1.1/nunit.engine.tests.netstandard.dll"; // Package sources for nuget restore var PACKAGE_SOURCE = new string[] @@ -190,26 +192,26 @@ Task("CheckForError") // TEST ENGINE ////////////////////////////////////////////////////////////////////// -Task("TestEngine") +Task("TestNet20Engine") .Description("Tests the engine") .IsDependentOn("Build") .OnError(exception => { ErrorDetail.Add(exception.Message); }) .Does(() => { - RunTest(NUNIT3_CONSOLE, BIN_DIR, ENGINE_TESTS, "TestEngine", ref ErrorDetail); + RunTest(NET20_CONSOLE, NET35_BIN_DIR, ENGINE_TESTS, "TestEngine", ref ErrorDetail); }); ////////////////////////////////////////////////////////////////////// // TEST CONSOLE ////////////////////////////////////////////////////////////////////// -Task("TestConsole") +Task("TestNet20Console") .Description("Tests the console runner") .IsDependentOn("Build") .OnError(exception => { ErrorDetail.Add(exception.Message); }) .Does(() => { - RunTest(NUNIT3_CONSOLE, BIN_DIR, CONSOLE_TESTS, "TestConsole", ref ErrorDetail); + RunTest(NET20_CONSOLE, NET35_BIN_DIR, CONSOLE_TESTS, "TestConsole", ref ErrorDetail); }); ////////////////////////////////////////////////////////////////////// @@ -224,7 +226,8 @@ Task("TestNetStandardEngine") { if(IsDotNetCoreInstalled) { - DotNetCoreExecute(DOTNETCORE_TEST_ASSEMBLY); + DotNetCoreExecute(NETCOREAPP11_BIN_DIR + ENGINE_TESTS); + DotNetCoreExecute(NETCOREAPP20_BIN_DIR + ENGINE_TESTS); } else { @@ -285,10 +288,10 @@ Task("CreateImage") foreach(FilePath file in BinFiles) { - if (FileExists(BIN_DIR + file)) + if (FileExists(NET35_BIN_DIR + file)) { CreateDirectory(CURRENT_IMG_BIN_DIR + file.GetDirectory()); - CopyFile(BIN_DIR + file, CURRENT_IMG_BIN_DIR + file); + CopyFile(NET35_BIN_DIR + file, CURRENT_IMG_BIN_DIR + file); } } }); @@ -366,18 +369,18 @@ Task("PackageChocolatey") new ChocolateyNuSpecContent { Source = PROJECT_DIR + "CHANGES.txt", Target = "tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "VERIFICATION.txt", Target = "tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "nunit.choco.addins", Target = "tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit-agent.exe", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit-agent.exe.config", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent.exe", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent.exe.config", Target="tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "nunit-agent.exe.ignore", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit-agent-x86.exe", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit-agent-x86.exe.config", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent-x86.exe", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent-x86.exe.config", Target="tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "nunit-agent-x86.exe.ignore", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit3-console.exe", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit3-console.exe.config", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit.engine.api.dll", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit.engine.api.xml", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "nunit.engine.dll", Target="tools" }, - new ChocolateyNuSpecContent { Source = BIN_DIR + "Mono.Cecil.dll", Target="tools" } + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit3-console.exe", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit3-console.exe.config", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit.engine.api.dll", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit.engine.api.xml", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit.engine.dll", Target="tools" }, + new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "Mono.Cecil.dll", Target="tools" } } }); @@ -581,8 +584,8 @@ Task("Rebuild") Task("Test") .Description("Builds and tests the engine and console runner") - .IsDependentOn("TestEngine") - .IsDependentOn("TestConsole") + .IsDependentOn("TestNet20Engine") + .IsDependentOn("TestNet20Console") .IsDependentOn("TestNetStandardEngine"); Task("Package") From bb2305cf0ea1c7c43383215144db69341daade0c Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 00:07:00 +0100 Subject: [PATCH 09/29] Get .NET Standard 1.3 Engine tests passing --- build.cake | 1 + .../Runners/DirectTestRunnerTests.cs | 52 +++++++++---------- .../Services/DefaultTestRunnerFactoryTests.cs | 12 ++++- .../Services/ServiceDependencyTests.cs | 2 + .../nunit.engine/Runners/DirectTestRunner.cs | 4 -- .../Services/DefaultTestRunnerFactory.cs | 2 + 6 files changed, 41 insertions(+), 32 deletions(-) diff --git a/build.cake b/build.cake index 423887b09..0dcb6cc79 100644 --- a/build.cake +++ b/build.cake @@ -220,6 +220,7 @@ Task("TestNet20Console") Task("TestNetStandardEngine") .Description("Tests the .NET Standard Engine") + .IsDependentOn("Build") .WithCriteria(IsRunningOnWindows()) .OnError(exception => { ErrorDetail.Add(exception.Message); }) .Does(() => diff --git a/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs b/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs index 8b3273033..68bd1bb68 100644 --- a/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Runners/DirectTestRunnerTests.cs @@ -33,14 +33,14 @@ namespace NUnit.Engine.Tests.Runners { public class DirectTestRunnerTests { - private IFrameworkDriver driver; - private EmptyDirectTestRunner directTestRunner; - private TestFilter testFilter = new TestFilter(string.Empty); + private IFrameworkDriver _driver; + private EmptyDirectTestRunner _directTestRunner; + private readonly TestFilter _testFilter = new TestFilter(string.Empty); [SetUp] public void Initialize() { - driver = Substitute.For(); + _driver = Substitute.For(); var driverService = Substitute.For(); driverService.GetDriver( @@ -49,27 +49,27 @@ public void Initialize() string.Empty, #endif string.Empty, - false).ReturnsForAnyArgs(driver); + false).ReturnsForAnyArgs(_driver); var serviceLocator = Substitute.For(); serviceLocator.GetService().Returns(driverService); - directTestRunner = new EmptyDirectTestRunner(serviceLocator, new TestPackage("mock-assembly.dll")); + _directTestRunner = new EmptyDirectTestRunner(serviceLocator, new TestPackage("mock-assembly.dll")); } [Test] public void Explore_Passes_Along_NUnitEngineException() { - driver.Explore(Arg.Any()).Throws(new NUnitEngineException("Message")); - var ex = Assert.Throws(() => directTestRunner.Explore(new TestFilter(string.Empty))); + _driver.Explore(Arg.Any()).Throws(new NUnitEngineException("Message")); + var ex = Assert.Throws(() => _directTestRunner.Explore(new TestFilter(string.Empty))); Assert.That(ex.Message, Is.EqualTo("Message")); } [Test] public void Explore_Throws_NUnitEngineException() { - driver.Explore(Arg.Any()).Throws(new ArgumentException("Message")); - var ex = Assert.Throws(() => directTestRunner.Explore(new TestFilter(string.Empty))); + _driver.Explore(Arg.Any()).Throws(new ArgumentException("Message")); + var ex = Assert.Throws(() => _directTestRunner.Explore(new TestFilter(string.Empty))); Assert.That(ex.InnerException is ArgumentException); Assert.That(ex.InnerException.Message, Is.EqualTo("Message")); } @@ -77,16 +77,16 @@ public void Explore_Throws_NUnitEngineException() [Test] public void Load_Passes_Along_NUnitEngineException() { - driver.Load(Arg.Any(), Arg.Any>()).Throws(new NUnitEngineException("Message")); - var ex = Assert.Throws(() => directTestRunner.Load()); + _driver.Load(Arg.Any(), Arg.Any>()).Throws(new NUnitEngineException("Message")); + var ex = Assert.Throws(() => _directTestRunner.Load()); Assert.That(ex.Message, Is.EqualTo("Message")); } [Test] public void Load_Throws_NUnitEngineException() { - driver.Load(Arg.Any(), Arg.Any>()).Throws(new ArgumentException("Message")); - var ex = Assert.Throws(() => directTestRunner.Load()); + _driver.Load(Arg.Any(), Arg.Any>()).Throws(new ArgumentException("Message")); + var ex = Assert.Throws(() => _directTestRunner.Load()); Assert.That(ex.InnerException is ArgumentException); Assert.That(ex.InnerException.Message, Is.EqualTo("Message")); } @@ -94,16 +94,16 @@ public void Load_Throws_NUnitEngineException() [Test] public void CountTestCases_Passes_Along_NUnitEngineException() { - driver.CountTestCases(Arg.Any()).Throws(new NUnitEngineException("Message")); - var ex = Assert.Throws(() => directTestRunner.CountTestCases(testFilter)); + _driver.CountTestCases(Arg.Any()).Throws(new NUnitEngineException("Message")); + var ex = Assert.Throws(() => _directTestRunner.CountTestCases(_testFilter)); Assert.That(ex.Message, Is.EqualTo("Message")); } [Test] public void CountTestCases_Throws_NUnitEngineException() { - driver.CountTestCases(Arg.Any()).Throws(new ArgumentException("Message")); - var ex = Assert.Throws(() => directTestRunner.CountTestCases(testFilter)); + _driver.CountTestCases(Arg.Any()).Throws(new ArgumentException("Message")); + var ex = Assert.Throws(() => _directTestRunner.CountTestCases(_testFilter)); Assert.That(ex.InnerException is ArgumentException); Assert.That(ex.InnerException.Message, Is.EqualTo("Message")); } @@ -111,16 +111,16 @@ public void CountTestCases_Throws_NUnitEngineException() [Test] public void Run_Passes_Along_NUnitEngineException() { - driver.Run(Arg.Any(), Arg.Any()).Throws(new NUnitEngineException("Message")); - var ex = Assert.Throws(() => directTestRunner.Run(Substitute.For(), testFilter)); + _driver.Run(Arg.Any(), Arg.Any()).Throws(new NUnitEngineException("Message")); + var ex = Assert.Throws(() => _directTestRunner.Run(Substitute.For(), _testFilter)); Assert.That(ex.Message, Is.EqualTo("Message")); } [Test] public void Run_Throws_NUnitEngineException() { - driver.Run(Arg.Any(), Arg.Any()).Throws(new ArgumentException("Message")); - var ex = Assert.Throws(() => directTestRunner.Run(Substitute.For(), testFilter)); + _driver.Run(Arg.Any(), Arg.Any()).Throws(new ArgumentException("Message")); + var ex = Assert.Throws(() => _directTestRunner.Run(Substitute.For(), _testFilter)); Assert.That(ex.InnerException is ArgumentException); Assert.That(ex.InnerException.Message, Is.EqualTo("Message")); } @@ -128,20 +128,20 @@ public void Run_Throws_NUnitEngineException() [Test] public void StopRun_Passes_Along_NUnitEngineException() { - driver.When(x => x.StopRun(Arg.Any())) + _driver.When(x => x.StopRun(Arg.Any())) .Do(x => { throw new NUnitEngineException("Message"); }); - var ex = Assert.Throws(() => directTestRunner.StopRun(true)); + var ex = Assert.Throws(() => _directTestRunner.StopRun(true)); Assert.That(ex.Message, Is.EqualTo("Message")); } [Test] public void StopRun_Throws_NUnitEngineException() { - driver.When(x => x.StopRun(Arg.Any())) + _driver.When(x => x.StopRun(Arg.Any())) .Do(x => { throw new ArgumentException("Message"); }); - var ex = Assert.Throws(() => directTestRunner.StopRun(true)); + var ex = Assert.Throws(() => _directTestRunner.StopRun(true)); Assert.That(ex.InnerException is ArgumentException); Assert.That(ex.InnerException.Message, Is.EqualTo("Message")); } diff --git a/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs index 8c9e368a7..f112790a5 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/DefaultTestRunnerFactoryTests.cs @@ -42,8 +42,8 @@ public void CreateServiceContext() _services = new ServiceContext(); #if !NETCOREAPP1_1 _services.Add(new ExtensionService()); -#endif _services.Add(new FakeProjectService()); +#endif _factory = new DefaultTestRunnerFactory(); _services.Add(_factory); _services.ServiceManager.StartServices(); @@ -55,7 +55,14 @@ public void ServiceIsStarted() Assert.That(_factory.Status, Is.EqualTo(ServiceStatus.Started)); } -#if NETCOREAPP1_1 || NETCOREAPP2_0 +#if NETCOREAPP1_1 + // Single file + [TestCase("x.dll", null, typeof(LocalTestRunner))] + // Two files + [TestCase("x.dll y.dll", null, typeof(AggregatingTestRunner))] + // Three files + [TestCase("x.dll y.dll z.dll", null, typeof(AggregatingTestRunner))] +#elif NETCOREAPP2_0 // Single file [TestCase("x.nunit", null, typeof(AggregatingTestRunner))] [TestCase("x.dll", null, typeof(LocalTestRunner))] @@ -66,6 +73,7 @@ public void ServiceIsStarted() // Three files [TestCase("x.nunit y.dll z.nunit", null, typeof(AggregatingTestRunner))] [TestCase("x.dll y.nunit z.dll", null, typeof(AggregatingTestRunner))] + #else // Single file [TestCase("x.nunit", null, typeof(AggregatingTestRunner))] diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ServiceDependencyTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ServiceDependencyTests.cs index f4ce0dcdf..de44f1389 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ServiceDependencyTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ServiceDependencyTests.cs @@ -73,6 +73,7 @@ public void DefaultTestRunnerFactory_ProjectServiceError() Assert.That(service.Status, Is.EqualTo(ServiceStatus.Error)); } +#if !NETCOREAPP1_1 [Test] public void DefaultTestRunnerFactory_ProjectServiceMissing() { @@ -81,5 +82,6 @@ public void DefaultTestRunnerFactory_ProjectServiceMissing() service.StartService(); Assert.That(service.Status, Is.EqualTo(ServiceStatus.Error)); } +#endif } } diff --git a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs index 6a86c49db..12a4932d3 100644 --- a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs @@ -136,11 +136,7 @@ protected override TestEngineResult LoadPackage() private IDriverService GetDriverService() { -#if NETSTANDARD1_3 - return new Services.DriverService(); -#else return Services.GetService(); -#endif } private static string LoadDriver(IFrameworkDriver driver, string testFile, TestPackage subPackage) diff --git a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs index 9d8172935..d5c8a983a 100644 --- a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs @@ -49,6 +49,8 @@ public override void StartService() Status = _projectService != null && ((IService)_projectService).Status == ServiceStatus.Started ? ServiceStatus.Started : ServiceStatus.Error; +#else + Status = ServiceStatus.Started; #endif } From b9430cce90703b2ac120b50eb06f8e686de40d69 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 01:08:21 +0100 Subject: [PATCH 10/29] Create multi-platform image and fix existing .NET 2.0 packaging --- build.cake | 92 +++++++++++-------- msi/nunit/addin-files.wxi | 14 +-- msi/nunit/console-files.wxi | 4 +- msi/nunit/engine-files.wxi | 16 ++-- nuget/engine/nunit.engine.api.nuspec | 2 +- nuget/engine/nunit.engine.nuspec | 16 ++-- nuget/runners/nunit.console-runner.nuspec | 20 ++-- nuget/runners/nunit.runners.nuspec | 7 +- .../nunit.engine/nunit.engine.csproj | 2 +- 9 files changed, 92 insertions(+), 81 deletions(-) diff --git a/build.cake b/build.cake index 0dcb6cc79..67bcfeefc 100644 --- a/build.cake +++ b/build.cake @@ -36,7 +36,9 @@ var TOOLS_DIR = PROJECT_DIR + "tools/"; var IMAGE_DIR = PROJECT_DIR + "images/"; var MSI_DIR = PROJECT_DIR + "msi/"; var CURRENT_IMG_DIR = IMAGE_DIR + $"NUnit-{productVersion}/"; -var CURRENT_IMG_BIN_DIR = CURRENT_IMG_DIR + "bin/"; +var CURRENT_IMG_NET20_BIN_DIR = CURRENT_IMG_DIR + "bin/net20/"; +var CURRENT_IMG_NETSTANDARD13_BIN_DIR = CURRENT_IMG_DIR + "bin/netstandard1.3/"; +var CURRENT_IMG_NETSTANDARD20_BIN_DIR = CURRENT_IMG_DIR + "bin/netstandard2.0/"; var EXTENSION_PACKAGES_DIR = PROJECT_DIR + "extension-packages/"; var ZIP_IMG = PROJECT_DIR + "zip-image/"; @@ -284,15 +286,39 @@ Task("CreateImage") CopyFiles(RootFiles, CURRENT_IMG_DIR); - CreateDirectory(CURRENT_IMG_BIN_DIR); - Information("Created directory " + CURRENT_IMG_BIN_DIR); + CreateDirectory(CURRENT_IMG_NET20_BIN_DIR); + Information("Created directory " + CURRENT_IMG_NET20_BIN_DIR); foreach(FilePath file in BinFiles) { - if (FileExists(NET35_BIN_DIR + file)) - { - CreateDirectory(CURRENT_IMG_BIN_DIR + file.GetDirectory()); - CopyFile(NET35_BIN_DIR + file, CURRENT_IMG_BIN_DIR + file); + if (FileExists(NET35_BIN_DIR + file)) + { + CreateDirectory(CURRENT_IMG_NET20_BIN_DIR + file.GetDirectory()); + CopyFile(NET35_BIN_DIR + file, CURRENT_IMG_NET20_BIN_DIR + file); + } + } + + CreateDirectory(CURRENT_IMG_NETSTANDARD13_BIN_DIR); + Information("Created directory " + CURRENT_IMG_NETSTANDARD13_BIN_DIR); + + foreach(FilePath file in BinFiles) + { + if (FileExists(NETCOREAPP11_BIN_DIR + file)) + { + CreateDirectory(CURRENT_IMG_NETSTANDARD13_BIN_DIR + file.GetDirectory()); + CopyFile(NETCOREAPP11_BIN_DIR + file, CURRENT_IMG_NETSTANDARD13_BIN_DIR + file); + } + } + + CreateDirectory(CURRENT_IMG_NETSTANDARD20_BIN_DIR); + Information("Created directory " + CURRENT_IMG_NETSTANDARD20_BIN_DIR); + + foreach(FilePath file in BinFiles) + { + if (FileExists(NETCOREAPP20_BIN_DIR + file)) + { + CreateDirectory(CURRENT_IMG_NETSTANDARD20_BIN_DIR + file.GetDirectory()); + CopyFile(NETCOREAPP20_BIN_DIR + file, CURRENT_IMG_NETSTANDARD20_BIN_DIR + file); } } }); @@ -365,23 +391,23 @@ Task("PackageChocolatey") Version = productVersion, OutputDirectory = PACKAGE_DIR, Files = new [] { - new ChocolateyNuSpecContent { Source = PROJECT_DIR + "LICENSE.txt", Target = "tools" }, - new ChocolateyNuSpecContent { Source = PROJECT_DIR + "NOTICES.txt", Target = "tools" }, - new ChocolateyNuSpecContent { Source = PROJECT_DIR + "CHANGES.txt", Target = "tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_DIR + "LICENSE.txt", Target = "tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_DIR + "NOTICES.txt", Target = "tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_DIR + "CHANGES.txt", Target = "tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "VERIFICATION.txt", Target = "tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "nunit.choco.addins", Target = "tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent.exe", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent.exe.config", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit-agent.exe", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit-agent.exe.config", Target="tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "nunit-agent.exe.ignore", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent-x86.exe", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit-agent-x86.exe.config", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit-agent-x86.exe", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit-agent-x86.exe.config", Target="tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "nunit-agent-x86.exe.ignore", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit3-console.exe", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit3-console.exe.config", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit.engine.api.dll", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit.engine.api.xml", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "nunit.engine.dll", Target="tools" }, - new ChocolateyNuSpecContent { Source = NET35_BIN_DIR + "Mono.Cecil.dll", Target="tools" } + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit3-console.exe", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit3-console.exe.config", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit.engine.api.dll", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit.engine.api.xml", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "nunit.engine.dll", Target="tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_NET20_BIN_DIR + "Mono.Cecil.dll", Target="tools" } } }); @@ -391,8 +417,8 @@ Task("PackageChocolatey") Version = productVersion, OutputDirectory = PACKAGE_DIR, Files = new [] { - new ChocolateyNuSpecContent { Source = PROJECT_DIR + "LICENSE.txt", Target = "tools" }, - new ChocolateyNuSpecContent { Source = PROJECT_DIR + "NOTICES.txt", Target = "tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_DIR + "LICENSE.txt", Target = "tools" }, + new ChocolateyNuSpecContent { Source = CURRENT_IMG_DIR + "NOTICES.txt", Target = "tools" }, new ChocolateyNuSpecContent { Source = CHOCO_DIR + "VERIFICATION.txt", Target = "tools" } } }); @@ -438,7 +464,7 @@ Task("CreateCombinedImage") .IsDependentOn("FetchExtensions") .Does(() => { - var addinsImgDir = CURRENT_IMG_BIN_DIR + "addins/"; + var addinsImgDir = CURRENT_IMG_NET20_BIN_DIR + "addins/"; CopyDirectory(MSI_DIR + "resources/", CURRENT_IMG_DIR); CleanDirectory(addinsImgDir); @@ -468,15 +494,13 @@ Task("PackageZip") .Does(() => { CleanDirectory(ZIP_IMG); - - //Flatten for zip CopyDirectory(CURRENT_IMG_DIR, ZIP_IMG); - CopyDirectory(ZIP_IMG + "bin/", ZIP_IMG); - DeleteDirectory(ZIP_IMG + "bin/", new DeleteDirectorySettings { Recursive = true }); - //Ensure single and correct addins file + //Ensure single and correct addins file (.NET Framework only) + var net20ZipImg = ZIP_IMG + "bin/net20/"; DeleteFiles(ZIP_IMG + "*.addins"); - CopyFile(CURRENT_IMG_DIR + "nunit.bundle.addins", ZIP_IMG + "nunit.bundle.addins"); + DeleteFiles(net20ZipImg + "*.addins"); + CopyFile(CURRENT_IMG_DIR + "nunit.bundle.addins", net20ZipImg + "nunit.bundle.addins"); var zipPath = string.Format("{0}NUnit.Console-{1}.zip", PACKAGE_DIR, version); Zip(ZIP_IMG, zipPath); @@ -504,14 +528,6 @@ bool CheckIfDotNetCoreInstalled() return true; } -void RunGitCommand(string arguments) -{ - StartProcess("git", new ProcessSettings() - { - Arguments = arguments - }); -} - void CheckForError(ref List errorDetail) { if(errorDetail.Count != 0) @@ -595,7 +611,7 @@ Task("Package") .IsDependentOn("PackageEngine") .IsDependentOn("PackageConsole") .IsDependentOn("PackageNetStandardEngine") - .IsDependentOn("PackageChocolatey") + .IsDependentOn("PackageChocolatey") .IsDependentOn("PackageMsi") .IsDependentOn("PackageZip"); diff --git a/msi/nunit/addin-files.wxi b/msi/nunit/addin-files.wxi index 5a925f32e..549fdf165 100644 --- a/msi/nunit/addin-files.wxi +++ b/msi/nunit/addin-files.wxi @@ -4,43 +4,43 @@ + Source="$(var.InstallImage)bin/net20/addins/nunit-project-loader.dll" /> + Source="$(var.InstallImage)bin/net20/addins/vs-project-loader.dll" /> + Source="$(var.InstallImage)bin/net20/addins/nunit-v2-result-writer.dll" /> + Source="$(var.InstallImage)bin/net20/addins/teamcity-event-listener.dll" /> + Source="$(var.InstallImage)bin/net20/addins/nunit.v2.driver.dll" /> + Source="$(var.InstallImage)bin/net20/addins/nunit.core.dll" /> + Source="$(var.InstallImage)bin/net20/addins/nunit.core.interfaces.dll" /> diff --git a/msi/nunit/console-files.wxi b/msi/nunit/console-files.wxi index 6e772ff1b..061f28c17 100644 --- a/msi/nunit/console-files.wxi +++ b/msi/nunit/console-files.wxi @@ -5,9 +5,9 @@ + Source="$(var.InstallImage)bin/net20/nunit3-console.exe" /> + Source="$(var.InstallImage)bin/net20/nunit3-console.exe.config" /> diff --git a/msi/nunit/engine-files.wxi b/msi/nunit/engine-files.wxi index f60bdbc01..42d936e35 100644 --- a/msi/nunit/engine-files.wxi +++ b/msi/nunit/engine-files.wxi @@ -5,7 +5,7 @@ + Source="$(var.InstallImage)bin/net20/nunit.engine.dll" /> + Source="$(var.InstallImage)bin/net20/nunit.engine.api.dll" /> + Source="$(var.InstallImage)bin/net20/nunit.engine.api.xml" /> + Source="$(var.InstallImage)bin/net20/nunit-agent.exe" /> + Source="$(var.InstallImage)bin/net20/nunit-agent.exe.config" /> + Source="$(var.InstallImage)bin/net20/nunit-agent-x86.exe" /> + Source="$(var.InstallImage)bin/net20/nunit-agent-x86.exe.config" /> + Source="$(var.InstallImage)bin/net20/Mono.Cecil.dll" /> diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index 759aa7749..54d5ce21e 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -20,6 +20,6 @@ - + \ No newline at end of file diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index 4f7d5e042..a19fc2871 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -22,13 +22,13 @@ - - - - - - - - + + + + + + + + \ No newline at end of file diff --git a/nuget/runners/nunit.console-runner.nuspec b/nuget/runners/nunit.console-runner.nuspec index aec511715..23c560908 100644 --- a/nuget/runners/nunit.console-runner.nuspec +++ b/nuget/runners/nunit.console-runner.nuspec @@ -26,16 +26,16 @@ - - - - - - - - - - + + + + + + + + + + diff --git a/nuget/runners/nunit.runners.nuspec b/nuget/runners/nunit.runners.nuspec index f01204db1..5dff6e9c7 100644 --- a/nuget/runners/nunit.runners.nuspec +++ b/nuget/runners/nunit.runners.nuspec @@ -32,12 +32,7 @@ Copyright (c) 2018 Charlie Poole - - - - - - + diff --git a/src/NUnitEngine/nunit.engine/nunit.engine.csproj b/src/NUnitEngine/nunit.engine/nunit.engine.csproj index 794fd5e84..88de4c892 100644 --- a/src/NUnitEngine/nunit.engine/nunit.engine.csproj +++ b/src/NUnitEngine/nunit.engine/nunit.engine.csproj @@ -31,7 +31,7 @@ - + PreserveNewest From cb738a9c243279047bcbc406e155649fe2817916 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 13:18:27 +0100 Subject: [PATCH 11/29] Add extra level of redirection --- nuget/engine/nunit.nuget.addins | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nuget/engine/nunit.nuget.addins b/nuget/engine/nunit.nuget.addins index 6dee52be6..64c3e8a74 100644 --- a/nuget/engine/nunit.nuget.addins +++ b/nuget/engine/nunit.nuget.addins @@ -1,2 +1,2 @@ -../../NUnit.Extension.*/**/tools/ # nuget v2 layout -../../../NUnit.Extension.*/**/tools/ # nuget v3 layout +../../../NUnit.Extension.*/**/tools/ # nuget v2 layout +../../../../NUnit.Extension.*/**/tools/ # nuget v3 layout From 2ff720c9ed89f32feb766017eaa68d916fc52afc Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 13:48:03 +0100 Subject: [PATCH 12/29] Add packaging for all platforms --- build.cake | 164 +++++++++------------------ nuget/engine/nunit.engine.api.nuspec | 4 +- nuget/engine/nunit.engine.nuspec | 8 +- 3 files changed, 62 insertions(+), 114 deletions(-) diff --git a/build.cake b/build.cake index 67bcfeefc..1f554cdda 100644 --- a/build.cake +++ b/build.cake @@ -37,13 +37,17 @@ var IMAGE_DIR = PROJECT_DIR + "images/"; var MSI_DIR = PROJECT_DIR + "msi/"; var CURRENT_IMG_DIR = IMAGE_DIR + $"NUnit-{productVersion}/"; var CURRENT_IMG_NET20_BIN_DIR = CURRENT_IMG_DIR + "bin/net20/"; -var CURRENT_IMG_NETSTANDARD13_BIN_DIR = CURRENT_IMG_DIR + "bin/netstandard1.3/"; -var CURRENT_IMG_NETSTANDARD20_BIN_DIR = CURRENT_IMG_DIR + "bin/netstandard2.0/"; var EXTENSION_PACKAGES_DIR = PROJECT_DIR + "extension-packages/"; var ZIP_IMG = PROJECT_DIR + "zip-image/"; -var SOLUTION_FILE = "NUnitConsole.sln"; -var DOTNETCORE_SOLUTION_FILE = "NUnit.Engine.NetStandard.sln"; +var SOLUTION_FILE = PROJECT_DIR + "NUnitConsole.sln"; +var ENGINE_CSPROJ = PROJECT_DIR + "src/NunitEngine/nunit.engine/nunit.engine.csproj"; +var ENGINE_API_CSPROJ = PROJECT_DIR + "src/NunitEngine/nunit.engine.api/nunit.engine.api.csproj"; +var ENGINE_TESTS_CSPROJ = PROJECT_DIR + "src/NunitEngine/nunit.engine.tests/nunit.engine.tests.csproj"; + +var NETFX_FRAMEWORKS = new [] { "net20", "net35" }; //Production code targets net20, tests target nets35 +var NETSTANDARD_FRAMEWORKS = new [] { "netstandard1.3", "netstandard2.0" }; +var NETCORE_FRAMEWORKS = new [] { "netcoreapp1.1", "netcoreapp2.0" }; // Test Runner var NET20_CONSOLE = BIN_DIR + "net20/" + "nunit3-console.exe"; @@ -162,6 +166,30 @@ Task("Build") .Does(() => { MSBuild(SOLUTION_FILE, CreateMSBuildSettings("Build").WithRestore()); + + Information("Publishing netstandard engine so that dependencies are present..."); + + foreach(var framework in NETSTANDARD_FRAMEWORKS) + MSBuild(ENGINE_CSPROJ, CreateMSBuildSettings("Publish") + .WithProperty("TargetFramework", framework) + .WithProperty("NoBuild", "true") // https://github.com/dotnet/cli/issues/5331#issuecomment-338392972 + .WithProperty("PublishDir", BIN_DIR + framework)); + + Information("Publishing netstandard engine api so that dependencies are present..."); + + foreach(var framework in NETSTANDARD_FRAMEWORKS) + MSBuild(ENGINE_API_CSPROJ, CreateMSBuildSettings("Publish") + .WithProperty("TargetFramework", framework) + .WithProperty("NoBuild", "true") // https://github.com/dotnet/cli/issues/5331#issuecomment-338392972 + .WithProperty("PublishDir", BIN_DIR + framework)); + + Information("Publishing netcoreapp tests so that dependencies are present..."); + + foreach(var framework in NETCORE_FRAMEWORKS) + MSBuild(ENGINE_TESTS_CSPROJ, CreateMSBuildSettings("Publish") + .WithProperty("TargetFramework", framework) + .WithProperty("NoBuild", "true") // https://github.com/dotnet/cli/issues/5331#issuecomment-338392972 + .WithProperty("PublishDir", BIN_DIR + framework)); }); ////////////////////////////////////////////////////////////////////// @@ -250,81 +278,17 @@ var RootFiles = new FilePath[] "nunit.ico" }; -var BinFiles = new FilePath[] -{ - "ConsoleTests.nunit", - "EngineTests.nunit", - "mock-assembly.dll", - "notest-assembly.dll", - "Mono.Cecil.dll", - "nunit-agent-x86.exe", - "nunit-agent-x86.exe.config", - "nunit-agent.exe", - "nunit-agent.exe.config", - "nunit.engine.addins", - "nunit.engine.api.dll", - "nunit.engine.api.xml", - "nunit.engine.dll", - "nunit.engine.tests.dll", - "nunit.engine.tests.dll.config", - "nunit.framework.dll", - "nunit.framework.xml", - "NUnit.System.Linq.dll", - "NUnit2TestResult.xsd", - "nunit3-console.exe", - "nunit3-console.exe.config", - "nunit3-console.tests.dll", - "TestListWithEmptyLine.tst", - "TextSummary.xslt", -}; - Task("CreateImage") .Description("Copies all files into the image directory") .Does(() => { CleanDirectory(CURRENT_IMG_DIR); - CopyFiles(RootFiles, CURRENT_IMG_DIR); - - CreateDirectory(CURRENT_IMG_NET20_BIN_DIR); - Information("Created directory " + CURRENT_IMG_NET20_BIN_DIR); - - foreach(FilePath file in BinFiles) - { - if (FileExists(NET35_BIN_DIR + file)) - { - CreateDirectory(CURRENT_IMG_NET20_BIN_DIR + file.GetDirectory()); - CopyFile(NET35_BIN_DIR + file, CURRENT_IMG_NET20_BIN_DIR + file); - } - } - - CreateDirectory(CURRENT_IMG_NETSTANDARD13_BIN_DIR); - Information("Created directory " + CURRENT_IMG_NETSTANDARD13_BIN_DIR); - - foreach(FilePath file in BinFiles) - { - if (FileExists(NETCOREAPP11_BIN_DIR + file)) - { - CreateDirectory(CURRENT_IMG_NETSTANDARD13_BIN_DIR + file.GetDirectory()); - CopyFile(NETCOREAPP11_BIN_DIR + file, CURRENT_IMG_NETSTANDARD13_BIN_DIR + file); - } - } - - CreateDirectory(CURRENT_IMG_NETSTANDARD20_BIN_DIR); - Information("Created directory " + CURRENT_IMG_NETSTANDARD20_BIN_DIR); - - foreach(FilePath file in BinFiles) - { - if (FileExists(NETCOREAPP20_BIN_DIR + file)) - { - CreateDirectory(CURRENT_IMG_NETSTANDARD20_BIN_DIR + file.GetDirectory()); - CopyFile(NETCOREAPP20_BIN_DIR + file, CURRENT_IMG_NETSTANDARD20_BIN_DIR + file); - } - } + CopyDirectory(BIN_DIR, CURRENT_IMG_DIR + "bin/"); }); -Task("PackageEngine") - .Description("Creates NuGet packages of the engine") +Task("PackageNuGet") + .Description("Creates NuGet packages of the engine/console") .IsDependentOn("CreateImage") .Does(() => { @@ -345,14 +309,6 @@ Task("PackageEngine") OutputDirectory = PACKAGE_DIR, NoPackageAnalysis = true }); - }); - -Task("PackageConsole") - .Description("Creates NuGet packages of the console runner") - .IsDependentOn("CreateImage") - .Does(() => - { - CreateDirectory(PACKAGE_DIR); NuGetPack("nuget/runners/nunit.console-runner.nuspec", new NuGetPackSettings() { @@ -424,26 +380,6 @@ Task("PackageChocolatey") }); }); -////////////////////////////////////////////////////////////////////// -// PACKAGE NETSTANDARD ENGINE -////////////////////////////////////////////////////////////////////// - -Task("PackageNetStandardEngine") - .Description("Copies the .NET Standard Engine nuget package in the packages directory") - .WithCriteria(IsRunningOnWindows()) - .Does(() => - { - if(IsDotNetCoreInstalled) - { - var nuget = $"nunit.engine.netstandard.{productVersion}.nupkg"; - var src = "src/NUnitEngine/nunit.engine.netstandard/bin/" + configuration + "/" + nuget; - var dest = PACKAGE_DIR + nuget; - - CreateDirectory(PACKAGE_DIR); - CopyFile(src, dest); - } - }); - ////////////////////////////////////////////////////////////////////// // PACKAGE COMBINED DISTRIBUTIONS ////////////////////////////////////////////////////////////////////// @@ -464,13 +400,16 @@ Task("CreateCombinedImage") .IsDependentOn("FetchExtensions") .Does(() => { - var addinsImgDir = CURRENT_IMG_NET20_BIN_DIR + "addins/"; + foreach(var framework in NETFX_FRAMEWORKS) + { + var addinsImgDir = CURRENT_IMG_DIR + "bin/" + framework +"/addins/"; - CopyDirectory(MSI_DIR + "resources/", CURRENT_IMG_DIR); - CleanDirectory(addinsImgDir); + CopyDirectory(MSI_DIR + "resources/", CURRENT_IMG_DIR); + CleanDirectory(addinsImgDir); - foreach(var packageDir in GetAllDirectories(EXTENSION_PACKAGES_DIR)) - CopyPackageContents(packageDir, addinsImgDir); + foreach(var packageDir in GetAllDirectories(EXTENSION_PACKAGES_DIR)) + CopyPackageContents(packageDir, addinsImgDir); + } }); Task("PackageMsi") @@ -496,11 +435,14 @@ Task("PackageZip") CleanDirectory(ZIP_IMG); CopyDirectory(CURRENT_IMG_DIR, ZIP_IMG); - //Ensure single and correct addins file (.NET Framework only) - var net20ZipImg = ZIP_IMG + "bin/net20/"; - DeleteFiles(ZIP_IMG + "*.addins"); - DeleteFiles(net20ZipImg + "*.addins"); - CopyFile(CURRENT_IMG_DIR + "nunit.bundle.addins", net20ZipImg + "nunit.bundle.addins"); + foreach(var framework in NETFX_FRAMEWORKS) + { + //Ensure single and correct addins file (.NET Framework only) + var netfxZipImg = ZIP_IMG + "bin/" + framework + "/"; + DeleteFiles(ZIP_IMG + "*.addins"); + DeleteFiles(netfxZipImg + "*.addins"); + CopyFile(CURRENT_IMG_DIR + "nunit.bundle.addins", netfxZipImg + "nunit.bundle.addins"); + } var zipPath = string.Format("{0}NUnit.Console-{1}.zip", PACKAGE_DIR, version); Zip(ZIP_IMG, zipPath); @@ -608,9 +550,7 @@ Task("Test") Task("Package") .Description("Packages the engine and console runner") .IsDependentOn("CheckForError") - .IsDependentOn("PackageEngine") - .IsDependentOn("PackageConsole") - .IsDependentOn("PackageNetStandardEngine") + .IsDependentOn("PackageNuGet") .IsDependentOn("PackageChocolatey") .IsDependentOn("PackageMsi") .IsDependentOn("PackageZip"); diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index 54d5ce21e..f9b375ddd 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -1,6 +1,6 @@ - + NUnit.Engine.Api NUnit Test Engine Api $version$ @@ -21,5 +21,7 @@ + + \ No newline at end of file diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index a19fc2871..82c7d0ad3 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -1,6 +1,6 @@ - + NUnit.Engine NUnit Test Engine $version$ @@ -30,5 +30,11 @@ + + + + + + \ No newline at end of file From 6f0427f1831a7ae4fb2e55bcece8ca2831d66682 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 14:01:45 +0100 Subject: [PATCH 13/29] Remove old .NET Standard specific classes --- NuGet.config | 2 +- .../mock-assembly.netstandard.csproj | 32 -- .../Drivers/NUnitNetStandardDriver.cs | 203 ------------ .../Drivers/NUnitNetStandardDriverFactory.cs | 59 ---- .../Runners/DirectTestRunner.cs | 162 --------- .../Runners/MasterTestRunner.cs | 309 ------------------ .../Services/DefaultTestRunnerFactory.cs | 72 ---- .../Services/DriverService.cs | 91 ------ .../nunit.engine.netstandard/TestEngine.cs | 108 ------ .../nunit.engine.netstandard.csproj | 170 ---------- .../API/TestPackageTests.cs | 95 ------ .../Drivers/NUnitNetStandardDriverTests.cs | 187 ----------- .../nunit.engine.tests.netstandard/Program.cs | 15 - .../Properties/launchSettings.json | 8 - .../nunit.engine.tests.netstandard.csproj | 49 --- 15 files changed, 1 insertion(+), 1561 deletions(-) delete mode 100644 src/NUnitEngine/mock-assembly.netstandard/mock-assembly.netstandard.csproj delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriver.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriverFactory.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/Runners/DirectTestRunner.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/Runners/MasterTestRunner.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/Services/DefaultTestRunnerFactory.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/TestEngine.cs delete mode 100644 src/NUnitEngine/nunit.engine.netstandard/nunit.engine.netstandard.csproj delete mode 100644 src/NUnitEngine/nunit.engine.tests.netstandard/API/TestPackageTests.cs delete mode 100644 src/NUnitEngine/nunit.engine.tests.netstandard/Drivers/NUnitNetStandardDriverTests.cs delete mode 100644 src/NUnitEngine/nunit.engine.tests.netstandard/Program.cs delete mode 100644 src/NUnitEngine/nunit.engine.tests.netstandard/Properties/launchSettings.json delete mode 100644 src/NUnitEngine/nunit.engine.tests.netstandard/nunit.engine.tests.netstandard.csproj diff --git a/NuGet.config b/NuGet.config index f2b88c1fe..a90607ba0 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,7 @@ - + diff --git a/src/NUnitEngine/mock-assembly.netstandard/mock-assembly.netstandard.csproj b/src/NUnitEngine/mock-assembly.netstandard/mock-assembly.netstandard.csproj deleted file mode 100644 index 7f06a9b99..000000000 --- a/src/NUnitEngine/mock-assembly.netstandard/mock-assembly.netstandard.csproj +++ /dev/null @@ -1,32 +0,0 @@ - - - NUnit.Tests - netstandard1.6 - mock-assembly - - - true - - - ..\..\nunit.snk - false - $(PackageVersion) - - - - - - - - - - - - - - - - nunit.snk - - - \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriver.cs b/src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriver.cs deleted file mode 100644 index 563d8a61d..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriver.cs +++ /dev/null @@ -1,203 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2016 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN METHOD -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using System; -using System.Linq; -using System.Collections.Generic; -using NUnit.Engine.Internal; -using System.Reflection; -using NUnit.Engine.Extensibility; -using Mono.Cecil; - -namespace NUnit.Engine.Drivers -{ - /// - /// NUnitNetStandardDriver is used by the test-runner to load and run - /// tests using the NUnit framework assembly. - /// - public class NUnitNetStandardDriver : IFrameworkDriver - { - const string LOAD_MESSAGE = "Method called without calling Load first"; - const string INVALID_FRAMEWORK_MESSAGE = "Running tests against this version of the framework using this driver is not supported. Please update NUnit.Framework to the latest version."; - const string FAILED_TO_LOAD_TEST_ASSEMBLY = "Failed to load the test assembly {0}"; - const string FAILED_TO_LOAD_NUNIT = "Failed to load the NUnit Framework in the test assembly"; - - static readonly string CONTROLLER_TYPE = "NUnit.Framework.Api.FrameworkController"; - static readonly string LOAD_METHOD = "LoadTests"; - static readonly string EXPLORE_METHOD = "ExploreTests"; - static readonly string COUNT_METHOD = "CountTests"; - static readonly string RUN_METHOD = "RunTests"; - static readonly string RUN_ASYNC_METHOD = "RunTests"; - static readonly string STOP_RUN_METHOD = "StopRun"; - - static ILogger log = InternalTrace.GetLogger(nameof(NUnitNetStandardDriver)); - - Assembly _testAssembly; - Assembly _frameworkAssembly; - object _frameworkController; - Type _frameworkControllerType; - - /// - /// An id prefix that will be passed to the test framework and used as part of the - /// test ids created. - /// - public string ID { get; set; } - - /// - /// Loads the tests in an assembly. - /// - /// The NUnit Framework that the tests reference - /// The test assembly - /// The test settings - /// An Xml string representing the loaded test - public string Load(string testAssembly, IDictionary settings) - { - var idPrefix = string.IsNullOrEmpty(ID) ? "" : ID + "-"; - - var assemblyRef = AssemblyDefinition.ReadAssembly(testAssembly); - _testAssembly = Assembly.Load(new AssemblyName(assemblyRef.FullName)); - if(_testAssembly == null) - throw new NUnitEngineException(string.Format(FAILED_TO_LOAD_TEST_ASSEMBLY, assemblyRef.FullName)); - - var nunitRef = assemblyRef.MainModule.AssemblyReferences.Where(reference => reference.Name.Equals("nunit.framework", StringComparison.OrdinalIgnoreCase)).FirstOrDefault(); - if (nunitRef == null) - throw new NUnitEngineException(FAILED_TO_LOAD_NUNIT); - - var nunit = Assembly.Load(new AssemblyName(nunitRef.FullName)); - if (nunit == null) - throw new NUnitEngineException(FAILED_TO_LOAD_NUNIT); - - _frameworkAssembly = nunit; - - _frameworkController = CreateObject(CONTROLLER_TYPE, _testAssembly, idPrefix, settings); - if (_frameworkController == null) - throw new NUnitEngineException(INVALID_FRAMEWORK_MESSAGE); - - _frameworkControllerType = _frameworkController.GetType(); - - log.Info("Loading {0} - see separate log file", _testAssembly.FullName); - return ExecuteMethod(LOAD_METHOD) as string; - } - - /// - /// Counts the number of test cases for the loaded test assembly - /// - /// The XML test filter - /// The number of test cases - public int CountTestCases(string filter) - { - CheckLoadWasCalled(); - object count = ExecuteMethod(COUNT_METHOD, filter); - return count != null ? (int)count : 0; - } - - /// - /// Executes the tests in an assembly. - /// - /// An ITestEventHandler that receives progress notices - /// A filter that controls which tests are executed - /// An Xml string representing the result - public string Run(ITestEventListener listener, string filter) - { - CheckLoadWasCalled(); - log.Info("Running {0} - see separate log file", _testAssembly.FullName); - Action callback = listener != null ? listener.OnTestEvent : (Action)null; - return ExecuteMethod(RUN_METHOD, new[] { typeof(Action), typeof(string) }, callback, filter) as string; - } - - /// - /// Executes the tests in an assembly asyncronously. - /// - /// A callback that receives XML progress notices - /// A filter that controls which tests are executed - public void RunAsync(Action callback, string filter) - { - CheckLoadWasCalled(); - log.Info("Running {0} - see separate log file", _testAssembly.FullName); - ExecuteMethod(RUN_ASYNC_METHOD, new[] { typeof(Action), typeof(string) }, callback, filter); - } - - /// - /// Cancel the ongoing test run. If no test is running, the call is ignored. - /// - /// If true, cancel any ongoing test threads, otherwise wait for them to complete. - public void StopRun(bool force) - { - ExecuteMethod(STOP_RUN_METHOD, force); - } - - /// - /// Returns information about the tests in an assembly. - /// - /// A filter indicating which tests to include - /// An Xml string representing the tests - public string Explore(string filter) - { - CheckLoadWasCalled(); - - log.Info("Exploring {0} - see separate log file", _testAssembly.FullName); - return ExecuteMethod(EXPLORE_METHOD, filter) as string; - } - - #region Helper Methods - - void CheckLoadWasCalled() - { - if (_frameworkController == null) - throw new InvalidOperationException(LOAD_MESSAGE); - } - - object CreateObject(string typeName, params object[] args) - { - var typeinfo = _frameworkAssembly.DefinedTypes.FirstOrDefault(t => t.FullName == typeName); - if (typeinfo == null) - { - log.Error("Could not find type {0}", typeName); - } - return Activator.CreateInstance(typeinfo.AsType(), args); - } - - object ExecuteMethod(string methodName, params object[] args) - { - var method = _frameworkControllerType.GetMethod(methodName, BindingFlags.Public | BindingFlags.Instance); - return ExecuteMethod(method, args); - } - - object ExecuteMethod(string methodName, Type[] ptypes, params object[] args) - { - var method = _frameworkControllerType.GetMethod(methodName, ptypes); - return ExecuteMethod(method, args); - } - - object ExecuteMethod(MethodInfo method, params object[] args) - { - if (method == null) - { - throw new NUnitEngineException(INVALID_FRAMEWORK_MESSAGE); - } - return method.Invoke(_frameworkController, args); - } - - #endregion - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriverFactory.cs b/src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriverFactory.cs deleted file mode 100644 index 23a1122b2..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/Drivers/NUnitNetStandardDriverFactory.cs +++ /dev/null @@ -1,59 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2014 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using System; -using System.Reflection; -using NUnit.Common; -using NUnit.Engine.Extensibility; - -namespace NUnit.Engine.Drivers -{ - public class NUnitNetStandardDriverFactory - { - private const string NUNIT_FRAMEWORK = "nunit.framework"; - - /// - /// Gets a flag indicating whether a given assembly name and version - /// represent a test framework supported by this factory. - /// - /// An AssemblyName referring to the possible test framework. - public bool IsSupportedTestFramework(AssemblyName reference) - { - return NUNIT_FRAMEWORK.Equals(reference.Name, StringComparison.OrdinalIgnoreCase) && reference.Version.Major == 3; - } - - /// - /// Gets a driver for a given test assembly and a framework - /// which the assembly is already known to reference. - /// - /// The domain in which the assembly will be loaded - /// An AssemblyName referring to the test framework. - /// - public IFrameworkDriver GetDriver(AssemblyName reference) - { - Guard.ArgumentValid(IsSupportedTestFramework(reference), "Invalid framework", "reference"); - - return new NUnitNetStandardDriver(); - } - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/Runners/DirectTestRunner.cs b/src/NUnitEngine/nunit.engine.netstandard/Runners/DirectTestRunner.cs deleted file mode 100644 index 5e18f6d7d..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/Runners/DirectTestRunner.cs +++ /dev/null @@ -1,162 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2011-2014 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using System; -using System.Collections.Generic; -using NUnit.Engine.Extensibility; -using NUnit.Engine.Internal; -using NUnit.Engine.Drivers; -using NUnit.Engine.Services; - -namespace NUnit.Engine.Runners -{ - /// - /// DirectTestRunner is the abstract base for runners - /// that deal directly with a framework driver. - /// - public class DirectTestRunner : AbstractTestRunner - { - private readonly List _drivers = new List(); - - public DirectTestRunner(TestPackage package) : base(package) - { - } - - #region AbstractTestRunner Overrides - - /// - /// Explores a previously loaded TestPackage and returns information - /// about the tests found. - /// - /// The TestFilter to be used to select tests - /// - /// A TestEngineResult. - /// - public override TestEngineResult Explore(TestFilter filter) - { - EnsurePackageIsLoaded(); - - var result = new TestEngineResult(); - - foreach (var driver in _drivers) - result.Add(driver.Explore(filter.Text)); - - return result; - } - - /// - /// Load a TestPackage for exploration or execution - /// - /// A TestEngineResult. - protected override TestEngineResult LoadPackage() - { - var result = new TestEngineResult(); - - // DirectRunner may be called with a single-assembly package - // or a set of assemblies as subpackages. - var packages = TestPackage.SubPackages; - if (packages.Count == 0) - packages.Add(TestPackage); - - var driverService = new DriverService(); - - foreach (var subPackage in packages) - { - var testFile = subPackage.FullName; - - bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false); - - IFrameworkDriver driver = driverService.GetDriver(testFile, skipNonTestAssemblies); - driver.ID = TestPackage.ID; - - result.Add(driver.Load(testFile, subPackage.Settings)); - _drivers.Add(driver); - } - - return result; - } - - /// - /// Count the test cases that would be run under - /// the specified filter. - /// - /// A TestFilter - /// The count of test cases - public override int CountTestCases(TestFilter filter) - { - EnsurePackageIsLoaded(); - - int count = 0; - - foreach (var driver in _drivers) - count += driver.CountTestCases(filter.Text); - - return count; - } - - - /// - /// Run the tests in the loaded TestPackage. - /// - /// An ITestEventHandler to receive events - /// A TestFilter used to select tests - /// - /// A TestEngineResult giving the result of the test execution - /// - protected override TestEngineResult RunTests(ITestEventListener listener, TestFilter filter) - { - EnsurePackageIsLoaded(); - - var result = new TestEngineResult(); - - foreach (var driver in _drivers) - { - result.Add(driver.Run(listener, filter.Text)); - } - - return result; - } - - /// - /// Cancel the ongoing test run. If no test is running, the call is ignored. - /// - /// If true, cancel any ongoing test threads, otherwise wait for them to complete. - public override void StopRun(bool force) - { - foreach(var driver in _drivers) - driver.StopRun(force); - } - - #endregion - - #region Helper Methods - - private void EnsurePackageIsLoaded() - { - if (!IsPackageLoaded) - LoadResult = LoadPackage(); - } - - #endregion - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/Runners/MasterTestRunner.cs b/src/NUnitEngine/nunit.engine.netstandard/Runners/MasterTestRunner.cs deleted file mode 100644 index 4316dac92..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/Runners/MasterTestRunner.cs +++ /dev/null @@ -1,309 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2011-2014 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using System; -using System.Diagnostics; -using System.Globalization; -using System.IO; -using System.Reflection; -using System.Xml; -using System.ComponentModel; -using NUnit.Engine.Services; -using NUnit.Engine.Internal; - -namespace NUnit.Engine.Runners -{ - public class MasterTestRunner : ITestRunner - { - private const string TEST_RUN_ELEMENT = "test-run"; - private readonly ITestEngineRunner _engineRunner; - private bool _disposed; - - public MasterTestRunner(TestPackage package) - { - if (package == null) throw new ArgumentNullException("package"); - - TestPackage = package; - - // Get references to the services we use - var runnerFactory = new DefaultTestRunnerFactory(); - _engineRunner = runnerFactory.MakeTestRunner(package); - - InitializePackage(); - } - - #region Properties - - /// - /// The TestPackage for which this is the runner - /// - protected TestPackage TestPackage { get; set; } - - /// - /// The result of the last call to LoadPackage - /// - protected TestEngineResult LoadResult { get; set; } - - /// - /// Gets an indicator of whether the package has been loaded. - /// - protected bool IsPackageLoaded - { - get { return LoadResult != null; } - } - - #endregion - - #region ITestRunner Members - - /// - /// Get a flag indicating whether a test is running - /// - public bool IsTestRunning { get; private set; } - - /// - /// Load a TestPackage for possible execution. The - /// explicit implementation returns an ITestEngineResult - /// for consumption by clients. - /// - /// An XmlNode representing the loaded assembly. - public XmlNode Load() - { - LoadResult = _engineRunner.Load(); - return LoadResult.Xml; - } - - /// - /// Unload any loaded TestPackage. If none is loaded, - /// the call is ignored. - /// - public void Unload() - { - UnloadPackage(); - } - - /// - /// Reload the currently loaded test package. - /// - /// An XmlNode representing the loaded package - /// If no package has been loaded - public XmlNode Reload() - { - LoadResult = _engineRunner.Reload(); - return LoadResult.Xml; - } - - /// - /// Count the test cases that would be run under the specified - /// filter, loading the TestPackage if it is not already loaded. - /// - /// A TestFilter - /// The count of test cases. - public int CountTestCases(TestFilter filter) - { - return _engineRunner.CountTestCases(filter); - } - - /// - /// Run the tests in a loaded TestPackage. The explicit - /// implementation returns an ITestEngineResult for use - /// by external clients. - /// - /// An ITestEventHandler to receive events - /// A TestFilter used to select tests - /// An XmlNode giving the result of the test execution - public XmlNode Run(ITestEventListener listener, TestFilter filter) - { - return RunTests(listener, filter).Xml; - } - - /// - /// Cancel the ongoing test run. If no test is running, the call is ignored. - /// - /// If true, cancel any ongoing test threads, otherwise wait for them to complete. - public void StopRun(bool force) - { - _engineRunner.StopRun(force); - } - - /// - /// Explore a loaded TestPackage and return information about - /// the tests found. - /// - /// A TestFilter used to select tests - /// An XmlNode representing the tests found. - public XmlNode Explore(TestFilter filter) - { - LoadResult = _engineRunner.Explore(filter) - .Aggregate(TEST_RUN_ELEMENT, TestPackage.Name, TestPackage.FullName); - - return LoadResult.Xml; - } - - #endregion - - #region IDisposable - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - /// - /// Dispose of this object. - /// - private void Dispose(bool disposing) - { - if (!_disposed) - { - if (disposing && _engineRunner != null) - _engineRunner.Dispose(); - - _disposed = true; - } - } - - #endregion - - #region Helper Methods - - /// - /// Check the package settings, expand projects and - /// determine what runtimes may be needed. - /// - private void InitializePackage() - { - // Last chance to catch invalid settings in package, - // in case the client runner missed them. - ValidatePackageSettings(); - - // Some files in the top level package may be projects. - // Expand them so that they contain subprojects for - // each contained assembly. - EnsurePackagesAreExpanded(TestPackage); - } - - private void ValidatePackageSettings() - { - // TODO: Any package settings to validate? - } - - private void EnsurePackagesAreExpanded(TestPackage package) - { - if (package == null) throw new ArgumentNullException("package"); - - foreach (var subPackage in package.SubPackages) - { - EnsurePackagesAreExpanded(subPackage); - } - } - - /// - /// Unload any loaded TestPackage. - /// - private void UnloadPackage() - { - LoadResult = null; - if (_engineRunner != null) - _engineRunner.Unload(); - } - - /// - /// Count the test cases that would be run under - /// the specified filter. Returns zero if the - /// package has not yet been loaded. - /// - /// A TestFilter - /// The count of test cases - private int CountTests(TestFilter filter) - { - if (!IsPackageLoaded) return 0; - - return _engineRunner.CountTestCases(filter); - } - - /// - /// Run the tests in the loaded TestPackage and return a test result. The tests - /// are run synchronously and the listener interface is notified as it progresses. - /// - /// An ITestEventHandler to receive events - /// A TestFilter used to select tests - /// A TestEngineResult giving the result of the test execution - private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter) - { - var eventDispatcher = new TestEventDispatcher(); - if (listener != null) - eventDispatcher.Listeners.Add(listener); - - IsTestRunning = true; - - eventDispatcher.OnTestEvent(string.Format("", CountTests(filter))); - - DateTime startTime = DateTime.UtcNow; - long startTicks = Stopwatch.GetTimestamp(); - - TestEngineResult result = _engineRunner.Run(eventDispatcher, filter).Aggregate("test-run", TestPackage.Name, TestPackage.FullName); - - // These are inserted in reverse order, since each is added as the first child. - InsertFilterElement(result.Xml, filter); - - result.Xml.AddAttribute("engine-version", typeof(MasterTestRunner).GetTypeInfo().Assembly.GetName().Version.ToString()); - result.Xml.AddAttribute("clr-version", Microsoft.DotNet.InternalAbstractions.RuntimeEnvironment.GetRuntimeIdentifier()); - - double duration = (double)(Stopwatch.GetTimestamp() - startTicks) / Stopwatch.Frequency; - result.Xml.AddAttribute("start-time", XmlConvert.ToString(startTime, "u")); - result.Xml.AddAttribute("end-time", XmlConvert.ToString(DateTime.UtcNow, "u")); - result.Xml.AddAttribute("duration", duration.ToString("0.000000", NumberFormatInfo.InvariantInfo)); - - IsTestRunning = false; - - eventDispatcher.OnTestEvent(result.Xml.OuterXml); - - return result; - } - - private static void InsertFilterElement(XmlNode resultNode, TestFilter filter) - { - // Convert the filter to an XmlNode - var tempNode = XmlHelper.CreateXmlNode(filter.Text); - - // Don't include it if it's an empty filter - if (tempNode.ChildNodes.Count <= 0) - { - return; - } - - var doc = resultNode.OwnerDocument; - if (doc == null) - { - return; - } - - var filterElement = doc.ImportNode(tempNode, true); - resultNode.InsertAfter(filterElement, null); - } - - #endregion - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/Services/DefaultTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine.netstandard/Services/DefaultTestRunnerFactory.cs deleted file mode 100644 index 283bcba74..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/Services/DefaultTestRunnerFactory.cs +++ /dev/null @@ -1,72 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2017 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using NUnit.Engine.Internal; -using NUnit.Engine.Runners; - -namespace NUnit.Engine.Services -{ - /// - /// DefaultTestRunnerFactory handles creation of a suitable test - /// runner for a given package to be loaded and run either in a - /// separate process or within the same process. - /// - public class DefaultTestRunnerFactory : ITestRunnerFactory - { - #region InProcessTestRunnerFactory Overrides - - /// - /// Returns a test runner based on the settings in a TestPackage. - /// Any setting that is "consumed" by the factory is removed, so - /// that downstream runners using the factory will not repeatedly - /// create the same type of runner. - /// - /// The TestPackage to be loaded and run - /// A TestRunner - public virtual ITestEngineRunner MakeTestRunner(TestPackage package) - { - int assemblyCount = 0; - - foreach (var subPackage in package.SubPackages) - { - var testFile = subPackage.FullName; - - if (PathUtils.IsAssemblyFileType(testFile)) - assemblyCount++; - } - - if ( assemblyCount > 0) - return new AggregatingTestRunner(package); - - // TODO: What about bad extensions? - return new DirectTestRunner(package); - } - - public virtual bool CanReuse(ITestEngineRunner runner, TestPackage package) - { - return false; - } - - #endregion - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs b/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs deleted file mode 100644 index 53f4deb12..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/Services/DriverService.cs +++ /dev/null @@ -1,91 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2017 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Linq; -using Mono.Cecil; -using NUnit.Engine.Drivers; -using NUnit.Engine.Extensibility; -using NUnit.Engine.Internal; - -namespace NUnit.Engine.Services -{ - /// - /// The DriverService provides drivers able to load and run tests - /// using various frameworks. - /// - public class DriverService - { - /// - /// Get a driver suitable for use with a particular test assembly. - /// - /// The full path to the test assembly - /// True if non-test assemblies should simply be skipped rather than reporting an error - /// - public IFrameworkDriver GetDriver(string assemblyPath, bool skipNonTestAssemblies) - { - if (!File.Exists(assemblyPath)) - return new InvalidAssemblyFrameworkDriver(assemblyPath, "File not found: " + assemblyPath); - - if (!PathUtils.IsAssemblyFileType(assemblyPath)) - return new InvalidAssemblyFrameworkDriver(assemblyPath, "File type is not supported"); - - try - { - var assemblyDef = AssemblyDefinition.ReadAssembly(assemblyPath); - - if (skipNonTestAssemblies) - { - if (assemblyDef.CustomAttributes.Any(attr => attr.AttributeType.FullName == "NUnit.Framework.NonTestAssemblyAttribute")) - return new SkippedAssemblyFrameworkDriver(assemblyPath); - } - - var references = new List(); - foreach (var cecilRef in assemblyDef.MainModule.AssemblyReferences) - references.Add(new AssemblyName(cecilRef.FullName)); - - var factory = new NUnitNetStandardDriverFactory(); - var driver = references.Where(reference => factory.IsSupportedTestFramework(reference)) - .Select(reference => factory.GetDriver(reference)) - .FirstOrDefault(); - if(driver != null) - { - return driver; - } - } - catch (BadImageFormatException ex) - { - return new InvalidAssemblyFrameworkDriver(assemblyPath, ex.Message); - } - - if (skipNonTestAssemblies) - return new SkippedAssemblyFrameworkDriver(assemblyPath); - else - return new InvalidAssemblyFrameworkDriver(assemblyPath, string.Format("No suitable tests found in '{0}'.\n" + - "Either assembly contains no tests or proper test driver has not been found.", assemblyPath)); - } - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/TestEngine.cs b/src/NUnitEngine/nunit.engine.netstandard/TestEngine.cs deleted file mode 100644 index 793d1e304..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/TestEngine.cs +++ /dev/null @@ -1,108 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2011 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using NUnit.Engine.Internal; -using System; -using System.Diagnostics; -using System.IO; -using System.Runtime.InteropServices; - -namespace NUnit.Engine -{ - /// - /// The TestEngine provides services that allow a client - /// program to interact with NUnit in order to explore, - /// load and run tests. - /// - public class TestEngine : ITestEngine - { - public TestEngine() - { - WorkDirectory = Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "Home"); - InternalTraceLevel = InternalTraceLevel.Default; - } - - #region Public Properties - - public string WorkDirectory { get; set; } - - public InternalTraceLevel InternalTraceLevel { get; set; } - - #endregion - - #region ITestEngine Members - - /// - /// Initialize the engine. This includes initializing mono addins, - /// setting the trace level and creating the standard set of services - /// used in the Engine. - /// - /// This interface is not normally called by user code. Programs linking - /// only to the nunit.engine.api assembly are given a - /// pre-initialized instance of TestEngine. Programs - /// that link directly to nunit.engine usually do so - /// in order to perform custom initialization. - /// - public void Initialize() - { - if (InternalTraceLevel != InternalTraceLevel.Off && !InternalTrace.Initialized) - { - var logName = string.Format("InternalTrace.{0}.log", Process.GetCurrentProcess().Id); - InternalTrace.Initialize(Path.Combine(WorkDirectory, logName), InternalTraceLevel); - } - } - - /// - /// Returns a test runner for use by clients that need to load the - /// tests once and run them multiple times. If necessary, the - /// services are initialized first. - /// - /// An ITestRunner. - public ITestRunner GetRunner(TestPackage package) - { - return new Runners.MasterTestRunner(package); - } - - #endregion - - #region IDisposable Members - - private bool _disposed = false; - - public void Dispose() - { - Dispose(true); - GC.SuppressFinalize(this); - } - - protected virtual void Dispose(bool disposing) - { - if (!_disposed) - { - _disposed = true; - } - } - - #endregion - } -} diff --git a/src/NUnitEngine/nunit.engine.netstandard/nunit.engine.netstandard.csproj b/src/NUnitEngine/nunit.engine.netstandard/nunit.engine.netstandard.csproj deleted file mode 100644 index 51dc7806e..000000000 --- a/src/NUnitEngine/nunit.engine.netstandard/nunit.engine.netstandard.csproj +++ /dev/null @@ -1,170 +0,0 @@ - - - netstandard1.3 - NUnit.Engine - nunit.engine.netstandard - 3.8.0-dev - - - true - - - ..\..\nunit.snk - True - false - nunit.engine.netstandard - NUnit .NET Standard Engine - Charlie Poole, Rob Prouse - Charlie Poole, Rob Prouse - Provides a common interface for loading, exploring and running NUnit tests in .NET Core and .NET Standard - Copyright (C) 2017 Charlie Poole, Rob Prouse - $(PackageVersion) - https://raw.githubusercontent.com/nunit/nunit-console/master/LICENSE.txt - http://nunit.org - https://cdn.rawgit.com/nunit/resources/master/images/icon/nunit_256.png - https://github.com/nunit/nunit-console.git - git - nunit test testing tdd engine - - - - - - - - Extensibility\IFrameworkDriver.cs - - - - ILogger.cs - - - - ISettings.cs - - - - Drivers\NotRunnableFrameworkDriver.cs - - - EnginePackageSettings.cs - - - Guard.cs - - - InternalEnginePackageSettings.cs - - - Internal\CecilExtensions.cs - - - Internal\DirectoryFinder.cs - - - Internal\Logging\InternalTrace.cs - - - Internal\Logging\InternalTraceWriter.cs - - - Internal\Logging\Logger.cs - - - Internal\PathUtils.cs - - - Internal\ResultHelper.cs - - - Internal\SettingsGroup.cs - - - Internal\SettingsStore.cs - - - ITestEngineRunner.cs - - - ITestRunnerFactory.cs - - - - Runners\AbstractTestRunner.cs - - - Runners\AggregatingTestRunner.cs - - - Runners\ITestExecutionTask.cs - - - Runners\TestEventDispatcher.cs - - - Runners\TestExecutionTask.cs - - - - - - - - - - TestEngineResult.cs - - - XmlHelper.cs - - - Extensibility\ExtensionAttribute.cs - - - Extensibility\TypeExtensionPointAttribute.cs - - - InternalTraceLevel.cs - - - ITestEngine.cs - - - ITestEventListener.cs - - - ITestFilterBuilder.cs - - - ITestFilterService.cs - - - ITestRunner.cs - - - TestFilter.cs - - - TestPackage.cs - - - - - nunit.snk - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests.netstandard/API/TestPackageTests.cs b/src/NUnitEngine/nunit.engine.tests.netstandard/API/TestPackageTests.cs deleted file mode 100644 index 037bab2a2..000000000 --- a/src/NUnitEngine/nunit.engine.tests.netstandard/API/TestPackageTests.cs +++ /dev/null @@ -1,95 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2017 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using NUnit.Framework; - -namespace NUnit.Engine.Api.Tests -{ - public class TestPackageTests_SingleAssembly - { - private TestPackage package; - - [SetUp] - public void CreatePackage() - { - package = new TestPackage(@"c:\test.dll"); - } - - [Test] - public void PackageIDsAreUnique() - { - var another = new TestPackage(@"c:\another.dll"); - Assert.That(another.ID, Is.Not.EqualTo(package.ID)); - } - - [Test] - public void AssemblyPathIsUsedAsFullName() - { - Assert.AreEqual(@"c:\test.dll", package.FullName); - } - - [Test] - public void FileNameIsUsedAsPackageName() - { - Assert.That(package.Name, Is.EqualTo("test.dll")); - } - - [Test] - public void HasNoSubPackages() - { - Assert.That(package.SubPackages.Count, Is.EqualTo(0)); - } - - [Test] - public void NonRootedPathThrows() - { - Assert.That(() => new TestPackage("test1.dll"), Throws.InstanceOf()); - } - } - - public class TestPackageTests_MultipleAssemblies - { - private TestPackage package; - - [SetUp] - public void CreatePackage() - { - package = new TestPackage(new string[] { @"c:\test1.dll", @"c:\test2.dll", @"c:\test3.dll" }); - } - - [Test] - public void PackageIsAnonymous() - { - Assert.Null(package.FullName); - } - - [Test] - public void PackageContainsThreeSubpackages() - { - Assert.That(package.SubPackages.Count, Is.EqualTo(3)); - Assert.That(package.SubPackages[0].FullName, Is.EqualTo(@"c:\test1.dll")); - Assert.That(package.SubPackages[1].FullName, Is.EqualTo(@"c:\test2.dll")); - Assert.That(package.SubPackages[2].FullName, Is.EqualTo(@"c:\test3.dll")); - } - } -} diff --git a/src/NUnitEngine/nunit.engine.tests.netstandard/Drivers/NUnitNetStandardDriverTests.cs b/src/NUnitEngine/nunit.engine.tests.netstandard/Drivers/NUnitNetStandardDriverTests.cs deleted file mode 100644 index f70bcb7e4..000000000 --- a/src/NUnitEngine/nunit.engine.tests.netstandard/Drivers/NUnitNetStandardDriverTests.cs +++ /dev/null @@ -1,187 +0,0 @@ -// *********************************************************************** -// Copyright (c) 2014 Charlie Poole -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// *********************************************************************** - -using System; -using System.Collections.Generic; -using System.Web.UI; -using System.Xml; -using NUnit.Tests.Assemblies; -using NUnit.Engine.Internal; -using NUnit.Framework; -using NUnit.Framework.Internal; -using NUnit.Engine.Services; -using NUnit.Engine.Extensibility; - -namespace NUnit.Engine.Drivers.Tests -{ - // Functional tests of the NUnitFrameworkDriver calling into the framework. - public class NUnitNetStandardDriverTests - { - private const string MOCK_ASSEMBLY = "mock-assembly.dll"; - private const string MISSING_FILE = "junk.dll"; - private const string NUNIT_FRAMEWORK = "nunit.framework"; - private const string LOAD_MESSAGE = "Method called without calling Load first"; - - private IDictionary _settings = new Dictionary(); - - private IFrameworkDriver _driver; - private string _mockAssemblyPath; - - [SetUp] - public void CreateDriver() - { - _mockAssemblyPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY); - var service = new DriverService(); - _driver = service.GetDriver(_mockAssemblyPath, true); - } - - public void GetsCorrectDriver() - { - Assert.That(_driver, Is.Not.Null); - Assert.That(_driver.GetType(), Is.EqualTo(typeof(NUnitNetStandardDriver))); - } - - #region Load - [Test] - public void Load_GoodFile_ReturnsRunnableSuite() - { - var result = XmlHelper.CreateXmlNode(_driver.Load(_mockAssemblyPath, _settings)); - - Assert.That(result.Name, Is.EqualTo("test-suite")); - Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly")); - Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable")); - Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString())); - Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests"); - } - #endregion - - #region Explore - [Test] - public void Explore_AfterLoad_ReturnsRunnableSuite() - { - _driver.Load(_mockAssemblyPath, _settings); - var result = XmlHelper.CreateXmlNode(_driver.Explore(TestFilter.Empty.Text)); - - Assert.That(result.Name, Is.EqualTo("test-suite")); - Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly")); - Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable")); - Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString())); - Assert.That(result.SelectNodes("test-suite").Count, Is.GreaterThan(0), "Explore result should have child tests"); - } - - [Test] - public void ExploreTestsAction_WithoutLoad_ThrowsInvalidOperationException() - { - var ex = Assert.Catch(() => _driver.Explore(TestFilter.Empty.Text)); - if (ex is System.Reflection.TargetInvocationException) - ex = ex.InnerException; - Assert.That(ex, Is.TypeOf()); - Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); - } - #endregion - - #region CountTests - [Test] - public void CountTestsAction_AfterLoad_ReturnsCorrectCount() - { - _driver.Load(_mockAssemblyPath, _settings); - Assert.That(_driver.CountTestCases(TestFilter.Empty.Text), Is.EqualTo(MockAssembly.Tests)); - } - - [Test] - public void CountTestsAction_WithoutLoad_ThrowsInvalidOperationException() - { - var ex = Assert.Catch(() => _driver.CountTestCases(TestFilter.Empty.Text)); - if (ex is System.Reflection.TargetInvocationException) - ex = ex.InnerException; - Assert.That(ex, Is.TypeOf()); - Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); - } - #endregion - - #region RunTests - [Test] - public void RunTestsAction_AfterLoad_ReturnsRunnableSuite() - { - _driver.Load(_mockAssemblyPath, _settings); - var result = XmlHelper.CreateXmlNode(_driver.Run(new NullListener(), TestFilter.Empty.Text)); - - Assert.That(result.Name, Is.EqualTo("test-suite")); - Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly")); - Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable")); - Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString())); - Assert.That(result.GetAttribute("result"), Is.EqualTo("Failed")); - Assert.That(result.GetAttribute("passed"), Is.EqualTo(MockAssembly.Passed.ToString())); - Assert.That(result.GetAttribute("failed"), Is.EqualTo(MockAssembly.Failed.ToString())); - Assert.That(result.GetAttribute("skipped"), Is.EqualTo(MockAssembly.Skipped.ToString())); - Assert.That(result.GetAttribute("inconclusive"), Is.EqualTo(MockAssembly.Inconclusive.ToString())); - Assert.That(result.SelectNodes("test-suite").Count, Is.GreaterThan(0), "Explore result should have child tests"); - } - - [Test] - public void RunTestsAction_WithoutLoad_ThrowsInvalidOperationException() - { - var ex = Assert.Catch(() => _driver.Run(new NullListener(), TestFilter.Empty.Text)); - if (ex is System.Reflection.TargetInvocationException) - ex = ex.InnerException; - Assert.That(ex, Is.TypeOf()); - Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); - } - #endregion - - #region Helper Methods - private static string GetSkipReason(XmlNode result) - { - var propNode = result.SelectSingleNode(string.Format("properties/property[@name='{0}']", PropertyNames.SkipReason)); - return propNode == null ? null : propNode.GetAttribute("value"); - } - #endregion - - #region Nested Callback Class - private class CallbackEventHandler : System.Web.UI.ICallbackEventHandler - { - private string _result; - - public string GetCallbackResult() - { - return _result; - } - - public void RaiseCallbackEvent(string eventArgument) - { - _result = eventArgument; - } - } - #endregion - - #region Nested NullListener Class - public class NullListener : ITestEventListener - { - public void OnTestEvent(string testEvent) - { - // No action - } - } - #endregion - } -} diff --git a/src/NUnitEngine/nunit.engine.tests.netstandard/Program.cs b/src/NUnitEngine/nunit.engine.tests.netstandard/Program.cs deleted file mode 100644 index 6d76b00cc..000000000 --- a/src/NUnitEngine/nunit.engine.tests.netstandard/Program.cs +++ /dev/null @@ -1,15 +0,0 @@ -using NUnitLite; -using System; -using System.Reflection; - -namespace NUnit.Engine.Tests -{ - class Program - { - static int Main(string[] args) - { - int result = new TextRunner(typeof(Program).GetTypeInfo().Assembly).Execute(args); - return result; - } - } -} \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests.netstandard/Properties/launchSettings.json b/src/NUnitEngine/nunit.engine.tests.netstandard/Properties/launchSettings.json deleted file mode 100644 index fb7f4b28f..000000000 --- a/src/NUnitEngine/nunit.engine.tests.netstandard/Properties/launchSettings.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "profiles": { - "nunit.engine.tests.netstandard": { - "commandName": "Project", - "commandLineArgs": "--wait" - } - } -} \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests.netstandard/nunit.engine.tests.netstandard.csproj b/src/NUnitEngine/nunit.engine.tests.netstandard/nunit.engine.tests.netstandard.csproj deleted file mode 100644 index db2aa9a69..000000000 --- a/src/NUnitEngine/nunit.engine.tests.netstandard/nunit.engine.tests.netstandard.csproj +++ /dev/null @@ -1,49 +0,0 @@ - - - - Exe - netcoreapp1.1 - True - ..\..\nunit.snk - false - $(PackageVersion) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file From 6cc8b287bb38f7a0dbfa14784a599142e63180ae Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 17:27:01 +0100 Subject: [PATCH 14/29] Get tests working on OSX and Linux --- .travis.yml | 4 ++-- NUnitConsole.sln | 1 - build.cake | 7 +++---- .../nunit.engine/Internal/NUnitConfiguration.cs | 2 +- 4 files changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index aa2661f1c..9c0fa1857 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: csharp sudo: required -dotnet: 2.1.4 # SDK version; includes runtime version 2.0.5. Need 2.0+ for netcoreapp2.0 tests. +dotnet: 2.1.402 mono: 5.10.0 # Need 5.2+ for the included MSBuild. @@ -19,7 +19,7 @@ matrix: # .NET Core 2 requires OSX 10.12+ # https://github.com/dotnet/core/blob/master/release-notes/2.0/2.0-supported-os.md#macos # https://docs.travis-ci.com/user/reference/osx/#OS-X-Version - osx_image: xcode9.1 + osx_image: xcode9.4 script: - ./build.sh --target "Travis" --configuration "Release" diff --git a/NUnitConsole.sln b/NUnitConsole.sln index 69cbb2744..967edef7a 100644 --- a/NUnitConsole.sln +++ b/NUnitConsole.sln @@ -14,7 +14,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution BUILDING.md = BUILDING.md CHANGES.txt = CHANGES.txt CONTRIBUTING.md = CONTRIBUTING.md - EngineAndConsoleTests.nunit = EngineAndConsoleTests.nunit LICENSE.txt = LICENSE.txt NOTICES.txt = NOTICES.txt NuGet.config = NuGet.config diff --git a/build.cake b/build.cake index 1f554cdda..d85e1bee1 100644 --- a/build.cake +++ b/build.cake @@ -41,9 +41,9 @@ var EXTENSION_PACKAGES_DIR = PROJECT_DIR + "extension-packages/"; var ZIP_IMG = PROJECT_DIR + "zip-image/"; var SOLUTION_FILE = PROJECT_DIR + "NUnitConsole.sln"; -var ENGINE_CSPROJ = PROJECT_DIR + "src/NunitEngine/nunit.engine/nunit.engine.csproj"; -var ENGINE_API_CSPROJ = PROJECT_DIR + "src/NunitEngine/nunit.engine.api/nunit.engine.api.csproj"; -var ENGINE_TESTS_CSPROJ = PROJECT_DIR + "src/NunitEngine/nunit.engine.tests/nunit.engine.tests.csproj"; +var ENGINE_CSPROJ = PROJECT_DIR + "src/NUnitEngine/nunit.engine/nunit.engine.csproj"; +var ENGINE_API_CSPROJ = PROJECT_DIR + "src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj"; +var ENGINE_TESTS_CSPROJ = PROJECT_DIR + "src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj"; var NETFX_FRAMEWORKS = new [] { "net20", "net35" }; //Production code targets net20, tests target nets35 var NETSTANDARD_FRAMEWORKS = new [] { "netstandard1.3", "netstandard2.0" }; @@ -251,7 +251,6 @@ Task("TestNet20Console") Task("TestNetStandardEngine") .Description("Tests the .NET Standard Engine") .IsDependentOn("Build") - .WithCriteria(IsRunningOnWindows()) .OnError(exception => { ErrorDetail.Add(exception.Message); }) .Does(() => { diff --git a/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs b/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs index f574ebc88..d3b5025a0 100644 --- a/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs +++ b/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs @@ -66,7 +66,7 @@ public static string ApplicationDirectory { _applicationDirectory = Path.Combine( #if NETSTANDARD1_3 - Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "Home"), + Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "HOME"), #else Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), #endif From aab445f20b94311f60b2df702caa321169a4736b Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sat, 15 Sep 2018 17:46:02 +0100 Subject: [PATCH 15/29] Specify .NET Core runtime versions --- .travis.yml | 19 ++++++++++++------- build.cake | 10 ++++++++-- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9c0fa1857..7c7d6aec3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,25 +1,30 @@ language: csharp sudo: required -dotnet: 2.1.402 - +dotnet: 2.1.401 mono: 5.10.0 # Need 5.2+ for the included MSBuild. matrix: include: - os: linux install: - - sudo apt-get install dotnet-sharedframework-microsoft.netcore.app-1.1.6 + - wget -q https://packages.microsoft.com/config/ubuntu/14.04/packages-microsoft-prod.deb + - sudo dpkg -i packages-microsoft-prod.deb + - sudo apt-get install apt-transport-https + - sudo apt-get update + - sudo apt-get install dotnet-sharedframework-microsoft.netcore.app-1.1.2 + - sudo apt-get install dotnet-runtime-2.0.6 - os: osx - install: - - curl https://download.microsoft.com/download/A/7/E/A7EF2AFF-F77B-4F77-A21B-0F7BD09A4065/dotnet-osx-x64.1.1.6.pkg -O - - sudo installer -pkg dotnet-osx-x64.1.1.6.pkg -target / - # .NET Core 2 requires OSX 10.12+ # https://github.com/dotnet/core/blob/master/release-notes/2.0/2.0-supported-os.md#macos # https://docs.travis-ci.com/user/reference/osx/#OS-X-Version osx_image: xcode9.4 + install: + - curl https://download.microsoft.com/download/D/0/2/D028801E-0802-43C8-9F9F-C7DB0A39B344/dotnet-osx-x64.1.1.2.pkg -O + - sudo installer -pkg dotnet-osx-x64.1.1.2.pkg -target / + - curl https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/dotnet-runtime-2.0.6-osx-x64.pkg -O + - sudo installer -pkg dotnet-runtime-2.0.6-osx-x64.pkg -target / script: - ./build.sh --target "Travis" --configuration "Release" diff --git a/build.cake b/build.cake index d85e1bee1..08641287f 100644 --- a/build.cake +++ b/build.cake @@ -256,8 +256,14 @@ Task("TestNetStandardEngine") { if(IsDotNetCoreInstalled) { - DotNetCoreExecute(NETCOREAPP11_BIN_DIR + ENGINE_TESTS); - DotNetCoreExecute(NETCOREAPP20_BIN_DIR + ENGINE_TESTS); + DotNetCoreExecute(NETCOREAPP11_BIN_DIR + ENGINE_TESTS, "", new DotNetCoreExecuteSettings + { + FrameworkVersion = "1.1.2" //1.1.2 as the highest version currently available on Appveyor + }); + DotNetCoreExecute(NETCOREAPP20_BIN_DIR + ENGINE_TESTS, "", new DotNetCoreExecuteSettings + { + FrameworkVersion = "2.0.6" + }); } else { From ffd06d83309249b03e46349f559fbc052387c2eb Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Sun, 7 Oct 2018 16:48:00 -0400 Subject: [PATCH 16/29] Put the NuGet assemblies in platform appropriate directories --- nuget/engine/nunit.engine.api.nuspec | 6 +++--- nuget/engine/nunit.engine.nuspec | 30 +++++++++++++++------------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index f9b375ddd..550efe2bb 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -20,8 +20,8 @@ - - - + + + \ No newline at end of file diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index 82c7d0ad3..2449c0cd6 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -22,19 +22,21 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + \ No newline at end of file From 06c4597d6556fa6f4c489a440591374785cc50b0 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Sun, 7 Oct 2018 17:32:27 -0400 Subject: [PATCH 17/29] Add dependencies to the Nuspec files --- nuget/engine/nunit.engine.api.nuspec | 11 +++++++++++ nuget/engine/nunit.engine.nuspec | 19 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index 550efe2bb..19be78a52 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -17,6 +17,17 @@ en-US nunit test testing tdd engine Copyright (c) 2018 Charlie Poole, Rob Prouse + + + + + + + + + + + diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index 2449c0cd6..a32d2d66e 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -17,6 +17,25 @@ en-US nunit test testing tdd engine Copyright (c) 2018 Charlie Poole, Rob Prouse + + + + + + + + + + + + + + + + + + + From fa097fb87aed37ab5c735300aa14686bbd53b205 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Sat, 13 Oct 2018 15:50:11 -0400 Subject: [PATCH 18/29] Enable extensions in .NET Standard 2.0 --- .../nunit.engine/Runners/MasterTestRunner.cs | 12 ++++++++---- .../nunit.engine/Services/ServiceManager.cs | 1 - 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs index f5705f788..99b3804bf 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs @@ -38,8 +38,10 @@ public class MasterTestRunner : ITestRunner private const string TEST_RUN_ELEMENT = "test-run"; private readonly ITestEngineRunner _engineRunner; private readonly IServiceLocator _services; -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if NET20 private readonly IRuntimeFrameworkService _runtimeService; +#endif +#if !NETSTANDARD1_3 private readonly ExtensionService _extensionService; #endif private readonly IProjectService _projectService; @@ -55,8 +57,10 @@ public MasterTestRunner(IServiceLocator services, TestPackage package) // Get references to the services we use _projectService = _services.GetService(); -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if NET20 _runtimeService = _services.GetService(); +#endif +#if !NETSTANDARD1_3 _extensionService = _services.GetService(); #endif _engineRunner = _services.GetService().MakeTestRunner(package); @@ -299,7 +303,7 @@ private void ExpandProjects(TestPackage package) // runner is putting invalid values into the package. private void ValidatePackageSettings() { -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 // TODO: How do we validate runtime framework for .NET Standard 2.0? var frameworkSetting = TestPackage.GetSetting(EnginePackageSettings.RuntimeFramework, ""); if (frameworkSetting.Length > 0) { @@ -362,7 +366,7 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter var eventDispatcher = new TestEventDispatcher(); if (listener != null) eventDispatcher.Listeners.Add(listener); -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_3 foreach (var extension in _extensionService.GetExtensions()) eventDispatcher.Listeners.Add(extension); #endif diff --git a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs index e525e5a4d..35df2d665 100644 --- a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs +++ b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs @@ -56,7 +56,6 @@ public IService GetService( Type serviceType ) { #if NETSTANDARD1_3 if (serviceType.GetTypeInfo().IsAssignableFrom(service.GetType().GetTypeInfo())) - //if ( service.GetType().GetTypeInfo().IsAssignableFrom( serviceType.GetTypeInfo() ) ) #else if( serviceType.IsInstanceOfType( service ) ) #endif From 749c813b70bad57d8c52fb052d401c244fd77ec1 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Sun, 14 Oct 2018 15:59:31 +0100 Subject: [PATCH 19/29] Try travis_wait for macOS build timeouts --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 7c7d6aec3..448345d46 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,4 +27,4 @@ matrix: - sudo installer -pkg dotnet-runtime-2.0.6-osx-x64.pkg -target / script: - - ./build.sh --target "Travis" --configuration "Release" + - travis_wait 30 ./build.sh --target "Travis" --configuration "Release" From 34e43600abbff28ad29639e86440c3492bfa9cf0 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Mon, 15 Oct 2018 23:04:33 +0100 Subject: [PATCH 20/29] Fix minor review catches --- .travis.yml | 17 +- src/CommonAssemblyInfo.cs | 6 +- .../nunit3-console.tests.csproj | 2 +- .../mock-assembly/mock-assembly.csproj | 2 +- .../notest-assembly/notest-assembly.csproj | 2 +- .../Drivers/NUnitNetStandardDriverTests.cs | 145 ++++++++++++++++++ .../nunit.engine.tests.csproj | 5 +- .../nunit.engine/AsyncTestEngineResult.cs | 2 +- .../Drivers/NUnitNetStandardDriver.cs | 8 +- .../nunit.engine/Internal/Logging/Logger.cs | 15 +- .../DotNetFrameworkLocator.cs | 2 +- .../nunit.engine/Runners/DirectTestRunner.cs | 7 +- .../nunit.engine/Runners/MasterTestRunner.cs | 22 +-- .../nunit.engine/RuntimeFramework.cs | 76 --------- 14 files changed, 182 insertions(+), 129 deletions(-) create mode 100644 src/NUnitEngine/nunit.engine.tests/Drivers/NUnitNetStandardDriverTests.cs diff --git a/.travis.yml b/.travis.yml index 448345d46..8a9a69f18 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,16 +15,17 @@ matrix: - sudo apt-get install dotnet-sharedframework-microsoft.netcore.app-1.1.2 - sudo apt-get install dotnet-runtime-2.0.6 - - os: osx +# macOS package restore currently taking >30 mins on Travis +# - os: osx # .NET Core 2 requires OSX 10.12+ # https://github.com/dotnet/core/blob/master/release-notes/2.0/2.0-supported-os.md#macos # https://docs.travis-ci.com/user/reference/osx/#OS-X-Version - osx_image: xcode9.4 - install: - - curl https://download.microsoft.com/download/D/0/2/D028801E-0802-43C8-9F9F-C7DB0A39B344/dotnet-osx-x64.1.1.2.pkg -O - - sudo installer -pkg dotnet-osx-x64.1.1.2.pkg -target / - - curl https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/dotnet-runtime-2.0.6-osx-x64.pkg -O - - sudo installer -pkg dotnet-runtime-2.0.6-osx-x64.pkg -target / +# osx_image: xcode9.4 +# install: +# - curl https://download.microsoft.com/download/D/0/2/D028801E-0802-43C8-9F9F-C7DB0A39B344/dotnet-osx-x64.1.1.2.pkg -O +# - sudo installer -pkg dotnet-osx-x64.1.1.2.pkg -target / +# - curl https://download.microsoft.com/download/8/D/A/8DA04DA7-565B-4372-BBCE-D44C7809A467/dotnet-runtime-2.0.6-osx-x64.pkg -O +# - sudo installer -pkg dotnet-runtime-2.0.6-osx-x64.pkg -target / script: - - travis_wait 30 ./build.sh --target "Travis" --configuration "Release" + - ./build.sh --target "Travis" --configuration "Release" diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index 0da04b580..576960cf2 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -35,7 +35,7 @@ [assembly: AssemblyConfiguration(".NET 3.5 Debug")] #elif NET20 [assembly: AssemblyConfiguration(".NET 2.0 Debug")] -#elif NETSTANDARD1_3 || NETCOREAPP1_0 +#elif NETSTANDARD1_3 || NETCOREAPP1_1 [assembly: AssemblyConfiguration(".NET Standard 1.3 Debug")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 [assembly: AssemblyConfiguration(".NET Standard 2.0 Debug")] @@ -47,9 +47,7 @@ [assembly: AssemblyConfiguration(".NET 3.5")] #elif NET20 [assembly: AssemblyConfiguration(".NET 2.0")] -#elif PORTABLE -[assembly: AssemblyConfiguration("Portable")] -#elif NETSTANDARD1_3 || NETCOREAPP1_0 +#elif NETSTANDARD1_3 || NETCOREAPP1_1 [assembly: AssemblyConfiguration(".NET Standard 1.3")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 [assembly: AssemblyConfiguration(".NET Standard 2.0")] diff --git a/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj b/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj index 5f8ae0432..69b82db27 100644 --- a/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj +++ b/src/NUnitConsole/nunit3-console.tests/nunit3-console.tests.csproj @@ -12,7 +12,7 @@ - + diff --git a/src/NUnitEngine/mock-assembly/mock-assembly.csproj b/src/NUnitEngine/mock-assembly/mock-assembly.csproj index b7b576a24..23fc1041f 100644 --- a/src/NUnitEngine/mock-assembly/mock-assembly.csproj +++ b/src/NUnitEngine/mock-assembly/mock-assembly.csproj @@ -11,7 +11,7 @@ 7 - + diff --git a/src/NUnitEngine/notest-assembly/notest-assembly.csproj b/src/NUnitEngine/notest-assembly/notest-assembly.csproj index a21f76baf..ef03a5512 100644 --- a/src/NUnitEngine/notest-assembly/notest-assembly.csproj +++ b/src/NUnitEngine/notest-assembly/notest-assembly.csproj @@ -7,6 +7,6 @@ ..\..\..\bin\$(Configuration)\ - + \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/Drivers/NUnitNetStandardDriverTests.cs b/src/NUnitEngine/nunit.engine.tests/Drivers/NUnitNetStandardDriverTests.cs new file mode 100644 index 000000000..a0532d95e --- /dev/null +++ b/src/NUnitEngine/nunit.engine.tests/Drivers/NUnitNetStandardDriverTests.cs @@ -0,0 +1,145 @@ +// *********************************************************************** +// Copyright (c) 2014 Charlie Poole, Rob Prouse +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// *********************************************************************** + +#if NETCOREAPP + +using System; +using System.Collections.Generic; +using System.Xml; +using NUnit.Tests.Assemblies; +using NUnit.Framework; +using NUnit.Engine.Extensibility; + +namespace NUnit.Engine.Drivers.Tests +{ + [TestOf(typeof(NUnitNetStandardDriver))] + public class NUnitNetStandardDriverTests + { + private const string MOCK_ASSEMBLY = "mock-assembly.dll"; + private const string MISSING_FILE = "junk.dll"; + private const string NUNIT_FRAMEWORK = "nunit.framework"; + private const string LOAD_MESSAGE = "Method called without calling Load first"; + + private IDictionary _settings = new Dictionary(); + + private IFrameworkDriver _driver; + private string _mockAssemblyPath; + + [SetUp] + public void CreateDriver() + { + _mockAssemblyPath = System.IO.Path.Combine(TestContext.CurrentContext.TestDirectory, MOCK_ASSEMBLY); + _driver = new NUnitNetStandardDriver(); + + } + + [Test] + public void Load_GoodFile_ReturnsRunnableSuite() + { + var result = XmlHelper.CreateXmlNode(_driver.Load(_mockAssemblyPath, _settings)); + + Assert.That(result.Name, Is.EqualTo("test-suite")); + Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly")); + Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable")); + Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString())); + Assert.That(result.SelectNodes("test-suite").Count, Is.EqualTo(0), "Load result should not have child tests"); + } + + [Test] + public void Explore_AfterLoad_ReturnsRunnableSuite() + { + _driver.Load(_mockAssemblyPath, _settings); + var result = XmlHelper.CreateXmlNode(_driver.Explore(TestFilter.Empty.Text)); + + Assert.That(result.Name, Is.EqualTo("test-suite")); + Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly")); + Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable")); + Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString())); + Assert.That(result.SelectNodes("test-suite").Count, Is.GreaterThan(0), "Explore result should have child tests"); + } + + [Test] + public void ExploreTestsAction_WithoutLoad_ThrowsInvalidOperationException() + { + var ex = Assert.Catch(() => _driver.Explore(TestFilter.Empty.Text)); + if (ex is System.Reflection.TargetInvocationException) + ex = ex.InnerException; + Assert.That(ex, Is.TypeOf()); + Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); + } + + [Test] + public void CountTestsAction_AfterLoad_ReturnsCorrectCount() + { + _driver.Load(_mockAssemblyPath, _settings); + Assert.That(_driver.CountTestCases(TestFilter.Empty.Text), Is.EqualTo(MockAssembly.Tests)); + } + + [Test] + public void CountTestsAction_WithoutLoad_ThrowsInvalidOperationException() + { + var ex = Assert.Catch(() => _driver.CountTestCases(TestFilter.Empty.Text)); + if (ex is System.Reflection.TargetInvocationException) + ex = ex.InnerException; + Assert.That(ex, Is.TypeOf()); + Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); + } + + [Test] + public void RunTestsAction_AfterLoad_ReturnsRunnableSuite() + { + _driver.Load(_mockAssemblyPath, _settings); + var result = XmlHelper.CreateXmlNode(_driver.Run(new NullListener(), TestFilter.Empty.Text)); + + Assert.That(result.Name, Is.EqualTo("test-suite")); + Assert.That(result.GetAttribute("type"), Is.EqualTo("Assembly")); + Assert.That(result.GetAttribute("runstate"), Is.EqualTo("Runnable")); + Assert.That(result.GetAttribute("testcasecount"), Is.EqualTo(MockAssembly.Tests.ToString())); + Assert.That(result.GetAttribute("result"), Is.EqualTo("Failed")); + Assert.That(result.GetAttribute("passed"), Is.EqualTo(MockAssembly.Passed.ToString())); + Assert.That(result.GetAttribute("failed"), Is.EqualTo(MockAssembly.Failed.ToString())); + Assert.That(result.GetAttribute("skipped"), Is.EqualTo(MockAssembly.Skipped.ToString())); + Assert.That(result.GetAttribute("inconclusive"), Is.EqualTo(MockAssembly.Inconclusive.ToString())); + Assert.That(result.SelectNodes("test-suite").Count, Is.GreaterThan(0), "Explore result should have child tests"); + } + + [Test] + public void RunTestsAction_WithoutLoad_ThrowsInvalidOperationException() + { + var ex = Assert.Catch(() => _driver.Run(new NullListener(), TestFilter.Empty.Text)); + if (ex is System.Reflection.TargetInvocationException) + ex = ex.InnerException; + Assert.That(ex, Is.TypeOf()); + Assert.That(ex.Message, Is.EqualTo(LOAD_MESSAGE)); + } + + public class NullListener : ITestEventListener + { + public void OnTestEvent(string testEvent) + { + // No action + } + } + } +} +#endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj index 782cd7bbb..12109f0e6 100644 --- a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj +++ b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj @@ -4,7 +4,6 @@ nunit.engine.tests net35;netcoreapp1.1;netcoreapp2.0 Exe - false ..\..\..\bin\$(Configuration)\ true @@ -20,11 +19,11 @@ - + - + diff --git a/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs b/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs index 1a01d1e6e..ed9c76e30 100644 --- a/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs +++ b/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs @@ -31,7 +31,7 @@ namespace NUnit.Engine /// /// The TestRun class encapsulates an ongoing test run. /// -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_3 [Serializable] #endif public class AsyncTestEngineResult : ITestRun diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs index 7141087d9..e9925c918 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnitNetStandardDriver.cs @@ -1,5 +1,5 @@ // *********************************************************************** -// Copyright (c) 2016 Charlie Poole +// Copyright (c) 2016 Charlie Poole, Rob Prouse // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD using System; using System.Linq; using System.Collections.Generic; @@ -160,7 +160,7 @@ public string Explore(string filter) return ExecuteMethod(EXPLORE_METHOD, filter) as string; } - #region Helper Methods +#region Helper Methods void CheckLoadWasCalled() { @@ -199,7 +199,7 @@ object ExecuteMethod(MethodInfo method, params object[] args) return method.Invoke(_frameworkController, args); } - #endregion +#endregion } } #endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs b/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs index e105c97a3..2cc718316 100644 --- a/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs +++ b/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs @@ -32,11 +32,7 @@ namespace NUnit.Engine.Internal public class Logger : ILogger { private readonly static string TIME_FMT = "HH:mm:ss.fff"; -#if NETSTANDARD1_3 - private readonly static string TRACE_FMT = "{0} {1,-5} {2}: {3}"; -#else private readonly static string TRACE_FMT = "{0} {1,-5} [{2,2}] {3}: {4}"; -#endif private string name; private string fullname; @@ -79,13 +75,6 @@ public void Error(string message, params object[] args) Log(InternalTraceLevel.Error, message, args); } - //public void Error(string message, Exception ex) - //{ - // if (service.Level >= InternalTraceLevel.Error) - // { - // service.Log(InternalTraceLevel.Error, message, name, ex); - // } - //} #endregion #region Warning @@ -170,8 +159,10 @@ private void WriteLog(InternalTraceLevel level, string message) writer.WriteLine(TRACE_FMT, DateTime.Now.ToString(TIME_FMT), level == InternalTraceLevel.Verbose ? "Debug" : level.ToString(), -#if !NETSTANDARD1_3 +#if NET20 System.Threading.Thread.CurrentThread.ManagedThreadId, +#elif NETSTANDARD + Environment.CurrentManagedThreadId, #endif name, message); } diff --git a/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs b/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs index ddb9f041e..f6b408a0f 100644 --- a/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs +++ b/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs @@ -1,5 +1,5 @@ // *********************************************************************** -// Copyright (c) 2018 Charlie Poole, Rob Prouse +// Copyright (c) 2007 Charlie Poole, Rob Prouse // // Permission is hereby granted, free of charge, to any person obtaining // a copy of this software and associated documentation files (the diff --git a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs index 12a4932d3..1114a30f3 100644 --- a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs @@ -105,7 +105,7 @@ protected override TestEngineResult LoadPackage() if (packages.Count == 0) packages.Add(TestPackage); - var driverService = GetDriverService(); + var driverService = Services.GetService(); foreach (var subPackage in packages) { @@ -134,11 +134,6 @@ protected override TestEngineResult LoadPackage() return result; } - private IDriverService GetDriverService() - { - return Services.GetService(); - } - private static string LoadDriver(IFrameworkDriver driver, string testFile, TestPackage subPackage) { try diff --git a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs index 99b3804bf..0fa0e20f9 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs @@ -38,11 +38,11 @@ public class MasterTestRunner : ITestRunner private const string TEST_RUN_ELEMENT = "test-run"; private readonly ITestEngineRunner _engineRunner; private readonly IServiceLocator _services; -#if NET20 - private readonly IRuntimeFrameworkService _runtimeService; -#endif #if !NETSTANDARD1_3 private readonly ExtensionService _extensionService; +#if !NETSTANDARD2_0 + private readonly IRuntimeFrameworkService _runtimeService; +#endif #endif private readonly IProjectService _projectService; private bool _disposed; @@ -57,7 +57,7 @@ public MasterTestRunner(IServiceLocator services, TestPackage package) // Get references to the services we use _projectService = _services.GetService(); -#if NET20 +#if !NETSTANDARD1_3 && !NETSTANDARD2_0 _runtimeService = _services.GetService(); #endif #if !NETSTANDARD1_3 @@ -68,7 +68,7 @@ public MasterTestRunner(IServiceLocator services, TestPackage package) InitializePackage(); } - #region Properties +#region Properties /// /// The TestPackage for which this is the runner @@ -88,9 +88,9 @@ protected bool IsPackageLoaded get { return LoadResult != null; } } - #endregion +#endregion - #region ITestRunner Members +#region ITestRunner Members /// /// Get a flag indicating whether a test is running @@ -191,9 +191,9 @@ public XmlNode Explore(TestFilter filter) return LoadResult.Xml; } - #endregion +#endregion - #region IDisposable +#region IDisposable public void Dispose() { @@ -215,9 +215,9 @@ private void Dispose(bool disposing) } } - #endregion +#endregion - #region Helper Methods +#region Helper Methods /// /// Check the package settings, expand projects and diff --git a/src/NUnitEngine/nunit.engine/RuntimeFramework.cs b/src/NUnitEngine/nunit.engine/RuntimeFramework.cs index ed64fe9af..5ddcfe0a8 100644 --- a/src/NUnitEngine/nunit.engine/RuntimeFramework.cs +++ b/src/NUnitEngine/nunit.engine/RuntimeFramework.cs @@ -687,82 +687,6 @@ private static void AddMonoFramework(Version frameworkVersion, string profile) } #endregion - - #region Helper Methods - .NET - - private static void FindDotNetFrameworks() - { - // Handle Version 1.0, using a different registry key - FindExtremelyOldDotNetFrameworkVersions(); - - RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\NET Framework Setup\NDP"); - if (key != null) - { - foreach (string name in key.GetSubKeyNames()) - { - if (name.StartsWith("v") && name != "v4.0") // v4.0 is a duplicate, legacy key - { - var versionKey = key.OpenSubKey(name); - if (versionKey == null) continue; - - if (name.StartsWith("v4", StringComparison.Ordinal)) - // Version 4 and 4.5 - AddDotNetFourFrameworkVersions(versionKey); - else if (CheckInstallDword(versionKey)) - // Versions 1.1 through 3.5 - AddDotNetFramework(new Version(name.Substring(1))); - } - } - } - } - - private static void FindExtremelyOldDotNetFrameworkVersions() - { - RegistryKey key = Registry.LocalMachine.OpenSubKey(@"Software\Microsoft\.NETFramework\policy\v1.0"); - if (key != null) - foreach (string build in key.GetValueNames()) - _availableFrameworks.Add(new RuntimeFramework(RuntimeType.Net, new Version("1.0." + build))); - } - - // Note: this method cannot be generalized past V4, because (a) it has - // specific code for detecting .NET 4.5 and (b) we don't know what - // microsoft will do in the future - private static void AddDotNetFourFrameworkVersions(RegistryKey versionKey) - { - foreach (string profile in new string[] { "Full", "Client" }) - { - var profileKey = versionKey.OpenSubKey(profile); - if (profileKey == null) continue; - - if (CheckInstallDword(profileKey)) - { - AddDotNetFramework(new Version(4, 0), profile); - - var release = (int)profileKey.GetValue("Release", 0); - if (release > 0) // TODO: Other higher versions? - AddDotNetFramework(new Version(4, 5)); - - return; //If full profile found, return and don't check for client profile - } - } - } - - private static void AddDotNetFramework(Version version) - { - _availableFrameworks.Add(new RuntimeFramework(RuntimeType.Net, version)); - } - - private static void AddDotNetFramework(Version version, string profile) - { - _availableFrameworks.Add(new RuntimeFramework(RuntimeType.Net, version, profile)); - } - - private static bool CheckInstallDword(RegistryKey key) - { - return ((int)key.GetValue("Install", 0) == 1); - } - - #endregion } } #endif \ No newline at end of file From 3f04977de97e1cf3b2dc1832d5d47ea1b13e3c69 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Mon, 15 Oct 2018 20:59:14 -0400 Subject: [PATCH 21/29] Enable the ExtensionAssemblyTests for the .NET Standard 2.0 target --- .../Extensibility/ExtensionAssemblyTests.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NUnitEngine/nunit.engine.tests/Extensibility/ExtensionAssemblyTests.cs b/src/NUnitEngine/nunit.engine.tests/Extensibility/ExtensionAssemblyTests.cs index 57d429264..78233c4f7 100644 --- a/src/NUnitEngine/nunit.engine.tests/Extensibility/ExtensionAssemblyTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Extensibility/ExtensionAssemblyTests.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETCOREAPP1_1 && !NETCOREAPP2_0 +#if !NETCOREAPP1_1 using System; using System.Reflection; using NUnit.Engine.Extensibility; @@ -69,6 +69,7 @@ public void AssemblyVersion() Assert.That(_ea.AssemblyVersion, Is.EqualTo(THIS_ASSEMBLY_VERSION)); } +#if !NETCOREAPP2_0 [Test] public void TargetFramework() { @@ -78,6 +79,7 @@ public void TargetFramework() Assert.That(_ea.TargetFramework, Has.Property(nameof(RuntimeFramework.FrameworkVersion)).EqualTo(new Version(2, 0))); }); } +#endif } } #endif \ No newline at end of file From ed7b18b99342543924843ad781cf15d205c68d87 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Thu, 18 Oct 2018 19:07:30 -0400 Subject: [PATCH 22/29] Updates based on feedback from code reviews --- NuGet.config | 2 +- nuget/engine/nunit.engine.api.nuspec | 1 - nuget/engine/nunit.engine.nuspec | 1 + .../nunit3-console/ConsoleRunner.cs | 4 ++- .../nunit.engine.api/TestEngineActivator.cs | 31 ------------------- .../Internal/PathUtilTests.cs | 15 +++++++-- .../Services/ExtensionServiceTests.cs | 22 +++++++++++++ .../nunit.engine/Internal/Logging/Logger.cs | 2 +- .../nunit.engine/RuntimeFramework.cs | 2 +- .../nunit.engine/Services/ExtensionService.cs | 22 +++++++++++++ .../nunit.engine/Services/ResultService.cs | 2 +- .../nunit.engine/Services/ServiceManager.cs | 4 --- .../nunit.engine/nunit.engine.csproj | 3 ++ 13 files changed, 67 insertions(+), 44 deletions(-) diff --git a/NuGet.config b/NuGet.config index a90607ba0..e2b46bc4e 100644 --- a/NuGet.config +++ b/NuGet.config @@ -2,7 +2,7 @@ - + diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index 19be78a52..45d01bc12 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -24,7 +24,6 @@ - diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index a32d2d66e..dc549c9ec 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -24,6 +24,7 @@ + diff --git a/src/NUnitConsole/nunit3-console/ConsoleRunner.cs b/src/NUnitConsole/nunit3-console/ConsoleRunner.cs index b17a16919..4155cce44 100644 --- a/src/NUnitConsole/nunit3-console/ConsoleRunner.cs +++ b/src/NUnitConsole/nunit3-console/ConsoleRunner.cs @@ -313,7 +313,9 @@ private void DisplayExtensionList() foreach (var node in ep.Extensions) { _outWriter.Write(" Extension: "); - _outWriter.Write(ColorStyle.Value, $"{node.TypeName} (.NET {node.TargetFramework?.FrameworkVersion})"); + _outWriter.Write(ColorStyle.Value, $"{node.TypeName}"); + if(node.TargetFramework != null) + _outWriter.Write(ColorStyle.Value, $"(.NET {node.TargetFramework?.FrameworkVersion})"); _outWriter.WriteLine(node.Enabled ? "" : " (Disabled)"); foreach (var prop in node.PropertyNames) { diff --git a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs index 7bfdef62b..fd2b52ddc 100644 --- a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs +++ b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs @@ -120,37 +120,6 @@ private static Assembly FindNewestEngine(Version minVersion) } } - // Check for an engine that has been installed as part of a - // development project using NuGet. - // - // NOTE: This code assumes that we are working in - // bin/Debug or bin/Release and includes a lot of - // knowledge of how we handle nuget packages. It - // is only intended for use while a new runner is - // under development. - if (newestAssemblyFound == null) - { - var packages = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../packages"); - - if (Directory.Exists(packages)) - { - var packagesDir = new DirectoryInfo(packages); - foreach (var subDir in packagesDir.GetDirectories("NUnit.Engine.*")) - { - // In future, we will use tools directory but currently we use lib - path = Path.Combine(Path.Combine(subDir.FullName, "tools"), DefaultAssemblyName); - newestAssemblyFound = CheckPathForEngine(path, minVersion, ref newestVersionFound, null); - if (newestAssemblyFound != null) - break; - - path = Path.Combine(Path.Combine(subDir.FullName, "lib"), DefaultAssemblyName); - newestAssemblyFound = CheckPathForEngine(path, minVersion, ref newestVersionFound, null); - if (newestAssemblyFound != null) - break; - } - } - } - return newestAssemblyFound; } diff --git a/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs b/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs index 9188e1163..6d4f3c667 100644 --- a/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Internal/PathUtilTests.cs @@ -23,6 +23,7 @@ using System; using System.IO; +using System.Runtime.InteropServices; using NUnit.Framework; namespace NUnit.Engine.Internal.Tests @@ -86,11 +87,20 @@ public void Canonicalize() PathUtils.Canonicalize( @"folder1\folder2\..\..\..\file.tmp" ) ); } -#if !NETCOREAPP1_1 && !NETCOREAPP2_0 [Test] - [Platform(Exclude="Linux,UNIX,MacOSX")] public void RelativePath() { + bool windows = false; + +#if NETCOREAPP1_1 || NETCOREAPP2_0 + windows = RuntimeInformation.IsOSPlatform(OSPlatform.Windows); +#else + var platform = Environment.OSVersion.Platform; + windows = platform == PlatformID.Win32NT; +#endif + + Assume.That(windows, Is.True); + Assert.AreEqual( @"folder2\folder3", PathUtils.RelativePath( @"c:\folder1", @"c:\folder1\folder2\folder3" ) ); Assert.AreEqual( @"..\folder2\folder3", PathUtils.RelativePath( @@ -122,7 +132,6 @@ public void RelativePath() Assert.AreEqual(@"..\Folder2\folder3", PathUtils.RelativePath( @"c:\folder1", @"C:\Folder2\folder3")); } -#endif [Test] public void SamePathOrUnder() diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs index 580654077..f091619e9 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs @@ -26,6 +26,7 @@ using System.Linq; using NUnit.Framework; using NUnit.Engine.Extensibility; +using System.IO; namespace NUnit.Engine.Services.Tests { @@ -145,6 +146,27 @@ public void DisabledExtensionMayBeEnabled() Has.One.Property(nameof(ExtensionNode.TypeName)).EqualTo("NUnit.Engine.Tests.DummyDisabledExtension") .And.Property(nameof(ExtensionNode.Enabled)).True); } + + [Test] + public void FailsGracefullyLoadingOtherFrameworkExtensionAssembly() + { +#if NETCOREAPP2_0 + string other = "net35"; // Attempt to load the .NET 3.5 version of the extensions from the .NET Core 2.0 tests +#elif NET35 + string other = "netcoreapp2.0"; // Attempt to load the .NET Core 2.0 version of the extensions from the .NET 3.5 tests +#endif + var file = new FileInfo(GetType().Assembly.Location); + var assemblyName = Path.Combine(Path.Combine(file.Directory.Parent.FullName, other), "nunit.engine.tests.dll"); + Assert.That(assemblyName, Does.Exist); + + Assert.That(() => + { + var service = new ExtensionService(); + service.FindExtensionPoints(typeof(TestEngine).Assembly); + service.FindExtensionPoints(typeof(ITestEngine).Assembly); + service.FindExtensionsInAssembly(new ExtensionAssembly(assemblyName, false)); + }, Throws.TypeOf()); + } } } #endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs b/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs index 2cc718316..d65919fc1 100644 --- a/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs +++ b/src/NUnitEngine/nunit.engine/Internal/Logging/Logger.cs @@ -161,7 +161,7 @@ private void WriteLog(InternalTraceLevel level, string message) level == InternalTraceLevel.Verbose ? "Debug" : level.ToString(), #if NET20 System.Threading.Thread.CurrentThread.ManagedThreadId, -#elif NETSTANDARD +#else Environment.CurrentManagedThreadId, #endif name, message); diff --git a/src/NUnitEngine/nunit.engine/RuntimeFramework.cs b/src/NUnitEngine/nunit.engine/RuntimeFramework.cs index 5ddcfe0a8..ed709b238 100644 --- a/src/NUnitEngine/nunit.engine/RuntimeFramework.cs +++ b/src/NUnitEngine/nunit.engine/RuntimeFramework.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs index 59b15908a..44e146ba2 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs @@ -431,6 +431,28 @@ internal void FindExtensionsInAssembly(ExtensionAssembly assembly) { log.Info("Scanning {0} assembly for Extensions", assembly.FilePath); + var entry = Assembly.GetEntryAssembly(); + if (entry != null) + { + var extension = new TargetFrameworkHelper(assembly.FilePath); + var runner = new TargetFrameworkHelper(entry.Location); + if (runner.FrameworkName?.StartsWith(".NETStandard") == true) + { + throw new NUnitEngineException("Test runners must target .NET Core or .NET Framework, not .NET Standard"); + } + else if (runner.FrameworkName?.StartsWith(".NETCoreApp") == true) + { + if (extension.FrameworkName?.StartsWith(".NETStandard") != true && extension.FrameworkName?.StartsWith(".NETCoreApp") != true) + { + throw new NUnitEngineException(".NET Core runners require .NET Core or .NET Standard extensions"); + } + } + else if (extension.FrameworkName?.StartsWith(".NETCoreApp") == true) + { + throw new NUnitEngineException(".NET Framework runners cannot load .NET Core extensions"); + } + } + IRuntimeFramework assemblyTargetFramework = null; #if !NETSTANDARD2_0 var currentFramework = RuntimeFramework.CurrentFramework; diff --git a/src/NUnitEngine/nunit.engine/Services/ResultService.cs b/src/NUnitEngine/nunit.engine/Services/ResultService.cs index 1541cf18d..24efd2959 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultService.cs @@ -27,7 +27,7 @@ namespace NUnit.Engine.Services { - public class ResultService : Service, IResultService + public class ResultService : Service, IResultService { #if NETSTANDARD1_3 || NETSTANDARD2_0 private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases" }; diff --git a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs index 35df2d665..eae4fe771 100644 --- a/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs +++ b/src/NUnitEngine/nunit.engine/Services/ServiceManager.cs @@ -54,11 +54,7 @@ public IService GetService( Type serviceType ) else foreach( IService service in _services ) { -#if NETSTANDARD1_3 - if (serviceType.GetTypeInfo().IsAssignableFrom(service.GetType().GetTypeInfo())) -#else if( serviceType.IsInstanceOfType( service ) ) -#endif { _serviceIndex[serviceType] = service; theService = service; diff --git a/src/NUnitEngine/nunit.engine/nunit.engine.csproj b/src/NUnitEngine/nunit.engine/nunit.engine.csproj index 88de4c892..428bb13a3 100644 --- a/src/NUnitEngine/nunit.engine/nunit.engine.csproj +++ b/src/NUnitEngine/nunit.engine/nunit.engine.csproj @@ -15,6 +15,9 @@ + + + From db6c6e9fdb42ad9d9eff75401812627ba7981bb4 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Thu, 18 Oct 2018 20:21:04 -0400 Subject: [PATCH 23/29] Refactor and fully test A can load B extensions --- .../Services/ExtensionServiceTests.cs | 95 ++++++++++++++++++- .../nunit.engine/Services/ExtensionService.cs | 54 ++++++----- 2 files changed, 125 insertions(+), 24 deletions(-) diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs index f091619e9..bb1d300f8 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs @@ -27,6 +27,8 @@ using NUnit.Framework; using NUnit.Engine.Extensibility; using System.IO; +using System.Reflection; +using System.Collections.Generic; namespace NUnit.Engine.Services.Tests { @@ -155,8 +157,7 @@ public void FailsGracefullyLoadingOtherFrameworkExtensionAssembly() #elif NET35 string other = "netcoreapp2.0"; // Attempt to load the .NET Core 2.0 version of the extensions from the .NET 3.5 tests #endif - var file = new FileInfo(GetType().Assembly.Location); - var assemblyName = Path.Combine(Path.Combine(file.Directory.Parent.FullName, other), "nunit.engine.tests.dll"); + var assemblyName = Path.Combine(GetSiblingDirectory(other), "nunit.engine.tests.dll"); Assert.That(assemblyName, Does.Exist); Assert.That(() => @@ -167,6 +168,96 @@ public void FailsGracefullyLoadingOtherFrameworkExtensionAssembly() service.FindExtensionsInAssembly(new ExtensionAssembly(assemblyName, false)); }, Throws.TypeOf()); } + + [TestCaseSource(nameof(ValidCombos))] + public void ValidTargetFrameworkCombinations(FrameworkCombo combo) + { + Assert.That(() => ExtensionService.ValidateTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly), + Throws.Nothing); + } + + [TestCaseSource(nameof(InvalidCombos))] + public void InvalidTargetFrameworkCombinations(FrameworkCombo combo) + { + Assert.That(() => ExtensionService.ValidateTargetFramework(combo.RunnerAssembly, combo.ExtensionAssembly), + Throws.TypeOf()); + } + + // ExtensionAssembly is internal, so cannot be part of the public test parameters + public struct FrameworkCombo + { + internal Assembly RunnerAssembly { get; } + internal ExtensionAssembly ExtensionAssembly { get; } + + internal FrameworkCombo(Assembly runnerAsm, ExtensionAssembly extensionAsm) + { + RunnerAssembly = runnerAsm; + ExtensionAssembly = extensionAsm; + } + + public override string ToString() => + $"{RunnerAssembly.GetName()}:{ExtensionAssembly.AssemblyName}"; + } + + public static IEnumerable ValidCombos() + { +#if NETCOREAPP2_0 + Assembly netstandard = typeof(ExtensionService).Assembly; + Assembly netcore = Assembly.GetExecutingAssembly(); + + var extNetStandard = new ExtensionAssembly(netstandard.Location, false); + var extNetCore = new ExtensionAssembly(netcore.Location, false); + + yield return new TestCaseData(new FrameworkCombo(netcore, extNetStandard)).SetName("ValidCombo(.NET Core, .NET Standard)"); + yield return new TestCaseData(new FrameworkCombo(netcore, extNetCore)).SetName("ValidCombo(.NET Core, .Net Core)"); +#else + Assembly netFramework = typeof(ExtensionService).Assembly; + + var extNetFramework = new ExtensionAssembly(netFramework.Location, false); + + yield return new TestCaseData(new FrameworkCombo(netFramework, extNetFramework)).SetName("ValidCombo(.NET Framework, .NET Framework)"); +#endif + } + + public static IEnumerable InvalidCombos() + { +#if NETCOREAPP2_0 + Assembly netstandard = typeof(ExtensionService).Assembly; + Assembly netcore = Assembly.GetExecutingAssembly(); + + var extNetStandard = new ExtensionAssembly(netstandard.Location, false); + var extNetCore = new ExtensionAssembly(netcore.Location, false); + var extNetFramework = new ExtensionAssembly(Path.Combine(GetSiblingDirectory("net35"), "nunit.engine.dll"), false); + + yield return new TestCaseData(new FrameworkCombo(netstandard, extNetStandard)).SetName("InvalidCombo(.NET Standard, .NET Standard)"); + yield return new TestCaseData(new FrameworkCombo(netstandard, extNetCore)).SetName("InvalidCombo(.NET Standard, .NET Core)"); + yield return new TestCaseData(new FrameworkCombo(netstandard, extNetFramework)).SetName("InvalidCombo(.NET Standard, .NET Framework)"); + yield return new TestCaseData(new FrameworkCombo(netcore, extNetFramework)).SetName("InvalidCombo(.NET Core, .NET Standard)"); +#else + Assembly netFramework = typeof(ExtensionService).Assembly; + + var extNetStandard = new ExtensionAssembly(Path.Combine(GetSiblingDirectory("netstandard2.0"), "nunit.engine.dll"), false); + var extNetCore = new ExtensionAssembly(Path.Combine(GetSiblingDirectory("netcoreapp2.0"), "nunit.engine.tests.dll"), false); + + yield return new TestCaseData(new FrameworkCombo(netFramework, extNetStandard)).SetName("InvalidCombo(.NET Framework, .NET Standard)"); + yield return new TestCaseData(new FrameworkCombo(netFramework, extNetCore)).SetName("InvalidCombo(.NET Framework, .NET Core)"); +#endif + + } + + /// + /// Returns a directory in the parent directory that the current test assembly is in. This + /// is used to load assemblies that target different frameworks than the current tests. So + /// if these tests are in bin\release\net35 and dir is netstandard2.0, this will return + /// bin\release\netstandard2.0. + /// + /// The sibling directory + /// + private static string GetSiblingDirectory(string dir) + { + var file = new FileInfo(typeof(ExtensionServiceTests).Assembly.Location); + return Path.Combine(file.Directory.Parent.FullName, dir); + } } } #endif \ No newline at end of file diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs index 44e146ba2..78bbf8219 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs @@ -431,27 +431,7 @@ internal void FindExtensionsInAssembly(ExtensionAssembly assembly) { log.Info("Scanning {0} assembly for Extensions", assembly.FilePath); - var entry = Assembly.GetEntryAssembly(); - if (entry != null) - { - var extension = new TargetFrameworkHelper(assembly.FilePath); - var runner = new TargetFrameworkHelper(entry.Location); - if (runner.FrameworkName?.StartsWith(".NETStandard") == true) - { - throw new NUnitEngineException("Test runners must target .NET Core or .NET Framework, not .NET Standard"); - } - else if (runner.FrameworkName?.StartsWith(".NETCoreApp") == true) - { - if (extension.FrameworkName?.StartsWith(".NETStandard") != true && extension.FrameworkName?.StartsWith(".NETCoreApp") != true) - { - throw new NUnitEngineException(".NET Core runners require .NET Core or .NET Standard extensions"); - } - } - else if (extension.FrameworkName?.StartsWith(".NETCoreApp") == true) - { - throw new NUnitEngineException(".NET Framework runners cannot load .NET Core extensions"); - } - } + ValidateTargetFramework(Assembly.GetEntryAssembly(), assembly); IRuntimeFramework assemblyTargetFramework = null; #if !NETSTANDARD2_0 @@ -537,7 +517,37 @@ internal void FindExtensionsInAssembly(ExtensionAssembly assembly) } } -#endregion + /// + /// Checks that the target framework of the current runner can load the extension assembly. For example, .NET Core + /// cannot load .NET Framework assemblies and visa-versa. + /// + /// The executing runner + /// The extension we are attempting to load + internal static void ValidateTargetFramework(Assembly runnerAsm, ExtensionAssembly extensionAsm) + { + if (runnerAsm == null) + return; + + var extHelper = new TargetFrameworkHelper(extensionAsm.FilePath); + var runnerHelper = new TargetFrameworkHelper(runnerAsm.Location); + if (runnerHelper.FrameworkName?.StartsWith(".NETStandard") == true) + { + throw new NUnitEngineException("Test runners must target .NET Core or .NET Framework, not .NET Standard"); + } + else if (runnerHelper.FrameworkName?.StartsWith(".NETCoreApp") == true) + { + if (extHelper.FrameworkName?.StartsWith(".NETStandard") != true && extHelper.FrameworkName?.StartsWith(".NETCoreApp") != true) + { + throw new NUnitEngineException(".NET Core runners require .NET Core or .NET Standard extensions"); + } + } + else if (extHelper.FrameworkName?.StartsWith(".NETCoreApp") == true || extHelper.FrameworkName?.StartsWith(".NETStandard") == true) + { + throw new NUnitEngineException(".NET Framework runners cannot load .NET Core extensions"); + } + } + + #endregion } } #endif \ No newline at end of file From 7d928ec2acd155cb95ee314869dcb6bfd1adbe49 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Thu, 18 Oct 2018 20:28:37 -0400 Subject: [PATCH 24/29] .NET Framework runners should be able to load .NET Standard extensions --- .../nunit.engine.tests/Services/ExtensionServiceTests.cs | 3 ++- src/NUnitEngine/nunit.engine/Services/ExtensionService.cs | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs index bb1d300f8..cdf5d2917 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs @@ -214,8 +214,10 @@ public static IEnumerable ValidCombos() Assembly netFramework = typeof(ExtensionService).Assembly; var extNetFramework = new ExtensionAssembly(netFramework.Location, false); + var extNetStandard = new ExtensionAssembly(Path.Combine(GetSiblingDirectory("netstandard2.0"), "nunit.engine.dll"), false); yield return new TestCaseData(new FrameworkCombo(netFramework, extNetFramework)).SetName("ValidCombo(.NET Framework, .NET Framework)"); + yield return new TestCaseData(new FrameworkCombo(netFramework, extNetStandard)).SetName("ValidCombo(.NET Framework, .NET Standard)"); #endif } @@ -239,7 +241,6 @@ public static IEnumerable InvalidCombos() var extNetStandard = new ExtensionAssembly(Path.Combine(GetSiblingDirectory("netstandard2.0"), "nunit.engine.dll"), false); var extNetCore = new ExtensionAssembly(Path.Combine(GetSiblingDirectory("netcoreapp2.0"), "nunit.engine.tests.dll"), false); - yield return new TestCaseData(new FrameworkCombo(netFramework, extNetStandard)).SetName("InvalidCombo(.NET Framework, .NET Standard)"); yield return new TestCaseData(new FrameworkCombo(netFramework, extNetCore)).SetName("InvalidCombo(.NET Framework, .NET Core)"); #endif diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs index 78bbf8219..04aaabccb 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs @@ -541,7 +541,7 @@ internal static void ValidateTargetFramework(Assembly runnerAsm, ExtensionAssemb throw new NUnitEngineException(".NET Core runners require .NET Core or .NET Standard extensions"); } } - else if (extHelper.FrameworkName?.StartsWith(".NETCoreApp") == true || extHelper.FrameworkName?.StartsWith(".NETStandard") == true) + else if (extHelper.FrameworkName?.StartsWith(".NETCoreApp") == true) { throw new NUnitEngineException(".NET Framework runners cannot load .NET Core extensions"); } From 40a66e41706874c8dc93b539ea43a0edc75182ad Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Thu, 25 Oct 2018 20:35:43 +0100 Subject: [PATCH 25/29] Add xml transforms to .NET Standard 2.0, resolve Working dir issues --- build.cake | 27 +++++++++++++++-- .../nunit.engine.api/TestEngineActivator.cs | 25 ++++++++++++---- .../Services/ResultServiceTests.cs | 2 +- .../Services/ResultWriters/XmlOutputTest.cs | 8 ++--- .../XmlTransformResultWriterTests.cs | 2 +- .../WorkingDirectoryTests.cs | 30 +++++++++++++++++++ .../nunit.engine.tests.csproj | 3 ++ .../nunit.engine/Services/ResultService.cs | 4 +-- .../ResultWriters/XmlTransformResultWriter.cs | 2 +- 9 files changed, 84 insertions(+), 19 deletions(-) create mode 100644 src/NUnitEngine/nunit.engine.tests/WorkingDirectoryTests.cs diff --git a/build.cake b/build.cake index 08641287f..9f3fc0972 100644 --- a/build.cake +++ b/build.cake @@ -245,10 +245,10 @@ Task("TestNet20Console") }); ////////////////////////////////////////////////////////////////////// -// TEST NETSTANDARD ENGINE +// TEST NETSTANDARD 1.3 ENGINE ////////////////////////////////////////////////////////////////////// -Task("TestNetStandardEngine") +Task("TestNetStandard13Engine") .Description("Tests the .NET Standard Engine") .IsDependentOn("Build") .OnError(exception => { ErrorDetail.Add(exception.Message); }) @@ -260,6 +260,25 @@ Task("TestNetStandardEngine") { FrameworkVersion = "1.1.2" //1.1.2 as the highest version currently available on Appveyor }); + } + else + { + Warning("Skipping .NET Standard tests because .NET Core is not installed"); + } + }); + +////////////////////////////////////////////////////////////////////// +// TEST NETSTANDARD 2.0 ENGINE +////////////////////////////////////////////////////////////////////// + +Task("TestNetStandard20Engine") + .Description("Tests the .NET Standard Engine") + .IsDependentOn("Build") + .OnError(exception => { ErrorDetail.Add(exception.Message); }) + .Does(() => + { + if(IsDotNetCoreInstalled) + { DotNetCoreExecute(NETCOREAPP20_BIN_DIR + ENGINE_TESTS, "", new DotNetCoreExecuteSettings { FrameworkVersion = "2.0.6" @@ -271,6 +290,7 @@ Task("TestNetStandardEngine") } }); + ////////////////////////////////////////////////////////////////////// // PACKAGE ////////////////////////////////////////////////////////////////////// @@ -550,7 +570,8 @@ Task("Test") .Description("Builds and tests the engine and console runner") .IsDependentOn("TestNet20Engine") .IsDependentOn("TestNet20Console") - .IsDependentOn("TestNetStandardEngine"); + .IsDependentOn("TestNetStandard13Engine") + .IsDependentOn("TestNetStandard20Engine"); Task("Package") .Description("Packages the engine and console runner") diff --git a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs index fd2b52ddc..177757254 100644 --- a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs +++ b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs @@ -39,7 +39,7 @@ public static class TestEngineActivator private const string DefaultAssemblyName = "nunit.engine.dll"; internal const string DefaultTypeName = "NUnit.Engine.TestEngine"; -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD1_3 /// /// Create an instance of the test engine. /// @@ -51,8 +51,23 @@ public static ITestEngine CreateInstance() var engineType = assembly.GetType(DefaultTypeName); return Activator.CreateInstance(engineType) as ITestEngine; } + +#elif NETSTANDARD2_0 + /// + /// Create an instance of the test engine. + /// + /// An + public static ITestEngine CreateInstance() + { + var apiLocation = typeof(TestEngineActivator).Assembly.Location; + var directoryName = Path.GetDirectoryName(apiLocation); + var enginePath = directoryName == null ? DefaultAssemblyName : Path.Combine(directoryName, DefaultAssemblyName); + var assembly = Assembly.LoadFrom(enginePath); + var engineType = assembly.GetType(DefaultTypeName); + return Activator.CreateInstance(engineType) as ITestEngine; + } #else - #region Public Methods +#region Public Methods /// /// Create an instance of the test engine. @@ -93,9 +108,9 @@ public static ITestEngine CreateInstance(Version minVersion, bool unused = false } } - #endregion +#endregion - #region Private Methods +#region Private Methods private static Assembly FindNewestEngine(Version minVersion) { @@ -172,7 +187,7 @@ private static string FindEngineInRegistry(RegistryKey rootKey, string subKey) catch (Exception) { } return null; } - #endregion +#endregion #endif } } diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs index ede3b1389..5f2ac85ef 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultServiceTests.cs @@ -53,7 +53,7 @@ public void ServiceIsStarted() [Test] public void AvailableFormats() { -#if NETCOREAPP1_1 || NETCOREAPP2_0 +#if NETCOREAPP1_1 Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases" })); #else Assert.That(_resultService.Formats, Is.EquivalentTo(new string[] { "nunit3", "cases", "user" })); diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs index 772070702..5365396d6 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlOutputTest.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETCOREAPP1_1 && !NETSTANDARD2_0 +#if !NETCOREAPP1_1 using System; using System.Collections.Generic; using System.IO; @@ -49,7 +49,6 @@ namespace NUnit.Engine.Services.ResultWriters.Tests public abstract class XmlOutputTest { private ITestEngine engine; - private string localDirectory; protected TestEngineResult EngineResult { get; private set; } @@ -59,15 +58,12 @@ public abstract class XmlOutputTest // Method used by derived classes to get the path to a file name protected string GetLocalPath(string fileName) { - return Path.Combine(localDirectory, fileName); + return Path.Combine(TestContext.CurrentContext.TestDirectory, fileName); } [OneTimeSetUp] public void InitializeTestEngineResult() { - // Save the local directory - used by GetLocalPath - Uri uri = new Uri(Assembly.GetExecutingAssembly().CodeBase); - localDirectory = Path.GetDirectoryName(uri.LocalPath); AssemblyPath = GetLocalPath(AssemblyName); diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs index 81b69749f..ca736d27c 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ResultWriters/XmlTransformResultWriterTests.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETCOREAPP1_1 && !NETCOREAPP2_0 +#if !NETCOREAPP1_1 using System.IO; using NUnit.Framework; diff --git a/src/NUnitEngine/nunit.engine.tests/WorkingDirectoryTests.cs b/src/NUnitEngine/nunit.engine.tests/WorkingDirectoryTests.cs new file mode 100644 index 000000000..79ef6a369 --- /dev/null +++ b/src/NUnitEngine/nunit.engine.tests/WorkingDirectoryTests.cs @@ -0,0 +1,30 @@ +using System.IO; +using NUnit.Framework; + +namespace NUnit.Engine.Tests +{ + [NonParallelizable] + class WorkingDirectoryTests + { + private string _origWorkingDir; + + [OneTimeSetUp] + public void SetWorkingDirToTempDir() + { + _origWorkingDir = Directory.GetCurrentDirectory(); + Directory.SetCurrentDirectory(Path.GetTempPath()); + } + + [OneTimeTearDown] + public void ResetWorkingDir() + { + Directory.SetCurrentDirectory(_origWorkingDir); + } + + [Test] + public void EngineCanBeCreatedFromAnyWorkingDirectory() + { + Assert.That(() => TestEngineActivator.CreateInstance(), Throws.Nothing); + } + } +} diff --git a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj index 12109f0e6..55f814866 100644 --- a/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj +++ b/src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj @@ -41,6 +41,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/src/NUnitEngine/nunit.engine/Services/ResultService.cs b/src/NUnitEngine/nunit.engine/Services/ResultService.cs index 24efd2959..24516f013 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultService.cs @@ -29,7 +29,7 @@ namespace NUnit.Engine.Services { public class ResultService : Service, IResultService { -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD1_3 private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases" }; #else private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases", "user" }; @@ -74,7 +74,7 @@ public IResultWriter GetResultWriter(string format, object[] args) return new NUnit3XmlResultWriter(); case "cases": return new TestCaseResultWriter(); -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_3 case "user": return new XmlTransformResultWriter(args); #endif diff --git a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs index fbeab6e81..279471ab9 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_3 using System; using System.IO; using System.Text; From bf57ae54d4806c02fb33672220c8a7c4195bc1aa Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Mon, 19 Nov 2018 21:12:06 -0500 Subject: [PATCH 26/29] Switch to .NET Standard 1.6 from 1.3 and get the assembly load test working --- build.cake | 2 +- nuget/engine/nunit.engine.api.nuspec | 5 +++-- nuget/engine/nunit.engine.nuspec | 10 +++++----- src/CommonAssemblyInfo.cs | 4 ++-- .../Exceptions/NUnitEngineException.cs | 6 +++--- .../Exceptions/NUnitEngineNotFoundException.cs | 2 +- .../Exceptions/NUnitEngineUnloadException.cs | 6 +++--- .../Extensibility/IDriverFactory.cs | 2 +- .../nunit.engine.api/ITestRunner.cs | 2 +- .../nunit.engine.api/TestEngineActivator.cs | 16 +++++++++------- src/NUnitEngine/nunit.engine.api/TestFilter.cs | 2 +- .../nunit.engine.api/TestPackage.cs | 2 +- .../TestSelectionParserException.cs | 6 +++--- .../nunit.engine.api/nunit.engine.api.csproj | 7 +++++-- .../nunit.engine/Agents/RemoteTestAgent.cs | 2 +- .../Agents/RemoteTestAgentProxy.cs | 2 +- .../nunit.engine/Agents/TestAgent.cs | 2 +- .../nunit.engine/AsyncTestEngineResult.cs | 2 +- .../nunit.engine/CallbackHandler.cs | 2 +- .../Drivers/NUnit2DriverFactory.cs | 2 +- .../Drivers/NUnit3DriverFactory.cs | 2 +- .../Drivers/NUnit3FrameworkDriver.cs | 2 +- .../Extensibility/ExtensionAssembly.cs | 2 +- .../Extensibility/ExtensionNode.cs | 2 +- .../Extensibility/ExtensionPoint.cs | 2 +- .../Extensibility/ExtensionSelector.cs | 2 +- .../Extensibility/IExtensionAssembly.cs | 2 +- src/NUnitEngine/nunit.engine/IDriverService.cs | 2 +- .../nunit.engine/ITestEngineRunner.cs | 2 +- .../nunit.engine/Internal/AssemblyHelper.cs | 2 +- .../Internal/DomainDetailsBuilder.cs | 2 +- .../nunit.engine/Internal/DomainUsage.cs | 2 +- .../Internal/NUnitConfiguration.cs | 4 ++-- .../nunit.engine/Internal/ProcessModel.cs | 2 +- .../Internal/ProvidedPathsAssemblyResolver.cs | 2 +- .../DotNetFrameworkLocator.cs | 2 +- .../nunit.engine/Internal/ServerBase.cs | 2 +- .../nunit.engine/Internal/SettingsStore.cs | 4 ++-- ...tils.ObservableServerChannelSinkProvider.cs | 2 +- .../nunit.engine/Internal/TcpChannelUtils.cs | 2 +- .../nunit.engine/Properties/AssemblyInfo.cs | 2 +- .../nunit.engine/RunTestsCallbackHandler.cs | 2 +- .../nunit.engine/Runners/AbstractTestRunner.cs | 4 ++-- .../Runners/AggregatingTestRunner.cs | 4 ++-- .../nunit.engine/Runners/DirectTestRunner.cs | 8 ++++---- .../nunit.engine/Runners/LocalTestRunner.cs | 2 +- .../nunit.engine/Runners/MasterTestRunner.cs | 18 +++++++++--------- .../Runners/MultipleTestDomainRunner.cs | 2 +- .../Runners/MultipleTestProcessRunner.cs | 2 +- .../Runners/ParallelTaskWorkerPool.cs | 2 +- .../nunit.engine/Runners/ProcessRunner.cs | 2 +- .../nunit.engine/Runners/TestDomainRunner.cs | 2 +- .../Runners/TestEventDispatcher.cs | 4 ++-- .../nunit.engine/Services/AgentDataBase.cs | 2 +- .../Services/DefaultTestRunnerFactory.cs | 8 ++++---- .../nunit.engine/Services/DomainManager.cs | 2 +- .../nunit.engine/Services/DriverService.cs | 6 +++--- .../nunit.engine/Services/ExtensionService.cs | 2 +- .../Services/InProcessTestRunnerFactory.cs | 2 +- .../nunit.engine/Services/ProjectService.cs | 2 +- .../nunit.engine/Services/ResultService.cs | 12 ++++++------ .../ResultWriters/NUnit3XmlResultWriter.cs | 2 +- .../ResultWriters/XmlTransformResultWriter.cs | 2 +- .../Services/RuntimeFrameworkService.cs | 2 +- .../nunit.engine/Services/TestAgency.cs | 2 +- src/NUnitEngine/nunit.engine/TestEngine.cs | 4 ++-- .../nunit.engine/TestEngineResult.cs | 4 ++-- .../nunit.engine/nunit.engine.csproj | 6 +++--- 68 files changed, 123 insertions(+), 117 deletions(-) diff --git a/build.cake b/build.cake index 9f3fc0972..323144126 100644 --- a/build.cake +++ b/build.cake @@ -46,7 +46,7 @@ var ENGINE_API_CSPROJ = PROJECT_DIR + "src/NUnitEngine/nunit.engine.api/nunit.en var ENGINE_TESTS_CSPROJ = PROJECT_DIR + "src/NUnitEngine/nunit.engine.tests/nunit.engine.tests.csproj"; var NETFX_FRAMEWORKS = new [] { "net20", "net35" }; //Production code targets net20, tests target nets35 -var NETSTANDARD_FRAMEWORKS = new [] { "netstandard1.3", "netstandard2.0" }; +var NETSTANDARD_FRAMEWORKS = new [] { "netstandard1.6", "netstandard2.0" }; var NETCORE_FRAMEWORKS = new [] { "netcoreapp1.1", "netcoreapp2.0" }; // Test Runner diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index 45d01bc12..eab4d426b 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -19,8 +19,9 @@ Copyright (c) 2018 Charlie Poole, Rob Prouse - + + @@ -31,7 +32,7 @@ - + \ No newline at end of file diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index dc549c9ec..336f9884f 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -19,7 +19,7 @@ Copyright (c) 2018 Charlie Poole, Rob Prouse - + @@ -50,10 +50,10 @@ - - - - + + + + diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index 576960cf2..dc86c71b5 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -35,7 +35,7 @@ [assembly: AssemblyConfiguration(".NET 3.5 Debug")] #elif NET20 [assembly: AssemblyConfiguration(".NET 2.0 Debug")] -#elif NETSTANDARD1_3 || NETCOREAPP1_1 +#elif NETSTANDARD1_6 || NETCOREAPP1_1 [assembly: AssemblyConfiguration(".NET Standard 1.3 Debug")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 [assembly: AssemblyConfiguration(".NET Standard 2.0 Debug")] @@ -47,7 +47,7 @@ [assembly: AssemblyConfiguration(".NET 3.5")] #elif NET20 [assembly: AssemblyConfiguration(".NET 2.0")] -#elif NETSTANDARD1_3 || NETCOREAPP1_1 +#elif NETSTANDARD1_6 || NETCOREAPP1_1 [assembly: AssemblyConfiguration(".NET Standard 1.3")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 [assembly: AssemblyConfiguration(".NET Standard 2.0")] diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs index aa1812835..a399c5439 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineException.cs @@ -22,7 +22,7 @@ // *********************************************************************** using System; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System.Runtime.Serialization; #endif @@ -33,7 +33,7 @@ namespace NUnit.Engine /// called with improper values or when a particular facility /// is not available. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class NUnitEngineException : Exception @@ -52,7 +52,7 @@ public NUnitEngineException(string message, Exception innerException) : base(mes { } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Serialization constructor /// diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs index 5d81b536d..778c6c12a 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineNotFoundException.cs @@ -28,7 +28,7 @@ namespace NUnit.Engine /// /// The exception that is thrown if a valid test engine is not found /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class NUnitEngineNotFoundException : Exception diff --git a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs index f0bae47d1..02f632619 100644 --- a/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs +++ b/src/NUnitEngine/nunit.engine.api/Exceptions/NUnitEngineUnloadException.cs @@ -23,7 +23,7 @@ using System; using System.Collections.Generic; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System.Runtime.Serialization; #endif @@ -35,7 +35,7 @@ namespace NUnit.Engine /// but one or more errors were encountered when attempting to unload /// and shut down the test run cleanly. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class NUnitEngineUnloadException : NUnitEngineException //Inherits from NUnitEngineException for backwards compatibility of calling runners @@ -66,7 +66,7 @@ public NUnitEngineUnloadException(ICollection aggregatedExceptions) : AggregatedExceptions = aggregatedExceptions; } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Serialization constructor. /// diff --git a/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs b/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs index e308c6245..c6d846b9e 100644 --- a/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs +++ b/src/NUnitEngine/nunit.engine.api/Extensibility/IDriverFactory.cs @@ -40,7 +40,7 @@ public interface IDriverFactory /// An AssemblyName referring to the possible test framework. bool IsSupportedTestFramework(AssemblyName reference); -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD1_6 || NETSTANDARD2_0 /// /// Gets a driver for a given test assembly and a framework /// which the assembly is already known to reference. diff --git a/src/NUnitEngine/nunit.engine.api/ITestRunner.cs b/src/NUnitEngine/nunit.engine.api/ITestRunner.cs index f83f93d7d..763076292 100644 --- a/src/NUnitEngine/nunit.engine.api/ITestRunner.cs +++ b/src/NUnitEngine/nunit.engine.api/ITestRunner.cs @@ -77,7 +77,7 @@ public interface ITestRunner : IDisposable /// An XmlNode giving the result of the test execution XmlNode Run(ITestEventListener listener, TestFilter filter); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Start a run of the tests in the loaded TestPackage. The tests are run /// asynchronously and the listener interface is notified as it progresses. diff --git a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs index 177757254..87e76a88c 100644 --- a/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs +++ b/src/NUnitEngine/nunit.engine.api/TestEngineActivator.cs @@ -39,19 +39,21 @@ public static class TestEngineActivator private const string DefaultAssemblyName = "nunit.engine.dll"; internal const string DefaultTypeName = "NUnit.Engine.TestEngine"; -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 /// /// Create an instance of the test engine. /// /// An public static ITestEngine CreateInstance() { - var assemblyName = new AssemblyName(DefaultAssemblyName); + var apiLocation = typeof(TestEngineActivator).GetTypeInfo().Assembly.Location; + var directoryName = Path.GetDirectoryName(apiLocation); + var enginePath = directoryName == null ? DefaultAssemblyName : Path.Combine(directoryName, DefaultAssemblyName); + var assemblyName = System.Runtime.Loader.AssemblyLoadContext.GetAssemblyName(enginePath); var assembly = Assembly.Load(assemblyName); var engineType = assembly.GetType(DefaultTypeName); return Activator.CreateInstance(engineType) as ITestEngine; } - #elif NETSTANDARD2_0 /// /// Create an instance of the test engine. @@ -67,7 +69,7 @@ public static ITestEngine CreateInstance() return Activator.CreateInstance(engineType) as ITestEngine; } #else -#region Public Methods + #region Public Methods /// /// Create an instance of the test engine. @@ -108,9 +110,9 @@ public static ITestEngine CreateInstance(Version minVersion, bool unused = false } } -#endregion + #endregion -#region Private Methods + #region Private Methods private static Assembly FindNewestEngine(Version minVersion) { @@ -187,7 +189,7 @@ private static string FindEngineInRegistry(RegistryKey rootKey, string subKey) catch (Exception) { } return null; } -#endregion + #endregion #endif } } diff --git a/src/NUnitEngine/nunit.engine.api/TestFilter.cs b/src/NUnitEngine/nunit.engine.api/TestFilter.cs index 9c7cfb0dc..3e56506c6 100644 --- a/src/NUnitEngine/nunit.engine.api/TestFilter.cs +++ b/src/NUnitEngine/nunit.engine.api/TestFilter.cs @@ -32,7 +32,7 @@ namespace NUnit.Engine /// In the console runner, filters serve only to carry this /// XML representation, as all filtering is done by the engine. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class TestFilter diff --git a/src/NUnitEngine/nunit.engine.api/TestPackage.cs b/src/NUnitEngine/nunit.engine.api/TestPackage.cs index 913505479..3be4ef3e4 100644 --- a/src/NUnitEngine/nunit.engine.api/TestPackage.cs +++ b/src/NUnitEngine/nunit.engine.api/TestPackage.cs @@ -33,7 +33,7 @@ namespace NUnit.Engine /// tests for one or more test files. TestPackages may be named /// or anonymous, depending on how they are constructed. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class TestPackage diff --git a/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs b/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs index 284189ad7..4b4684b17 100644 --- a/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs +++ b/src/NUnitEngine/nunit.engine.api/TestSelectionParserException.cs @@ -22,7 +22,7 @@ // *********************************************************************** using System; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System.Runtime.Serialization; #endif @@ -32,7 +32,7 @@ namespace NUnit.Engine /// TestSelectionParserException is thrown when an error /// is found while parsing the selection expression. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class TestSelectionParserException : Exception @@ -49,7 +49,7 @@ public TestSelectionParserException(string message) : base(message) { } /// public TestSelectionParserException(string message, Exception innerException) : base(message, innerException) { } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Serialization constructor /// diff --git a/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj b/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj index bb2fcf1de..053ab121d 100644 --- a/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj +++ b/src/NUnitEngine/nunit.engine.api/nunit.engine.api.csproj @@ -2,7 +2,7 @@ NUnit.Engine nunit.engine.api - net20;netstandard1.3;netstandard2.0 + net20;netstandard1.6;netstandard2.0 false ..\..\..\bin\$(Configuration)\ true @@ -14,7 +14,10 @@ - + + + + diff --git a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs index 77a93bd76..d4bc35237 100644 --- a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs +++ b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgent.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Runtime.Remoting.Channels; using System.Runtime.Remoting.Channels.Tcp; diff --git a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs index c4dadf707..d8366902c 100644 --- a/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs +++ b/src/NUnitEngine/nunit.engine/Agents/RemoteTestAgentProxy.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Text; diff --git a/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs b/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs index e26657960..dcbee290d 100644 --- a/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs +++ b/src/NUnitEngine/nunit.engine/Agents/TestAgent.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; namespace NUnit.Engine.Agents diff --git a/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs b/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs index ed9c76e30..070abf2a0 100644 --- a/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs +++ b/src/NUnitEngine/nunit.engine/AsyncTestEngineResult.cs @@ -31,7 +31,7 @@ namespace NUnit.Engine /// /// The TestRun class encapsulates an ongoing test run. /// -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [Serializable] #endif public class AsyncTestEngineResult : ITestRun diff --git a/src/NUnitEngine/nunit.engine/CallbackHandler.cs b/src/NUnitEngine/nunit.engine/CallbackHandler.cs index f64acede1..ae7fc242f 100644 --- a/src/NUnitEngine/nunit.engine/CallbackHandler.cs +++ b/src/NUnitEngine/nunit.engine/CallbackHandler.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Web.UI; diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs index ef7224d43..28e2f0090 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnit2DriverFactory.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Reflection; diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs index 64fc6ad9d..7db7a557f 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnit3DriverFactory.cs @@ -42,7 +42,7 @@ public bool IsSupportedTestFramework(AssemblyName reference) return NUNIT_FRAMEWORK.Equals(reference.Name, StringComparison.OrdinalIgnoreCase) && reference.Version.Major == 3; } -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 /// /// Gets a driver for a given test assembly and a framework /// which the assembly is already known to reference. diff --git a/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs b/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs index d9c59a5aa..bd18c52ac 100644 --- a/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs +++ b/src/NUnitEngine/nunit.engine/Drivers/NUnit3FrameworkDriver.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.IO; diff --git a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionAssembly.cs b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionAssembly.cs index 76353954b..6b80a1f5d 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionAssembly.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionAssembly.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.IO; using Mono.Cecil; diff --git a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs index 939f6da82..d7852ea37 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionNode.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.Collections.Generic; using System.Reflection; diff --git a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs index 1f7c08d34..d47691569 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionPoint.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.Collections.Generic; diff --git a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionSelector.cs b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionSelector.cs index e49f951d7..55f4ce339 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/ExtensionSelector.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/ExtensionSelector.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using NUnit.Common; namespace NUnit.Engine.Extensibility diff --git a/src/NUnitEngine/nunit.engine/Extensibility/IExtensionAssembly.cs b/src/NUnitEngine/nunit.engine/Extensibility/IExtensionAssembly.cs index 183ce0378..a778e58e3 100644 --- a/src/NUnitEngine/nunit.engine/Extensibility/IExtensionAssembly.cs +++ b/src/NUnitEngine/nunit.engine/Extensibility/IExtensionAssembly.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; namespace NUnit.Engine.Extensibility diff --git a/src/NUnitEngine/nunit.engine/IDriverService.cs b/src/NUnitEngine/nunit.engine/IDriverService.cs index a943e63eb..6edc436b7 100644 --- a/src/NUnitEngine/nunit.engine/IDriverService.cs +++ b/src/NUnitEngine/nunit.engine/IDriverService.cs @@ -32,7 +32,7 @@ namespace NUnit.Engine /// public interface IDriverService { -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 /// /// Get a driver suitable for use with a particular test assembly. /// diff --git a/src/NUnitEngine/nunit.engine/ITestEngineRunner.cs b/src/NUnitEngine/nunit.engine/ITestEngineRunner.cs index caadb4045..a0b896a79 100644 --- a/src/NUnitEngine/nunit.engine/ITestEngineRunner.cs +++ b/src/NUnitEngine/nunit.engine/ITestEngineRunner.cs @@ -68,7 +68,7 @@ public interface ITestEngineRunner : IDisposable /// A TestEngineResult giving the result of the test execution TestEngineResult Run(ITestEventListener listener, TestFilter filter); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Start a run of the tests in the loaded TestPackage. The tests are run /// asynchronously and the listener interface is notified as it progresses. diff --git a/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs b/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs index 35445f467..a356673d7 100644 --- a/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs +++ b/src/NUnitEngine/nunit.engine/Internal/AssemblyHelper.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.IO; using System.Reflection; diff --git a/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs b/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs index 485bb0833..209eacdd8 100644 --- a/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs +++ b/src/NUnitEngine/nunit.engine/Internal/DomainDetailsBuilder.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Reflection; diff --git a/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs b/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs index 25b92b51b..b28332977 100644 --- a/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs +++ b/src/NUnitEngine/nunit.engine/Internal/DomainUsage.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 namespace NUnit.Engine.Internal { /// diff --git a/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs b/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs index d3b5025a0..d14b2a63b 100644 --- a/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs +++ b/src/NUnitEngine/nunit.engine/Internal/NUnitConfiguration.cs @@ -36,7 +36,7 @@ public static class NUnitConfiguration { #region Public Properties -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 #region EngineDirectory private static string _engineDirectory; @@ -65,7 +65,7 @@ public static string ApplicationDirectory if (_applicationDirectory == null) { _applicationDirectory = Path.Combine( -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 Environment.GetEnvironmentVariable(RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "LocalAppData" : "HOME"), #else Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), diff --git a/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs b/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs index fc61460fc..0a2fe70d8 100644 --- a/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs +++ b/src/NUnitEngine/nunit.engine/Internal/ProcessModel.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; namespace NUnit.Engine.Internal diff --git a/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs b/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs index 12b77c327..8e2aa0f96 100644 --- a/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs +++ b/src/NUnitEngine/nunit.engine/Internal/ProvidedPathsAssemblyResolver.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.Collections.Generic; using System.Reflection; diff --git a/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs b/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs index f6b408a0f..05065de78 100644 --- a/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs +++ b/src/NUnitEngine/nunit.engine/Internal/RuntimeFrameworks/DotNetFrameworkLocator.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using Microsoft.Win32; diff --git a/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs b/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs index 5842781af..83a04f0d2 100644 --- a/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs +++ b/src/NUnitEngine/nunit.engine/Internal/ServerBase.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Threading; using System.Runtime.Remoting; diff --git a/src/NUnitEngine/nunit.engine/Internal/SettingsStore.cs b/src/NUnitEngine/nunit.engine/Internal/SettingsStore.cs index 59a52c48a..624610257 100644 --- a/src/NUnitEngine/nunit.engine/Internal/SettingsStore.cs +++ b/src/NUnitEngine/nunit.engine/Internal/SettingsStore.cs @@ -27,7 +27,7 @@ using System.IO; using System.Text; using System.Xml; -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 using System.Xml.Linq; #endif @@ -110,7 +110,7 @@ public void SaveSettings() if (!Directory.Exists(dirPath)) Directory.CreateDirectory(dirPath); -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 var settings = new XElement("Settings"); List keys = new List(_settings.Keys); diff --git a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs index 47e3f9c68..c29f9898e 100644 --- a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs +++ b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.ObservableServerChannelSinkProvider.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections; using System.IO; diff --git a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs index 226187ec2..8e019816d 100644 --- a/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs +++ b/src/NUnitEngine/nunit.engine/Internal/TcpChannelUtils.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Runtime.Remoting; diff --git a/src/NUnitEngine/nunit.engine/Properties/AssemblyInfo.cs b/src/NUnitEngine/nunit.engine/Properties/AssemblyInfo.cs index 22af054ee..fd876709e 100644 --- a/src/NUnitEngine/nunit.engine/Properties/AssemblyInfo.cs +++ b/src/NUnitEngine/nunit.engine/Properties/AssemblyInfo.cs @@ -5,7 +5,7 @@ // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 [assembly: AssemblyTitle("NUnit .NET Standard Engine")] [assembly: AssemblyDescription("Provides a common interface for loading, exploring and running NUnit tests in .NET Core and .NET Standard")] #else diff --git a/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs b/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs index 647282cd3..72b906148 100644 --- a/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs +++ b/src/NUnitEngine/nunit.engine/RunTestsCallbackHandler.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Diagnostics; using System.IO; diff --git a/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs index e5288c815..5042e4cdb 100644 --- a/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/AbstractTestRunner.cs @@ -109,7 +109,7 @@ public virtual void UnloadPackage() /// A TestEngineResult giving the result of the test execution protected abstract TestEngineResult RunTests(ITestEventListener listener, TestFilter filter); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Start a run of the tests in the loaded TestPackage, returning immediately. /// The tests are run asynchronously and the listener interface is notified @@ -205,7 +205,7 @@ public TestEngineResult Run(ITestEventListener listener, TestFilter filter) return RunTests(listener, filter); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Start a run of the tests in the loaded TestPackage. The tests are run /// asynchronously and the listener interface is notified as it progresses. diff --git a/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs index 13cda0159..107ea6579 100644 --- a/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/AggregatingTestRunner.cs @@ -159,7 +159,7 @@ protected override TestEngineResult RunTests(ITestEventListener listener, TestFi bool disposeRunners = TestPackage.GetSetting(EnginePackageSettings.DisposeRunners, false); -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 RunTestsSequentially(listener, filter, results, disposeRunners); #else if (LevelOfParallelism <= 1) @@ -186,7 +186,7 @@ private void RunTestsSequentially(ITestEventListener listener, TestFilter filter } } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 private void RunTestsInParallel(ITestEventListener listener, TestFilter filter, List results, bool disposeRunners) { var workerPool = new ParallelTaskWorkerPool(LevelOfParallelism); diff --git a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs index 1114a30f3..e3b91ba5a 100644 --- a/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/DirectTestRunner.cs @@ -37,7 +37,7 @@ public abstract class DirectTestRunner : AbstractTestRunner { private readonly List _drivers = new List(); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 private ProvidedPathsAssemblyResolver _assemblyResolver; protected AppDomain TestDomain { get; set; } @@ -45,7 +45,7 @@ public abstract class DirectTestRunner : AbstractTestRunner public DirectTestRunner(IServiceLocator services, TestPackage package) : base(services, package) { -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 // Bypass the resolver if not in the default AppDomain. This prevents trying to use the resolver within // NUnit's own automated tests (in a test AppDomain) which does not make sense anyway. if (AppDomain.CurrentDomain.IsDefaultAppDomain()) @@ -114,7 +114,7 @@ protected override TestEngineResult LoadPackage() string targetFramework = subPackage.GetSetting(InternalEnginePackageSettings.ImageTargetFrameworkName, (string)null); bool skipNonTestAssemblies = subPackage.GetSetting(EnginePackageSettings.SkipNonTestAssemblies, false); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 if (_assemblyResolver != null && !TestDomain.IsDefaultAppDomain() && subPackage.GetSetting(InternalEnginePackageSettings.ImageRequiresDefaultAppDomainAssemblyResolver, false)) { @@ -204,7 +204,7 @@ protected override TestEngineResult RunTests(ITestEventListener listener, TestFi result.Add(driverResult); } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 if (_assemblyResolver != null) { var packages = TestPackage.SubPackages; diff --git a/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs index 1e38ea0a5..84ef11aed 100644 --- a/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/LocalTestRunner.cs @@ -32,7 +32,7 @@ public class LocalTestRunner : DirectTestRunner { public LocalTestRunner(IServiceLocator services, TestPackage package) : base(services, package) { -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 this.TestDomain = AppDomain.CurrentDomain; #endif } diff --git a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs index 0fa0e20f9..5f4996464 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MasterTestRunner.cs @@ -38,7 +38,7 @@ public class MasterTestRunner : ITestRunner private const string TEST_RUN_ELEMENT = "test-run"; private readonly ITestEngineRunner _engineRunner; private readonly IServiceLocator _services; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 private readonly ExtensionService _extensionService; #if !NETSTANDARD2_0 private readonly IRuntimeFrameworkService _runtimeService; @@ -57,10 +57,10 @@ public MasterTestRunner(IServiceLocator services, TestPackage package) // Get references to the services we use _projectService = _services.GetService(); -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 _runtimeService = _services.GetService(); #endif -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 _extensionService = _services.GetService(); #endif _engineRunner = _services.GetService().MakeTestRunner(package); @@ -154,7 +154,7 @@ public XmlNode Run(ITestEventListener listener, TestFilter filter) } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 /// /// Start a run of the tests in the loaded TestPackage. The tests are run /// asynchronously and the listener interface is notified as it progresses. @@ -238,7 +238,7 @@ private void InitializePackage() // Info will be left behind in the package about // each contained assembly, which will subsequently // be used to determine how to run the assembly. -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 _runtimeService.SelectRuntimeFramework(TestPackage); #endif @@ -303,7 +303,7 @@ private void ExpandProjects(TestPackage package) // runner is putting invalid values into the package. private void ValidatePackageSettings() { -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 // TODO: How do we validate runtime framework for .NET Standard 2.0? +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 // TODO: How do we validate runtime framework for .NET Standard 2.0? var frameworkSetting = TestPackage.GetSetting(EnginePackageSettings.RuntimeFramework, ""); if (frameworkSetting.Length > 0) { @@ -366,7 +366,7 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter var eventDispatcher = new TestEventDispatcher(); if (listener != null) eventDispatcher.Listeners.Add(listener); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 foreach (var extension in _extensionService.GetExtensions()) eventDispatcher.Listeners.Add(extension); #endif @@ -383,7 +383,7 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter // These are inserted in reverse order, since each is added as the first child. InsertFilterElement(result.Xml, filter); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 InsertCommandLineElement(result.Xml); result.Xml.AddAttribute("engine-version", Assembly.GetExecutingAssembly().GetName().Version.ToString()); result.Xml.AddAttribute("clr-version", Environment.Version.ToString()); @@ -404,7 +404,7 @@ private TestEngineResult RunTests(ITestEventListener listener, TestFilter filter return result; } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 private AsyncTestEngineResult RunTestsAsync(ITestEventListener listener, TestFilter filter) { var testRun = new AsyncTestEngineResult(); diff --git a/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs index de2a70662..c2b1691de 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MultipleTestDomainRunner.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 namespace NUnit.Engine.Runners { /// diff --git a/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs b/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs index d3807c137..101046887 100644 --- a/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/MultipleTestProcessRunner.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; namespace NUnit.Engine.Runners diff --git a/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs b/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs index ad572614b..589a68c49 100644 --- a/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs +++ b/src/NUnitEngine/nunit.engine/Runners/ParallelTaskWorkerPool.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs b/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs index 6c759022d..af856515a 100644 --- a/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/ProcessRunner.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Net.Sockets; using NUnit.Common; diff --git a/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs b/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs index 141c69333..5b63152d1 100644 --- a/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs +++ b/src/NUnitEngine/nunit.engine/Runners/TestDomainRunner.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using NUnit.Engine.Services; namespace NUnit.Engine.Runners diff --git a/src/NUnitEngine/nunit.engine/Runners/TestEventDispatcher.cs b/src/NUnitEngine/nunit.engine/Runners/TestEventDispatcher.cs index 7bf81edd9..1c3e914be 100644 --- a/src/NUnitEngine/nunit.engine/Runners/TestEventDispatcher.cs +++ b/src/NUnitEngine/nunit.engine/Runners/TestEventDispatcher.cs @@ -30,7 +30,7 @@ namespace NUnit.Engine.Runners /// TestEventDispatcher is used to send test events to a number of listeners /// public class TestEventDispatcher : -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 MarshalByRefObject, #endif ITestEventListener @@ -53,7 +53,7 @@ public void OnTestEvent(string report) } } -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 public override object InitializeLifetimeService() { return null; diff --git a/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs b/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs index d9c6ca4cc..5dfad9a4b 100644 --- a/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs +++ b/src/NUnitEngine/nunit.engine/Services/AgentDataBase.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.Diagnostics; diff --git a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs index d5c8a983a..7589e5039 100644 --- a/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/DefaultTestRunnerFactory.cs @@ -33,7 +33,7 @@ namespace NUnit.Engine.Services /// public class DefaultTestRunnerFactory : InProcessTestRunnerFactory, ITestRunnerFactory { -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 private IProjectService _projectService; #endif @@ -41,7 +41,7 @@ public class DefaultTestRunnerFactory : InProcessTestRunnerFactory, ITestRunnerF public override void StartService() { -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 // TestRunnerFactory requires the ProjectService _projectService = ServiceContext.GetService(); @@ -75,7 +75,7 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) if (PathUtils.IsAssemblyFileType(testFile)) assemblyCount++; -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 else if (_projectService.CanLoadFrom(testFile)) projectCount++; #endif @@ -90,7 +90,7 @@ public override ITestEngineRunner MakeTestRunner(TestPackage package) if (projectCount > 1 || projectCount > 0 && assemblyCount > 0) return new AggregatingTestRunner(ServiceContext, package); -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD1_6 || NETSTANDARD2_0 if (projectCount > 0 || package.SubPackages.Count > 1) return new AggregatingTestRunner(ServiceContext, package); diff --git a/src/NUnitEngine/nunit.engine/Services/DomainManager.cs b/src/NUnitEngine/nunit.engine/Services/DomainManager.cs index 95b291fb2..7dbeb3e22 100644 --- a/src/NUnitEngine/nunit.engine/Services/DomainManager.cs +++ b/src/NUnitEngine/nunit.engine/Services/DomainManager.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.IO; using System.Collections.Generic; diff --git a/src/NUnitEngine/nunit.engine/Services/DriverService.cs b/src/NUnitEngine/nunit.engine/Services/DriverService.cs index 0606a63ca..47af005eb 100644 --- a/src/NUnitEngine/nunit.engine/Services/DriverService.cs +++ b/src/NUnitEngine/nunit.engine/Services/DriverService.cs @@ -51,7 +51,7 @@ public class DriverService : Service, IDriverService /// The value of any TargetFrameworkAttribute on the assembly, or null /// True if non-test assemblies should simply be skipped rather than reporting an error /// -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 public IFrameworkDriver GetDriver(string assemblyPath, bool skipNonTestAssemblies) #else public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string targetFramework, bool skipNonTestAssemblies) @@ -63,7 +63,7 @@ public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string if (!PathUtils.IsAssemblyFileType(assemblyPath)) return new InvalidAssemblyFrameworkDriver(assemblyPath, "File type is not supported"); -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 if (targetFramework != null) { // This takes care of an issue with Roslyn. It may get fixed, but we still @@ -97,7 +97,7 @@ public IFrameworkDriver GetDriver(AppDomain domain, string assemblyPath, string foreach (var reference in references) { if (factory.IsSupportedTestFramework(reference)) -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD1_6 || NETSTANDARD2_0 return factory.GetDriver(reference); #else return factory.GetDriver(domain, reference); diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs index 04aaabccb..84e0b9baa 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.Collections.Generic; using System.IO; diff --git a/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs b/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs index b0a7293ea..57773a4b3 100644 --- a/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs +++ b/src/NUnitEngine/nunit.engine/Services/InProcessTestRunnerFactory.cs @@ -44,7 +44,7 @@ public class InProcessTestRunnerFactory : Service, ITestRunnerFactory /// An ITestEngineRunner public virtual ITestEngineRunner MakeTestRunner(TestPackage package) { -#if NETSTANDARD1_3 || NETSTANDARD2_0 +#if NETSTANDARD1_6 || NETSTANDARD2_0 return new LocalTestRunner(ServiceContext, package); #else DomainUsage domainUsage = (DomainUsage)System.Enum.Parse( diff --git a/src/NUnitEngine/nunit.engine/Services/ProjectService.cs b/src/NUnitEngine/nunit.engine/Services/ProjectService.cs index 45a48f060..2e0a27368 100644 --- a/src/NUnitEngine/nunit.engine/Services/ProjectService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ProjectService.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System.Collections.Generic; using System.IO; using NUnit.Common; diff --git a/src/NUnitEngine/nunit.engine/Services/ResultService.cs b/src/NUnitEngine/nunit.engine/Services/ResultService.cs index 24516f013..4a7e6c681 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultService.cs @@ -29,12 +29,12 @@ namespace NUnit.Engine.Services { public class ResultService : Service, IResultService { -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases" }; #else private readonly string[] BUILT_IN_FORMATS = new string[] { "nunit3", "cases", "user" }; #endif -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 private IEnumerable _extensionNodes; #endif @@ -47,7 +47,7 @@ public string[] Formats { var formatList = new List(BUILT_IN_FORMATS); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 foreach (var node in _extensionNodes) foreach (var format in node.GetValues("Format")) formatList.Add(format); @@ -74,12 +74,12 @@ public IResultWriter GetResultWriter(string format, object[] args) return new NUnit3XmlResultWriter(); case "cases": return new TestCaseResultWriter(); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 case "user": return new XmlTransformResultWriter(args); #endif default: -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 foreach (var node in _extensionNodes) foreach (var supported in node.GetValues("Format")) if (supported == format) @@ -95,7 +95,7 @@ public override void StartService() { try { -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 var extensionService = ServiceContext.GetService(); if (extensionService != null && extensionService.Status == ServiceStatus.Started) diff --git a/src/NUnitEngine/nunit.engine/Services/ResultWriters/NUnit3XmlResultWriter.cs b/src/NUnitEngine/nunit.engine/Services/ResultWriters/NUnit3XmlResultWriter.cs index 2ae765a60..4ac879a7b 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultWriters/NUnit3XmlResultWriter.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultWriters/NUnit3XmlResultWriter.cs @@ -76,7 +76,7 @@ private XmlNode GetStubResult() test.AddAttribute("start-time", DateTime.UtcNow.ToString("u")); doc.AppendChild(test); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 var cmd = doc.CreateElement("command-line"); var cdata = doc.CreateCDataSection(Environment.CommandLine); cmd.AppendChild(cdata); diff --git a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs index 279471ab9..9dd531192 100644 --- a/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs +++ b/src/NUnitEngine/nunit.engine/Services/ResultWriters/XmlTransformResultWriter.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 using System; using System.IO; using System.Text; diff --git a/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs b/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs index fa8365bb7..7a71e3f68 100644 --- a/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs +++ b/src/NUnitEngine/nunit.engine/Services/RuntimeFrameworkService.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.Collections.Generic; using System.IO; diff --git a/src/NUnitEngine/nunit.engine/Services/TestAgency.cs b/src/NUnitEngine/nunit.engine/Services/TestAgency.cs index e4692596e..c4f40115b 100644 --- a/src/NUnitEngine/nunit.engine/Services/TestAgency.cs +++ b/src/NUnitEngine/nunit.engine/Services/TestAgency.cs @@ -21,7 +21,7 @@ // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // *********************************************************************** -#if !NETSTANDARD1_3 && !NETSTANDARD2_0 +#if !NETSTANDARD1_6 && !NETSTANDARD2_0 using System; using System.IO; using System.Threading; diff --git a/src/NUnitEngine/nunit.engine/TestEngine.cs b/src/NUnitEngine/nunit.engine/TestEngine.cs index 764d37f0d..7f3d22852 100644 --- a/src/NUnitEngine/nunit.engine/TestEngine.cs +++ b/src/NUnitEngine/nunit.engine/TestEngine.cs @@ -41,7 +41,7 @@ public class TestEngine : ITestEngine public TestEngine() { Services = new ServiceContext(); -#if NETSTANDARD1_3 +#if NETSTANDARD1_6 WorkDirectory = NUnitConfiguration.ApplicationDirectory; #else WorkDirectory = Environment.CurrentDirectory; @@ -105,7 +105,7 @@ public void Initialize() Services.Add(new DriverService()); Services.Add(new RecentFilesService()); Services.Add(new TestFilterService()); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 Services.Add(new ExtensionService()); Services.Add(new ProjectService()); #if !NETSTANDARD2_0 diff --git a/src/NUnitEngine/nunit.engine/TestEngineResult.cs b/src/NUnitEngine/nunit.engine/TestEngineResult.cs index ed5c96f27..becf9a802 100644 --- a/src/NUnitEngine/nunit.engine/TestEngineResult.cs +++ b/src/NUnitEngine/nunit.engine/TestEngineResult.cs @@ -47,14 +47,14 @@ namespace NUnit.Engine /// for combining multiple TestEngineResults into one. /// /// - #if !NETSTANDARD1_3 + #if !NETSTANDARD1_6 [Serializable] #endif public class TestEngineResult { private List _xmlText = new List(); -#if !NETSTANDARD1_3 +#if !NETSTANDARD1_6 [NonSerialized] #endif private List _xmlNodes = new List(); diff --git a/src/NUnitEngine/nunit.engine/nunit.engine.csproj b/src/NUnitEngine/nunit.engine/nunit.engine.csproj index 428bb13a3..77ad85a94 100644 --- a/src/NUnitEngine/nunit.engine/nunit.engine.csproj +++ b/src/NUnitEngine/nunit.engine/nunit.engine.csproj @@ -2,7 +2,7 @@ NUnit.Engine nunit.engine - net20;netstandard1.3;netstandard2.0 + net20;netstandard1.6;netstandard2.0 false ..\..\..\bin\$(Configuration)\ true @@ -15,10 +15,10 @@ - + - + From 6dc6c781ddce3748a2c3316d1940de8daf226d44 Mon Sep 17 00:00:00 2001 From: Rob Prouse Date: Thu, 22 Nov 2018 21:22:06 -0500 Subject: [PATCH 27/29] Fixed packaging of NuGet packages --- nuget/engine/nunit.engine.api.nuspec | 2 +- nuget/engine/nunit.engine.nuspec | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nuget/engine/nunit.engine.api.nuspec b/nuget/engine/nunit.engine.api.nuspec index eab4d426b..31915b890 100644 --- a/nuget/engine/nunit.engine.api.nuspec +++ b/nuget/engine/nunit.engine.api.nuspec @@ -21,7 +21,7 @@ - + diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index 336f9884f..f12f9d8ed 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -24,7 +24,7 @@ - + From 5c9e23e192759d423a995aad61dc1c438b0fb2b0 Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Tue, 27 Nov 2018 13:08:29 +0000 Subject: [PATCH 28/29] Apply suggestions from code review --- build.cake | 6 +++--- src/CommonAssemblyInfo.cs | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/build.cake b/build.cake index 323144126..01d595efd 100644 --- a/build.cake +++ b/build.cake @@ -245,10 +245,10 @@ Task("TestNet20Console") }); ////////////////////////////////////////////////////////////////////// -// TEST NETSTANDARD 1.3 ENGINE +// TEST NETSTANDARD 1.6 ENGINE ////////////////////////////////////////////////////////////////////// -Task("TestNetStandard13Engine") +Task("TestNetStandard16Engine") .Description("Tests the .NET Standard Engine") .IsDependentOn("Build") .OnError(exception => { ErrorDetail.Add(exception.Message); }) @@ -570,7 +570,7 @@ Task("Test") .Description("Builds and tests the engine and console runner") .IsDependentOn("TestNet20Engine") .IsDependentOn("TestNet20Console") - .IsDependentOn("TestNetStandard13Engine") + .IsDependentOn("TestNetStandard16Engine") .IsDependentOn("TestNetStandard20Engine"); Task("Package") diff --git a/src/CommonAssemblyInfo.cs b/src/CommonAssemblyInfo.cs index dc86c71b5..ccb71338c 100644 --- a/src/CommonAssemblyInfo.cs +++ b/src/CommonAssemblyInfo.cs @@ -36,7 +36,7 @@ #elif NET20 [assembly: AssemblyConfiguration(".NET 2.0 Debug")] #elif NETSTANDARD1_6 || NETCOREAPP1_1 -[assembly: AssemblyConfiguration(".NET Standard 1.3 Debug")] +[assembly: AssemblyConfiguration(".NET Standard 1.6 Debug")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 [assembly: AssemblyConfiguration(".NET Standard 2.0 Debug")] #else @@ -48,7 +48,7 @@ #elif NET20 [assembly: AssemblyConfiguration(".NET 2.0")] #elif NETSTANDARD1_6 || NETCOREAPP1_1 -[assembly: AssemblyConfiguration(".NET Standard 1.3")] +[assembly: AssemblyConfiguration(".NET Standard 1.6")] #elif NETSTANDARD2_0 || NETCOREAPP2_0 [assembly: AssemblyConfiguration(".NET Standard 2.0")] #else From 014340a65c7d0d91a07b049dc25e3717e4a6db2b Mon Sep 17 00:00:00 2001 From: Chris Maddock Date: Tue, 27 Nov 2018 22:09:12 +0000 Subject: [PATCH 29/29] Add debug info to FailsGracefullyLoadingOtherFrameworkExtensionAssembly() and remove old dependency --- nuget/engine/nunit.engine.nuspec | 1 - .../Services/ExtensionServiceTests.cs | 18 +++++++++++------- .../nunit.engine/Services/ExtensionService.cs | 2 +- .../nunit.engine/nunit.engine.csproj | 3 --- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/nuget/engine/nunit.engine.nuspec b/nuget/engine/nunit.engine.nuspec index f12f9d8ed..29c61906e 100644 --- a/nuget/engine/nunit.engine.nuspec +++ b/nuget/engine/nunit.engine.nuspec @@ -24,7 +24,6 @@ - diff --git a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs index cdf5d2917..d0aa54b0f 100644 --- a/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs +++ b/src/NUnitEngine/nunit.engine.tests/Services/ExtensionServiceTests.cs @@ -29,6 +29,7 @@ using System.IO; using System.Reflection; using System.Collections.Generic; +using NUnit.Engine.Internal; namespace NUnit.Engine.Services.Tests { @@ -152,6 +153,9 @@ public void DisabledExtensionMayBeEnabled() [Test] public void FailsGracefullyLoadingOtherFrameworkExtensionAssembly() { + //May be null on mono + Assume.That(Assembly.GetEntryAssembly(), Is.Not.Null, "Entry assembly is null, framework loading validation will be skipped."); + #if NETCOREAPP2_0 string other = "net35"; // Attempt to load the .NET 3.5 version of the extensions from the .NET Core 2.0 tests #elif NET35 @@ -160,13 +164,13 @@ public void FailsGracefullyLoadingOtherFrameworkExtensionAssembly() var assemblyName = Path.Combine(GetSiblingDirectory(other), "nunit.engine.tests.dll"); Assert.That(assemblyName, Does.Exist); - Assert.That(() => - { - var service = new ExtensionService(); - service.FindExtensionPoints(typeof(TestEngine).Assembly); - service.FindExtensionPoints(typeof(ITestEngine).Assembly); - service.FindExtensionsInAssembly(new ExtensionAssembly(assemblyName, false)); - }, Throws.TypeOf()); + var service = new ExtensionService(); + service.FindExtensionPoints(typeof(TestEngine).Assembly); + service.FindExtensionPoints(typeof(ITestEngine).Assembly); + var extensionAssembly = new ExtensionAssembly(assemblyName, false); + + Assert.That(() => service.FindExtensionsInAssembly(extensionAssembly), + Throws.TypeOf(), $"Loading extension targeting {new TargetFrameworkHelper(extensionAssembly.FilePath).FrameworkName} did not throw."); } [TestCaseSource(nameof(ValidCombos))] diff --git a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs index 84e0b9baa..675c70f36 100644 --- a/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs +++ b/src/NUnitEngine/nunit.engine/Services/ExtensionService.cs @@ -519,7 +519,7 @@ internal void FindExtensionsInAssembly(ExtensionAssembly assembly) /// /// Checks that the target framework of the current runner can load the extension assembly. For example, .NET Core - /// cannot load .NET Framework assemblies and visa-versa. + /// cannot load .NET Framework assemblies and vice-versa. /// /// The executing runner /// The extension we are attempting to load diff --git a/src/NUnitEngine/nunit.engine/nunit.engine.csproj b/src/NUnitEngine/nunit.engine/nunit.engine.csproj index 77ad85a94..2d16f5eab 100644 --- a/src/NUnitEngine/nunit.engine/nunit.engine.csproj +++ b/src/NUnitEngine/nunit.engine/nunit.engine.csproj @@ -15,9 +15,6 @@ - - -