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
30 changes: 15 additions & 15 deletions tests/Help.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ BeforeDiscovery {
build the module. #>
if ($null -eq $Env:BHBuildOutput) {
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
# the values it needs (BHPSModuleManifest, BHProjectName) when running
# the values it needs (BHPSModuleManifest, BHProjectName) - when running
# via ./build.ps1 this happens before psake; running tests in isolation
# bypasses that, so we do it here.
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
Set-BuildEnvironment -Path (Split-Path -Path $PSScriptRoot -Parent) -Force
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
$invokePsakeParameters = @{
TaskList = 'Build'
Expand All @@ -83,10 +83,10 @@ BeforeDiscovery {
}

# PowerShellBuild outputs to Output/<ModuleName>/<Version>/, override BHBuildOutput
$projectRoot = Split-Path -Parent $PSScriptRoot
$sourceManifest = Join-Path $projectRoot "$Env:BHProjectName/$Env:BHProjectName.psd1"
$moduleVersion = (Import-PowerShellDataFile -Path $sourceManifest).ModuleVersion
$Env:BHBuildOutput = Join-Path $projectRoot "Output/$Env:BHProjectName/$moduleVersion"
$projectRoot = Split-Path -Path $PSScriptRoot -Parent
$sourceManifest = Join-Path -Path $projectRoot -ChildPath "$Env:BHProjectName/$Env:BHProjectName.psd1"
$moduleVersion = (Import-PowerShellDataFile $sourceManifest).ModuleVersion
$Env:BHBuildOutput = Join-Path -Path $projectRoot -ChildPath "Output/$Env:BHProjectName/$moduleVersion"

# Define the path to the module manifest
$moduleManifestFilename = $Env:BHProjectName + '.psd1'
Expand All @@ -105,7 +105,7 @@ BeforeDiscovery {

# Remove all versions of the module from the session. Pester can't handle multiple versions.
Get-Module $Env:BHProjectName | Remove-Module -Force -ErrorAction 'Ignore'
Import-Module -Name $moduleManifestPath -Verbose:$false -ErrorAction 'Stop'
Import-Module $moduleManifestPath -Verbose:$false -ErrorAction 'Stop'

# Get module commands
$getCommandParameters = @{
Expand All @@ -128,10 +128,10 @@ BeforeAll {
build the module. #>
if ($null -eq $Env:BHBuildOutput) {
# Populate BuildHelpers env vars so build.psake.ps1's properties block has
# the values it needs (BHPSModuleManifest, BHProjectName) when running
# the values it needs (BHPSModuleManifest, BHProjectName) - when running
# via ./build.ps1 this happens before psake; running tests in isolation
# bypasses that, so we do it here.
Set-BuildEnvironment -Path (Split-Path -Parent $PSScriptRoot) -Force
Set-BuildEnvironment -Path (Split-Path -Path $PSScriptRoot -Parent) -Force
$buildFilePath = Join-Path -Path $PSScriptRoot -ChildPath '..\build.psake.ps1'
$invokePsakeParameters = @{
TaskList = 'Build'
Expand All @@ -149,10 +149,10 @@ Describe "Test help for <_.Name>" -ForEach $commands {
# -ForEach, which Pester evaluates during discovery (before BeforeAll runs).
$command = $_
$commandName = $command.Name
$commandHelp = Get-Help -Name $command.Name -ErrorAction 'SilentlyContinue'
$commandParameters = global:FilterOutCommonParameters -Parameters $command.ParameterSets.Parameters
$commandHelp = Get-Help $command.Name -ErrorAction 'SilentlyContinue'
$commandParameters = global:FilterOutCommonParameters $command.ParameterSets.Parameters
$commandParameterNames = $commandParameters.Name
$helpParameters = global:FilterOutCommonParameters -Parameters $commandHelp.Parameters.Parameter
$helpParameters = global:FilterOutCommonParameters $commandHelp.Parameters.Parameter
$helpParameterNames = $helpParameters.Name
$helpLinks = $commandHelp.relatedLinks.navigationLink.uri | Where-Object { $_ -match '^https?://' }
}
Expand All @@ -161,10 +161,10 @@ Describe "Test help for <_.Name>" -ForEach $commands {
# These variables are needed in both discovery and test phases so we need to duplicate them here
$command = $_
$commandName = $_.Name
$commandHelp = Get-Help -Name $command.Name -ErrorAction 'SilentlyContinue'
$commandParameters = global:FilterOutCommonParameters -Parameters $command.ParameterSets.Parameters
$commandHelp = Get-Help $command.Name -ErrorAction 'SilentlyContinue'
$commandParameters = global:FilterOutCommonParameters $command.ParameterSets.Parameters
$commandParameterNames = $commandParameters.Name
$helpParameters = global:FilterOutCommonParameters -Parameters $commandHelp.Parameters.Parameter
$helpParameters = global:FilterOutCommonParameters $commandHelp.Parameters.Parameter
$helpParameterNames = $helpParameters.Name
}

Expand Down
4 changes: 2 additions & 2 deletions tests/Meta.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ BeforeAll {
Set-StrictMode -Version 'Latest'

# Make sure MetaFixers.psm1 is loaded - it contains Get-TextFilesList
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'MetaFixers.psm1') -Verbose:$false -Force
Import-Module (Join-Path -Path $PSScriptRoot -ChildPath 'MetaFixers.psm1') -Verbose:$false -Force

$projectRoot = $Env:BHProjectPath
if (-not $projectRoot) {
Expand All @@ -24,7 +24,7 @@ BeforeAll {
$unicodeFilesCount | Should -Be 0

$fileName = $textFile.FullName
(Get-Content $fileName -Raw) | Select-String "`t" | Foreach-Object {
(Get-Content -Path $fileName -Raw) | Select-String "`t" | Foreach-Object {
Write-Warning (
"There are tabs in $fileName." +
' Use Fixer "Get-TextFilesList `$pwd | ConvertTo-SpaceIndentation".'
Expand Down
4 changes: 4 additions & 0 deletions tests/MetaFixers.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function ConvertTo-UTF8 {
[OutputType([void])]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNull()]
[System.IO.FileInfo]$FileInfo
)

Expand Down Expand Up @@ -56,6 +57,7 @@ function ConvertTo-SpaceIndentation {
[OutputType([void])]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNull()]
[System.IO.FileInfo]$FileInfo
)

Expand Down Expand Up @@ -85,6 +87,7 @@ function Get-TextFilesList {
[OutputType([System.IO.FileInfo])]
param(
[Parameter(Mandatory = $true, ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[string]$Root
)

Expand Down Expand Up @@ -159,6 +162,7 @@ function Get-UnicodeFilesList {
[OutputType([System.IO.FileInfo])]
param(
[Parameter(Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[string]$Root
)

Expand Down
Loading