mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 18:32:56 +08:00
Restructure how the headless storage is used / documented to hopefully make more sense
This commit is contained in:
parent
49e2a8afa3
commit
5631e75f16
@ -81,8 +81,7 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||||
{
|
{
|
||||||
if (!UseFreshStoragePerRun)
|
isolatedHostStorage = (parent.Get<GameHost>() as HeadlessGameHost)?.Storage;
|
||||||
isolatedHostStorage = (parent.Get<GameHost>() as HeadlessGameHost)?.Storage;
|
|
||||||
|
|
||||||
Resources = parent.Get<OsuGameBase>().Resources;
|
Resources = parent.Get<OsuGameBase>().Resources;
|
||||||
|
|
||||||
@ -149,8 +148,16 @@ namespace osu.Game.Tests.Visual
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
localStorage =
|
localStorage = new Lazy<Storage>(() =>
|
||||||
new Lazy<Storage>(() => isolatedHostStorage ?? new TemporaryNativeStorage($"{GetType().Name}-{Guid.NewGuid()}"));
|
{
|
||||||
|
// When running headless, there is an opportunity to use the host storage rather than creating a second isolated one.
|
||||||
|
// This is because the host is recycled per TestScene execution in headless at an nunit level.
|
||||||
|
// Importantly, we can't use this optimisation when `UseFreshStoragePerRun` is true, as it doesn't reset per test method.
|
||||||
|
if (!UseFreshStoragePerRun && isolatedHostStorage != null)
|
||||||
|
return isolatedHostStorage;
|
||||||
|
|
||||||
|
return new TemporaryNativeStorage($"{GetType().Name}-{Guid.NewGuid()}");
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
|
Loading…
Reference in New Issue
Block a user