Skip to content
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
2 changes: 1 addition & 1 deletion build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ function Copy-Content ($Content) {

$content = @(
, ("$PSScriptRoot/src/en-US/*.txt", "$PSScriptRoot/bin/en-US/")
, ("$PSScriptRoot/src/Pester.ps1", "$PSScriptRoot/bin/")
, ("$PSScriptRoot/src/Pester.ScriptScope.ps1", "$PSScriptRoot/bin/")
, ("$PSScriptRoot/src/Pester.psd1", "$PSScriptRoot/bin/")
, ("$PSScriptRoot/src/Pester.Format.ps1xml", "$PSScriptRoot/bin/")
)
Expand Down
2 changes: 1 addition & 1 deletion publish/filesToPublish.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
@(
'Pester.ps1'
'Pester.ScriptScope.ps1'
'Pester.psd1'
'Pester.psm1'
'Pester.Format.ps1xml'
Expand Down
3 changes: 2 additions & 1 deletion src/Pester.Runtime.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2693,7 +2693,8 @@ function Invoke-InNewScriptScope ([ScriptBlock] $ScriptBlock, $SessionState) {
# correct session state, and then invoke the file. We can also pass a script block tied
# to the current module to invoke internal function in the newly pushed script scope.

$Path = "$PSScriptRoot/Pester.ps1"
# Invoked as a standalone script file (not Pester.ps1; see Pester.ScriptScope.ps1 for why).
$Path = "$PSScriptRoot/Pester.ScriptScope.ps1"
$Data = @{ ScriptBlock = $ScriptBlock }

$wrapper = {
Expand Down
10 changes: 10 additions & 0 deletions src/Pester.ScriptScope.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# This file is invoked as a real script file by Invoke-InNewScriptScope to push a new
# script scope into the caller's session state (see src/Pester.Runtime.ps1).
#
# Do NOT rename it to Pester.ps1. PSResourceGet treats a '<ModuleName>.ps1' file in the
# package (i.e. Pester.ps1) as a script and prints a spurious installation-path warning
# on Install-PSResource Pester. See https://github.com/pester/Pester/issues/2826.
param ($ScriptBlock)

. $ScriptBlock

4 changes: 0 additions & 4 deletions src/Pester.ps1

This file was deleted.

18 changes: 18 additions & 0 deletions tst/Pester.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,24 @@ Describe 'Style rules' -Tag StyleRules {
}
}

Describe 'Module packaging' -Tag StyleRules {
# Issue #2826: PSResourceGet decides a package is a script by looking for a
# '<ModuleName>.ps1' file in the package root (i.e. Pester.ps1). When that file is
# present it prints a spurious installation-path warning on Install-PSResource Pester.
# The script-scope helper is therefore shipped as Pester.ScriptScope.ps1 instead.
BeforeAll {
$pesterRoot = (Get-Module Pester).ModuleBase
}

It 'does not ship a Pester.ps1 that PSResourceGet would treat as a script' {
(Join-Path $pesterRoot 'Pester.ps1') | Should -Not -Exist
}

It 'ships the script-scope helper as Pester.ScriptScope.ps1' {
(Join-Path $pesterRoot 'Pester.ScriptScope.ps1') | Should -Exist
}
}

InPesterModuleScope {
Describe 'Find-File' {
BeforeAll {
Expand Down
Loading