mirror of
https://github.com/aphrody-labs/PowerShell.git
synced 2026-10-17 04:36:39 +00:00
Fix tests that were broken by the sxs module path change. Also fix some unreliable tests.
This commit is contained in:
1 parent
896577e285
commit
753b202a75
8 files changed
+29
-26
No files matched your search
@@ -11,8 +11,8 @@ Describe "Configuration file locations" -tags "CI","Slow" {
|
|||||||
|
|
||||||
if ($IsWindows) {
|
if ($IsWindows) {
|
||||||
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
|
$expectedCache = [IO.Path]::Combine($env:LOCALAPPDATA, "Microsoft", "Windows", "PowerShell", "StartupProfileData-NonInteractive")
|
||||||
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", "WindowsPowerShell", "Modules")
|
$expectedModule = [IO.Path]::Combine($env:USERPROFILE, "Documents", "PowerShell", "Modules")
|
||||||
$expectedProfile = [io.path]::Combine($env:USERPROFILE, "Documents","WindowsPowerShell",$profileName)
|
$expectedProfile = [io.path]::Combine($env:USERPROFILE, "Documents","PowerShell",$profileName)
|
||||||
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
|
$expectedReadline = [IO.Path]::Combine($env:AppData, "Microsoft", "Windows", "PowerShell", "PSReadline", "ConsoleHost_history.txt")
|
||||||
} else {
|
} else {
|
||||||
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
|
$expectedCache = [IO.Path]::Combine($env:HOME, ".cache", "powershell", "StartupProfileData-NonInteractive")
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Describe 'use of a module from two runspaces' -Tags "CI" {
|
|||||||
|
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\)[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\)[0].FullName)
|
||||||
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
||||||
$env:PSMODULEPATH += ";$resolvedTestDrivePath"
|
$env:PSMODULEPATH += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ Describe 'NestedModules' -Tags "CI" {
|
|||||||
|
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\)[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((get-childitem TestDrive:\)[0].FullName)
|
||||||
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
||||||
$env:PSMODULEPATH += ";$resolvedTestDrivePath"
|
$env:PSMODULEPATH += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ Describe 'using module' -Tags "CI" {
|
|||||||
|
|
||||||
$resolvedTestDrivePath = Split-Path ((get-childitem "${TestDrive}\$ModulePathPrefix")[0].FullName)
|
$resolvedTestDrivePath = Split-Path ((get-childitem "${TestDrive}\$ModulePathPrefix")[0].FullName)
|
||||||
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
if (-not ($env:PSMODULEPATH -like "*$resolvedTestDrivePath*")) {
|
||||||
$env:PSMODULEPATH += ";$resolvedTestDrivePath"
|
$env:PSMODULEPATH += "$([System.IO.Path]::PathSeparator)$resolvedTestDrivePath"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
Describe "Export-Csv" -Tags "CI" {
|
Describe "Export-Csv" -Tags "CI" {
|
||||||
$testObject = @("test","object","array")
|
$testObject = @("test","object","array")
|
||||||
$testCsv = "output.csv"
|
$testCsv = Join-Path -Path $TestDrive -ChildPath "output.csv"
|
||||||
|
|
||||||
AfterEach {
|
AfterEach {
|
||||||
Remove-Item $testCsv -Force -ErrorAction SilentlyContinue
|
Remove-Item $testCsv -Force -ErrorAction SilentlyContinue
|
||||||
@@ -51,7 +51,7 @@ Describe "Export-Csv" -Tags "CI" {
|
|||||||
It "Should have the same information when using the alias vs the cmdlet" {
|
It "Should have the same information when using the alias vs the cmdlet" {
|
||||||
$testObject | Export-Csv -Path $testCsv
|
$testObject | Export-Csv -Path $testCsv
|
||||||
|
|
||||||
$aliasObject = "alias.csv"
|
$aliasObject = Join-Path -Path $TestDrive -ChildPath "alias.csv"
|
||||||
|
|
||||||
$testObject | epcsv -Path $aliasObject
|
$testObject | epcsv -Path $aliasObject
|
||||||
|
|
||||||
|
|||||||
@@ -16,26 +16,29 @@ Describe "Export-FormatData DRT Unit Tests" -Tags "CI" {
|
|||||||
|
|
||||||
Describe "Export-FormatData" -Tags "CI" {
|
Describe "Export-FormatData" -Tags "CI" {
|
||||||
|
|
||||||
|
$testOutput = Join-Path -Path $TestDrive -ChildPath "outputfile"
|
||||||
|
|
||||||
|
AfterEach {
|
||||||
|
Remove-Item $testOutput -Force -ErrorAction SilentlyContinue
|
||||||
|
}
|
||||||
|
|
||||||
Context "Check Export-FormatData can be called validly." {
|
Context "Check Export-FormatData can be called validly." {
|
||||||
It "Should be able to be called without error" {
|
It "Should be able to be called without error" {
|
||||||
{ Get-FormatData | Export-FormatData -Path "outputfile" } | Should Not Throw
|
{ Get-FormatData | Export-FormatData -Path $testOutput } | Should Not Throw
|
||||||
Remove-Item "outputfile" -Force -ErrorAction SilentlyContinue
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Context "Check that the output is in the correct format" {
|
Context "Check that the output is in the correct format" {
|
||||||
It "Should not return an empty xml file" {
|
It "Should not return an empty xml file" {
|
||||||
Get-FormatData | Export-FormatData -Path "outputfile"
|
Get-FormatData | Export-FormatData -Path $testOutput
|
||||||
$piped = Get-Content "outputfile"
|
$piped = Get-Content $testOutput
|
||||||
$piped | Should Not Be ""
|
$piped | Should Not Be ""
|
||||||
Remove-Item "outputfile" -Force -ErrorAction SilentlyContinue
|
}
|
||||||
}
|
|
||||||
|
|
||||||
It "Should have a valid xml tag at the start of the file" {
|
It "Should have a valid xml tag at the start of the file" {
|
||||||
Get-FormatData | Export-FormatData -Path "outputfile"
|
Get-FormatData | Export-FormatData -Path $testOutput
|
||||||
$piped = Get-Content "outputfile"
|
$piped = Get-Content $testOutput
|
||||||
$piped[0] | Should Be "<"
|
$piped[0] | Should Be "<"
|
||||||
Remove-Item "outputfile" -Force -ErrorAction SilentlyContinue
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
Describe "Out-File DRT Unit Tests" -Tags "CI" {
|
Describe "Out-File DRT Unit Tests" -Tags "CI" {
|
||||||
It "Should be able to write the contens into a file with -pspath" {
|
It "Should be able to write the contens into a file with -pspath" {
|
||||||
$tempFile = "ExposeBug928965"
|
$tempFile = Join-Path -Path $TestDrive -ChildPath "ExposeBug928965"
|
||||||
{ 1 | Out-File -PSPath $tempFile } | Should Not Throw
|
{ 1 | Out-File -PSPath $tempFile } | Should Not Throw
|
||||||
$fileContents = Get-Content $tempFile
|
$fileContents = Get-Content $tempFile
|
||||||
$fileContents | Should be 1
|
$fileContents | Should be 1
|
||||||
@@ -8,7 +8,7 @@ Describe "Out-File DRT Unit Tests" -Tags "CI" {
|
|||||||
}
|
}
|
||||||
|
|
||||||
It "Should be able to write the contens into a file with -pspath" {
|
It "Should be able to write the contens into a file with -pspath" {
|
||||||
$tempFile = "outfileAppendTest.txt"
|
$tempFile = Join-Path -Path $TestDrive -ChildPath "outfileAppendTest.txt"
|
||||||
{ 'This is first line.' | out-file $tempFile } | Should Not Throw
|
{ 'This is first line.' | out-file $tempFile } | Should Not Throw
|
||||||
{ 'This is second line.' | out-file -append $tempFile } | Should Not Throw
|
{ 'This is second line.' | out-file -append $tempFile } | Should Not Throw
|
||||||
$tempFile |Should Contain "first"
|
$tempFile |Should Contain "first"
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
Describe "Stream writer tests" -Tags "CI" {
|
Describe "Stream writer tests" -Tags "CI" {
|
||||||
$targetfile = "writeoutput.txt"
|
$targetfile = Join-Path -Path $TestDrive -ChildPath "writeoutput.txt"
|
||||||
|
|
||||||
# A custom function is defined here do handle the debug stream dealing with the confirm prompt
|
# A custom function is defined here do handle the debug stream dealing with the confirm prompt
|
||||||
# that would normally
|
# that would normally
|
||||||
|
|||||||
Reference in new issue
Block a user