Adding PlatformNotSupportedException to Counter cmdlets when running on IoT.#2952
Conversation
…pdh.dll is not available.
…r cmdlets on IoT.
lzybkr
left a comment
There was a problem hiding this comment.
You are missing a test in Export-Counter.Tests.ps1
|
@lzybkr: Thanks for review. In order to run the Export-Counter cmdlet, you need to create a counter (which is not possible on IoT), this is the reason why there is not test for this scenario. |
|
|
||
| Describe "Get-Counter cmdlet does not run on IoT" -Tags "CI" { | ||
|
|
||
| It "Get-Counter throws PlatformNotSupportedException" -Skip:$(-not [System.Management.Automation.Platform]::IsIoT) { |
There was a problem hiding this comment.
We skip all counter test for Linux, IOS and IoT. Why do we test the throw only for IoT?
There was a problem hiding this comment.
Hi @iSazonov. The Counter cmdlets are present on CoreCLR for Windows systems only (which are Desktop with CoreCLR, Nano Server and IoT). On GitHub, we run our tests against Desktop, OSX, and Linux (Ubuntu). Because of this, almost all tests (with the exception of these two in this PR) will be skipped.
Going back to your question, we only throw on IoT because '$env:windir\System32\pdh.dll' is not present. Also, these cmdlets are not available on OSX and Ubuntu, so there is nothing to test there. I hope this make sense. Thanks.
…on IoT. (PowerShell#2952) * Adding PlatformNotSupportedException to *-Counter cmdlets for IoT as pdh.dll is not available. * Adding tests to validate PlatformNotSupportedException for the Counter cmdlets on IoT.
We have enabled the Counter cmdlets for PowerShell on OneCore for Windows. This means that these cmdlets are available Full Desktop with CoreCLR, Nano Server and IoT. However, one of the dependencies, the '$env:windir\System32\pdh.dll' assembly, is not available on IoT. Because of this, when the user tries to use the Counter cmdlets on IoT, they will get a PlatformNotSupportedException.
This PR includes the code change and new test cases to validate that PlatformNotSupportedException is thrown on IoT.