@@ -7,10 +7,6 @@ Describe "Select-String" -Tags "CI" {
7
7
$currentDirectory = $pwd.Path
8
8
}
9
9
10
- AfterAll {
11
- Push-Location $currentDirectory
12
- }
13
-
14
10
Context " String actions" {
15
11
$testinputone = " hello" , " Hello" , " goodbye"
16
12
$testinputtwo = " hello" , " Hello"
@@ -80,47 +76,47 @@ Describe "Select-String" -Tags "CI" {
80
76
}
81
77
82
78
it " Should output a string with the first match highlighted" {
83
- if ($Host.UI.SupportsVirtualTerminal -and ! ( Test-Path env:__SuppressAnsiEscapeSequences) )
79
+ if ($Host.UI.SupportsVirtualTerminal )
84
80
{
85
81
$result = $testinputone | Select-String - Pattern " l" | Out-String
86
- $result | Should - Be " ${nl} he ` e [7ml`e [0mlo${nl} He ` e [7ml`e [0mlo${nl}${nl} "
82
+ $result | Should - Be " `n he ` e [7ml`e [0mlo`n He ` e [7ml`e [0mlo`n`n "
87
83
}
88
84
else
89
85
{
90
86
$result = $testinputone | Select-String - Pattern " l" | Out-String
91
- $result | Should - Be " ${nl} hello ${nl} Hello ${nl}${nl} "
87
+ $result | Should - Be " `n hello `n Hello `n`n "
92
88
}
93
89
}
94
90
95
91
it " Should output a string with all matches highlighted when AllMatch is used" {
96
- if ($Host.UI.SupportsVirtualTerminal -and ! ( Test-Path env:__SuppressAnsiEscapeSequences) )
92
+ if ($Host.UI.SupportsVirtualTerminal )
97
93
{
98
94
$result = $testinputone | Select-String - Pattern " l" - AllMatch | Out-String
99
- $result | Should - Be " ${nl} he ` e [7ml`e [0m`e [7ml`e [0mo${nl} He ` e [7ml`e [0m`e [7ml`e [0mo${nl}${nl} "
95
+ $result | Should - Be " `n he ` e [7ml`e [0m`e [7ml`e [0mo`n He ` e [7ml`e [0m`e [7ml`e [0mo`n`n "
100
96
}
101
97
else
102
98
{
103
99
$result = $testinputone | Select-String - Pattern " l" - AllMatch | Out-String
104
- $result | Should - Be " ${nl} hello ${nl} Hello ${nl}${nl} "
100
+ $result | Should - Be " `n hello `n Hello `n`n "
105
101
}
106
102
}
107
103
108
104
it " Should output a string with the first match highlighted when SimpleMatch is used" {
109
- if ($Host.UI.SupportsVirtualTerminal -and ! ( Test-Path env:__SuppressAnsiEscapeSequences) )
105
+ if ($Host.UI.SupportsVirtualTerminal )
110
106
{
111
107
$result = $testinputone | Select-String - Pattern " l" - SimpleMatch | Out-String
112
- $result | Should - Be " ${nl} he ` e [7ml`e [0mlo${nl} He ` e [7ml`e [0mlo${nl}${nl} "
108
+ $result | Should - Be " `n he ` e [7ml`e [0mlo`n He ` e [7ml`e [0mlo`n`n "
113
109
}
114
110
else
115
111
{
116
112
$result = $testinputone | Select-String - Pattern " l" - SimpleMatch | Out-String
117
- $result | Should - Be " ${nl} hello ${nl} Hello ${nl}${nl} "
113
+ $result | Should - Be " `n hello `n Hello `n`n "
118
114
}
119
115
}
120
116
121
117
it " Should output a string without highlighting when NoEmphasis is used" {
122
118
$result = $testinputone | Select-String - Pattern " l" - NoEmphasis | Out-String
123
- $result | Should - Be " ${nl} hello ${nl} Hello ${nl}${nl} "
119
+ $result | Should - Be " `n hello `n Hello `n`n "
124
120
}
125
121
126
122
it " Should return an array of matching strings without virtual terminal sequences" {
@@ -251,4 +247,8 @@ Describe "Select-String" -Tags "CI" {
251
247
Select-String second $testInputFile - Raw - Context 2 , 2 | Should - BeExactly $expected
252
248
}
253
249
}
250
+
251
+ AfterAll {
252
+ Push-Location $currentDirectory
253
+ }
254
254
}
0 commit comments