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

Added SelfSignedCertificate module to the test package #8350

Merged
merged 1 commit into from
Nov 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 15 additions & 12 deletions build.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
# On Windows paths is separated by semicolon
$script:TestModulePathSeparator = [System.IO.Path]::PathSeparator

# Path to a directory to store modules we temporarily need to test PowerShell
$script:TestModuleDirPath = Join-Path ([System.IO.Path]::GetTempPath()) 'PwshTestModules'
$null = New-Item -Force -ItemType Directory -Path $script:TestModuleDirPath

$dotnetCLIChannel = "release"
$dotnetCLIRequiredVersion = $(Get-Content $PSScriptRoot/global.json | ConvertFrom-Json).Sdk.Version

Expand Down Expand Up @@ -556,7 +552,7 @@ function Restore-PSModuleToBuild

Write-Log "Restore PowerShell modules to $publishPath"
$modulesDir = Join-Path -Path $publishPath -ChildPath "Modules"
Copy-PSGalleryModules -Destination $modulesDir
Copy-PSGalleryModules -Destination $modulesDir -CsProjPath "$PSScriptRoot\src\Modules\PSGalleryModules.csproj"
}

function Restore-PSPester
Expand Down Expand Up @@ -848,8 +844,8 @@ function Publish-PSTestTools {
}
}

# Get the SelfSignedCertificate module so the web listener can use it
Save-Module -Name SelfSignedCertificate -Path $script:TestModuleDirPath -Repository "PSGallery" -MinimumVersion '0.0.2' -Force -Confirm:$false
# `dotnet restore` on test project is not called if product projects have been restored unless -Force is specified.
Copy-PSGalleryModules -Destination "${PSScriptRoot}/test/tools/Modules" -CsProjPath "$PSScriptRoot/test/tools/Modules/PSGalleryTestModules.csproj" -Force
}

function Get-ExperimentalFeatureTests {
Expand Down Expand Up @@ -893,7 +889,7 @@ function Start-PSPester {

if (-not (Get-Module -ListAvailable -Name $Pester -ErrorAction SilentlyContinue | Where-Object { $_.Version -ge "4.2" } ))
{
Restore-PSPester
Restore-PSPester
}

if ($IncludeFailingTest.IsPresent)
Expand Down Expand Up @@ -954,7 +950,7 @@ function Start-PSPester {
}

# Autoload (in subprocess) temporary modules used in our tests
$newPathFragment = $TestModulePath + $TestModulePathSeparator + $script:TestModuleDirPath + $TestModulePathSeparator
$newPathFragment = $TestModulePath + $TestModulePathSeparator
$command += '$env:PSModulePath = '+"'$newPathFragment'" + '+$env:PSModulePath;'

# Windows needs the execution policy adjusted
Expand Down Expand Up @@ -2271,15 +2267,22 @@ function Copy-PSGalleryModules
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[string]$Destination
[string]$CsProjPath,

[Parameter(Mandatory=$true)]
[string]$Destination,

[Parameter()]
[switch]$Force
)

if (!$Destination.EndsWith("Modules")) {
throw "Installing to an unexpected location"
}

Find-DotNet
Restore-PSPackage

Restore-PSPackage -ProjectDirs (Split-Path $CsProjPath) -Force:$Force.IsPresent

$cache = dotnet nuget locals global-packages -l
if ($cache -match "info : global-packages: (.*)") {
Expand All @@ -2289,7 +2292,7 @@ function Copy-PSGalleryModules
throw "Can't find nuget global cache"
}

$psGalleryProj = [xml](Get-Content -Raw $PSScriptRoot\src\Modules\PSGalleryModules.csproj)
$psGalleryProj = [xml](Get-Content -Raw $CsProjPath)

foreach ($m in $psGalleryProj.Project.ItemGroup.PackageReference) {
$name = $m.Include
Expand Down
9 changes: 9 additions & 0 deletions test/tools/Modules/PSGalleryTestModules.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">

<Import Project="..\..\Test.Common.props" />

<ItemGroup>
<PackageReference Include="SelfSignedCertificate" Version="0.0.2" />
</ItemGroup>

</Project>