Skip to content

Commit

Permalink
Check for case sensitivity rather than branching on OS type
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWTruher committed Jun 3, 2019
1 parent 6c946c0 commit 9588e7f
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions Tests/Engine/CustomizedRule.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,29 @@
$testRootDirectory = Split-Path -Parent $directory
Import-Module (Join-Path $testRootDirectory 'PSScriptAnalyzerTestHelper.psm1')

# we need a way to determine whether the file system is case sensitive
# using $IsLinux or $IsMacOS is not sufficient
try
{
$module = get-module pester
# we can use the Pester New-TestDrive function
$d = & $module New-TestDrive -Pass
foreach ( $f in "file1","FILE2","fIlE3" ) {
$null = new-item -type file (Join-Path $d.root $f)
}
$count = @(get-childitem (Join-Path $d.root "file?")).Count
if ( $count -eq 1 ) {
$CaseSensitiveFS = $true
}
else {
$CaseSensitiveFS = $false
}
}
finally {
Remove-PSDrive $d
Remove-Item -force -recurse $d.root
}

if (-not (Test-PSEditionCoreCLR))
{
# Force Get-Help not to prompt for interactive input to download help using Update-Help
Expand Down Expand Up @@ -97,7 +120,7 @@ Describe "Test importing correct customized rules" {
It "will show the custom rules when given a glob" {
# needs fixing for Linux
$expectedNumRules = 4
if ($IsLinux)
if ($CaseSensitiveFS)
{
$expectedNumRules = 3
}
Expand All @@ -111,9 +134,8 @@ Describe "Test importing correct customized rules" {
}

It "will show the custom rules when given glob with recurse switch" {
# needs fixing for Linux
$expectedNumRules = 5
if ($IsLinux)
if ($CaseSensitiveFS)
{
$expectedNumRules = 4
}
Expand Down

0 comments on commit 9588e7f

Please sign in to comment.