Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Commit c613a95

Browse files
authored
Update CI scripts to incorporate the breaking changes in PSCore. (#190)
Updated travis.yml Replaced $TestDrive variable usage with [System.IO.Path]::GetTempPath() as latest Pester module is not compatible on OSX. Fixed Accept License Test failures
1 parent 4e558af commit c613a95

10 files changed

Lines changed: 108 additions & 225 deletions

.travis.yml

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,9 @@ os:
99
- osx
1010
sudo: required
1111
dist: trusty
12-
osx_image: xcode8.2
12+
osx_image: xcode8.1
1313

1414
matrix:
15-
allow_failures:
16-
- os: osx
1715
fast_finish: true
1816

1917

@@ -23,15 +21,16 @@ addons:
2321

2422

2523
install:
26-
- export PATH=~/.dotnet:$PATH
27-
- pushd tools
28-
- chmod +x download.sh
29-
- chmod +x travis.sh
30-
- ./download.sh
31-
- popd
3224
# Default 2.0.0 Ruby is buggy
3325
# Default bundler version is buggy
34-
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then rvm install ruby-2.3.1; rvm use 2.3.1; gem uninstall bundler -v1.13.1; fi
26+
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
27+
rvm install ruby-2.3.3;
28+
rvm --default use 2.3.3;
29+
fi
30+
- bash <(wget -O - https://raw.githubusercontent.com/PowerShell/PowerShell/master/tools/install-powershell.sh)
31+
- pushd tools
32+
- chmod +x travis.sh
33+
- popd
3534

3635
script:
3736
- echo "TRAVIS_EVENT_TYPE value $TRAVIS_EVENT_TYPE"

Tests/PSGetInstallModule.Tests.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ Describe PowerShell.PSGet.InstallModuleTests -Tags 'BVT','InnerLoop' {
454454
# Expected Result: it should fail with an error
455455
#
456456
It "InstallModuleNeedsCurrentUserScopeParameterForNonAdminUser" {
457-
$NonAdminConsoleOutput = Join-Path $TestDrive 'nonadminconsole-out.txt'
457+
$NonAdminConsoleOutput = Join-Path ([System.IO.Path]::GetTempPath()) 'nonadminconsole-out.txt'
458458

459459
Start-Process "$PSHOME\PowerShell.exe" -ArgumentList '$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser;
460460
$null = Import-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;
@@ -489,7 +489,7 @@ Describe PowerShell.PSGet.InstallModuleTests -Tags 'BVT','InnerLoop' {
489489
# Expected Result: should fail with an error
490490
#
491491
It "ValidateModuleIsInUseError" {
492-
$NonAdminConsoleOutput = Join-Path $TestDrive 'nonadminconsole-out.txt'
492+
$NonAdminConsoleOutput = Join-Path ([System.IO.Path]::GetTempPath()) 'nonadminconsole-out.txt'
493493
Start-Process "$PSHOME\PowerShell.exe" -ArgumentList '$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser;
494494
$null = Import-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;
495495
Install-Module -Name DscTestModule -Scope CurrentUser;

Tests/PSGetInstallScript.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ Describe PowerShell.PSGet.InstallScriptTests -Tags 'BVT','InnerLoop' {
500500
# Expected Result: it should fail with an error
501501
#
502502
It "InstallScriptNeedsCurrentUserScopeParameterForNonAdminUser" {
503-
$NonAdminConsoleOutput = Join-Path $TestDrive 'nonadminconsole-out.txt'
503+
$NonAdminConsoleOutput = Join-Path ([System.IO.Path]::GetTempPath()) 'nonadminconsole-out.txt'
504504
Start-Process "$PSHOME\PowerShell.exe" -ArgumentList '$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser;
505505
$null = Import-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;
506506
Install-Script -Name Fabrikam-ServerScript -Scope AllUsers' `

tests/PSGetRequireLicenseAcceptance.ps1 renamed to Tests/PSGetRequireLicenseAcceptance.Tests.ps1

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ Describe PowerShell.PSGet.PSGetRequireLicenseAcceptance.InstallSaveUpdate -Tags
493493

494494
try
495495
{
496-
$result = ExecuteCommand $runspace 'Install-Script ScriptRequireLicenseAcceptance'
496+
$result = ExecuteCommand $runspace 'Install-Script ScriptRequireLicenseAcceptance -NoPathUpdate'
497497
}
498498
finally
499499
{
@@ -539,7 +539,7 @@ Describe PowerShell.PSGet.PSGetRequireLicenseAcceptance.InstallSaveUpdate -Tags
539539

540540
try
541541
{
542-
$result = ExecuteCommand $runspace 'Install-Script ScriptRequireLicenseAcceptance'
542+
$result = ExecuteCommand $runspace 'Install-Script ScriptRequireLicenseAcceptance -NoPathUpdate'
543543
}
544544
finally
545545
{
@@ -574,7 +574,7 @@ Describe PowerShell.PSGet.PSGetRequireLicenseAcceptance.InstallSaveUpdate -Tags
574574
# Expected Result: script and dependant module are installed successfully
575575
#
576576
It "InstallScriptAcceptLicense" {
577-
Install-Script ScriptRequireLicenseAcceptance -AcceptLicense
577+
Install-Script ScriptRequireLicenseAcceptance -AcceptLicense -NoPathUpdate
578578

579579
$res = Get-InstalledScript ScriptRequireLicenseAcceptance
580580
AssertEquals $res.Name "ScriptRequireLicenseAcceptance" "Install-Script failed to install $scriptName, $res"
@@ -958,7 +958,7 @@ Describe PowerShell.PSGet.PSGetRequireLicenseAcceptance.InstallSaveUpdate -Tags
958958
$UpdateShouldProcessMessage = $script:LocalizedData.AcceptanceLicenseQuery -f ($itemInfo.Name)
959959
Assert ($content -and ($content -match $UpdateShouldProcessMessage)) "Update module confirm prompt is not working, Expected:$UpdateShouldProcessMessage, Actual:$content"
960960

961-
$res = Get-InstalledModule ModuleRequireLicenseAcceptance -RequiredVersion 2.0
961+
$res = Get-InstalledModule ModuleRequireLicenseAcceptance -RequiredVersion 3.0
962962
AssertNotNull $res "Update-Module should Update a module if Confirm is accepted"
963963
} `
964964
-Skip:$(($PSEdition -eq 'Core') -or ([System.Environment]::OSVersion.Version -lt "6.2.9200.0") -or ($PSCulture -ne 'en-US'))
@@ -973,7 +973,7 @@ Describe PowerShell.PSGet.PSGetRequireLicenseAcceptance.InstallSaveUpdate -Tags
973973
It "UpdateModuleAcceptLicnese" {
974974
Install-module ModuleRequireLicenseAcceptance -RequiredVersion 1.0 -AcceptLicense -Force
975975
Update-Module ModuleRequireLicenseAcceptance -AcceptLicense
976-
$res = Get-InstalledModule ModuleRequireLicenseAcceptance -RequiredVersion 2.0
976+
$res = Get-InstalledModule ModuleRequireLicenseAcceptance -RequiredVersion 3.0
977977
AssertNotNull $res "Update-Module should Update a module"
978978
}
979979

Tests/PSGetUnInstallModule.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ Describe 'PowerShell.PSGet.UnInstallModuleTests' -Tags 'BVT','InnerLoop' {
248248
# Expected Result: should fail with an error
249249
#
250250
It "ValidateModuleIsInUseErrorDuringUninstallModule" {
251-
$NonAdminConsoleOutput = Join-Path $TestDrive 'nonadminconsole-out.txt'
251+
$NonAdminConsoleOutput = Join-Path ([System.IO.Path]::GetTempPath()) 'nonadminconsole-out.txt'
252252
Start-Process "$PSHOME\PowerShell.exe" -ArgumentList '$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser;
253253
$null = Import-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;
254254
Install-Module -Name DscTestModule -Scope CurrentUser;

Tests/PSGetUpdateModule.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ Describe PowerShell.PSGet.UpdateModuleTests.P2 -Tags 'P2','OuterLoop' {
573573
#
574574
It "AdminPrivilegesAreRequiredForUpdatingAllUsersModule" {
575575
Install-Module -Name ContosoServer -RequiredVersion 1.0
576-
$NonAdminConsoleOutput = Join-Path $TestDrive 'nonadminconsole-out.txt'
576+
$NonAdminConsoleOutput = Join-Path ([System.IO.Path]::GetTempPath()) 'nonadminconsole-out.txt'
577577
Start-Process "$PSHOME\PowerShell.exe" -ArgumentList '$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser;
578578
$null = Import-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;
579579
Update-Module -Name ContosoServer' `

Tests/PSGetUpdateScript.Tests.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ Describe PowerShell.PSGet.UpdateScriptTests -Tags 'BVT','InnerLoop' {
419419
#
420420
It "AdminPrivilegesAreRequiredForUpdatingAllUsersScript" {
421421
Install-Script -Name Fabrikam-ServerScript -RequiredVersion 1.0 -Scope AllUsers
422-
$NonAdminConsoleOutput = Join-Path $TestDrive 'nonadminconsole-out.txt'
422+
$NonAdminConsoleOutput = Join-Path ([System.IO.Path]::GetTempPath()) 'nonadminconsole-out.txt'
423423
Start-Process "$PSHOME\PowerShell.exe" -ArgumentList '$null = Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force -Scope CurrentUser;
424424
$null = Import-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force;
425425
Update-Script -Name Fabrikam-ServerScript' `

tools/build.psm1

Lines changed: 86 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
$script:PowerShellGet = 'PowerShellGet'
33
$script:IsInbox = $PSHOME.EndsWith('\WindowsPowerShell\v1.0', [System.StringComparison]::OrdinalIgnoreCase)
44
$script:IsWindows = (-not (Get-Variable -Name IsWindows -ErrorAction Ignore)) -or $IsWindows
5-
$script:IsLinux = (Get-Variable -Name IsLinux -ErrorAction Ignore) -and $IsLinux
6-
$script:IsOSX = (Get-Variable -Name IsOSX -ErrorAction Ignore) -and $IsOSX
5+
$script:IsLinux = (Get-Variable -Name IsLinux -ErrorAction Ignore) -and $IsLinux
6+
$script:IsMacOS = (Get-Variable -Name IsMacOS -ErrorAction Ignore) -and $IsMacOS
77
$script:IsCoreCLR = (Get-Variable -Name IsCoreCLR -ErrorAction Ignore) -and $IsCoreCLR
88

99
if($script:IsInbox) {
@@ -58,54 +58,6 @@ Write-Host "PowerShellEdition value: $script:PowerShellEdition"
5858
#endregion script variables
5959

6060
function Install-Dependencies {
61-
if($script:PowerShellEdition -eq 'Desktop') {
62-
$NuGetExeName = 'NuGet.exe'
63-
$NugetExeFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetProgramDataPath -ChildPath $NuGetExeName
64-
65-
if(-not (Test-Path -Path $NugetExeFilePath -PathType Leaf)) {
66-
if(-not (Microsoft.PowerShell.Management\Test-Path -Path $script:PSGetProgramDataPath))
67-
{
68-
$null = Microsoft.PowerShell.Management\New-Item -Path $script:PSGetProgramDataPath -ItemType Directory -Force
69-
}
70-
71-
# Download the NuGet.exe from https://nuget.org/NuGet.exe
72-
Microsoft.PowerShell.Utility\Invoke-WebRequest -Uri https://nuget.org/NuGet.exe -OutFile $NugetExeFilePath
73-
}
74-
75-
Get-ChildItem $NugetExeFilePath -File
76-
77-
if(-not (Get-Module -ListAvailable Pester))
78-
{
79-
& $NugetExeFilePath install pester -source https://www.powershellgallery.com/api/v2 -outputDirectory $script:ProgramFilesModulesPath -ExcludeVersion
80-
}
81-
82-
$AllUsersModulesPath = $script:ProgramFilesModulesPath
83-
# Install latest PackageManagement module from PSGallery
84-
$TempModulePath = Microsoft.PowerShell.Management\Join-Path -Path $script:TempPath -ChildPath "$(Get-Random)"
85-
$null = Microsoft.PowerShell.Management\New-Item -Path $TempModulePath -Force -ItemType Directory
86-
$OneGetModuleName = 'PackageManagement'
87-
try
88-
{
89-
& $NugetExeFilePath install $OneGetModuleName -source https://dtlgalleryint.cloudapp.net/api/v2 -outputDirectory $TempModulePath -verbosity detailed
90-
$OneGetWithVersion = Microsoft.PowerShell.Management\Get-ChildItem -Path $TempModulePath -Directory
91-
$OneGetVersion = ($OneGetWithVersion.Name.Split('.',2))[1]
92-
93-
$OneGetModulePath = Microsoft.PowerShell.Management\Join-Path -Path $AllUsersModulesPath -ChildPath $OneGetModuleName
94-
if($PSVersionTable.PSVersion -ge '5.0.0')
95-
{
96-
$OneGetModulePath = Microsoft.PowerShell.Management\Join-Path -Path $OneGetModulePath -ChildPath $OneGetVersion
97-
}
98-
99-
$null = Microsoft.PowerShell.Management\New-Item -Path $OneGetModulePath -Force -ItemType Directory
100-
Microsoft.PowerShell.Management\Copy-Item -Path "$($OneGetWithVersion.FullName)\*" -Destination "$OneGetModulePath\" -Recurse -Force
101-
Get-Module -ListAvailable -Name $OneGetModuleName | Microsoft.PowerShell.Core\Where-Object {$_.Version -eq $OneGetVersion}
102-
}
103-
finally
104-
{
105-
Remove-Item -Path $TempModulePath -Recurse -Force
106-
}
107-
}
108-
10961
# Update build title for daily builds
11062
if($script:IsWindows -and (Test-DailyBuild)) {
11163
if($env:APPVEYOR_PULL_REQUEST_TITLE)
@@ -178,11 +130,32 @@ function Invoke-PowerShellGetTest {
178130
$PowerShellGetTestsPath = "$ClonedProjectPath\Tests\"
179131
$PowerShellHome = Get-PSHome
180132
if($script:IsWindows){
181-
$PowerShellExePath = Join-Path -Path $PowerShellHome -ChildPath 'PowerShell.exe'
133+
if ($script:PowerShellEdition -eq 'Core') {
134+
$PowerShellExePath = Join-Path -Path $PowerShellHome -ChildPath 'pwsh.exe'
135+
}
136+
else {
137+
$PowerShellExePath = Join-Path -Path $PowerShellHome -ChildPath 'PowerShell.exe'
138+
}
182139
} else {
183-
$PowerShellExePath = 'powershell'
140+
$PowerShellExePath = 'pwsh'
141+
}
142+
143+
# Bootstrap NuGet.exe
144+
$NuGetExeName = 'NuGet.exe'
145+
$NugetExeFilePath = Microsoft.PowerShell.Management\Join-Path -Path $script:PSGetProgramDataPath -ChildPath $NuGetExeName
146+
147+
if(-not (Test-Path -Path $NugetExeFilePath -PathType Leaf)) {
148+
if(-not (Microsoft.PowerShell.Management\Test-Path -Path $script:PSGetProgramDataPath))
149+
{
150+
$null = Microsoft.PowerShell.Management\New-Item -Path $script:PSGetProgramDataPath -ItemType Directory -Force
151+
}
152+
153+
# Download the NuGet.exe from https://nuget.org/NuGet.exe
154+
Microsoft.PowerShell.Utility\Invoke-WebRequest -Uri https://nuget.org/NuGet.exe -OutFile $NugetExeFilePath
184155
}
185156

157+
Get-ChildItem -Path $NugetExeFilePath -File
158+
186159
# Test Environment
187160
# - PowerShellGet from Current branch
188161
# - PowerShellGet packaged with PowerShellCore build:
@@ -213,6 +186,49 @@ function Invoke-PowerShellGetTest {
213186
$AllUsersModulesPath = Microsoft.PowerShell.Management\Join-Path -Path $PowerShellHome -ChildPath 'Modules'
214187
}
215188

189+
# Install latest PackageManagement from Gallery
190+
$OneGetModuleName = 'PackageManagement'
191+
$OneGetModuleInfo = Get-Module -ListAvailable -Name $OneGetModuleName | Select-Object -First 1
192+
if ($OneGetModuleInfo)
193+
{
194+
$NuGetProvider = Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' }
195+
if(-not $NuGetProvider) {
196+
Install-PackageProvider -Name NuGet -Force
197+
}
198+
199+
$LatestOneGetInPSGallery = Find-Module -Name $OneGetModuleName
200+
if($LatestOneGetInPSGallery.Version -gt $OneGetModuleInfo.Version) {
201+
Install-Module -InputObject $LatestOneGetInPSGallery -Force
202+
}
203+
}
204+
else
205+
{
206+
# Install latest PackageManagement module from PSGallery
207+
$TempModulePath = Microsoft.PowerShell.Management\Join-Path -Path $script:TempPath -ChildPath "$(Get-Random)"
208+
$null = Microsoft.PowerShell.Management\New-Item -Path $TempModulePath -Force -ItemType Directory
209+
$OneGetModuleName = 'PackageManagement'
210+
try
211+
{
212+
& $NugetExeFilePath install $OneGetModuleName -source https://www.powershellgallery.com/api/v2 -outputDirectory $TempModulePath -verbosity detailed
213+
$OneGetWithVersion = Microsoft.PowerShell.Management\Get-ChildItem -Path $TempModulePath -Directory
214+
$OneGetVersion = ($OneGetWithVersion.Name.Split('.',2))[1]
215+
216+
$OneGetModulePath = Microsoft.PowerShell.Management\Join-Path -Path $AllUsersModulesPath -ChildPath $OneGetModuleName
217+
if($PSVersionTable.PSVersion -ge '5.0.0')
218+
{
219+
$OneGetModulePath = Microsoft.PowerShell.Management\Join-Path -Path $OneGetModulePath -ChildPath $OneGetVersion
220+
}
221+
222+
$null = Microsoft.PowerShell.Management\New-Item -Path $OneGetModulePath -Force -ItemType Directory
223+
Microsoft.PowerShell.Management\Copy-Item -Path "$($OneGetWithVersion.FullName)\*" -Destination "$OneGetModulePath\" -Recurse -Force
224+
Get-Module -ListAvailable -Name $OneGetModuleName | Microsoft.PowerShell.Core\Where-Object {$_.Version -eq $OneGetVersion}
225+
}
226+
finally
227+
{
228+
Remove-Item -Path $TempModulePath -Recurse -Force
229+
}
230+
}
231+
216232
# Copy OneGet and PSGet modules to PSHOME
217233
$PowerShellGetSourcePath = Microsoft.PowerShell.Management\Join-Path -Path $ClonedProjectPath -ChildPath $script:PowerShellGet
218234
$PowerShellGetModuleInfo = Test-ModuleManifest "$PowerShellGetSourcePath\PowerShellGet.psd1" -ErrorAction Ignore
@@ -237,6 +253,24 @@ function Invoke-PowerShellGetTest {
237253
Get-PSRepository;
238254
Get-Module;
239255
256+
$NuGetProvider = Get-PackageProvider | Where-Object { $_.Name -eq 'NuGet' }
257+
if(-not $NuGetProvider) {
258+
Install-PackageProvider -Name NuGet -Force
259+
}
260+
261+
# 4.0.8 version of Pester module is not compatible on MacOS, so using the Pester version installed with PWSH.
262+
if(-not (Get-Variable -Name IsMacOS -ErrorAction Ignore) -or -not $IsMacOS) {
263+
Install-Module -Name Pester -MaximumVersion 4.0.8 -Force
264+
}
265+
Get-Module -Name Pester -ListAvailable;
266+
267+
# Remove PSGetModuleInfo.xml files from the installed module bases to ensure that Update-Module tests executed properly.
268+
Get-InstalledModule -Name Pester,PackageManagement -ErrorAction SilentlyContinue | Foreach-Object {
269+
$PSGetModuleInfoXmlPath = Join-Path -Path $_.InstalledLocation -ChildPath 'PSGetModuleInfo.xml'
270+
Remove-Item -Path $PSGetModuleInfoXmlPath -Force -Verbose
271+
}
272+
Get-InstalledModule
273+
240274
# WMF 4 appveyor OS Image has duplicate entries in $env:PSModulePath
241275
if($PSVersionTable.PSVersion -le '5.0.0') {
242276
Write-Host "PSModulePath value before removing the duplicate entries:"

0 commit comments

Comments
 (0)