Skip to content

Fix continueonerror#296

Merged
devblackops merged 3 commits intopsake:masterfrom
UberDoodles:fix-continueonerror
Apr 12, 2020
Merged

Fix continueonerror#296
devblackops merged 3 commits intopsake:masterfrom
UberDoodles:fix-continueonerror

Conversation

@UberDoodles
Copy link
Copy Markdown
Contributor

Description

  1. Created a Pester test to assert that the -ContinueOnError parameter has the desired behaviour.
  2. Removed the additional call stack pop from Invoke-Task, which was causing that test to fail.
  3. Added a try...finally to Invoke-Task immediately after the task is pushed onto the stack. The finally block ensures that the task is always popped, even if the task fails. This resolved a new bug which surfaced, where if a task with -ContinueOnError depends on another task, which fails, the failed task would not pop itself from the stack, and when the dependent task tried to pop itself from the stack, it would actually pop the failed task, causing a validation error.

Related Issue

#295

Motivation and Context

As described in the issue, this is an issue which has broken a feature which previously worked.

How Has This Been Tested?

Created a new Pester test, and ran all existing tests locally.

Tested on Windows 10, Powershell 5.1.

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

The current task is popped from the call stack at the end of the function. When the task fails and -ContinueOnError is specified, the catch block unnecessarily pops the task from the call stack at this point. This causes the pop at the end of the function to actually pop the parent task from the stack.
This is to resolve a specific scenario where a task with -ContinueOnError depends on a task which fails. The task which fails never pops itself from the stack (it fails before it gets to that point), then the task which depends on in attempts to pop itself from the stack, but actually pops the failed task, which results in a validation error.

To fix this, I've added a try block immediately after the task is pushed onto the stack, and put the code which pops it into a finally block.
@devblackops
Copy link
Copy Markdown
Member

Thanks for fixing this @UberDoodles!

@devblackops devblackops self-assigned this Apr 12, 2020
@devblackops devblackops merged commit eb37760 into psake:master Apr 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants