FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Improve test coverage for CDXML cmdlet infrastructure by JamesWTruher · Pull Request #4537 · PowerShell/PowerShell · GitHub

Improve test coverage for CDXML cmdlet infrastructure - #4537

Merged
Dongbo Wang (daxian-dbw) merged 4 commits into
PowerShell:masterfrom
JamesWTruher:jameswtruher/cdxmltest001
Aug 16, 2017
Merged

Improve test coverage for CDXML cmdlet infrastructure #4537
Dongbo Wang (daxian-dbw) merged 4 commits into
PowerShell:masterfrom
JamesWTruher:jameswtruher/cdxmltest001

Conversation

Copy link
Copy Markdown
Collaborator

address issue #4159

Create custom cim classes (via MOF) and cdxml cmdlets against the new cim class
Create tests for CRUD operations for CDXML cmdlets
Coverage for Microsoft.PowerShell.Cmdletization namespace is nearly 50%

Includes MOF files to create and delete class and instances which are used by the tests
updated create mof file to support associations as well as complex objects
updated delete mof file to remove all classes
added an enum to cdxml (not yet used)
updated psd1 to export new cmdlets for set and new

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM with minor comments

Context "Remove-CimTest cmdlet" {
BeforeEach {
Get-CimTest | Remove-CimTest
1..4 | %{ New-CimInstance -namespace root/default -class PSCore_Test1 -property @{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Please use ForEach-Object instead of %

Dongbo Wang (daxian-dbw) Aug 12, 2017
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

This needs to be addressed.
As stated in #3791, our scripts should not have PSScriptAnalyzer warnings and errors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fixed

field2 = 0
}
New-CimTest @instanceArgs
$result = Get-CimInstance -namespace root/default -class PSCore_Test1 | ?{$_.id -eq "telephone"}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Use Where-Object instead of ?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Same here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fixed

$result.field2 | should be 33
}
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Extra line.

HelpInfoUri = "https://go.microsoft.com/fwlink/?linkid=390832"
}


Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Remove extra lines.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fixed

AliasesToExport = @()
CmdletsToExport = @()
FunctionsToExport = @( 'Get-CimTest', 'Remove-CimTest', 'New-CimTest', 'Set-CimTest' )
HelpInfoUri = "https://go.microsoft.com/fwlink/?linkid=390832"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do we need this? This probably points to something else.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

probably not - removed

Describe "Cdxml cmdlets are supported" -Tag CI,RequireAdminOnWindows {
BeforeAll {
$skipNotWindows = ! $IsWindows
if ( $skipNotWindows ) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why not use a direct $IsWindows test versus a variable?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I thought it was clearer here -skip (I've seen other tests do exactly the opposite of what was wanted)

}
$result = MofComp.exe $deleteMof
if ( $LASTEXITCODE -ne 0 ) {
$script:ItSkipOrPending = @{ Pending = $true }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why isn't this an outright failure? It appears to be masking a bug.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I thought about this, and while it might be a bug in the mof file or a problem with mofcomp, marking a test as pending doesn't get us off the hook - all pending tests must be resolved before we ship (and I do track our pending tests). However, I didn't want to invalidate the build because I couldn't even get to the actual test. I thought it was better to mark the test as pending rather than fail.

$job = Get-CimTest -id 3 | Remove-CimTest -asjob
$result = $null
$i = 0
# wait up to 10 seconds, then the test will fail

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why isn't Wait-Job -Timeout sufficient?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

ahem, yes, that's much better
-fixed-

If there is a problem with mofcomp execution, the tests will fail rather than
being marked as pending (feedback from DanTra)
use cmdlet names rather than aliases for foreach-object and where-object
Script analyzer report is clean

Also remove unneeded empty lines and helpinfouri from psd1 file

Copy link
Copy Markdown
Collaborator Author

Dan Travison (@dantraMSFT), I believe this is ok now

Copy link
Copy Markdown
Member

Dan Travison (@dantraMSFT) Can you please take another look at this PR?

Dongbo Wang (daxian-dbw) merged commit 0d1e191 into PowerShell:master Aug 16, 2017
James Truher (JamesWTruher) deleted the jameswtruher/cdxmltest001 branch May 11, 2022 16:35
Thatgfsj (Thatgfsj) pushed a commit to Thatgfsj/PowerShell that referenced this pull request Aug 6, 2026
Create custom CIM classes (via MOF) and CDXML cmdlets against the new CIM class
Create tests for CRUD operations for CDXML cmdlets
Coverage for Microsoft.PowerShell.Cmdletization namespace is nearly 50%
This file contains hidden or 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
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.

5 participants


Back | FazBrowse Home | New Git URL