Skip to content

Conversation

@gep13
Copy link
Member

@gep13 gep13 commented May 26, 2025

Currently, Cake prints out a task execution summary on each successful execution. This summary includes which tasks were executed or skipped, and the duration of the task. However, then an execution of Cake fails, the task summary is not printed, and it is necessary to scroll through the Cake output, to find out what task failed. You also lose the information about which tasks, if any, were skipped.

Any changes to this workflow will have to be done carefully though, as we don't want to alter how tasks are executed, in what order, or what is done in the cases of ContinueOnError, etc. There are a number of unit tests that check for this execution, and these will need to continue to pass.

This commit aims to address this problem by introducing a new CakeReportException, which has a property called Report of type CakeReport. That way, when an exception needs to be thrown, the current execution status report can be passed along with it, and from there, the task execution summary can be printed.

The introduction of the CakeReportException has meant that a number of unit tests have had to be updated, since there is an expectation that an InvalidOperationException will be returned, however, I think that this is "ok", since it hasn't meant a change to how the workflow of task executions completes.

@gep13 gep13 requested a review from devlead May 26, 2025 10:01
@gep13
Copy link
Member Author

gep13 commented May 26, 2025

The output of these changes can be seen here:

image

For both the CakeSpectreReportPrinter and the CakeReportPrinter.

@gep13
Copy link
Member Author

gep13 commented May 26, 2025

When attempting to solve this problem, I tried to:

  • simply remove the throw here, but that introduced a number of failing tests, which led me to think it was a bad idea
  • pass the _reportPrinter through in the call to RunTargetAsync here, but that was a fairly serious breaking change, that I didn't want to continue with

While this is technically a breaking change, since the exception type that is returned is different, the original exception type is still available to be found, so I personally think that this is "ok".

Happy to hear any other ideas about what can be done here.

Currently, Cake prints out a task execution summary on each successful
execution.  This summary includes which tasks were executed or skipped,
and the duration of the task.  However, then an execution of Cake
fails, the task summary is not printed, and it is necessary to scroll
through the Cake output, to find out what task failed.  You also lose
the information about which tasks, if any, were skipped.

Any changes to this workflow will have to be done carefully though, as
we don't want to alter how tasks are executed, in what order, or what
is done in the cases of ContinueOnError, etc.  There are a number of
unit tests that check for this execution, and these will need to
continue to pass.

This commit aims to address this problem by introducing a new
CakeReportException, which has a property called Report of type
CakeReport.  That way, when an exception needs to be thrown, the
current execution status report can be passed along with it, and from
there, the task execution summary can be printed.

The introduction of the CakeReportException has meant that a number of
unit tests have had to be updated, since there is an expectation that
an InvalidOperationException will be returned, however, I think that
this is "ok", since it hasn't meant a change to how the workflow of
task executions completes.
Copy link
Member

@patriksvensson patriksvensson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@gep13
Copy link
Member Author

gep13 commented May 26, 2025

@patriksvensson no objections to the possible breaking change here? Or do you not consider it a break?

@devlead
Copy link
Member

devlead commented May 26, 2025

@patriksvensson no objections to the possible breaking change here? Or do you not consider it a break?

Internal bits so think it's fine.

Copy link
Member

@devlead devlead left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@patriksvensson
Copy link
Member

No, changing the exception type (if I understand correctly) might theoretically be a breaking change but I can't see how this will impact anyone.

@devlead devlead changed the title (#4475) Always show task execution summary GH4475: Always show task execution summary May 26, 2025
@devlead devlead enabled auto-merge May 26, 2025 10:52
@patriksvensson
Copy link
Member

Perhaps make CakeReportException inherit from CakeException would be a good idea when I think of it.

@gep13
Copy link
Member Author

gep13 commented May 26, 2025

@patriksvensson said...
Perhaps make CakeReportException inherit from CakeException would be a good idea when I think of it.

No objections to doing that.

Are you both happy with CakeReportException? I sort of wanted to go with CakeExceptionWithReport but that didn't seem right.

@devlead devlead merged commit 260d274 into cake-build:develop May 26, 2025
15 checks passed
@gep13
Copy link
Member Author

gep13 commented May 26, 2025

@patriksvensson running into this...

'CakeReportException': cannot derive from sealed type 'CakeException'

Should I unseal CakeException? Or what is the correct course of action here?

@devlead
Copy link
Member

devlead commented May 26, 2025

Missed last comment after enabled automerge.

Agree CakeReportException should inherit CakeException.
@gep13 Please follow up with a PR when possible.

@gep13 gep13 deleted the issue4475 branch May 26, 2025 11:08
@gep13
Copy link
Member Author

gep13 commented May 26, 2025

@devlead happy to follow up with another PR, but I am unsure about unsealing CakeException.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Script execution does not always show a report summary

3 participants