mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add test coverage of corrupt realm creating backup
This commit is contained in:
@ -15,30 +15,38 @@ namespace osu.Game.Tests
|
||||
/// </summary>
|
||||
public class CleanRunHeadlessGameHost : TestRunHeadlessGameHost
|
||||
{
|
||||
private readonly bool bypassCleanupOnSetup;
|
||||
|
||||
/// <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>
|
||||
/// <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>
|
||||
/// <param name="bypassCleanupOnSetup">Whether to bypass directory cleanup on <see cref="SetupForRun"/>.</param>
|
||||
/// <param name="bypassCleanupOnDispose">Whether to bypass directory cleanup on host disposal. Should be used only if a subsequent test relies on the files still existing.</param>
|
||||
/// <param name="callingMethodName">The name of the calling method, used for test file isolation and clean-up.</param>
|
||||
public CleanRunHeadlessGameHost(bool bindIPC = false, bool realtime = true, bool bypassCleanup = false, [CallerMemberName] string callingMethodName = @"")
|
||||
public CleanRunHeadlessGameHost(bool bindIPC = false, bool realtime = true, bool bypassCleanupOnSetup = false, bool bypassCleanupOnDispose = false,
|
||||
[CallerMemberName] string callingMethodName = @"")
|
||||
: base($"{callingMethodName}-{Guid.NewGuid()}", new HostOptions
|
||||
{
|
||||
BindIPC = bindIPC,
|
||||
}, bypassCleanup: bypassCleanup, realtime: realtime)
|
||||
}, bypassCleanup: bypassCleanupOnDispose, realtime: realtime)
|
||||
{
|
||||
this.bypassCleanupOnSetup = bypassCleanupOnSetup;
|
||||
}
|
||||
|
||||
protected override void SetupForRun()
|
||||
{
|
||||
try
|
||||
if (!bypassCleanupOnSetup)
|
||||
{
|
||||
Storage.DeleteDirectory(string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// May fail if a logging target has already been set via OsuStorage.ChangeTargetStorage.
|
||||
try
|
||||
{
|
||||
Storage.DeleteDirectory(string.Empty);
|
||||
}
|
||||
catch
|
||||
{
|
||||
// May fail if a logging target has already been set via OsuStorage.ChangeTargetStorage.
|
||||
}
|
||||
}
|
||||
|
||||
// base call needs to be run *after* storage is emptied, as it updates the (static) logger's storage and may start writing
|
||||
|
Reference in New Issue
Block a user