1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:33:30 +08:00

Fix some regressing behaviour due to CleanRunHeadlessGameHost's naming structure changing

This commit is contained in:
Dean Herbert 2021-12-24 20:24:37 +09:00
parent be02c3f9f8
commit 1c0dc204c4
3 changed files with 13 additions and 7 deletions

View File

@ -128,8 +128,12 @@ namespace osu.Game.Tests.Collections.IO
[Test]
public async Task TestSaveAndReload()
{
using (HeadlessGameHost host = new CleanRunHeadlessGameHost(bypassCleanup: true))
string firstRunName;
using (var host = new CleanRunHeadlessGameHost(bypassCleanup: true))
{
firstRunName = host.Name;
try
{
var osu = LoadOsuIntoHost(host, true);
@ -150,7 +154,7 @@ namespace osu.Game.Tests.Collections.IO
}
// Name matches the automatically chosen name from `CleanRunHeadlessGameHost` above, so we end up using the same storage location.
using (HeadlessGameHost host = new TestRunHeadlessGameHost(nameof(TestSaveAndReload)))
using (HeadlessGameHost host = new TestRunHeadlessGameHost(firstRunName))
{
try
{

View File

@ -25,7 +25,7 @@ namespace osu.Game.Tests.NonVisual
{
try
{
string defaultStorageLocation = getDefaultLocationFor(nameof(TestDefaultDirectory));
string defaultStorageLocation = getDefaultLocationFor(host);
var osu = LoadOsuIntoHost(host);
var storage = osu.Dependencies.Get<Storage>();
@ -109,7 +109,7 @@ namespace osu.Game.Tests.NonVisual
{
try
{
string defaultStorageLocation = getDefaultLocationFor(nameof(TestMigration));
string defaultStorageLocation = getDefaultLocationFor(host);
var osu = LoadOsuIntoHost(host);
var storage = osu.Dependencies.Get<Storage>();
@ -284,9 +284,9 @@ namespace osu.Game.Tests.NonVisual
}
}
private static string getDefaultLocationFor(string testTypeName)
private static string getDefaultLocationFor(CustomTestHeadlessGameHost host)
{
string path = Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, testTypeName);
string path = Path.Combine(TestRunHeadlessGameHost.TemporaryTestDirectory, host.Name);
if (Directory.Exists(path))
Directory.Delete(path, true);
@ -315,7 +315,7 @@ namespace osu.Game.Tests.NonVisual
public CustomTestHeadlessGameHost([CallerMemberName] string callingMethodName = @"")
: base(callingMethodName: callingMethodName)
{
string defaultStorageLocation = getDefaultLocationFor(Name);
string defaultStorageLocation = getDefaultLocationFor(this);
InitialStorage = new DesktopStorage(defaultStorageLocation, this);
InitialStorage.DeleteDirectory(string.Empty);

View File

@ -12,6 +12,8 @@ namespace osu.Game.Tests
/// </summary>
public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost
{
public new string Name => base.Name;
/// <summary>
/// Create a new instance.
/// </summary>