Fix error triggered in label step execution not logged

This commit is contained in:
Salman Alshamrani
2024-11-11 16:38:30 -05:00
parent 43fdea246d
commit a73f205b63
3 changed files with 6 additions and 6 deletions

View File

@@ -590,7 +590,7 @@ namespace osu.Framework.Testing
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;

View File

@@ -204,7 +204,7 @@ namespace osu.Framework.Testing
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.
@@ -222,7 +222,7 @@ namespace osu.Framework.Testing
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
{
@@ -242,7 +242,7 @@ namespace osu.Framework.Testing
: "💥 Failed");
LoadingComponentsLogger.LogAndFlush();
onError?.Invoke(e);
onError?.Invoke(loadableStep, e);
return;
}
@@ -306,7 +306,7 @@ namespace osu.Framework.Testing
// 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"));
},
});
}

View File

@@ -76,7 +76,7 @@ namespace osu.Framework.Testing
test.RunAllSteps(() =>
{
Scheduler.AddDelayed(complete, time_between_tests);
}, e =>
}, (_, e) =>
{
exception = ExceptionDispatchInfo.Capture(e);
complete();