22Describe " Convert-LineNumber" {
33 # use the integration test code
44 BeforeAll {
5- Build-Module $PSScriptRoot \..\ Integration\ Source1\ build.psd1 - Passthru
5+ Build-Module $PSScriptRoot / .. / Integration/ Source1/ build.psd1 - Passthru
66 Push-Location $PSScriptRoot - StackName Convert-CodeCoverage
77
8- $global :Convert_LineNumber_ModulePath = Convert-Path " .\..\ Integration\ Result1\ Source1\ 1.0.0\ Source1.psm1"
9- $global :Convert_LineNumber_ModuleSource = Convert-Path " .\..\ Integration\ Source1"
8+ $global :Convert_LineNumber_ModulePath = Convert-Path " ./../ Integration/ Result1/ Source1/ 1.0.0/ Source1.psm1"
9+ $global :Convert_LineNumber_ModuleSource = Convert-Path " ./../ Integration/ Source1"
1010 $global :Convert_LineNumber_ModuleContent = Get-Content $global :Convert_LineNumber_ModulePath
11+ ${global :\} = [io.path ]::DirectorySeparatorChar
12+
13+ $global :TestCases = @ (
14+ @ { outputLine = 6 ; sourceFile = " .${\} Private${\} GetFinale.ps1" ; sourceLine = 4 }
15+ @ { outputLine = 18 ; sourceFile = " .${\} Private${\} GetPreview.ps1" ; sourceLine = 7 }
16+ @ { outputLine = 25 ; sourceFile = " .${\} Public${\} Get-Source.ps1" ; sourceLine = 5 }
17+ )
1118 }
1219 AfterAll {
1320 Pop-Location - StackName Convert-CodeCoverage
1421 }
1522
16- $TestCases = @ (
17- @ { outputLine = 6 ; sourceFile = " .\Private\GetFinale.ps1" ; sourceLine = 4 }
18- @ { outputLine = 18 ; sourceFile = " .\Private\GetPreview.ps1" ; sourceLine = 7 }
19- @ { outputLine = 25 ; sourceFile = " .\Public\Get-Source.ps1" ; sourceLine = 5 }
20- )
2123
2224 It " Should map line <outputLine> in the Module to line <sourceLine> in the source of <sourceFile>" - TestCases $TestCases {
2325 param ($outputLine , $sourceFile , $sourceLine )
@@ -35,30 +37,30 @@ Describe "Convert-LineNumber" {
3537 }
3638
3739 It " Should throw if the SourceFile doesn't exist" {
38- { Convert-LineNumber - SourceFile TestDrive:\ NoSuchFile - SourceLineNumber 10 } |
39- Should - Throw " 'TestDrive:\ NoSuchFile' does not exist"
40+ { Convert-LineNumber - SourceFile TestDrive:/ NoSuchFile - SourceLineNumber 10 } |
41+ Should - Throw " 'TestDrive:/ NoSuchFile' does not exist"
4042 }
4143
4244 It ' Should work with an error PositionMessage' {
4345 $line = Select-String - Path $Convert_LineNumber_ModulePath ' function Set-Source {' | ForEach-Object LineNumber
4446
4547 $SourceLocation = " At ${Convert_LineNumber_ModulePath} :$line char:17" | Convert-LineNumber
4648 # This test is assuming you built the code on Windows. Should Convert-LineNumber convert the path?
47- $SourceLocation.SourceFile | Should - Be " .\ Public\ Set-Source.ps1"
49+ $SourceLocation.SourceFile | Should - Be " .${\} Public${\} Set-Source.ps1"
4850 $SourceLocation.SourceLineNumber | Should - Be 1
4951 }
5052
5153 It ' Should work with ScriptStackTrace messages' {
5254
53- $SourceFile = Join-Path $Convert_LineNumber_ModuleSource Public\ Set-Source.ps1 | Convert-Path
55+ $SourceFile = Join-Path $Convert_LineNumber_ModuleSource Public/ Set-Source.ps1 | Convert-Path
5456
5557 $outputLine = Select-String - Path $Convert_LineNumber_ModulePath " sto͞o′pĭd" | % LineNumber
5658 $sourceLine = Select-String - Path $SourceFile " sto͞o′pĭd" | % LineNumber
5759
5860 $SourceLocation = " At Set-Source, ${Convert_LineNumber_ModulePath} : line $outputLine " | Convert-LineNumber
5961
6062 # This test is assuming you built the code on Windows. Should Convert-LineNumber convert the path?
61- $SourceLocation.SourceFile | Should - Be " .\ Public\ Set-Source.ps1"
63+ $SourceLocation.SourceFile | Should - Be " .${\} Public${\} Set-Source.ps1"
6264 $SourceLocation.SourceLineNumber | Should - Be $sourceLine
6365 }
6466
@@ -73,7 +75,7 @@ Describe "Convert-LineNumber" {
7375
7476 $SourceLocation = $PesterMiss | Convert-LineNumber - Passthru
7577 # This test is assuming you built the code on Windows. Should Convert-LineNumber convert the path?
76- $SourceLocation.SourceFile | Should - Be " .\ Public\ Get-Source.ps1"
78+ $SourceLocation.SourceFile | Should - Be " .${\} Public${\} Get-Source.ps1"
7779 $SourceLocation.SourceLineNumber | Should - Be 5
7880 $SourceLocation.Function | Should - Be ' Get-Source'
7981 }
0 commit comments