Pester icon indicating copy to clipboard operation
Pester copied to clipboard

Shorten length of temp directory name

Open splatteredbits opened this issue 3 years ago • 2 comments

Checklist

Summary of the feature request

As a Pester user on Windows, I sometimes get failures due to Windows' 260 character max path limitation. When Pester creates the temp directory for its test drive, it uses a Guid, which is 36 characters long, e.g. C:\Users\username\AppData\Local\Temp\19718499-6c05-4f67-bc4c-344f5c47c7bd.

Please shorten this to a four character directory name. This is what [IO.Path]::GetRandomFileName() uses for uniqueness. This saves 32 characters in the path.

How should it work?

Instead of using an entire GUID for the temp directory name, use just the first four characters. Change this (in TestDrive.ps1):

$Path = [IO.Path]::Combine($tempPath, ([Guid]::NewGuid()))

to

$Path = [IO.Path]::Combine($tempPath, ([Guid]::NewGuid().ToString().Substring(0, 4)))

splatteredbits avatar Aug 11 '22 18:08 splatteredbits

PR incoming...

splatteredbits avatar Aug 11 '22 18:08 splatteredbits

PR

splatteredbits avatar Aug 11 '22 18:08 splatteredbits