Skip to content

Commit c8769c8

Browse files
author
Kapil Borle
committed
Move test helper to test root directory
1 parent a9102ac commit c8769c8

File tree

4 files changed

+12
-8
lines changed

4 files changed

+12
-8
lines changed

Engine/PSScriptAnalyzer.psm1

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,6 @@
22
# Script module for module 'PSScriptAnalyzer'
33
#
44

5-
function Test-PSEditionCoreCLR
6-
{
7-
($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')
8-
}
9-
105
# Clear PSDefaultParameterValues in the module scope and enable strict mode
116
$PSDefaultParameterValues.Clear()
127
Set-StrictMode -Version Latest
@@ -19,7 +14,7 @@ $PSModuleRoot = $PSModule.ModuleBase
1914
$binaryModuleRoot = $PSModuleRoot
2015

2116

22-
if ((Test-PSEditionCoreCLR)) {
17+
if (($PSVersionTable.Keys -contains "PSEdition") -and ($PSVersionTable.PSEdition -ne 'Desktop')) {
2318
$binaryModuleRoot = Join-Path -Path $PSModuleRoot -ChildPath 'coreclr'
2419
}
2520
else

Tests/Engine/GetScriptAnalyzerRule.tests.ps1

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
Import-Module -Verbose PSScriptAnalyzer
1+
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
2+
Import-Module -Verbose PSScriptAnalyzer
3+
$testRootDirectory = Split-Path -Parent $directory
4+
Import-Module (Join-Path $testRootDirectory 'PSScriptAnalyzerTestHelper.psm1')
25
$sa = Get-Command Get-ScriptAnalyzerRule
3-
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
6+
47
$singularNouns = "PSUseSingularNouns" # this rule does not exist for coreclr version
58
$approvedVerbs = "PSUseApprovedVerbs"
69
$cmdletAliases = "PSAvoidUsingCmdletAliases"

Tests/Engine/InvokeScriptAnalyzer.tests.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
if (!(Get-Module PSScriptAnalyzer) -and !$testingLibraryUsage)
55
{
66
Import-Module PSScriptAnalyzer
7+
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
8+
$testRootDirectory = Split-Path -Parent $directory
9+
Import-Module (Join-Path $testRootDirectory 'PSScriptAnalyzerTestHelper.psm1')
710
}
811

912
$sa = Get-Command Invoke-ScriptAnalyzer

Tests/Engine/LibraryUsage.tests.ps1

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
$directory = Split-Path -Parent $MyInvocation.MyCommand.Path
2+
$testRootDirectory = Split-Path -Parent $directory
3+
Import-Module (Join-Path $testRootDirectory 'PSScriptAnalyzerTestHelper.psm1')
14
Import-Module PSScriptAnalyzer
25

36
# test is meant to verify functionality if chsarp apis are used. Hence not if psedition is CoreCLR

0 commit comments

Comments
 (0)