mirror of
https://github.com/PowerShell/PowerShell
synced 2026-06-08 12:12:50 +00:00
update tests to include $IsCoreCLR rather than $IsCore
also fix archive test to be sure it gets the proper archive module (not the one that's somewhere in the filesystem)
This commit is contained in:
+20
-9
@@ -8,11 +8,22 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
|
||||
AfterAll {
|
||||
$global:ProgressPreference = $_progressPreference
|
||||
$env:PSMODULEPATH = $_modulePath
|
||||
}
|
||||
BeforeAll {
|
||||
# remove the archive module forcefully, to be sure we get the correct version
|
||||
if ( Get-Module Microsoft.PowerShell.Archive. ) {
|
||||
Remove-Module Microsoft.PowerShell.Archive -force
|
||||
}
|
||||
# Version comparisons should use a System.Version rather than SemanticVersion
|
||||
$PSVersion = $PSVersionTable.PSVersion -as [Version]
|
||||
# Write-Progress not supported yet on Core
|
||||
$_progressPreference = $ProgressPreference
|
||||
if ( $IsCore ) { $global:ProgressPreference = "SilentlyContinue" }
|
||||
# we need to be sure that we get the correct archive module
|
||||
$_modulePath = $env:PSMODULEPATH
|
||||
$powershellexe = (get-process -pid $PID).MainModule.FileName
|
||||
$env:PSMODULEPATH = join-path ([io.path]::GetDirectoryName($powershellexe)) Modules
|
||||
if ( $IsCoreCLR ) { $global:ProgressPreference = "SilentlyContinue" }
|
||||
|
||||
Setup -d SourceDir
|
||||
Setup -d SourceDir/ChildDir-1
|
||||
@@ -37,7 +48,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
|
||||
function Add-CompressionAssemblies {
|
||||
Add-Type -AssemblyName System.IO.Compression
|
||||
if (($psedition -eq "Core") -or $IsCore )
|
||||
if (($psedition -eq "Core") -or $IsCoreCLR )
|
||||
{
|
||||
Add-Type -AssemblyName System.IO.Compression.ZipFile
|
||||
}
|
||||
@@ -259,7 +270,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
|
||||
It "Validate errors from Compress-Archive when invalid path (non-existing path / non-filesystem path) is supplied for Path or LiteralPath parameters" {
|
||||
CompressArchiveInValidPathValidator "$TestDrive/InvalidPath" $TestDrive "$TestDrive/InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
if ( ! $IsCore ) {
|
||||
if ( ! $IsCoreCLR ) {
|
||||
CompressArchiveInValidPathValidator "HKLM:/SOFTWARE" $TestDrive "HKLM:/SOFTWARE" "PathNotFound,Compress-Archive"
|
||||
}
|
||||
CompressArchiveInValidPathValidator "$TestDrive" "$TestDrive/NonExistingDirectory/sample.zip" "$TestDrive/NonExistingDirectory/sample.zip" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
@@ -267,7 +278,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
$path = @("$TestDrive", "$TestDrive/InvalidPath")
|
||||
CompressArchiveInValidPathValidator $path $TestDrive "$TestDrive/InvalidPath" "ArchiveCmdletPathNotFound,Compress-Archive"
|
||||
|
||||
if ( ! $IsCore ) {
|
||||
if ( ! $IsCoreCLR ) {
|
||||
$path = @("$TestDrive", "HKLM:/SOFTWARE")
|
||||
CompressArchiveInValidPathValidator $path $TestDrive "HKLM:/SOFTWARE" "PathNotFound,Compress-Archive"
|
||||
}
|
||||
@@ -375,7 +386,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
$destinationPath | Should Exist
|
||||
}
|
||||
# This test requires a fix in PS5 to support reading paths with square bracket
|
||||
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter with Special Characters" -skip:($PSVersionTable.psversion -lt "5.0") {
|
||||
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter with Special Characters" -skip:($PSVersion -lt "5.0") {
|
||||
$sourcePath = "$TestDrive/SourceDir/ChildDir-1/Sample[]File.txt"
|
||||
"Some Random Content" | Out-File -LiteralPath $sourcePath
|
||||
$destinationPath = "$TestDrive/SampleSingleFileWithSpecialCharacters.zip"
|
||||
@@ -430,7 +441,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
}
|
||||
}
|
||||
# This test requires a fix in PS5 to support reading paths with square bracket
|
||||
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter for a directory with Special Characters in the directory name" -skip:($PSVersionTable.psversion -lt "5.0") {
|
||||
It "Validate that Compress-Archive cmdlet can accept LiteralPath parameter for a directory with Special Characters in the directory name" -skip:($PSVersion -lt "5.0") {
|
||||
$sourcePath = "$TestDrive/Source[]Dir/ChildDir[]-1"
|
||||
New-Item $sourcePath -Type Directory | Out-Null
|
||||
"Some Random Content" | Out-File -LiteralPath "$sourcePath/Sample[]File.txt"
|
||||
@@ -460,7 +471,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
# Remove-Item -LiteralPath $destinationPath -Force
|
||||
}
|
||||
}
|
||||
It "Validate that Source Path can be at SystemDrive location" -skip:($IsCore) {
|
||||
It "Validate that Source Path can be at SystemDrive location" -skip:($IsCoreCLR) {
|
||||
$sourcePath = "$env:SystemDrive/SourceDir"
|
||||
$destinationPath = "$TestDrive/SampleFromSystemDrive.zip"
|
||||
New-Item $sourcePath -Type Directory | Out-Null
|
||||
@@ -678,7 +689,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
try { Expand-Archive -Path "$TestDrive/NonExistingArchive" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "ArchiveCmdletPathNotFound,Expand-Archive" }
|
||||
|
||||
if ( ! $IsCore ) {
|
||||
if ( ! $IsCoreCLR ) {
|
||||
try { Expand-Archive -Path "HKLM:/SOFTWARE" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive" }
|
||||
}
|
||||
@@ -686,7 +697,7 @@ Describe "Test suite for Microsoft.PowerShell.Archive module" -Tags "CI" {
|
||||
try { Expand-Archive -LiteralPath "$TestDrive/NonExistingArchive" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "ArchiveCmdletPathNotFound,Expand-Archive" }
|
||||
|
||||
if ( ! $IsCore ) {
|
||||
if ( ! $IsCoreCLR ) {
|
||||
try { Expand-Archive -LiteralPath "HKLM:/SOFTWARE" -DestinationPath "$TestDrive/SourceDir"; throw "Expand-Archive did NOT throw expected error" }
|
||||
catch { $_.FullyQualifiedErrorId | Should Be "PathNotFound,Expand-Archive" }
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
# If PS Remoting is not available, do not run the suite.
|
||||
function ShouldRun
|
||||
{
|
||||
if ( $IsCore ) { return $false }
|
||||
if ( $IsCoreCLR ) { return $false }
|
||||
$result = Invoke-Command -ComputerName . -ScriptBlock {1} -ErrorAction SilentlyContinue
|
||||
return ($result -eq 1)
|
||||
}
|
||||
|
||||
@@ -189,7 +189,7 @@ Describe "FormatHex" -tags "CI" {
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.Count | should be 2
|
||||
$result[0].ToString() | Should be "00000000 54 68 69 73 20 69 73 20 61 20 62 69 74 20 6D 6F This is a bit mo"
|
||||
if ( $IsCore ) {
|
||||
if ( $IsCoreCLR ) {
|
||||
$result[1].ToString() | Should be "00000010 72 65 20 74 65 78 74 re text "
|
||||
}
|
||||
}
|
||||
@@ -199,7 +199,7 @@ Describe "FormatHex" -tags "CI" {
|
||||
$result = Get-Content $InputFile1 -Encoding Byte | Format-Hex
|
||||
$result | Should Not BeNullOrEmpty
|
||||
$result.GetType().Name | Should Be "ByteCollection"
|
||||
if ( $IsCore ) {
|
||||
if ( $IsCoreCLR ) {
|
||||
$result.ToString() | Should be "00000000 48 65 6C 6C 6F 20 57 6F 72 6C 64 Hello World "
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -18,7 +18,7 @@
|
||||
)
|
||||
function Set-delimiter {
|
||||
param ( $delimiter )
|
||||
if ( $IsCore ) {
|
||||
if ( $IsCoreCLR ) {
|
||||
$enCulture.TextInfo.ListSeparator = $delimiter
|
||||
[System.Globalization.CultureInfo]::CurrentCulture = $enCulture
|
||||
}
|
||||
@@ -28,7 +28,7 @@
|
||||
}
|
||||
}
|
||||
AfterEach {
|
||||
if ( $IsCore ) {
|
||||
if ( $IsCoreCLR ) {
|
||||
$enCulture.TextInfo.ListSeparator = $defaultDelimiter
|
||||
[System.Globalization.CultureInfo]::CurrentCulture = $enCulture
|
||||
}
|
||||
|
||||
+7
-7
@@ -109,7 +109,7 @@ Describe "Json Tests" -Tags "Feature" {
|
||||
$response.d.Name.First | Should Match "Joel"
|
||||
}
|
||||
|
||||
It "Convert to Json using PSObject" -pending:($IsCore) {
|
||||
It "Convert to Json using PSObject" -pending:($IsCoreCLR) {
|
||||
|
||||
$response = ConvertFrom-Json '{"d":{"__type":"SimpleJsonObject","Name":{"First":"Joel","Last":"Wood"},"Greeting":"Hello"}}'
|
||||
|
||||
@@ -169,7 +169,7 @@ Describe "Json Tests" -Tags "Feature" {
|
||||
$response2 | Should Be $result3
|
||||
}
|
||||
|
||||
It "Convert to Json using hashtable" -pending:($IsCore) {
|
||||
It "Convert to Json using hashtable" -pending:($IsCoreCLR) {
|
||||
|
||||
$nameHash = @{First="Joe1";Last="Wood"}
|
||||
$dHash = @{Name=$nameHash; Greeting="Hello"}
|
||||
@@ -365,7 +365,7 @@ Describe "Validate Json serialization" -Tags "CI" {
|
||||
$testCases = @(
|
||||
@{
|
||||
TestInput = 0
|
||||
ToJson = if ( $IsCore ) { '"\u0000"' } else { 'null' }
|
||||
ToJson = if ( $IsCoreCLR ) { '"\u0000"' } else { 'null' }
|
||||
FromJson = ''
|
||||
}
|
||||
@{
|
||||
@@ -555,12 +555,12 @@ Describe "Validate Json serialization" -Tags "CI" {
|
||||
}
|
||||
@{
|
||||
TestInput = 38
|
||||
ToJson = if ( $IsCore ) { '"&"' } else { '"\u0026"' }
|
||||
ToJson = if ( $IsCoreCLR ) { '"&"' } else { '"\u0026"' }
|
||||
FromJson = '&'
|
||||
}
|
||||
@{
|
||||
TestInput = 39
|
||||
ToJson = if ( $IsCore ) { '"''"' } else { '"\u0027"' }
|
||||
ToJson = if ( $IsCoreCLR ) { '"''"' } else { '"\u0027"' }
|
||||
FromJson = "'"
|
||||
}
|
||||
@{
|
||||
@@ -665,7 +665,7 @@ Describe "Validate Json serialization" -Tags "CI" {
|
||||
}
|
||||
@{
|
||||
TestInput = 60
|
||||
ToJson = if ( $IsCore ) { '"<"' } else { '"\u003c"' }
|
||||
ToJson = if ( $IsCoreCLR ) { '"<"' } else { '"\u003c"' }
|
||||
FromJson = '<'
|
||||
}
|
||||
@{
|
||||
@@ -675,7 +675,7 @@ Describe "Validate Json serialization" -Tags "CI" {
|
||||
}
|
||||
@{
|
||||
TestInput = 62
|
||||
ToJson = if ( $IsCore ) { '">"' } else { '"\u003e"' }
|
||||
ToJson = if ( $IsCoreCLR ) { '">"' } else { '"\u003e"' }
|
||||
FromJson = '>'
|
||||
}
|
||||
@{
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
if ( test-path $actualLogFile ) { Remove-Item $actualLogFile }
|
||||
}
|
||||
|
||||
It "LogicalOperationStack works" -pending:($IsCore) {
|
||||
It "LogicalOperationStack works" -pending:($IsCoreCLR) {
|
||||
$keyword = "Trace_Command_ListenerOption_LogicalOperationStack_Foo"
|
||||
$stack = [System.Diagnostics.Trace]::CorrelationManager.LogicalOperationStack
|
||||
$stack.Push($keyword)
|
||||
@@ -22,7 +22,7 @@
|
||||
$log.Count | Should BeGreaterThan 0
|
||||
}
|
||||
|
||||
It "Callstack works" -pending:($IsCore) {
|
||||
It "Callstack works" -pending:($IsCoreCLR) {
|
||||
Trace-Command -Name * -Expression {write-output Foo} -ListenerOption Callstack -FilePath $logfile
|
||||
$log = Get-Content $logfile | Where-Object {$_ -like "*Callstack= * System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)*"}
|
||||
$log.Count | Should BeGreaterThan 0
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
(select-string -LiteralPath $fileNameWithDots "b").count | Should Be 2
|
||||
}
|
||||
|
||||
It "Network path" -skip:($IsCore) {
|
||||
It "Network path" -skip:($IsCoreCLR) {
|
||||
(select-string -LiteralPath $fileNameAsNetworkPath "b").count | Should Be 2
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,13 @@
|
||||
$testcases += [TestData]::new('literalpath with relative paths', @{LiteralPath = $fileName.Name; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('literalpath with absolute paths', @{LiteralPath = $fileName.FullName; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('literalpath with path with dots', @{LiteralPath = $fileNameWithDots; XPath = 'Root'})
|
||||
if ( ! $IsCore ) {
|
||||
if ( ! $IsCoreCLR ) {
|
||||
$testcases += [TestData]::new('literalpath with network path', @{LiteralPath = $fileNameAsNetworkPath; XPath = 'Root'})
|
||||
}
|
||||
$testcases += [TestData]::new('path with relative paths', @{Path = $fileName.Name; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('path with absolute paths', @{Path = $fileName.FullName; XPath = 'Root'})
|
||||
$testcases += [TestData]::new('path with path with dots', @{Path = $fileNameWithDots; XPath = 'Root'})
|
||||
if ( ! $IsCore ) {
|
||||
if ( ! $IsCoreCLR ) {
|
||||
$testcases += [TestData]::new('path with network path', @{Path = $fileNameAsNetworkPath; XPath = 'Root'})
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user