Fixed regression in container registration. Additional logging in case of integration test startup failures
This commit is contained in:
parent
2dfba130f5
commit
dc7986dbad
|
@ -53,7 +53,18 @@ namespace NzbDrone.Common.Composition
|
||||||
{
|
{
|
||||||
var factory = CreateSingletonImplementationFactory(implementation);
|
var factory = CreateSingletonImplementationFactory(implementation);
|
||||||
|
|
||||||
|
// For Resolve and ResolveAll
|
||||||
_container.Register(service, factory);
|
_container.Register(service, factory);
|
||||||
|
|
||||||
|
// For ctor(IEnumerable<T>)
|
||||||
|
var enumerableType = typeof(IEnumerable<>).MakeGenericType(service);
|
||||||
|
_container.Register(enumerableType, (c, p) =>
|
||||||
|
{
|
||||||
|
var instance = factory(c, p);
|
||||||
|
var result = Array.CreateInstance(service, 1);
|
||||||
|
result.SetValue(instance, 0);
|
||||||
|
return result;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<T> ResolveAll<T>() where T : class
|
public IEnumerable<T> ResolveAll<T>() where T : class
|
||||||
|
@ -67,6 +78,7 @@ namespace NzbDrone.Common.Composition
|
||||||
{
|
{
|
||||||
var factory = CreateSingletonImplementationFactory(implementation);
|
var factory = CreateSingletonImplementationFactory(implementation);
|
||||||
|
|
||||||
|
// For ResolveAll and ctor(IEnumerable<T>)
|
||||||
_container.Register(service, factory, implementation.FullName);
|
_container.Register(service, factory, implementation.FullName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ namespace NzbDrone.Console
|
||||||
System.Console.WriteLine("");
|
System.Console.WriteLine("");
|
||||||
System.Console.WriteLine("");
|
System.Console.WriteLine("");
|
||||||
Logger.Fatal(ex, "EPIC FAIL!");
|
Logger.Fatal(ex, "EPIC FAIL!");
|
||||||
|
System.Console.WriteLine("EPIC FAIL! " + ex.ToString());
|
||||||
Exit(ExitCodes.UnknownFailure);
|
Exit(ExitCodes.UnknownFailure);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
|
@ -8,6 +9,7 @@ using System.Xml.XPath;
|
||||||
using NLog;
|
using NLog;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using NzbDrone.Common.EnvironmentInfo;
|
using NzbDrone.Common.EnvironmentInfo;
|
||||||
|
using NzbDrone.Common.Extensions;
|
||||||
using NzbDrone.Common.Processes;
|
using NzbDrone.Common.Processes;
|
||||||
using NzbDrone.Core.Configuration;
|
using NzbDrone.Core.Configuration;
|
||||||
using RestSharp;
|
using RestSharp;
|
||||||
|
@ -19,6 +21,7 @@ namespace NzbDrone.Test.Common
|
||||||
private readonly IProcessProvider _processProvider;
|
private readonly IProcessProvider _processProvider;
|
||||||
private readonly IRestClient _restClient;
|
private readonly IRestClient _restClient;
|
||||||
private Process _nzbDroneProcess;
|
private Process _nzbDroneProcess;
|
||||||
|
private List<string> _startupLog;
|
||||||
|
|
||||||
public string AppData { get; private set; }
|
public string AppData { get; private set; }
|
||||||
public string ApiKey { get; private set; }
|
public string ApiKey { get; private set; }
|
||||||
|
@ -38,6 +41,7 @@ namespace NzbDrone.Test.Common
|
||||||
|
|
||||||
var sonarrConsoleExe = OsInfo.IsWindows ? "Sonarr.Console.exe" : "Sonarr.exe";
|
var sonarrConsoleExe = OsInfo.IsWindows ? "Sonarr.Console.exe" : "Sonarr.exe";
|
||||||
|
|
||||||
|
_startupLog = new List<string>();
|
||||||
if (BuildInfo.IsDebug)
|
if (BuildInfo.IsDebug)
|
||||||
{
|
{
|
||||||
Start(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "_output", "Sonarr.Console.exe"));
|
Start(Path.Combine(TestContext.CurrentContext.TestDirectory, "..", "_output", "Sonarr.Console.exe"));
|
||||||
|
@ -53,7 +57,10 @@ namespace NzbDrone.Test.Common
|
||||||
|
|
||||||
if (_nzbDroneProcess.HasExited)
|
if (_nzbDroneProcess.HasExited)
|
||||||
{
|
{
|
||||||
Assert.Fail("Process has exited");
|
Console.WriteLine("NzbDrone has exited unexpectedly");
|
||||||
|
Thread.Sleep(2000);
|
||||||
|
var output = _startupLog.Join(Environment.NewLine);
|
||||||
|
Assert.Fail("Process has exited: ExitCode={0} Output={1}", _nzbDroneProcess.ExitCode, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
var request = new RestRequest("system/status");
|
var request = new RestRequest("system/status");
|
||||||
|
@ -64,6 +71,7 @@ namespace NzbDrone.Test.Common
|
||||||
|
|
||||||
if (statusCall.ResponseStatus == ResponseStatus.Completed)
|
if (statusCall.ResponseStatus == ResponseStatus.Completed)
|
||||||
{
|
{
|
||||||
|
_startupLog = null;
|
||||||
Console.WriteLine("NzbDrone is started. Running Tests");
|
Console.WriteLine("NzbDrone is started. Running Tests");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -97,6 +105,8 @@ namespace NzbDrone.Test.Common
|
||||||
|
|
||||||
private void Start(string outputNzbdroneConsoleExe)
|
private void Start(string outputNzbdroneConsoleExe)
|
||||||
{
|
{
|
||||||
|
Console.WriteLine("Starting instance from {0}", outputNzbdroneConsoleExe);
|
||||||
|
|
||||||
var args = "-nobrowser -data=\"" + AppData + "\"";
|
var args = "-nobrowser -data=\"" + AppData + "\"";
|
||||||
_nzbDroneProcess = _processProvider.Start(outputNzbdroneConsoleExe, args, null, OnOutputDataReceived, OnOutputDataReceived);
|
_nzbDroneProcess = _processProvider.Start(outputNzbdroneConsoleExe, args, null, OnOutputDataReceived, OnOutputDataReceived);
|
||||||
|
|
||||||
|
@ -106,6 +116,11 @@ namespace NzbDrone.Test.Common
|
||||||
{
|
{
|
||||||
Console.WriteLine(data);
|
Console.WriteLine(data);
|
||||||
|
|
||||||
|
if (_startupLog != null)
|
||||||
|
{
|
||||||
|
_startupLog.Add(data);
|
||||||
|
}
|
||||||
|
|
||||||
if (data.Contains("Press enter to exit"))
|
if (data.Contains("Press enter to exit"))
|
||||||
{
|
{
|
||||||
_nzbDroneProcess.StandardInput.WriteLine(" ");
|
_nzbDroneProcess.StandardInput.WriteLine(" ");
|
||||||
|
|
Loading…
Reference in New Issue