diff --git a/osu.Game.Tournament.Tests/NonVisual/CustomTourneyDirectoryTest.cs b/osu.Game.Tournament.Tests/NonVisual/CustomTourneyDirectoryTest.cs index fcc9f44f0c..94472a8bc7 100644 --- a/osu.Game.Tournament.Tests/NonVisual/CustomTourneyDirectoryTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/CustomTourneyDirectoryTest.cs @@ -38,7 +38,7 @@ namespace osu.Game.Tournament.Tests.NonVisual { using (HeadlessGameHost host = new HeadlessGameHost(nameof(TestCustomDirectory))) // don't use clean run as we are writing a config file. { - string osuDesktopStorage = basePath(nameof(TestCustomDirectory)); + string osuDesktopStorage = PrepareBasePath(nameof(TestCustomDirectory)); const string custom_tournament = "custom"; // need access before the game has constructed its own storage yet. @@ -60,6 +60,15 @@ namespace osu.Game.Tournament.Tests.NonVisual finally { host.Exit(); + + try + { + if (Directory.Exists(osuDesktopStorage)) + Directory.Delete(osuDesktopStorage, true); + } + catch + { + } } } } @@ -69,7 +78,7 @@ namespace osu.Game.Tournament.Tests.NonVisual { using (HeadlessGameHost host = new HeadlessGameHost(nameof(TestMigration))) // don't use clean run as we are writing test files for migration. { - string osuRoot = basePath(nameof(TestMigration)); + string osuRoot = PrepareBasePath(nameof(TestMigration)); string configFile = Path.Combine(osuRoot, "tournament.ini"); if (File.Exists(configFile)) @@ -136,18 +145,29 @@ namespace osu.Game.Tournament.Tests.NonVisual } finally { + host.Exit(); + try { - host.Storage.Delete("tournament.ini"); - host.Storage.DeleteDirectory("tournaments"); + if (Directory.Exists(osuRoot)) + Directory.Delete(osuRoot, true); + } + catch + { } - catch { } - - host.Exit(); } } } - private string basePath(string testInstance) => Path.Combine(RuntimeInfo.StartupDirectory, "headless", testInstance); + public static string PrepareBasePath(string testInstance) + { + string basePath = Path.Combine(RuntimeInfo.StartupDirectory, "headless", testInstance); + + // manually clean before starting in case there are left-over files at the test site. + if (Directory.Exists(basePath)) + Directory.Delete(basePath, true); + + return basePath; + } } } diff --git a/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs b/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs index eaa009c180..db89855db7 100644 --- a/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/IPCLocationTest.cs @@ -3,7 +3,6 @@ using System.IO; using NUnit.Framework; -using osu.Framework; using osu.Framework.Allocation; using osu.Framework.Platform; using osu.Game.Tournament.IO; @@ -20,7 +19,7 @@ namespace osu.Game.Tournament.Tests.NonVisual // don't use clean run because files are being written before osu! launches. using (HeadlessGameHost host = new HeadlessGameHost(nameof(CheckIPCLocation))) { - string basePath = Path.Combine(RuntimeInfo.StartupDirectory, "headless", nameof(CheckIPCLocation)); + string basePath = CustomTourneyDirectoryTest.PrepareBasePath(nameof(CheckIPCLocation)); // Set up a fake IPC client for the IPC Storage to switch to. string testStableInstallDirectory = Path.Combine(basePath, "stable-ce"); @@ -42,9 +41,16 @@ namespace osu.Game.Tournament.Tests.NonVisual } finally { - host.Storage.DeleteDirectory(testStableInstallDirectory); - host.Storage.DeleteDirectory("tournaments"); host.Exit(); + + try + { + if (Directory.Exists(basePath)) + Directory.Delete(basePath, true); + } + catch + { + } } } } diff --git a/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs b/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs index 319a768e65..bf99f69b2a 100644 --- a/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs +++ b/osu.Game.Tournament.Tests/NonVisual/TournamentHostTest.cs @@ -20,7 +20,7 @@ namespace osu.Game.Tournament.Tests.NonVisual return tournament; } - public static void WaitForOrAssert(Func result, string failureMessage, int timeout = 90000) + public static void WaitForOrAssert(Func result, string failureMessage, int timeout = 30000) { Task task = Task.Run(() => {