Skip to content

Commit

Permalink
Log number of threads after test run
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Aug 15, 2024
1 parent 70cfac0 commit d98fc65
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ jobs:
os:
- { prettyname: Windows, fullname: windows-latest }
# macOS runner performance has gotten unbearably slow so let's turn them off temporarily.
# - { prettyname: macOS, fullname: macos-latest }
- { prettyname: macOS, fullname: macos-latest }
- { prettyname: Linux, fullname: ubuntu-latest }
threadingMode: ['SingleThread', 'MultiThreaded']
timeout-minutes: 120
Expand All @@ -82,7 +82,7 @@ jobs:
run: dotnet build -c Debug -warnaserror osu.Desktop.slnf

- name: Test
run: dotnet test $pwd/**/*.Tests/bin/Debug/*/*.Tests.dll --logger "trx;LogFileName=TestResults-${{matrix.os.prettyname}}-${{matrix.threadingMode}}.trx" -- NUnit.ConsoleOut=0
run: dotnet test $pwd/**/*.Tests/bin/Debug/*/*.Tests.dll
shell: pwsh

# Attempt to upload results even if test fails.
Expand Down
15 changes: 15 additions & 0 deletions osu.Game/Tests/Visual/OsuTestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
using System.Threading;
using System.Threading.Tasks;
using JetBrains.Annotations;
using NUnit.Framework;
using NUnit.Framework.Interfaces;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Audio.Track;
Expand All @@ -19,6 +21,7 @@
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Framework.Testing;
using osu.Framework.Timing;
Expand All @@ -38,6 +41,7 @@

namespace osu.Game.Tests.Visual
{
[LogThreads]
public abstract partial class OsuTestScene : TestScene
{
[Cached]
Expand Down Expand Up @@ -538,5 +542,16 @@ protected override void InitialiseFonts()

public void RunTestBlocking(TestScene test) => runner.RunTestBlocking(test);
}

private class LogThreads : TestActionAttribute
{
public override void AfterTest(ITest test)
{
base.AfterTest(test);
Logger.Log($"[Suite] Threads: {Process.GetCurrentProcess().Threads.Count}");
}

public override ActionTargets Targets => ActionTargets.Test;
}
}
}

0 comments on commit d98fc65

Please sign in to comment.