mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 20:32:55 +08:00
Add a method to recycle test storage between runs
This commit is contained in:
parent
99d5398262
commit
0e0c730095
@ -65,6 +65,8 @@ namespace osu.Game.Tests.Visual.Menus
|
|||||||
game.Dispose();
|
game.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RecycleLocalStorage();
|
||||||
|
|
||||||
game = new TestOsuGame(LocalStorage, API);
|
game = new TestOsuGame(LocalStorage, API);
|
||||||
game.SetHost(host);
|
game.SetHost(host);
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected new OsuScreenDependencies Dependencies { get; private set; }
|
protected new OsuScreenDependencies Dependencies { get; private set; }
|
||||||
|
|
||||||
private readonly Lazy<Storage> localStorage;
|
private Lazy<Storage> localStorage;
|
||||||
protected Storage LocalStorage => localStorage.Value;
|
protected Storage LocalStorage => localStorage.Value;
|
||||||
|
|
||||||
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
private readonly Lazy<DatabaseContextFactory> contextFactory;
|
||||||
@ -91,7 +91,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected OsuTestScene()
|
protected OsuTestScene()
|
||||||
{
|
{
|
||||||
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
RecycleLocalStorage();
|
||||||
contextFactory = new Lazy<DatabaseContextFactory>(() =>
|
contextFactory = new Lazy<DatabaseContextFactory>(() =>
|
||||||
{
|
{
|
||||||
var factory = new DatabaseContextFactory(LocalStorage);
|
var factory = new DatabaseContextFactory(LocalStorage);
|
||||||
@ -104,6 +104,23 @@ namespace osu.Game.Tests.Visual
|
|||||||
base.Content.Add(content = new DrawSizePreservingFillContainer());
|
base.Content.Add(content = new DrawSizePreservingFillContainer());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RecycleLocalStorage()
|
||||||
|
{
|
||||||
|
if (localStorage?.IsValueCreated == true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
localStorage.Value.DeleteDirectory(".");
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// we don't really care if this fails; it will just leave folders lying around from test runs.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
localStorage = new Lazy<Storage>(() => new NativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
||||||
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
protected AudioManager Audio { get; private set; }
|
protected AudioManager Audio { get; private set; }
|
||||||
|
|
||||||
@ -131,17 +148,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
if (contextFactory.IsValueCreated)
|
if (contextFactory.IsValueCreated)
|
||||||
contextFactory.Value.ResetDatabase();
|
contextFactory.Value.ResetDatabase();
|
||||||
|
|
||||||
if (localStorage.IsValueCreated)
|
RecycleLocalStorage();
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
localStorage.Value.DeleteDirectory(".");
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
// we don't really care if this fails; it will just leave folders lying around from test runs.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();
|
protected override ITestSceneTestRunner CreateRunner() => new OsuTestSceneTestRunner();
|
||||||
|
Loading…
Reference in New Issue
Block a user