@@ -126,7 +126,7 @@ Describe "Remove-Item" -Tags "CI" {
126
126
}
127
127
128
128
It " Should be able to remove a directory" {
129
- { Remove-Item $testdirectory } | Should -Not - Throw
129
+ { Remove-Item $testdirectory - ErrorAction Stop } | Should -Not - Throw
130
130
131
131
Test-Path $testdirectory | Should - BeFalse
132
132
}
@@ -138,16 +138,32 @@ Describe "Remove-Item" -Tags "CI" {
138
138
$complexDirectory = Join-Path - Path $testsubdirectory - ChildPath $testfile
139
139
Test-Path $complexDirectory | Should - BeTrue
140
140
141
- { Remove-Item $testdirectory - Recurse } | Should -Not - Throw
141
+ { Remove-Item $testdirectory - Recurse - ErrorAction Stop } | Should -Not - Throw
142
142
143
143
Test-Path $testdirectory | Should - BeFalse
144
144
}
145
+
146
+ It " Should be able to recursively delete a directory with a trailing backslash" {
147
+ New-Item - Name " subd" - Path $testdirectory - ItemType " directory"
148
+ New-Item - Name $testfile - Path $testsubdirectory - ItemType " file" - Value " lorem ipsum"
149
+
150
+ $complexDirectory = Join-Path - Path $testsubdirectory - ChildPath $testfile
151
+ Test-Path $complexDirectory | Should - BeTrue
152
+
153
+ $testdirectoryWithBackSlash = Join-Path - Path $testdirectory - ChildPath ([IO.Path ]::DirectorySeparatorChar)
154
+ Test-Path $testdirectoryWithBackSlash | Should - BeTrue
155
+
156
+ { Remove-Item $testdirectoryWithBackSlash - Recurse - ErrorAction Stop } | Should -Not - Throw
157
+
158
+ Test-Path $testdirectoryWithBackSlash | Should - BeFalse
159
+ Test-Path $testdirectory | Should - BeFalse
160
+ }
145
161
}
146
162
147
163
Context " Alternate Data Streams should be supported on Windows" {
148
164
BeforeAll {
149
165
if (! $IsWindows ) {
150
- return
166
+ return
151
167
}
152
168
$fileName = " ADStest.txt"
153
169
$streamName = " teststream"
0 commit comments