1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 04:13:21 +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() public void TestImportWhenClosed()
{ {
//unfortunately for the time being we need to reference osu.Framework.Desktop for a game host here. //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); var osu = loadOsu(host);
@ -44,11 +44,10 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test] [Test]
[NonParallelizable] [NonParallelizable]
[Ignore("Binding IPC on Appveyor isn't working (port in use). Need to figure out why")]
public void TestImportOverIPC() public void TestImportOverIPC()
{ {
using (HeadlessGameHost host = new HeadlessGameHost("host", true)) using (HeadlessGameHost host = new CleanRunHeadlessGameHost("host", true))
using (HeadlessGameHost client = new HeadlessGameHost("client", true)) using (HeadlessGameHost client = new CleanRunHeadlessGameHost("client", true))
{ {
Assert.IsTrue(host.IsPrimaryInstance); Assert.IsTrue(host.IsPrimaryInstance);
Assert.IsFalse(client.IsPrimaryInstance); Assert.IsFalse(client.IsPrimaryInstance);
@ -74,7 +73,7 @@ namespace osu.Game.Tests.Beatmaps.IO
[Test] [Test]
public void TestImportWhenFileOpen() public void TestImportWhenFileOpen()
{ {
using (HeadlessGameHost host = new HeadlessGameHost("TestImportWhenFileOpen")) using (HeadlessGameHost host = new CleanRunHeadlessGameHost("TestImportWhenFileOpen"))
{ {
var osu = loadOsu(host); 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 // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System; using System;
using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
namespace osu.Game.Tests.Visual namespace osu.Game.Tests.Visual
@ -11,12 +10,9 @@ namespace osu.Game.Tests.Visual
{ {
public override void RunTest() public override void RunTest()
{ {
using (var host = new HeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false)) using (var host = new CleanRunHeadlessGameHost($"test-{Guid.NewGuid()}", realtime: false))
{
host.Storage.DeleteDirectory(string.Empty);
host.Run(new OsuTestCaseTestRunner(this)); host.Run(new OsuTestCaseTestRunner(this));
} }
}
public class OsuTestCaseTestRunner : OsuGameBase public class OsuTestCaseTestRunner : OsuGameBase
{ {

View File

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