From fd75d29628fa473e4455b8bee01ced87565f8750 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Tue, 11 Aug 2015 16:03:00 -0700 Subject: [PATCH 01/14] changed ParsePathCommand.cs to get Split-Path unit tests to pass --- src/monad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monad b/src/monad index df562ce7e..1b1329dfa 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit df562ce7ecd60fb42e30702116123c8a58bf04d4 +Subproject commit 1b1329dfaa038799d0a9de5f17b6d3737abd2319 From 5968e97eaa1015424a72bb2cfbc344f5698b77b2 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Thu, 13 Aug 2015 11:40:07 -0700 Subject: [PATCH 02/14] changed PowerShell code to get Split-Path -Qualifier working in linux --- src/monad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monad b/src/monad index 1b1329dfa..9d5fa55fc 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit 1b1329dfaa038799d0a9de5f17b6d3737abd2319 +Subproject commit 9d5fa55fceaff9514c5ffa26a0e1af01df05b7f3 From 4862e6cfd8cb77c6cb1440eb72431d8a729c453a Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Mon, 17 Aug 2015 15:03:14 -0700 Subject: [PATCH 03/14] added more tests to more thoroughly test split-path --- src/pester-tests/Test-Split-Path.Tests.ps1 | 48 ++++++++++++++++++---- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index c599b2382..f4965bd0f 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -1,36 +1,66 @@ Describe "Test-Split-Path" { <# Dependencies: + 1. Split-Path - FUT 2. ForEach 3. Object piping 4. ls/Get-ChildItem - filter output of ls + parent and Literal + #> It "Should return a string object when invoked" { - (Split-Path .).GetType().Name | Should Be "String" - (Split-Path . -Leaf).GetType().Name | Should Be "String" - (Split-Path . -Resolve).GetType().Name | Should Be "String" + ( Split-Path . ).GetType().Name | Should Be "String" + ( Split-Path . -Leaf ).GetType().Name | Should Be "String" + ( Split-Path . -Resolve ).GetType().Name | Should Be "String" } It "Should return the name of the drive when the qualifier switch is used" { - Split-Path / -Qualifier | Should Be "/" + Split-Path / -Qualifier | Should Be "/" + Split-Path /usr/bin -Qualifier | Should Be "/" + } + + It "Should error when using the qualifier switch for a windows path while on a nonwindows machine" { + Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw + } + + It "Should error when no directory separator characters are used with a qualifier" { + Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw + } + + It "Should return the path minus the drive when the noqualifier switch is used" { + { Split-Path /usr/bin -NoQualifier } | Should Not Throw + Split-Path /usr/bin -NoQualifier | Should Be "usr/bin" } It "Should return the parent folder name when the leaf switch is used" { - Split-Path . -Leaf | Should be "pester-tests" + Split-Path /usr/bin -Leaf | Should be "bin" } It "Should be able to accept regular expression input and output an array for multiple objects" { - (Split-Path *Get*.ps1 -Leaf -Resolve).GetType().BaseType.Name | Should Be "Array" + ( Split-Path *Get*.ps1 -Leaf -Resolve ).GetType().BaseType.Name | Should Be "Array" } It "Should be able to tell if a given path is an absolute path" { - (Split-Path /usr/bin -IsAbsolute) | Should be $true - (Split-Path . -IsAbsolute) | Should be $false + ( Split-Path /usr/bin -IsAbsolute ) | Should be $true + ( Split-Path . -IsAbsolute ) | Should be $false } It "Should support piping" { - ("." | Split-Path -leaf) | Should Be "pester-tests" + ( "/usr/bin" | Split-Path ) | Should Be "/usr" } + + It "Should return the path up to the parent of the directory when Parent switch is used" { + Split-Path "/usr/bin" | Should Be ( Split-Path "/usr/bin" -Parent ) + } + + It "Should not throw if a parameterSetName is correct" { + { Split-Path "/usr/bin/" -Parent } | Should Not Throw + } + + It "Should throw if a parameterSetName is incorrect" { + { Split-Path "/usr/bin/" -Parentaoeu } | Should Throw + } + } From 2689741ddc6a3fe4bea7a20ae4c64f505e9adfb0 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Mon, 17 Aug 2015 15:07:00 -0700 Subject: [PATCH 04/14] added support for PSL to remove qualifiers correctly --- src/monad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monad b/src/monad index 9d5fa55fc..0a5744c8d 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit 9d5fa55fceaff9514c5ffa26a0e1af01df05b7f3 +Subproject commit 0a5744c8da185fdde71fe7df7424978875476fb9 From 8458e5779e84ce5c1299b6e02cb3ffd5f8e6ab01 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 21 Aug 2015 14:34:00 -0700 Subject: [PATCH 05/14] brought in submodule changes and modded test to not expect the / to be removed in the path --- src/monad | 2 +- src/pester-tests/Test-Split-Path.Tests.ps1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/monad b/src/monad index 0a5744c8d..4e2140b94 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit 0a5744c8da185fdde71fe7df7424978875476fb9 +Subproject commit 4e2140b9436b5e5978752539ad06dbb0828f9b7e diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index f4965bd0f..33c1f5a96 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -29,9 +29,9 @@ Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw } - It "Should return the path minus the drive when the noqualifier switch is used" { + It "Should return the path when the noqualifier switch is used on a linux system" { { Split-Path /usr/bin -NoQualifier } | Should Not Throw - Split-Path /usr/bin -NoQualifier | Should Be "usr/bin" + Split-Path /usr/bin -NoQualifier | Should Be "/usr/bin" } It "Should return the parent folder name when the leaf switch is used" { From 632a11a6c653393a83797aa517bb8ea372485ac2 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 21 Aug 2015 14:58:34 -0700 Subject: [PATCH 06/14] fixed typo using parent switch --- src/pester-tests/Test-Split-Path.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index 33c1f5a96..c200f35d5 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -52,7 +52,7 @@ } It "Should return the path up to the parent of the directory when Parent switch is used" { - Split-Path "/usr/bin" | Should Be ( Split-Path "/usr/bin" -Parent ) + Split-Path "/usr/bin" -Parent | Should Be ( Split-Path "/usr/bin" -Parent ) } It "Should not throw if a parameterSetName is correct" { From df2a4939ed374ee19cd22982842553e0f9c433fb Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Wed, 26 Aug 2015 10:53:36 -0700 Subject: [PATCH 07/14] added code review changes --- src/pester-tests/Test-Split-Path.Tests.ps1 | 48 ++++++++++++++-------- 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index c200f35d5..ec3283057 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -1,15 +1,8 @@ Describe "Test-Split-Path" { -<# - Dependencies: + $testDir = "/tmp" + $testfile = "testfile.ps1" + $FullyQualifiedTestFile = $testDir + "/" + $testFile - 1. Split-Path - FUT - 2. ForEach - 3. Object piping - 4. ls/Get-ChildItem - filter output of ls - - parent and Literal - -#> It "Should return a string object when invoked" { ( Split-Path . ).GetType().Name | Should Be "String" ( Split-Path . -Leaf ).GetType().Name | Should Be "String" @@ -22,6 +15,9 @@ } It "Should error when using the qualifier switch for a windows path while on a nonwindows machine" { + # ErrorAction SilentlyContinue merely suppresses the error from the console. + # Throwing exceptions still seen by Pester. + Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw } @@ -31,7 +27,7 @@ It "Should return the path when the noqualifier switch is used on a linux system" { { Split-Path /usr/bin -NoQualifier } | Should Not Throw - Split-Path /usr/bin -NoQualifier | Should Be "/usr/bin" + Split-Path /usr/bin -NoQualifier | Should Be "/usr/bin" } It "Should return the parent folder name when the leaf switch is used" { @@ -39,12 +35,32 @@ } It "Should be able to accept regular expression input and output an array for multiple objects" { - ( Split-Path *Get*.ps1 -Leaf -Resolve ).GetType().BaseType.Name | Should Be "Array" + $testfile2 = "testfilenumber2.ps1" + $FullyQualifiedTestFile2 = $testDir + "/" + $testfile2 + + New-Item -ItemType file -Path $FullyQualifiedTestFile, $FullyQualifiedTestFile2 + + Test-Path $FullyQualifiedTestFile | Should Be $true + Test-Path $FullyQualifiedTestFile2 | Should Be $true + + ( Split-Path /tmp/*estf*.ps1 -Leaf -Resolve ).GetType().BaseType.Name | Should Be "Array" + ( Split-path /tmp/*estf*.ps1 -Leaf -Resolve )[0] | Should Be $testfile + ( Split-path /tmp/*estf*.ps1 -Leaf -Resolve )[1] | Should Be $testfile2 + + Remove-Item $FullyQualifiedTestFile, $FullyQualifiedTestFile2 } It "Should be able to tell if a given path is an absolute path" { ( Split-Path /usr/bin -IsAbsolute ) | Should be $true + ( Split-Path .. -IsAbsolute ) | Should be $false + ( Split-Path /usr/.. -IsAbsolute ) | Should be $true + ( Split-Path /usr/../ -IsAbsolute ) | Should be $true + ( Split-Path ../ -IsAbsolute ) | Should be $false ( Split-Path . -IsAbsolute ) | Should be $false + ( Split-Path ~/ -IsAbsolute ) | Should be $false + ( Split-Path ~/.. -IsAbsolute ) | Should be $false + ( Split-Path ~/../.. -IsAbsolute ) | Should be $false + } It "Should support piping" { @@ -52,15 +68,11 @@ } It "Should return the path up to the parent of the directory when Parent switch is used" { - Split-Path "/usr/bin" -Parent | Should Be ( Split-Path "/usr/bin" -Parent ) - } - - It "Should not throw if a parameterSetName is correct" { - { Split-Path "/usr/bin/" -Parent } | Should Not Throw + Split-Path "/usr/bin" -Parent | Should Be "/usr" } It "Should throw if a parameterSetName is incorrect" { - { Split-Path "/usr/bin/" -Parentaoeu } | Should Throw + { Split-Path "/usr/bin/" -Parentaoeu } | Should Throw "A parameter cannot be found that matches parameter name" } } From f4ea2ba4f844157a0f43a4398264b3391c324770 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Wed, 26 Aug 2015 11:17:52 -0700 Subject: [PATCH 08/14] added tests from CR --- src/pester-tests/Test-Split-Path.Tests.ps1 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index ec3283057..cfd7ada3e 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -31,7 +31,9 @@ } It "Should return the parent folder name when the leaf switch is used" { - Split-Path /usr/bin -Leaf | Should be "bin" + Split-Path /usr/bin -Leaf | Should be "bin" + Split-Path /usr/local/bin -Leaf | Should be "bin" + Split-Path usr/bin -Leaf | Should be "bin" } It "Should be able to accept regular expression input and output an array for multiple objects" { @@ -68,7 +70,9 @@ } It "Should return the path up to the parent of the directory when Parent switch is used" { - Split-Path "/usr/bin" -Parent | Should Be "/usr" + Split-Path "/usr/bin" -Parent | Should Be "/usr" + Split-Path "/usr/local/bin" -Parent | Should Be "/usr/local" + Split-Path "usr/local/bin" -Parent | Should Be "usr/local" } It "Should throw if a parameterSetName is incorrect" { From 38c1047ebaf265c562171257e1e7f19dc49dafef Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Wed, 26 Aug 2015 12:56:38 -0700 Subject: [PATCH 09/14] Added logic to handle failing jenkins test --- src/pester-tests/Test-Split-Path.Tests.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index cfd7ada3e..e0c69c83c 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -40,7 +40,7 @@ $testfile2 = "testfilenumber2.ps1" $FullyQualifiedTestFile2 = $testDir + "/" + $testfile2 - New-Item -ItemType file -Path $FullyQualifiedTestFile, $FullyQualifiedTestFile2 + New-Item -ItemType file -Path $FullyQualifiedTestFile, $FullyQualifiedTestFile2 -Force Test-Path $FullyQualifiedTestFile | Should Be $true Test-Path $FullyQualifiedTestFile2 | Should Be $true From f475db96cb5653dd0462a2598428538b8c8c4889 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Wed, 26 Aug 2015 14:30:02 -0700 Subject: [PATCH 10/14] using a created temp directory instead of the root temp directory. --- src/pester-tests/Test-Split-Path.Tests.ps1 | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index e0c69c83c..5a50791b7 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -1,8 +1,9 @@ Describe "Test-Split-Path" { - $testDir = "/tmp" + # Use the local directory because it's renewed each time with the correct privileges + $testDir = "./tmp" $testfile = "testfile.ps1" $FullyQualifiedTestFile = $testDir + "/" + $testFile - +ls It "Should return a string object when invoked" { ( Split-Path . ).GetType().Name | Should Be "String" ( Split-Path . -Leaf ).GetType().Name | Should Be "String" @@ -45,11 +46,14 @@ Test-Path $FullyQualifiedTestFile | Should Be $true Test-Path $FullyQualifiedTestFile2 | Should Be $true - ( Split-Path /tmp/*estf*.ps1 -Leaf -Resolve ).GetType().BaseType.Name | Should Be "Array" - ( Split-path /tmp/*estf*.ps1 -Leaf -Resolve )[0] | Should Be $testfile - ( Split-path /tmp/*estf*.ps1 -Leaf -Resolve )[1] | Should Be $testfile2 + ( Split-Path ./tmp/*estf*.ps1 -Leaf -Resolve ).GetType().BaseType.Name | Should Be "Array" + ( Split-path ./tmp/*estf*.ps1 -Leaf -Resolve )[0] | Should Be $testfile + ( Split-path ./tmp/*estf*.ps1 -Leaf -Resolve )[1] | Should Be $testfile2 Remove-Item $FullyQualifiedTestFile, $FullyQualifiedTestFile2 + + Test-Path $FullyQualifiedTestFile | Should Be $false + Test-Path $FullyQualifiedTestFile2 | Should Be $false } It "Should be able to tell if a given path is an absolute path" { @@ -78,5 +82,4 @@ It "Should throw if a parameterSetName is incorrect" { { Split-Path "/usr/bin/" -Parentaoeu } | Should Throw "A parameter cannot be found that matches parameter name" } - } From 10c772829dc7415de36f6c0971e55e4327d52532 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 28 Aug 2015 16:06:27 -0700 Subject: [PATCH 11/14] fixed unordering of files created during test --- src/monad | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/monad b/src/monad index 2793b76e2..a1a05637e 160000 --- a/src/monad +++ b/src/monad @@ -1 +1 @@ -Subproject commit 2793b76e2d48f012a82b8e9106b9e9f496d3b785 +Subproject commit a1a05637ebc40bdbfef51f8435e8592587a4eb5d From 534de9d15ffe3e1f3c48715f2871432fabfda2a4 Mon Sep 17 00:00:00 2001 From: Zachary Folwick Date: Fri, 28 Aug 2015 16:07:11 -0700 Subject: [PATCH 12/14] Match array instead of testing elements So that we can ignore the ordering from the regexp --- src/pester-tests/Test-Split-Path.Tests.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index 5a50791b7..64aae8811 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -46,9 +46,10 @@ ls Test-Path $FullyQualifiedTestFile | Should Be $true Test-Path $FullyQualifiedTestFile2 | Should Be $true - ( Split-Path ./tmp/*estf*.ps1 -Leaf -Resolve ).GetType().BaseType.Name | Should Be "Array" - ( Split-path ./tmp/*estf*.ps1 -Leaf -Resolve )[0] | Should Be $testfile - ( Split-path ./tmp/*estf*.ps1 -Leaf -Resolve )[1] | Should Be $testfile2 + $actual = ( Split-Path ./tmp/*estf*.ps1 -Leaf -Resolve ) + $actual.GetType().BaseType.Name | Should Be "Array" + $actual | Should Match $testfile + $actual | Should Match $testfile2 Remove-Item $FullyQualifiedTestFile, $FullyQualifiedTestFile2 From 7b1280eb2e44912640e823f3dd14c9e3407bed7c Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 28 Aug 2015 17:22:51 -0700 Subject: [PATCH 13/14] Refactor Split-Path regexp test Fix issues with ordering etc. --- src/pester-tests/Test-Split-Path.Tests.ps1 | 32 ++++++++++------------ 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index 64aae8811..6d3357191 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -1,9 +1,4 @@ Describe "Test-Split-Path" { - # Use the local directory because it's renewed each time with the correct privileges - $testDir = "./tmp" - $testfile = "testfile.ps1" - $FullyQualifiedTestFile = $testDir + "/" + $testFile -ls It "Should return a string object when invoked" { ( Split-Path . ).GetType().Name | Should Be "String" ( Split-Path . -Leaf ).GetType().Name | Should Be "String" @@ -38,23 +33,26 @@ ls } It "Should be able to accept regular expression input and output an array for multiple objects" { - $testfile2 = "testfilenumber2.ps1" - $FullyQualifiedTestFile2 = $testDir + "/" + $testfile2 + $testDir = "./tmp" + Remove-Item $testDir -Recurse -Force - New-Item -ItemType file -Path $FullyQualifiedTestFile, $FullyQualifiedTestFile2 -Force + $testFile1 = "testfile1.ps1" + $testFile2 = "testfile2.ps1" + $testFilePath1 = $testDir + "/" + $testFile1 + $testFilePath2 = $testDir + "/" + $testFile2 - Test-Path $FullyQualifiedTestFile | Should Be $true - Test-Path $FullyQualifiedTestFile2 | Should Be $true + New-Item -ItemType file -Path $testFilePath1, $testFilePath2 -Force - $actual = ( Split-Path ./tmp/*estf*.ps1 -Leaf -Resolve ) + Test-Path $testFilePath1 | Should Be $true + Test-Path $testFilePath2 | Should Be $true + + $actual = ( Split-Path $testDir/*file*.ps1 -Leaf -Resolve ) | Sort-Object $actual.GetType().BaseType.Name | Should Be "Array" - $actual | Should Match $testfile - $actual | Should Match $testfile2 + $actual[0] | Should Be $testFile1 + $actual[1] | Should Be $testFile2 - Remove-Item $FullyQualifiedTestFile, $FullyQualifiedTestFile2 - - Test-Path $FullyQualifiedTestFile | Should Be $false - Test-Path $FullyQualifiedTestFile2 | Should Be $false + Remove-Item $testDir -Recurse -Force + Test-Path $testDir | Should Be $false } It "Should be able to tell if a given path is an absolute path" { From 92cd86d3f205cf80c0ac3fc2ca7b552c1ae46a83 Mon Sep 17 00:00:00 2001 From: Andrew Schwartzmeyer Date: Fri, 28 Aug 2015 20:13:10 -0700 Subject: [PATCH 14/14] Ignore Remove-Item errors in Split-Path setup --- src/pester-tests/Test-Split-Path.Tests.ps1 | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pester-tests/Test-Split-Path.Tests.ps1 b/src/pester-tests/Test-Split-Path.Tests.ps1 index 6d3357191..47dc536a0 100644 --- a/src/pester-tests/Test-Split-Path.Tests.ps1 +++ b/src/pester-tests/Test-Split-Path.Tests.ps1 @@ -14,27 +14,29 @@ # ErrorAction SilentlyContinue merely suppresses the error from the console. # Throwing exceptions still seen by Pester. - Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw + Split-Path "C:\Users" -Qualifier -ErrorAction SilentlyContinue | Should Throw } It "Should error when no directory separator characters are used with a qualifier" { - Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw + Split-Path "abadTest" -Qualifier -ErrorAction SilentlyContinue | Should Throw } - It "Should return the path when the noqualifier switch is used on a linux system" { + It "Should return the path when the noqualifier switch is used on a Linux system" { { Split-Path /usr/bin -NoQualifier } | Should Not Throw Split-Path /usr/bin -NoQualifier | Should Be "/usr/bin" } - It "Should return the parent folder name when the leaf switch is used" { + It "Should return the base name when the leaf switch is used" { Split-Path /usr/bin -Leaf | Should be "bin" Split-Path /usr/local/bin -Leaf | Should be "bin" Split-Path usr/bin -Leaf | Should be "bin" + Split-Path ./bin -Leaf | Should be "bin" + Split-Path bin -Leaf | Should be "bin" } It "Should be able to accept regular expression input and output an array for multiple objects" { $testDir = "./tmp" - Remove-Item $testDir -Recurse -Force + Remove-Item $testDir -Recurse -Force -ErrorAction Ignore $testFile1 = "testfile1.ps1" $testFile2 = "testfile2.ps1" @@ -51,7 +53,7 @@ $actual[0] | Should Be $testFile1 $actual[1] | Should Be $testFile2 - Remove-Item $testDir -Recurse -Force + Remove-Item $testDir -Recurse -Force -ErrorAction Ignore Test-Path $testDir | Should Be $false }