1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-19 04:02:54 +08:00

Fix non-visual tests not cleaning up previous executions

This commit is contained in:
Dean Herbert 2018-02-08 17:07:18 +09:00
parent 553c9bb2fa
commit 789e25069f
4 changed files with 25 additions and 10 deletions

View File

@ -24,7 +24,7 @@ namespace osu.Game.Tests.Beatmaps.IO
public void TestImportWhenClosed()
{
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here.
using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenClosed"))
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenClosed"))
{
var osu = loadOsu(host);
@ -44,11 +44,10 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test]
[NonParallelizable]
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
public void TestImportOverIPC()
{
using (HeadlessGameHost host = new HeadlessGameHost("host", true))
using (HeadlessGameHost client = new HeadlessGameHost("client", true))
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("host", true))
using (HeadlessGameHost client = new CleanRunHeadlessGameHost("client", true))
{
Assert.IsTrue(host.IsPrimaryInstance);
Assert.IsFalse(client.IsPrimaryInstance);
@ -74,7 +73,7 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test]
public void TestImportWhenFileOpen()
{
using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenFileOpen"))
using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenFileOpen"))
{
var osu = loadOsu(host);

View File

@ -0,0 +1,19 @@
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Platform;
namespace osu.Game.Tests
{
/// <summary>
/// A headless host which cleans up before running (removing any remnants from a previous execution).
/// </summary>
public class CleanRunHeadlessGameHost : HeadlessGameHost
{
public CleanRunHeadlessGameHost(string gameName = @"", bool bindIPC = false, bool realtime = true)
: base(gameName, bindIPC, realtime)
{
Storage.DeleteDirectory(string.Empty);
}
}
}

View File

@ -2,7 +2,6 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using osu.Framework.Platform;
using osu.Framework.Testing;
namespace osu.Game.Tests.Visual
@ -11,11 +10,8 @@ namespace osu.Game.Tests.Visual
{
public override void RunTest()
{
using (var host = new HeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
{
host.Storage.DeleteDirectory(string.Empty);
using (var host = new CleanRunHeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
host.Run(new OsuTestCaseTestRunner(this));
}
}
public class OsuTestCaseTestRunner : OsuGameBase

View File

@ -855,6 +855,7 @@
<Compile Include="Storyboards\StoryboardSample.cs" />
<Compile Include="Storyboards\StoryboardSprite.cs" />
<Compile Include="Tests\Beatmaps\TestWorkingBeatmap.cs" />
<Compile Include="Tests\CleanRunHeadlessGameHost.cs" />
<Compile Include="Tests\Platform\TestStorage.cs" />
<Compile Include="Tests\Visual\OsuTestCase.cs" />
<Compile Include="Tests\Visual\TestCasePerformancePoints.cs" />