Use a fully stubbed out MockConsole for unit tests rather than inheriting from CommandConsole.
This is so that the static MainConsole.Instance doesn't retain references to methods registered by scene and other modules to service commands. This prevents the scene from being garbage collected at the end of a test. This is not the final thing preventing GC - next up is the timer started by SimStatsReporter that holds a reference to Scene that prevents end of test gc.0.7.3-extended
parent
123e781cb3
commit
6fa3dffad2
|
@ -29,6 +29,7 @@ using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
using System.Xml;
|
||||||
|
|
||||||
namespace OpenSim.Framework.Console
|
namespace OpenSim.Framework.Console
|
||||||
{
|
{
|
||||||
|
@ -37,28 +38,42 @@ namespace OpenSim.Framework.Console
|
||||||
/// Don't use this except for Unit Testing or you're in for a world of hurt when the
|
/// Don't use this except for Unit Testing or you're in for a world of hurt when the
|
||||||
/// sim gets to ReadLine
|
/// sim gets to ReadLine
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class MockConsole : CommandConsole
|
public class MockConsole : ICommandConsole
|
||||||
{
|
{
|
||||||
public MockConsole(string defaultPrompt) : base(defaultPrompt)
|
private MockCommands m_commands = new MockCommands();
|
||||||
{
|
|
||||||
}
|
|
||||||
public override void Output(string text)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
public override void Output(string text, string level)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ReadLine(string p, bool isCommand, bool e)
|
public ICommands Commands { get { return m_commands; } }
|
||||||
{
|
|
||||||
//Thread.CurrentThread.Join(1000);
|
public void Prompt() {}
|
||||||
return string.Empty;
|
|
||||||
}
|
public void RunCommand(string cmd) {}
|
||||||
public override void UnlockOutput()
|
|
||||||
{
|
public string ReadLine(string p, bool isCommand, bool e) { return ""; }
|
||||||
}
|
|
||||||
public override void LockOutput()
|
public object ConsoleScene { get { return null; } }
|
||||||
{
|
|
||||||
}
|
public void Output(string text, string level) {}
|
||||||
|
public void Output(string text) {}
|
||||||
|
public void OutputFormat(string format, params object[] components) {}
|
||||||
|
|
||||||
|
public string CmdPrompt(string p) { return ""; }
|
||||||
|
public string CmdPrompt(string p, string def) { return ""; }
|
||||||
|
public string CmdPrompt(string p, List<char> excludedCharacters) { return ""; }
|
||||||
|
public string CmdPrompt(string p, string def, List<char> excludedCharacters) { return ""; }
|
||||||
|
|
||||||
|
public string CmdPrompt(string prompt, string defaultresponse, List<string> options) { return ""; }
|
||||||
|
|
||||||
|
public string PasswdPrompt(string p) { return ""; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MockCommands : ICommands
|
||||||
|
{
|
||||||
|
public void FromXml(XmlElement root, CommandDelegate fn) {}
|
||||||
|
public List<string> GetHelp(string[] cmd) { return null; }
|
||||||
|
public void AddCommand(string module, bool shared, string command, string help, string longhelp, CommandDelegate fn) {}
|
||||||
|
public void AddCommand(string module, bool shared, string command, string help, string longhelp, string descriptivehelp, CommandDelegate fn) {}
|
||||||
|
public string[] FindNextOption(string[] cmd, bool term) { return null; }
|
||||||
|
public string[] Resolve(string[] cmd) { return null; }
|
||||||
|
public XmlElement GetXml(XmlDocument doc) { return null; }
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -113,7 +113,7 @@ namespace OpenSim.Tests.Common
|
||||||
Console.WriteLine("Setting up test scene {0}", name);
|
Console.WriteLine("Setting up test scene {0}", name);
|
||||||
|
|
||||||
// We must set up a console otherwise setup of some modules may fail
|
// We must set up a console otherwise setup of some modules may fail
|
||||||
MainConsole.Instance = new MockConsole("TEST PROMPT");
|
MainConsole.Instance = new MockConsole();
|
||||||
|
|
||||||
RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
|
RegionInfo regInfo = new RegionInfo(x, y, new IPEndPoint(IPAddress.Loopback, 9000), "127.0.0.1");
|
||||||
regInfo.RegionName = name;
|
regInfo.RegionName = name;
|
||||||
|
|
Loading…
Reference in New Issue