Skip to content

Commit

Permalink
Fix error triggered in label step execution not logged
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Nov 11, 2024
1 parent 43fdea2 commit a73f205
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion osu.Framework/Testing/TestBrowser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,7 @@ private static IEnumerable getTestCaseSourceValue(MethodInfo testMethod, TestCas
private void runTests(Action onCompletion)
{
int actualStepCount = 0;
CurrentTest.RunAllSteps(onCompletion, e => Logger.Log($@"Error on step: {e}"), s =>
CurrentTest.RunAllSteps(onCompletion, (s, e) => Logger.Error(e, $"Step {s} triggered an error"), s =>
{
if (!interactive || RunAllSteps.Value)
return false;
Expand Down
8 changes: 4 additions & 4 deletions osu.Framework/Testing/TestScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ protected TestScene()
private ScheduledDelegate stepRunner;
private readonly ScrollContainer<Drawable> scroll;

public void RunAllSteps(Action onCompletion = null, Action<Exception> onError = null, Func<StepButton, bool> stopCondition = null, StepButton startFromStep = null)
public void RunAllSteps(Action onCompletion = null, Action<StepButton, Exception> onError = null, Func<StepButton, bool> stopCondition = null, StepButton startFromStep = null)
{
// schedule once as we want to ensure we have run our LoadComplete before attempting to execute steps.
// a user may be adding a step in LoadComplete.
Expand All @@ -222,7 +222,7 @@ public void RunAllSteps(Action onCompletion = null, Action<Exception> onError =

private StepButton loadableStep => actionIndex >= 0 ? StepsContainer.Children.ElementAtOrDefault(actionIndex) as StepButton : null;

private void runNextStep(Action onCompletion, Action<Exception> onError, Func<StepButton, bool> stopCondition)
private void runNextStep(Action onCompletion, Action<StepButton, Exception> onError, Func<StepButton, bool> stopCondition)
{
try
{
Expand All @@ -242,7 +242,7 @@ private void runNextStep(Action onCompletion, Action<Exception> onError, Func<St
: "💥 Failed");

LoadingComponentsLogger.LogAndFlush();
onError?.Invoke(e);
onError?.Invoke(loadableStep, e);
return;
}

Expand Down Expand Up @@ -306,7 +306,7 @@ public void AddLabel([NotNull] string description)

// kinda hacky way to avoid this doesn't get triggered by automated runs.
if (step.IsHovered)
RunAllSteps(startFromStep: step, stopCondition: s => s is LabelStep);
RunAllSteps(startFromStep: step, stopCondition: s => s is LabelStep, onError: (s, e) => Logger.Error(e, $"Step {s} triggered error"));
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion osu.Framework/Testing/TestSceneTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void complete()
test.RunAllSteps(() =>
{
Scheduler.AddDelayed(complete, time_between_tests);
}, e =>
}, (_, e) =>
{
exception = ExceptionDispatchInfo.Capture(e);
complete();
Expand Down

0 comments on commit a73f205

Please sign in to comment.