Skip to content
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

Use real path to temp path on macOS and GetTempPath() otherwise when constructing TestDrive #1294

Merged
merged 4 commits into from
May 1, 2019

Conversation

SteveL-MSFT
Copy link
Contributor

special case macOS to use /private/tmp which is the real folder path
otherwise, use GetTempPath() so that on Windows it returns the long path

1. General summary of the pull request

On macOS, the /tmp path is a symlink to /private/tmp, this causes problems in tests that create a test file and later tries to validate the path:

$testPath = Join-Path $TestDrive "foo"
...
$realPath | Should -BeExactly $testPath

This fails as $testPath will be something like: /tmp/foo but the real file path returned from some cmdlet or .NET API will be /private/tmp/foo.

On Windows, the problem is that $env:TEMP which is used to construct the TestDrive path uses the 8.1 path syntax. So on AzDevOps, the user is called VSSADMINISTRATOR so $env:TEMP is C:\Users\VSSADM~1\AppData\Local\Temp\ but similar to macOS where a test validates the paths, it will fail because a cmdlet or .NET API will often return the longpath C:\Users\VSSADMINISTRATOR\AppData\Local\Temp\.

On Linux, GetTempPath() simply returns /tmp/ which is correct.

otherwise, use GetTempPath() so that on Windows it returns the long path
@SteveL-MSFT
Copy link
Contributor Author

I'll fix the test failures tomorrow

@iSazonov
Copy link

Tests use

$expected = $env:TEMP = "C:\temp"

that doesn't change [io.path]::GetTempPath()

@nohwnd
Copy link
Member

nohwnd commented Apr 23, 2019

Interesting, I thought the code was using the GetTempPath() already.

@iSazonov
Copy link

iSazonov commented Apr 23, 2019

@SteveL-MSFT Do we ready jump to latest Pester version in PowerShell Core repo? I ask because perhaps we need servicing fix for version we use. Perhaps it is not good change Pester version and move to .Net Core 3.0 in the same time.

@SteveL-MSFT
Copy link
Contributor Author

@iSazonov unless there's a bunch of test failures with latest Pester, I don't see a reason not to move to latest stable version of Pester

@iSazonov
Copy link

In the case we should make this in PowerShell master branch before we move to .Net Core 3.0.

@SteveL-MSFT
Copy link
Contributor Author

@iSazonov we need to wait for a release first, but yes, we can take it in master branch

@nohwnd
Copy link
Member

nohwnd commented Apr 26, 2019

If you don't fix the name I will fix it and release on Saturday/Sunday.

@SteveL-MSFT
Copy link
Contributor Author

@nohwnd I believe your comment has been addressed

@nohwnd nohwnd merged commit c300092 into pester:master May 1, 2019
@SteveL-MSFT SteveL-MSFT deleted the testdrive-temp-path branch May 1, 2019 19:04
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.

3 participants