From a2b8679b1799953a0813ff8d053d932a3681ea40 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Thu, 18 Jan 2024 11:33:07 +0300 Subject: [PATCH 1/2] Add flaky test attribute and mark `CanSeekForwardOnInterpolationFail` as flaky --- .../Clocks/InterpolatingFramedClockTest.cs | 6 +++++ osu.Framework.Tests/FlakyTestAttribute.cs | 25 +++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 osu.Framework.Tests/FlakyTestAttribute.cs diff --git a/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs b/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs index 17ced5d0b6..553ebe78e7 100644 --- a/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs +++ b/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs @@ -156,7 +156,13 @@ public void NeverInterpolatesBackwardsOnInterpolationFail() Assert.Greater(interpolatedCount, 10); } + // always failing on single-thread macOS CI, failing when test asserts interpolating.IsInterpolating = false + // + // CanSeekForwardsOnInterpolationFail + // Expected: False + // But was: True [Test] + [FlakyTest] public void CanSeekForwardsOnInterpolationFail() { const int sleep_time = 20; diff --git a/osu.Framework.Tests/FlakyTestAttribute.cs b/osu.Framework.Tests/FlakyTestAttribute.cs new file mode 100644 index 0000000000..216178c1fe --- /dev/null +++ b/osu.Framework.Tests/FlakyTestAttribute.cs @@ -0,0 +1,25 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System; +using NUnit.Framework; + +namespace osu.Framework.Tests +{ + /// + /// An attribute to mark any flaky tests. + /// Will add a retry count unless environment variable `FAIL_FLAKY_TESTS` is set to `1`. + /// + public class FlakyTestAttribute : RetryAttribute + { + public FlakyTestAttribute() + : this(10) + { + } + + public FlakyTestAttribute(int tryCount) + : base(Environment.GetEnvironmentVariable("OSU_TESTS_FAIL_FLAKY") == "1" ? 1 : tryCount) + { + } + } +} From dd0a3d378d95c3eba0d70e764cc26134ff5097d5 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 18 Jan 2024 18:17:38 +0900 Subject: [PATCH 2/2] Change comment wording slightly --- osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs b/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs index 553ebe78e7..6eb338d6da 100644 --- a/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs +++ b/osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs @@ -156,7 +156,7 @@ public void NeverInterpolatesBackwardsOnInterpolationFail() Assert.Greater(interpolatedCount, 10); } - // always failing on single-thread macOS CI, failing when test asserts interpolating.IsInterpolating = false + // Regularly failing on single-thread macOS CI, failing when test asserts interpolating.IsInterpolating = false // // CanSeekForwardsOnInterpolationFail // Expected: False