From fdc41ace7e8e8a442c311615b62dd36de3f2eb65 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 13 Dec 2024 17:33:49 +0900 Subject: [PATCH] Fix flaky editor beatmap creation test As seen in https://github.com/ppy/osu/actions/runs/12289146465/job/34294167417#step:5:1588 or https://github.com/ppy/osu/actions/runs/12310133160/job/34358241666#step:5:53. Exception messages hint pretty strongly at this being a threading issue and there does seem to be a rather frivolous lack of waiting for `CreateNewDifficulty()` to do its thing, so I'm thinking maybe this will help. --- .../Editing/TestSceneEditorBeatmapCreation.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs index 32d019dd9f55..b7990b64c118 100644 --- a/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs +++ b/osu.Game.Tests/Visual/Editing/TestSceneEditorBeatmapCreation.cs @@ -203,12 +203,19 @@ public void TestCreateNewDifficulty([Values] bool sameRuleset) [Test] public void TestCreateNewDifficultyWithScrollSpeed_SameRuleset() { - string firstDifficultyName = Guid.NewGuid().ToString(); + string previousDifficultyName = null!; + AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = previousDifficultyName = Guid.NewGuid().ToString()); AddStep("save beatmap", () => Editor.Save()); AddStep("create new difficulty", () => Editor.CreateNewDifficulty(new ManiaRuleset().RulesetInfo)); - AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = firstDifficultyName); + AddUntilStep("wait for created", () => + { + string? difficultyName = Editor.ChildrenOfType().SingleOrDefault()?.BeatmapInfo.DifficultyName; + return difficultyName != null && difficultyName != previousDifficultyName; + }); + + AddStep("set unique difficulty name", () => EditorBeatmap.BeatmapInfo.DifficultyName = previousDifficultyName = Guid.NewGuid().ToString()); AddStep("add timing point", () => EditorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = 1000 })); AddStep("add effect points", () => { @@ -229,7 +236,7 @@ public void TestCreateNewDifficultyWithScrollSpeed_SameRuleset() AddUntilStep("wait for created", () => { string? difficultyName = Editor.ChildrenOfType().SingleOrDefault()?.BeatmapInfo.DifficultyName; - return difficultyName != null && difficultyName != firstDifficultyName; + return difficultyName != null && difficultyName != previousDifficultyName; }); AddAssert("created difficulty has timing point", () =>