Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikayla Hutchinson <m.j.hutchinson@gmail.com>2017-01-26 19:35:44 +0300
committerMikayla Hutchinson <m.j.hutchinson@gmail.com>2017-01-26 20:33:09 +0300
commit9baeaf6cdcddfc61bd8641c5b85b118a5734fb39 (patch)
tree51c5f3511df74d1962923ffd448fa342926ca9a6 /main/src/addins/MonoDevelop.UnitTesting.NUnit
parentbfe719850a431ab688e674bcaa4379c04f8f9e3f (diff)
parent239def51e3a1addbad9cffc818e978a8fc6d8afb (diff)
Merge remote-tracking branch 'xamarin/vNext' into roslyn-ivt
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting.NUnit')
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs3
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs24
2 files changed, 20 insertions, 7 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs
index 0b39c59b82..12248158f1 100644
--- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/MonoDevelop.UnitTesting.NUnit/ExternalTestRunner.cs
@@ -139,8 +139,7 @@ namespace MonoDevelop.UnitTesting.NUnit.External
public void Dispose ()
{
- connection.Disconnect (true);
- connection.Dispose ();
+ connection.Disconnect ().Ignore ();
}
}
diff --git a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs
index 05705f8e80..a375247036 100644
--- a/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting.NUnit/NUnitRunner/ExternalTestRunner.cs
@@ -70,7 +70,7 @@ namespace MonoDevelop.UnitTesting.NUnit.External
public RemoteTestResult Run (string[] nameFilter, string path, string suiteName, string[] supportAssemblies, string testRunnerType, string testRunnerAssembly, string crashLogFile)
{
- NUnitTestRunner runner = GetRunner (path);
+ NUnitTestRunner runner = GetRunner (path, false);
EventListenerWrapper listenerWrapper = new EventListenerWrapper (server);
UnhandledExceptionEventHandler exceptionHandler = (object sender, UnhandledExceptionEventArgs e) => {
@@ -90,19 +90,33 @@ namespace MonoDevelop.UnitTesting.NUnit.External
[MessageHandler]
public GetTestInfoResponse GetTestInfo (GetTestInfoRequest req)
{
- NUnitTestRunner runner = GetRunner (req.Path);
+ NUnitTestRunner runner = GetRunner (req.Path, true);
var r = runner.GetTestInfo (req.Path, req.SupportAssemblies);
return new GetTestInfoResponse { Result = r };
}
- NUnitTestRunner GetRunner (string assemblyPath)
+ NUnitTestRunner GetRunner (string assemblyPath, bool forQuery)
{
string basePath = Path.GetDirectoryName (GetType ().Assembly.Location);
TestPackage package = new TestPackage (assemblyPath);
package.Settings ["ShadowCopyFiles"] = false;
- package.BasePath = Path.GetDirectoryName(assemblyPath);
-
+
+ // This is a workaround for what could be a Mono bug (hard to tell).
+ // For the test runner to be able to load the app.config file,
+ // the BasePath of the domain needs to be set to the location
+ // of the test assembly (see bug #41541 - App Config is not read in Unit Tests).
+ // However, when doing that, the test runner crashes in some cases
+ // (for example when loading the MD unit tests). It crashes because
+ // Mono gets confused and tries to load assemblies from two different
+ // locations. As a workaround, we set the test assebmly directory
+ // as base path only when running, which seems to work.
+
+ if (forQuery)
+ package.BasePath = basePath;
+ else
+ package.BasePath = Path.GetDirectoryName (assemblyPath);
+
AppDomain domain = Services.DomainManager.CreateDomain (package);
string asm = Path.Combine (basePath, "NUnitRunner.exe");
runner = (NUnitTestRunner)domain.CreateInstanceFromAndUnwrap (asm, "MonoDevelop.UnitTesting.NUnit.External.NUnitTestRunner");