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

Fix error triggered in label step execution not being logged #6421

Merged
merged 2 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading