Skip to content

Commit 4fa4cc2

Browse files
Merge pull request #45 from ChrisLGardner/fix-scriptblock
Add support for file paths being provided for the pre-test scriptblock
2 parents 6e76e07 + eff620f commit 4fa4cc2

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

Extension/PesterTask/PesterV10/Pester.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ if ($CodeCoverageOutputFile) {
131131
}
132132

133133
if (-not([String]::IsNullOrWhiteSpace($ScriptBlock))) {
134+
if (Test-Path $ScriptBlock) {
135+
$ScriptBlock = Get-Content -Path $ScriptBlock -Raw
136+
}
134137
$ScriptBlockObject = [ScriptBlock]::Create($ScriptBlock)
135138

136139
$ScriptBlockObject.Invoke()

Extension/PesterTask/PesterV9/Pester.ps1

+3
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,9 @@ elseif ($CodeCoverageOutputFile -and (Get-Module Pester).Version -lt [Version]::
134134
}
135135

136136
if (-not([String]::IsNullOrWhiteSpace($ScriptBlock))) {
137+
if (Test-Path $ScriptBlock) {
138+
$ScriptBlock = Get-Content -Path $ScriptBlock -Raw
139+
}
137140
$ScriptBlockObject = [ScriptBlock]::Create($ScriptBlock)
138141

139142
$ScriptBlockObject.Invoke()

0 commit comments

Comments
 (0)