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:
authorMatt Ward <matt.ward@xamarin.com>2017-11-22 18:24:51 +0300
committerMatt Ward <matt.ward@xamarin.com>2017-11-22 18:32:40 +0300
commitfd7edb25eab5742a27d0a23acf70e1d8d5428501 (patch)
tree49a16090e5c3d1f461a5bade06a00b09ac977f3b /main/src/addins/MonoDevelop.UnitTesting
parent529eb57464b30ccc7a029ae4e9c34433ba5f7bb3 (diff)
[UnitTesting] Improve tests using NuGet restore
1) Using a custom NuGet.Config file that only uses the main NuGet package source. This improves the restore speed and also prevents other slower MyGet package sources from being used. 2) Use DisableParallelProcessing when running nuget restore. This should avoid any problems that happen in Mono when running restores in parallel for many NuGet packages.
Diffstat (limited to 'main/src/addins/MonoDevelop.UnitTesting')
-rw-r--r--main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/BasicTests.cs40
1 files changed, 31 insertions, 9 deletions
diff --git a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/BasicTests.cs b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/BasicTests.cs
index 61a118429c..b1c78d055c 100644
--- a/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/BasicTests.cs
+++ b/main/src/addins/MonoDevelop.UnitTesting/MonoDevelop.UnitTesting.Tests/BasicTests.cs
@@ -15,17 +15,18 @@
// 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;
using System;
-using UnitTests;
-using System.Threading.Tasks;
-using MonoDevelop.Projects;
+using System.Diagnostics;
+using System.IO;
using System.Linq;
-using MonoDevelop.Ide;
+using System.Threading;
+using System.Threading.Tasks;
using MonoDevelop.Core;
using MonoDevelop.DotNetCore;
-using System.Diagnostics;
-using System.Threading;
+using MonoDevelop.Ide;
+using MonoDevelop.Projects;
+using NUnit.Framework;
+using UnitTests;
namespace MonoDevelop.UnitTesting.Tests
{
@@ -51,6 +52,25 @@ namespace MonoDevelop.UnitTesting.Tests
base.TearDown ();
}
+ /// <summary>
+ /// Clear all other package sources and just use the main NuGet package source when
+ /// restoring the packages for the project temlate tests.
+ /// </summary>
+ void CreateNuGetConfigFile (FilePath directory)
+ {
+ var fileName = directory.Combine ("NuGet.Config");
+
+ string xml =
+ "<configuration>\r\n" +
+ " <packageSources>\r\n" +
+ " <clear />\r\n" +
+ " <add key=\"NuGet v3 Official\" value=\"https://api.nuget.org/v3/index.json\" />\r\n" +
+ " </packageSources>\r\n" +
+ "</configuration>";
+
+ File.WriteAllText (fileName, xml);
+ }
+
[Test()]
public async Task TestsXUnitDotNetFull()
{
@@ -69,9 +89,11 @@ namespace MonoDevelop.UnitTesting.Tests
async Task CommonTestDiscovery(string projectName)
{
- string solFile = Util.GetSampleProject("unit-testing-addin", "unit-testing-addin.sln");
+ FilePath solFile = Util.GetSampleProject("unit-testing-addin", "unit-testing-addin.sln");
+
+ CreateNuGetConfigFile (solFile.ParentDirectory);
- var process = Process.Start("nuget", $"restore {solFile}");
+ var process = Process.Start("nuget", $"restore -DisableParallelProcessing {solFile}");
Assert.IsTrue(process.WaitForExit(60000), "Timeout restoring nuget packages.");
Assert.AreEqual(0, process.ExitCode);