2019-01-24 08:43:03 +00:00
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 09:19:50 +00:00
2021-12-24 11:15:10 +00:00
using System ;
2020-09-08 02:31:42 +00:00
using System.Runtime.CompilerServices ;
2021-08-18 06:32:59 +00:00
using osu.Framework.Testing ;
2018-04-13 09:19:50 +00:00
namespace osu.Game.Tests
{
/// <summary>
/// A headless host which cleans up before running (removing any remnants from a previous execution).
/// </summary>
2021-08-18 06:32:59 +00:00
public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost
2018-04-13 09:19:50 +00:00
{
2020-09-08 02:31:42 +00:00
/// <summary>
/// Create a new instance.
/// </summary>
/// <param name="bindIPC">Whether to bind IPC channels.</param>
/// <param name="realtime">Whether the host should be forced to run in realtime, rather than accelerated test time.</param>
2021-12-22 04:38:20 +00:00
/// <param name="bypassCleanup">Whether to bypass directory cleanup on host disposal. Should be used only if a subsequent test relies on the files still existing.</param>
2020-09-08 02:31:42 +00:00
/// <param name="callingMethodName">The name of the calling method, used for test file isolation and clean-up.</param>
2021-12-24 11:15:10 +00:00
public CleanRunHeadlessGameHost ( bool bindIPC = false , bool realtime = true , bool bypassCleanup = false , [ CallerMemberName ] string callingMethodName = @"" )
: base ( $"{callingMethodName}-{Guid.NewGuid()}" , bindIPC , realtime , bypassCleanup : bypassCleanup )
2018-04-13 09:19:50 +00:00
{
2019-03-27 16:29:06 +00:00
}
protected override void SetupForRun ( )
{
2018-04-13 09:19:50 +00:00
Storage . DeleteDirectory ( string . Empty ) ;
2021-07-09 03:15:28 +00:00
// base call needs to be run *after* storage is emptied, as it updates the (static) logger's storage and may start writing
// log entries from another source if a unit test host is shared over multiple tests, causing a file access denied exception.
base . SetupForRun ( ) ;
2018-04-13 09:19:50 +00:00
}
}
}