Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add flaky test attribute and mark CanSeekForwardOnInterpolationFail as flaky #6140

Merged
merged 2 commits into from Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions osu.Framework.Tests/Clocks/InterpolatingFramedClockTest.cs
Expand Up @@ -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
Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it always fails, flaky probably won't work? It's only intended for intermittent failures.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well sometimes it passes (see current CI status), so I wasn't sure about fully ignoring it. But I could easily do so, and make the ignore macOS-only using Assert.Ignore. Will leave it to your call.

Copy link
Sponsor Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dunno, I read your comment "always failing" and made the assumption that was the case. Change the comment to "Intermittently failing" i guess

peppy marked this conversation as resolved.
Show resolved Hide resolved
//
// CanSeekForwardsOnInterpolationFail
// Expected: False
// But was: True
[Test]
[FlakyTest]
public void CanSeekForwardsOnInterpolationFail()
{
const int sleep_time = 20;
Expand Down
25 changes: 25 additions & 0 deletions osu.Framework.Tests/FlakyTestAttribute.cs
@@ -0,0 +1,25 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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
{
/// <summary>
/// An attribute to mark any flaky tests.
/// Will add a retry count unless environment variable `FAIL_FLAKY_TESTS` is set to `1`.
/// </summary>
public class FlakyTestAttribute : RetryAttribute
{
public FlakyTestAttribute()
: this(10)
{
}

public FlakyTestAttribute(int tryCount)
: base(Environment.GetEnvironmentVariable("OSU_TESTS_FAIL_FLAKY") == "1" ? 1 : tryCount)
{
}
}
}