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

PowerShellGet: Change AllUsers scope install location to SHARED_MODULES path #5633

Merged
merged 1 commit into from
Dec 7, 2017

Conversation

bmanikm
Copy link
Contributor

@bmanikm bmanikm commented Dec 6, 2017

PR Checklist

Note: Please mark anything not applicable to this PR NA.

PR Summary

  • Changed the install location of AllUsers scope on PWSH to SHARED_MODULES location. PowerShell/PowerShellGet#175.
  • Refreshing the PowerShellGet.Tests.ps1 file from PowerShell/PowerShellGet repository.
  • Removed $IsCoreCLR variable usage.
  • Updated the logic for retrieving MyDocuments path on Windows.

@daxian-dbw daxian-dbw added this to the 6.0.0-RC.2 milestone Dec 6, 2017
@bmanikm bmanikm changed the title Refresh PowerShellGet.Tests.ps1 from PowerShell/PowerShellGet repository PowerShellGet: Change AllUsers scope install location to SHARED_MODULES path Dec 6, 2017
@bmanikm bmanikm force-pushed the updatepsgettestscript branch 2 times, most recently from b8d02ce to a01f5e4 Compare December 6, 2017 19:53
Copy link
Member

@daxian-dbw daxian-dbw left a comment

Choose a reason for hiding this comment

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

LGTM. Please add [feature] tag to the commit message to trigger a full test run.

@bmanikm bmanikm force-pushed the updatepsgettestscript branch 3 times, most recently from 21f0dc4 to 4426696 Compare December 6, 2017 21:25
}
else
{
$script:MyDocumentsPSPath = Split-Path -Path ([System.Management.Automation.Platform]::SelectProductNameForDirectory('USER_MODULES')) -Parent
Copy link
Member

Choose a reason for hiding this comment

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

we don't really have a way to handle this if you don't have the privilege to write in the directory on non-windows platforms, we can look at extending the test framework for next release.

I recommend a test hook approach, which allows you to provide an alternative location. From a test perspective, the only thing you want to be sure of is when you select a location the files get placed there. It doesn't really matter what that location is, it could be anywhere - A testhook which makes [system.management.automation.platform]::SelectProductNameForDirectory('SHARED_MODULES') point to $TESTDRIVE should be sufficient as long as you have a separate test which returns what the default location of SHARED_MODULES should be.
This provides far more flexibility in the long run
If you can't do that, I would mark this specific test as pending for non-windows

@@ -154,7 +167,7 @@ Describe "PowerShellGet - Module tests (Admin)" -tags @('Feature', 'RequireAdmin
$module = Get-Module $ContosoServer -ListAvailable
$module.Name | Should be $ContosoServer
$module.ModuleBase | Should Be $installedModuleInfo.InstalledLocation
}
} -Skip:$IsLinux
Copy link
Member

Choose a reason for hiding this comment

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

Please use -Pending instead of -Skip. We track all pending tests because they are supposed to work but now at the time. -Skip means they are not applicable to the platform.

Copy link
Member

Choose a reason for hiding this comment

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

And also, please add -Pending before the open curly bracket, like

It "Should install a module correctly to the required location with default AllUsers scope" -Pending:$IsLinux {

@@ -219,7 +232,7 @@ Describe "PowerShellGet - Script tests (Admin)" -tags @('Feature', 'RequireAdmin
$installedScriptInfo | Should Not Be $null
$installedScriptInfo.Name | Should Be $FabrikamServerScript
$installedScriptInfo.InstalledLocation.StartsWith($script:ProgramFilesScriptsPath, [System.StringComparison]::OrdinalIgnoreCase) | Should Be $true
}
} -Skip:$IsLinux
Copy link
Member

Choose a reason for hiding this comment

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

Same comment here.

@daxian-dbw
Copy link
Member

In fact, with sudo: required in .travis.yml, you can use sudo without providing a password on Travis CI Linux to get the root privilege. So we should be able to support RequireAdminOnLinux. #5645 is opened to track that.

As for macOS, it turns out the Shared-Module path is not protected, and that's why it passed on macOS.

@daxian-dbw
Copy link
Member

daxian-dbw commented Dec 7, 2017

@adityapatwardhan Can you take a look at the failure in AppVeyor to see what might be wrong?

https://ci.appveyor.com/project/PowerShell/powershell/build/v6.1.0-preview.7209

@daxian-dbw
Copy link
Member

@bmanikm You didn't address my comment at #5633 (comment)
I have addressed it and also add comments about why we mark them pending on Linux.

…HARED_MODULES location.

Refresh PowerShellGet.Tests.ps1 from PowerShell/PowerShellGet repository.
PowerShell/PowerShellGet#175
@daxian-dbw daxian-dbw merged commit 15e609c into PowerShell:master Dec 7, 2017
@bmanikm bmanikm deleted the updatepsgettestscript branch December 7, 2017 19:27
TravisEz13 pushed a commit to TravisEz13/PowerShell that referenced this pull request Dec 8, 2017
…AllUsers scope. (PowerShell#5633)

Changed the install location of AllUsers scope on PWSH to SHARED_MODULES location.
TravisEz13 pushed a commit that referenced this pull request Dec 8, 2017
…AllUsers scope. (#5633)

Changed the install location of AllUsers scope on PWSH to SHARED_MODULES location.
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.

None yet

3 participants