Skip to content

Commit

Permalink
Further improve stacktrace output
Browse files Browse the repository at this point in the history
  • Loading branch information
smoogipoo committed Nov 11, 2024
1 parent 5c2d7fc commit 846bc9b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 28 deletions.
4 changes: 3 additions & 1 deletion osu.Framework/Testing/Drawables/Steps/AssertButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

using System;
using System.Diagnostics;
using System.Runtime.ExceptionServices;
using System.Text;
using NUnit.Framework;
using osuTK.Graphics;

namespace osu.Framework.Testing.Drawables.Steps
Expand Down Expand Up @@ -38,7 +40,7 @@ private void checkAssert()
if (GetFailureMessage != null)
builder.Append($": {GetFailureMessage()}");

throw new TracedException(builder.ToString(), CallStack);
throw ExceptionDispatchInfo.SetRemoteStackTrace(new AssertionException(builder.ToString()), CallStack.ToString());
}
}

Expand Down
21 changes: 0 additions & 21 deletions osu.Framework/Testing/Drawables/Steps/TracedException.cs

This file was deleted.

4 changes: 3 additions & 1 deletion osu.Framework/Testing/Drawables/Steps/UntilStepButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

using System;
using System.Diagnostics;
using System.Runtime.ExceptionServices;
using System.Text;
using NUnit.Framework;
using osu.Framework.Graphics;
using osuTK.Graphics;

Expand Down Expand Up @@ -59,7 +61,7 @@ private void checkAssert()
if (GetFailureMessage != null)
builder.Append($": {GetFailureMessage()}");

throw new TracedException(builder.ToString(), CallStack);
throw ExceptionDispatchInfo.SetRemoteStackTrace(new AssertionException(builder.ToString()), CallStack.ToString());
}

Action?.Invoke();
Expand Down
11 changes: 6 additions & 5 deletions osu.Framework/Testing/TestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ protected void AddUntilStep([CanBeNull] string description, [NotNull] Func<bool>
{
Text = description ?? @"Until",
IsSetupStep = addStepsAsSetupSteps,
CallStack = new StackTrace(1),
CallStack = new StackTrace(1, true),
Assertion = waitUntilTrueDelegate,
});
}
Expand All @@ -344,7 +344,7 @@ protected void AddUntilStep<T>([CanBeNull] string description, [NotNull] ActualV
{
Text = description ?? @"Until",
IsSetupStep = addStepsAsSetupSteps,
CallStack = new StackTrace(1),
CallStack = new StackTrace(1, true),
Assertion = () =>
{
lastResult = constraint().Resolve().ApplyTo(actualValue());
Expand Down Expand Up @@ -389,12 +389,13 @@ protected void AddAssert([NotNull] string description, [NotNull] Func<bool> asse
Text = description,
IsSetupStep = addStepsAsSetupSteps,
ExtendedDescription = extendedDescription,
CallStack = new StackTrace(1),
CallStack = new StackTrace(1, true),
Assertion = assert,
});
}

protected void AddAssert<T>([NotNull] string description, [NotNull] ActualValueDelegate<T> actualValue, [NotNull] Func<IResolveConstraint> constraint, [CanBeNull] string extendedDescription = null)
protected void AddAssert<T>([NotNull] string description, [NotNull] ActualValueDelegate<T> actualValue, [NotNull] Func<IResolveConstraint> constraint,
[CanBeNull] string extendedDescription = null)
{
ConstraintResult lastResult = null;

Expand All @@ -403,7 +404,7 @@ protected void AddAssert<T>([NotNull] string description, [NotNull] ActualValueD
Text = description,
IsSetupStep = addStepsAsSetupSteps,
ExtendedDescription = extendedDescription,
CallStack = new StackTrace(1),
CallStack = new StackTrace(1, true),
Assertion = () =>
{
lastResult = constraint().Resolve().ApplyTo(actualValue());
Expand Down

0 comments on commit 846bc9b

Please sign in to comment.