Skip to content

Replace Pester submodule with import #1371

Description

Per #1275 we need to test if we can use the Pester package and remove the submodule. Failing that, we will likely move it to a vendor folder.

Activity

  1. vors commented on Jul 30, 2016

    @vors
    Collaborator

    It's not going to work on non-windows without additional changes.
    This is post-Aug17 release item.

  2. added this to the Future milestone on Jul 30, 2016
  3. dlwyatt commented on Jul 30, 2016

    @dlwyatt
    Contributor

    I can't see the submodule's repository yet, but happy to take a look and see what changes need to be made in Pester once I've got access.

  4. vors commented on Jul 30, 2016

    @vors
    Collaborator
  5. dlwyatt commented on Jul 30, 2016

    @dlwyatt
    Contributor

    Working on it, should have something ready soon.

    I'm really not a fan of reading ${directorySeparatorChar} all over the place, so I'm doing that a different way. In most places, I'm just using / instead of \ (if it works fine on Windows anyway), and in some cases, using a new proxy function of Join-Path with nicer syntax for joining multiple path parts, like so:

    <#
        The "Ex" naming is stupid; I just want something to make it clear in the calls to this function that it's _not_
        the original Join-Path cmdlet (and doesn't need to be guarded with $SafeCommands.)
    
        The difference is that ChildPath is now an array with ValueFromRemainingArguments defined, so we can do this:
    
        Join-PathEx One Two Three Four Five
    
        However, we've removed pipeline input support from the ChildPath parameter, as a tradeoff.
    #>
    function Join-PathEx
    {
        [CmdletBinding()]
        param(
            [Parameter(Mandatory = $true, Position = 0, ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
            [Alias('PSPath')]
            [string[]]
            ${Path},
    
            [Parameter(Mandatory = $true, Position = 1, ValueFromRemainingArguments = $true)]
            [AllowEmptyString()]
            [AllowNull()]
            [string[]]
            ${ChildPath},
    
            [switch]
            ${Resolve},
    
            [Parameter(ValueFromPipelineByPropertyName = $true)]
            [pscredential]
            [System.Management.Automation.CredentialAttribute()]
            ${Credential}
        )
    
        begin
        {
            $null = $PSBoundParameters.Remove('Path')
            $null = $PSBoundParameters.Remove('ChildPath')
    
            $combinedChildPath = ''
    
            if ($ChildPath.Count -gt 0)
            {
                $combinedChildPath = $ChildPath[0]
    
                for ($i = 1; $i -lt $ChildPath.Count; $i++)
                {
                    $combinedChildPath = & $SafeCommands['Join-Path'] -Path $combinedChildPath -ChildPath $ChildPath[$i] @PSBoundParameters
                }
            }
        }
    
        process
        {
            $null = $PSBoundParameters.Remove('Path')
            $null = $PSBoundParameters.Remove('ChildPath')
    
            foreach ($p in $Path)
            {
                & $SafeCommands['Join-Path'] -Path $p -ChildPath $combinedChildPath @PSBoundParameters
            }
        }
    }
        Describe 'Stripping common parent paths' {
            $paths = @(
                Join-PathEx C: Common Folder UniqueSubFolder1 File.ps1
                Join-PathEx C: Common Folder UniqueSubFolder2 File2.ps1
                Join-PathEx C: Common Folder UniqueSubFolder3 File3.ps1
            )
    
            $commonPath = Get-CommonParentPath -Path $paths
            $expectedCommonPath = Join-PathEx C: Common Folder
    
            It 'Identifies the correct parent path' {
                $commonPath | Should Be $expectedCommonPath
            }
    
            $expectedRelativePath = Join-PathEx UniqueSubfolder1 File.ps1
    
            It 'Strips the common path correctly' {
                Get-RelativePath -Path $paths[0] -RelativeTo $commonPath |
                Should Be $expectedRelativePath
            }
        }
  6. andyleejordan commented on Jul 30, 2016

    @andyleejordan
    MemberAuthor

    Dave Wyatt (@dlwyatt) backward slashes should no longer be an issue, we recently made PowerShell on Linux slash agnostic (with the caveat that literal backslashes in file paths are not yet supported).

  7. dlwyatt commented on Jul 30, 2016

    @dlwyatt
    Contributor

    Ah, even better. That accounts for most of the differences between Pester and the psl-Pester fork. :) Thanks!

  8. andyleejordan commented on Jul 31, 2016

    @andyleejordan
    MemberAuthor

    Just about ;) And thank you!

  9. dlwyatt commented on Aug 4, 2016

    @dlwyatt
    Contributor

    James Truher (@JamesWTruher) mentioned that Add-Type is also coming (or already there), so there's not much that needs to be done here. I've just opened a PR for Pester (pester/Pester#589) which should be all we need to support backslashes, I think.

    The only other big change I see between the psl fork is that the Invoke-PesterInJob function was completely rewritten to use in-proc runspaces instead of Start-Job. Is this because Start-Job is or was not available yet in Open PS? If so, I can copy that code over as well. (Should give us a slight performance boost anyway, getting rid of the overhead of starting a new process.)

  10. vors commented on Sep 2, 2016

    @vors
    Collaborator

    Dave Wyatt (@dlwyatt) any updates here?

    Also, would you like to be assigned to this issue?

  11. dlwyatt commented on Sep 2, 2016

    @dlwyatt
    Contributor

    When I went through the code differences, they seemed to be lumped into three categories: slashes, Add-Type, and Start-Job. I believe the first two are already fixed in PS, but Start-Job may not be working yet on Linux. (Pester itself doesn't actually need it, but it's used in some of the test suite.)

  12. dlwyatt commented on Sep 2, 2016

    @dlwyatt
    Contributor

    So basically, download the latest Pester on a Linux build, run it and see what happens :)

  13. vors commented on Sep 2, 2016

    @vors
    Collaborator

    OK, will do

    Adding #1979 for cross-reference

  14. 2 remaining items

  15. andyleejordan commented on Oct 6, 2016

    @andyleejordan
    MemberAuthor

    For #1979, we're going to remove the Pester submodule and rely on importing Pester.

    Maintainers are assigning this over to James Truher (@JamesWTruher) for investigation.

  16. modified the milestones: , post-6.0.0 on Oct 6, 2016
  17. JamesWTruher commented on Feb 21, 2017

    @JamesWTruher
    Collaborator

    Dave Wyatt (@dlwyatt) I'm finally looking at this now - is there a specific branch I should be validating against? Running against 3.4.6 is failing about 7% of the tests

  18. joeyaiello commented on May 23, 2017

    @joeyaiello
    Contributor

    James Truher (@JamesWTruher) as far as I can tell, we already removed the Pester submodule from the repository. Is this item now implicitly to use the latest version of Pester from the Gallery in our tests? If so, can we change the title to that effect and move this out to 6.1.0 (unless you see a reason for us to be on 3.4.6)?

  19. modified the milestones: , on May 23, 2017
  20. joeyaiello commented on May 23, 2017

    @joeyaiello
    Contributor

    Based on an offline conversation with James Truher (@JamesWTruher), while we should do this, we should hold this work off until Pester is fully cross-platform (which will likely not happen until after we release a stable 6.0.0).

  21. iSazonov commented on Feb 9, 2018

    @iSazonov
    Collaborator

    Aditya Patwardhan (@adityapatwardhan) Should we close the Issue too after #6064?

  22. added and removed
    Up-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributors
    on Feb 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugResolution-FixedThe issue is fixed.WG-Quality-Testissues in a test or in test infrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions