If there are just one missed command in a test run, the task throws an exception,
Verbose logs
Missed commands in source files:
ERROR: Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'.
At C:\source\DscResource.Base\output\RequiredModules\Sampler\0.116.0\tasks\JaCoCo.coverage.build.ps1:381 char:5
+ $allMissedCommandsInSourceFiles = $missedCommands + (
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
At C:\source\DscResource.Base\output\RequiredModules\Sampler\0.116.0\tasks\JaCoCo.coverage.build.ps1:245 char:1
+ task Convert_Pester_Coverage {
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Build FAILED. 8 tasks, 1 errors, 0 warnings 00:00:04.8901719
InvalidOperation: C:\source\DscResource.Base\output\RequiredModules\Sampler\0.116.0\tasks\JaCoCo.coverage.build.ps1:381
Line |
381 | $allMissedCommandsInSourceFiles = $missedCommands + (
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'.
How to reproduce
Run the task on a test suite that only missed one command in the code.
Expected behavior
Should not throw.
Current behavior
Throws an exception:
ERROR: Method invocation failed because [System.Management.Automation.PSObject] does not contain a method named 'op_Addition'.
At C:\source\DscResource.Base\output\RequiredModules\Sampler\0.116.0\tasks\JaCoCo.coverage.build.ps1:381 char:5
+ $allMissedCommandsInSourceFiles = $missedCommands + (
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Should be changed so that $missedCommands and $missedCommands are always an array even if there is just one entry. This can be acccomplished by adding a comma after the assignment operator.
# Get all missed commands that are in the main module file.
$missedCommands = , $originalMissedCommands |
Where-Object -FilterScript { $_.File -match [RegEx]::Escape($moduleFileName) }
# Get all hit commands that are in the main module file.
$hitCommands = , $originalHitCommands |
Where-Object -FilterScript { $_.File -match [RegEx]::Escape($moduleFileName) }
Operating system the target node is running
n/a
PowerShell version and build the target node is running
Problem description
If there are just one missed command in a test run, the task throws an exception,
Verbose logs
How to reproduce
Run the task on a test suite that only missed one command in the code.
Expected behavior
Should not throw.
Current behavior
Throws an exception:
Suggested solution
The code block:
https://github.com/gaelcolas/Sampler/blob/3aa327f9e524148578cb885b9dfdf971724d8c90/.build/tasks/JaCoCo.coverage.build.ps1#L356-L362
Should be changed so that
$missedCommands
and$missedCommands
are always an array even if there is just one entry. This can be acccomplished by adding a comma after the assignment operator.Operating system the target node is running
PowerShell version and build the target node is running
Module version used