-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add explicit formatting for Github Actions and Azure Pipelines
- Loading branch information
Showing
8 changed files
with
135 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
filter GetGooglePositionMessage { | ||
[CmdletBinding()] | ||
[OUtputType([string])] | ||
param( | ||
[Parameter(ValueFromPipeline)] | ||
[System.Management.Automation.ErrorRecord] | ||
$InputObject | ||
) | ||
$InvocationInfo = $InputObject.InvocationInfo | ||
# Handle case where there is a TargetObject from a Pester `Should` assertion failure and we can show the error at the target rather than the script source | ||
# Note that in some versions, this is a Dictionary<,> and in others it's a hashtable. So we explicitly cast to a shared interface in the method invocation | ||
# to force using `IDictionary.Contains`. Hashtable does have it's own `ContainKeys` as well, but if they ever opt to use a custom `IDictionary`, that may not. | ||
$useTargetObject = $null -ne $InputObject.TargetObject -and | ||
$InputObject.TargetObject -is [System.Collections.IDictionary] -and | ||
([System.Collections.IDictionary]$InputObject.TargetObject).Contains('Line') -and | ||
([System.Collections.IDictionary]$InputObject.TargetObject).Contains('LineText') | ||
|
||
$file = if ($useTargetObject) { | ||
"$($InputObject.TargetObject.File)" | ||
} elseif (.ScriptName) { | ||
"$($InvocationInfo.ScriptName)" | ||
} | ||
|
||
$line = if ($useTargetObject) { | ||
$InputObject.TargetObject.Line | ||
} else { | ||
$InvocationInfo.ScriptLineNumber | ||
} | ||
|
||
if ($useTargetObject) { | ||
"sourcepath=$file;linenumber=$line" | ||
} else { | ||
$column = $InvocationInfo.OffsetInLine | ||
"sourcepath=$file;linenumber=$line,columnnumber=$column" | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...private/GetConciseViewPositionMessage.ps1 → source/private/GetConciseMessage.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
filter GetErrorTitle { | ||
[CmdletBinding()] | ||
[OUtputType([string])] | ||
param( | ||
[Parameter(ValueFromPipeline)] | ||
[System.Management.Automation.ErrorRecord] | ||
$InputObject | ||
) | ||
if (! $err.ErrorDetails -or ! $err.ErrorDetails.Message) { | ||
if ($err.CategoryInfo.Category -eq 'ParserError' -and $err.Exception.Message.Contains("~$newline")) { | ||
# need to parse out the relevant part of the pre-rendered positionmessage | ||
$err.Exception.Message.split("~$newline")[1].split("${newline}${newline}")[0] | ||
} elseif ($err.Exception) { | ||
$err.Exception.Message | ||
} elseif ($err.Message) { | ||
$err.Message | ||
} else { | ||
$err.ToString() | ||
} | ||
} else { | ||
$err.ErrorDetails.Message | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
filter GetErrorTitle { | ||
[CmdletBinding()] | ||
[OUtputType([string])] | ||
param( | ||
[Parameter(ValueFromPipeline)] | ||
[System.Management.Automation.ErrorRecord] | ||
$InputObject | ||
) | ||
|
||
if ($InputObject.Exception -and $InputObject.Exception.WasThrownFromThrowStatement) { | ||
'Exception' | ||
# MyCommand can be the script block, so we don't want to show that so check if it's an actual command | ||
} elseif ($InputObject.InvocationInfo.MyCommand -and $InputObject.InvocationInfo.MyCommand.Name -and (Get-Command -Name $InputObject.InvocationInfo.MyCommand -ErrorAction Ignore)) { | ||
$InputObject.InvocationInfo.MyCommand | ||
} elseif ($InputObject.CategoryInfo.Activity) { | ||
# If it's a scriptblock, better to show the command in the scriptblock that had the error | ||
$InputObject.CategoryInfo.Activity | ||
} elseif ($InputObject.InvocationInfo.MyCommand) { | ||
$InputObject.InvocationInfo.MyCommand | ||
} elseif ($InputObject.InvocationInfo.InvocationName) { | ||
$InputObject.InvocationInfo.InvocationName | ||
} elseif ($InputObject.CategoryInfo.Category) { | ||
$InputObject.CategoryInfo.Category | ||
} elseif ($InputObject.CategoryInfo.Reason) { | ||
$InputObject.CategoryInfo.Reason | ||
} else { | ||
'Error' | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
filter GetGoogleWorkflowPositionMessage { | ||
[CmdletBinding()] | ||
[OUtputType([string])] | ||
param( | ||
[Parameter(ValueFromPipeline)] | ||
[System.Management.Automation.ErrorRecord] | ||
$InputObject | ||
) | ||
$InvocationInfo = $InputObject.InvocationInfo | ||
# Handle case where there is a TargetObject from a Pester `Should` assertion failure and we can show the error at the target rather than the script source | ||
# Note that in some versions, this is a Dictionary<,> and in others it's a hashtable. So we explicitly cast to a shared interface in the method invocation | ||
# to force using `IDictionary.Contains`. Hashtable does have it's own `ContainKeys` as well, but if they ever opt to use a custom `IDictionary`, that may not. | ||
$useTargetObject = $null -ne $InputObject.TargetObject -and | ||
$InputObject.TargetObject -is [System.Collections.IDictionary] -and | ||
([System.Collections.IDictionary]$InputObject.TargetObject).Contains('Line') -and | ||
([System.Collections.IDictionary]$InputObject.TargetObject).Contains('LineText') | ||
|
||
$file = if ($useTargetObject) { | ||
"$($InputObject.TargetObject.File)" | ||
} elseif (.ScriptName) { | ||
"$($InvocationInfo.ScriptName)" | ||
} | ||
|
||
$line = if ($useTargetObject) { | ||
$InputObject.TargetObject.Line | ||
} else { | ||
$InvocationInfo.ScriptLineNumber | ||
} | ||
|
||
if ($useTargetObject) { | ||
"file=$file,line=$line" | ||
} else { | ||
$column = $InvocationInfo.OffsetInLine | ||
|
||
$Length = $InvocationInfo.PositionMessage.Split($newline)[-1].Substring(1).Trim().Length | ||
$endColumn = $column + $Length | ||
"file=$file,line=$line,col=$column,endColumn=$endColumn" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters