diff options
author | David Karlaš <david.karlas@xamarin.com> | 2016-09-16 14:46:20 +0300 |
---|---|---|
committer | David Karlaš <david.karlas@xamarin.com> | 2016-09-16 14:47:19 +0300 |
commit | 8932e0b98e8f8e2a4a55b2cafca0133ebe827454 (patch) | |
tree | f714af6e70cca819ebeab3864edb6019d151365c /main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs | |
parent | 9804bbc9dae393e03f1750ab50807d326be0e980 (diff) |
Bug 43522 - MonoDevelop.UnitTesting.NUnit.NUnitAssemblyTestSuite.RunUnitTest throws error on large test suite
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs')
-rw-r--r-- | main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs index 6885470811..3cb410a961 100644 --- a/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs +++ b/main/src/addins/MonoDevelop.UnitTesting/Services/AbstractResultsStore.cs @@ -54,34 +54,38 @@ namespace MonoDevelop.UnitTesting public void RegisterResult (string configuration, UnitTest test, UnitTestResult result) { - string aname = test.StoreRelativeName; - - TestRecord root = GetRootRecord (configuration, result.TestDate); - if (root == null) { - root = new TestRecord (); - fileCache [GetRootFileName (configuration, result.TestDate)] = root; - } - root.Modified = true; - TestRecord record = root; - - if (aname.Length > 0) { - string[] path = test.StoreRelativeName.Split ('.'); - foreach (string p in path) { - TestRecord ctr = record.Tests != null ? record.Tests [p] : null; - if (ctr == null) { - ctr = new TestRecord (); - ctr.Name = p; - if (record.Tests == null) - record.Tests = new TestRecordCollection (); - record.Tests.Add (ctr); + //This method can be called from multiple threads when remote process(test runner) is responding + //This lock is protecting collections fileCache, record.Tests and record.Results + lock (fileCache) { + string aname = test.StoreRelativeName; + + TestRecord root = GetRootRecord (configuration, result.TestDate); + if (root == null) { + root = new TestRecord (); + fileCache [GetRootFileName (configuration, result.TestDate)] = root; + } + root.Modified = true; + TestRecord record = root; + + if (aname.Length > 0) { + string [] path = test.StoreRelativeName.Split ('.'); + foreach (string p in path) { + TestRecord ctr = record.Tests != null ? record.Tests [p] : null; + if (ctr == null) { + ctr = new TestRecord (); + ctr.Name = p; + if (record.Tests == null) + record.Tests = new TestRecordCollection (); + record.Tests.Add (ctr); + } + record = ctr; } - record = ctr; } + + if (record.Results == null) + record.Results = new UnitTestResultCollection (); + record.Results.Add (result); } - - if (record.Results == null) - record.Results = new UnitTestResultCollection (); - record.Results.Add (result); } public UnitTestResult GetNextResult (string configuration, UnitTest test, DateTime date) |