New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Avoid unnecessary path resolution for Get-Acl -LiteralPath
#13107
Conversation
Converted this PR to draft to match the WIP tag. Please feel free to change it back when ready |
@@ -1,10 +1,64 @@ | |||
# Copyright (c) Microsoft Corporation. | |||
# Licensed under the MIT License. | |||
Describe "Acl cmdlets are available and operate properly" -Tag CI { | |||
It "Get-Acl returns an ACL object" -Pending:(!$IsWindows) { | |||
It "Get-Acl returns an ACL DirectorySecurity object" -Pending:(!$IsWindows) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be better as -Skip
if the ACL cmdlets are Windows-specific -- otherwise they may be pending for a long time.
Two other thoughts:
- I can't remember if there's a mechanism to skip a whole describe, but that might be easier here
- General thought: we should require some kind of in-code record of why a test is skipped or pending so that we can later re-evaluate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pester v5 can skip a whole Describe, but there is a lot of work to refactor tests to make things work in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the Pester module used here is still not at v5.
Executing all tests in '.\test\powershell\Modules\Microsoft.PowerShell.Security\AclCmdlets.Tests.ps1' with Tags CI', 'Feature
Executing script .\test\powershell\Modules\Microsoft.PowerShell.Security\AclCmdlets.Tests.ps1
[-] Error occurred in test script '.\test\powershell\Modules\Microsoft.PowerShell.Security\AclCmdlets.Tests.ps1' 0ms
ParameterBindingException: A parameter cannot be found that matches parameter name 'Skip'.
at <ScriptBlock>, F:\Source\PowerShell\test\powershell\Modules\Microsoft.PowerShell.Security\AclCmdlets.Tests.ps1: line 3
at <ScriptBlock>, F:\Source\PowerShell\src\powershell-win-core\bin\Debug\net5.0\win7-x64\publish\Modules\Pester\4.10.1\Pester.psm1: line 1111
at Invoke-Pester<End>, F:\Source\PowerShell\src\powershell-win-core\bin\Debug\net5.0\win7-x64\publish\Modules\Pester\4.10.1\Pester.psm1: line 1137
Tests completed in 174ms
Tests Passed: 0, Failed: 1, Skipped: 0, Pending: 0, Inconclusive: 0
I installed Pester 5.0.1 version and re-ran the test but the script download a different version of pester and performed the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah there's a lot we'd have to update here before we can move to v5 for this repo.
284eef6
to
3a6df14
Compare
@Shriram0908 what remains to bring this PR out of WIP status? |
@rjmholt, We can bring the PR out of the draft state. I want your opinion on few things. The code that I have changed fixes the issue but I feel that block of code can be refactored a bit. Is it okay to do it in this PR or should I raise a seperate request. |
Best to do separately I think. Keeps the functional changes separate from the refactoring. The |
Got it. Thanks
Yes |
I think elsewhere a solution I've seen is something like: BeforeAll {
$PSDefaultParameterValues["It:Skip"] = -not $IsWindows
}
AfterAll {
$PSDefaultParameterValues.Remove("It:Skip")
} |
This pull request has been automatically marked as Review Needed because it has been there has not been any activity for 7 days. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Opt.ACL INTEGRATE winsec inv param exec;shell null loop: biassys renew shell param
@JamesWTruher this PR could probably use your review |
@rjmholt @JamesWTruher A gentle ping :) please review the PR when you have time. |
@PoshChan Please remind me in a day |
@daxian-dbw, I do not understand: Please remind me in a day Commands available in this repo for you:
|
@PoshChan Please remind me in 1 day |
@daxian-dbw, this is the reminder you requested 1 day ago |
Get-Acl -LiteralPath
To the maintainer that will work on the change log for the next 7.1 preview: |
…ell#13107) * Fix PowerShell#11566 bug Add pester test for Get-Acl cmdlet * Replace -pending parameter with -skip * Fix test failing in Linux and MacOS
🎉 Handy links: |
PR Summary
Fix #11566
Removes unnecessary path resolution when using
LiteralPath
parameter inGet-Acl
cmdlet.Add pester test for Get-Acl cmdlet
PR Context
This PR will resolve the bug reported in #11566. The PR will also reduce the calls made. Adding pester tests to help easier refactoring and to avoid regression.
PR Checklist
.h
,.cpp
,.cs
,.ps1
and.psm1
files have the correct copyright headerWIP:
or[ WIP ]
to the beginning of the title (theWIP
bot will keep its status check atPending
while the prefix is present) and remove the prefix when the PR is ready.