mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 21:43:22 +08:00
Fix tournament tests potentially using data left over from previous runs
This commit is contained in:
parent
8c24d6eb76
commit
4624977b77
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,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 +42,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
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace osu.Game.Tournament.Tests.NonVisual
|
||||
return tournament;
|
||||
}
|
||||
|
||||
public static void WaitForOrAssert(Func<bool> result, string failureMessage, int timeout = 90000)
|
||||
public static void WaitForOrAssert(Func<bool> result, string failureMessage, int timeout = 30000)
|
||||
{
|
||||
Task task = Task.Run(() =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user