From 13848a5531fccfea4704ed0ffadb91875577ada7 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Fri, 9 Feb 2018 11:07:36 -0800 Subject: [PATCH 01/13] Adding Sudo parameter to Start-PSPester function. --- build.psm1 | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/build.psm1 b/build.psm1 index 96e88e38048..4c438a05cf9 100644 --- a/build.psm1 +++ b/build.psm1 @@ -978,6 +978,7 @@ function Start-PSPester { [switch]$Terse, [Parameter(ParameterSetName='PassThru',Mandatory=$true)] [switch]$PassThru, + [switch]$Sudo, [switch]$IncludeFailingTest ) @@ -1161,14 +1162,18 @@ Restore the module to '$Pester' by running: try { $Command += "|Export-Clixml -Path '$passThruFile' -Force" - if ($Terse) - { - Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Terse $_} + $PassThruCommand = {& $powershell -noprofile -c $Command } + if ($Sudo.IsPresent) { + $PassThruCommand = {& sudo $powershell -noprofile -c $Command } } - else + + $writeCommand = { Write-Host $_ } + if ($Terse) { - Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Host $_} + $writeCommand = { Write-Terse $_ } } + + Start-NativeExecution -sb $PassThruCommand | ForEach-Object $writeCommand Import-Clixml -Path $passThruFile | Where-Object {$_.TotalCount -is [Int32]} } finally From ee7227d90c1b3779223382c0b4a7ac6799e0ee69 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Fri, 9 Feb 2018 11:49:57 -0800 Subject: [PATCH 02/13] Running tests, which require sudo on Linux. --- tools/travis.ps1 | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 9e4795d9709..1c3420f410e 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -202,9 +202,11 @@ elseif($Stage -eq 'Build') } $pesterParam = @{ - 'binDir' = $output - 'PassThru' = $true - 'Terse' = $true + 'binDir' = $output + 'PassThru' = $true + 'Terse' = $true + 'Tag' = @() + 'ExcludeTag' = @('RequireSudo') } if ($isFullBuild) { @@ -226,8 +228,15 @@ elseif($Stage -eq 'Build') Remove-Item -force ${telemetrySemaphoreFilepath} } + # Running tests which do not require sudo. $pesterPassThruObject = Start-PSPester @pesterParam + # Running tests, which require sudo. + pesterParam['Tag'] = @('RequireSudo') + pesterParam['ExcludeTag'] = @() + pesterParam['Sudo'] = $true + $pesterPassThruObject += Start-PSPester @pesterParam + # Determine whether the build passed try { # this throws if there was an error From 466c8c73e716e1380cf29cce502ab943fb70c3a5 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Fri, 9 Feb 2018 12:09:24 -0800 Subject: [PATCH 03/13] Running tests on Linux which require Sudo. --- .../Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 index c5950aa7160..e3ace7b53df 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 @@ -1,12 +1,12 @@ -Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows') { +Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudo') { # Currently, CI tests on Linux/macOS are always run as normal user. So we need to skip these tests on non-Windows platform. # CI tests in root privilege on Linux/macOS is not supported. # See : https://github.com/PowerShell/PowerShell/issues/5645 - It "Set-Date should be able to set the date in an elevated context" -Skip:(!$IsWindows) { + It "Set-Date should be able to set the date in an elevated context" { { Get-Date | Set-Date } | Should Not Throw } - It "Set-Date should be able to set the date with -Date parameter" -Skip:(!$IsWindows) { + It "Set-Date should be able to set the date with -Date parameter" { $target = Get-Date $expected = $target Set-Date -Date $target | Should Be $expected From 07ae3f73601e404037dfd153dfb05b14658a18e5 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Fri, 9 Feb 2018 16:59:17 -0800 Subject: [PATCH 04/13] Assigning parameter in the same Parameter Set as PassThru in Start-PSPester function. --- build.psm1 | 1 + 1 file changed, 1 insertion(+) diff --git a/build.psm1 b/build.psm1 index 4c438a05cf9..a72a235534d 100644 --- a/build.psm1 +++ b/build.psm1 @@ -978,6 +978,7 @@ function Start-PSPester { [switch]$Terse, [Parameter(ParameterSetName='PassThru',Mandatory=$true)] [switch]$PassThru, + [Parameter(ParameterSetName='PassThru',HelpMessage='Run commands on Linux with sudo.')] [switch]$Sudo, [switch]$IncludeFailingTest ) From 65b85d3fa95260ed05a6773e1d1d9527ea75297a Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Mon, 12 Feb 2018 16:53:21 -0800 Subject: [PATCH 05/13] Correcting tag issues for tests run with sudo on Unix. --- build.psm1 | 18 ++++++++++-------- .../Set-Date.Tests.ps1 | 2 +- tools/travis.ps1 | 10 +++++----- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/build.psm1 b/build.psm1 index a72a235534d..ca92c267363 100644 --- a/build.psm1 +++ b/build.psm1 @@ -881,6 +881,7 @@ function Get-PesterTag { get-childitem -Recurse $testbase -File | Where-Object {$_.name -match "tests.ps1"}| ForEach-Object { $fullname = $_.fullname + Write-Host $_.fullname $tok = $err = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile($FullName, [ref]$tok,[ref]$err) $des = $ast.FindAll({$args[0] -is "System.Management.Automation.Language.CommandAst" -and $args[0].CommandElements[0].Value -eq "Describe"},$true) @@ -896,7 +897,7 @@ function Get-PesterTag { } $values = $vAst.FindAll({$args[0] -is "System.Management.Automation.Language.StringConstantExpressionAst"},$true).Value $values | ForEach-Object { - if (@('REQUIREADMINONWINDOWS', 'SLOW') -contains $_) { + if (@('REQUIREADMINONWINDOWS', 'REQUIRESUDOONUNIX', 'SLOW') -contains $_) { # These are valid tags also, but they are not the priority tags } elseif (@('CI', 'FEATURE', 'SCENARIO') -contains $_) { @@ -1159,27 +1160,28 @@ Restore the module to '$Pester' by running: { if ($PassThru.IsPresent) { - $passThruFile = [System.IO.Path]::GetTempFileName() + $PassThruFile = [System.IO.Path]::GetTempFileName() try { - $Command += "|Export-Clixml -Path '$passThruFile' -Force" + $Command += "|Export-Clixml -Path '$PassThruFile' -Force" + $PassThruCommand = {& $powershell -noprofile -c $Command } if ($Sudo.IsPresent) { $PassThruCommand = {& sudo $powershell -noprofile -c $Command } } - $writeCommand = { Write-Host $_ } + $WriteCommand = { Write-Host $_ } if ($Terse) { - $writeCommand = { Write-Terse $_ } + $WriteCommand = { Write-Terse $_ } } - Start-NativeExecution -sb $PassThruCommand | ForEach-Object $writeCommand - Import-Clixml -Path $passThruFile | Where-Object {$_.TotalCount -is [Int32]} + Start-NativeExecution -sb $PassThruCommand | ForEach-Object $WriteCommand + Import-Clixml -Path $PassThruFile | Where-Object {$_.TotalCount -is [Int32]} } finally { - Remove-Item $passThruFile -ErrorAction SilentlyContinue + Remove-Item $PassThruFile -ErrorAction SilentlyContinue } } else diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 index e3ace7b53df..cd1d794f477 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 @@ -1,4 +1,4 @@ -Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudo') { +Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') { # Currently, CI tests on Linux/macOS are always run as normal user. So we need to skip these tests on non-Windows platform. # CI tests in root privilege on Linux/macOS is not supported. # See : https://github.com/PowerShell/PowerShell/issues/5645 diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 1c3420f410e..0eb7d55ffb1 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -206,7 +206,7 @@ elseif($Stage -eq 'Build') 'PassThru' = $true 'Terse' = $true 'Tag' = @() - 'ExcludeTag' = @('RequireSudo') + 'ExcludeTag' = @('RequireSudoOnUnix') } if ($isFullBuild) { @@ -229,18 +229,18 @@ elseif($Stage -eq 'Build') } # Running tests which do not require sudo. - $pesterPassThruObject = Start-PSPester @pesterParam + $pesterPassThruNoSudoObject = Start-PSPester @pesterParam # Running tests, which require sudo. - pesterParam['Tag'] = @('RequireSudo') + pesterParam['Tag'] = @('RequireSudoOnUnix') pesterParam['ExcludeTag'] = @() pesterParam['Sudo'] = $true - $pesterPassThruObject += Start-PSPester @pesterParam + $pesterPassThruSudoObject = Start-PSPester @pesterParam # Determine whether the build passed try { # this throws if there was an error - Test-PSPesterResults -ResultObject $pesterPassThruObject + @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | For-Each Object { Test-PSPesterResults -ResultObject } $result = "PASS" } catch { From 42113a779f0958ed0494941142cfaf72b722d4ae Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Mon, 12 Feb 2018 17:53:08 -0800 Subject: [PATCH 06/13] Correcting cmdlet in travis.ps1 file. --- tools/travis.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 0eb7d55ffb1..31e626e8f6b 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -240,7 +240,7 @@ elseif($Stage -eq 'Build') # Determine whether the build passed try { # this throws if there was an error - @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | For-Each Object { Test-PSPesterResults -ResultObject } + @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | ForEach-Object { Test-PSPesterResults -ResultObject } $result = "PASS" } catch { From e43ddfa2bea4e675c635d536e1f9c2628cc4ff5c Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Tue, 13 Feb 2018 10:26:12 -0800 Subject: [PATCH 07/13] Correcting cmdlet in travis.ps1 file. --- tools/travis.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 31e626e8f6b..97347702c60 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -240,7 +240,7 @@ elseif($Stage -eq 'Build') # Determine whether the build passed try { # this throws if there was an error - @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | ForEach-Object { Test-PSPesterResults -ResultObject } + @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | ForEach-Object { Test-PSPesterResults -ResultObject $_ } $result = "PASS" } catch { From 0a7bdbb59343e22be386bd8ac85f20098b62b17a Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Tue, 13 Feb 2018 11:25:41 -0800 Subject: [PATCH 08/13] Style corrections in build.ps1 --- build.psm1 | 51 +++++++++++++++++++++++++-------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/build.psm1 b/build.psm1 index ca92c267363..ae23b812fa5 100644 --- a/build.psm1 +++ b/build.psm1 @@ -881,7 +881,6 @@ function Get-PesterTag { get-childitem -Recurse $testbase -File | Where-Object {$_.name -match "tests.ps1"}| ForEach-Object { $fullname = $_.fullname - Write-Host $_.fullname $tok = $err = $null $ast = [System.Management.Automation.Language.Parser]::ParseFile($FullName, [ref]$tok,[ref]$err) $des = $ast.FindAll({$args[0] -is "System.Management.Automation.Language.CommandAst" -and $args[0].CommandElements[0].Value -eq "Describe"},$true) @@ -1029,52 +1028,52 @@ Restore the module to '$Pester' by running: Publish-PSTestTools | ForEach-Object {Write-Host $_} # All concatenated commands/arguments are suffixed with the delimiter (space) - $Command = "" + $command = "" if ($Terse) { - $Command += "`$ProgressPreference = 'silentlyContinue'; " + $command += "`$ProgressPreference = 'silentlyContinue'; " } # Autoload (in subprocess) temporary modules used in our tests - $Command += '$env:PSModulePath = '+"'$TestModulePath$TestModulePathSeparator'" + '+$($env:PSModulePath);' + $command += '$env:PSModulePath = '+"'$TestModulePath$TestModulePathSeparator'" + '+$($env:PSModulePath);' # Windows needs the execution policy adjusted if ($Environment.IsWindows) { - $Command += "Set-ExecutionPolicy -Scope Process Unrestricted; " + $command += "Set-ExecutionPolicy -Scope Process Unrestricted; " } - $Command += "Import-Module '$Pester'; " + $command += "Import-Module '$Pester'; " if ($Unelevate) { $outputBufferFilePath = [System.IO.Path]::GetTempFileName() } - $Command += "Invoke-Pester " + $command += "Invoke-Pester " - $Command += "-OutputFormat ${OutputFormat} -OutputFile ${OutputFile} " + $command += "-OutputFormat ${OutputFormat} -OutputFile ${OutputFile} " if ($ExcludeTag -and ($ExcludeTag -ne "")) { - $Command += "-ExcludeTag @('" + (${ExcludeTag} -join "','") + "') " + $command += "-ExcludeTag @('" + (${ExcludeTag} -join "','") + "') " } if ($Tag) { - $Command += "-Tag @('" + (${Tag} -join "','") + "') " + $command += "-Tag @('" + (${Tag} -join "','") + "') " } # sometimes we need to eliminate Pester output, especially when we're # doing a daily build as the log file is too large if ( $Quiet ) { - $Command += "-Quiet " + $command += "-Quiet " } if ( $PassThru ) { - $Command += "-PassThru " + $command += "-PassThru " } - $Command += "'" + ($Path -join "','") + "'" + $command += "'" + ($Path -join "','") + "'" if ($Unelevate) { - $Command += " *> $outputBufferFilePath; '__UNELEVATED_TESTS_THE_END__' >> $outputBufferFilePath" + $command += " *> $outputBufferFilePath; '__UNELEVATED_TESTS_THE_END__' >> $outputBufferFilePath" } - Write-Verbose $Command + Write-Verbose $command $script:nonewline = $true $script:inerror = $false @@ -1160,39 +1159,39 @@ Restore the module to '$Pester' by running: { if ($PassThru.IsPresent) { - $PassThruFile = [System.IO.Path]::GetTempFileName() + $passThruFile = [System.IO.Path]::GetTempFileName() try { - $Command += "|Export-Clixml -Path '$PassThruFile' -Force" + $command += "|Export-Clixml -Path '$passThruFile' -Force" - $PassThruCommand = {& $powershell -noprofile -c $Command } + $passThruCommand = {& $powershell -noprofile -c $command } if ($Sudo.IsPresent) { - $PassThruCommand = {& sudo $powershell -noprofile -c $Command } + $passThruCommand = {& sudo $powershell -noprofile -c $command } } - $WriteCommand = { Write-Host $_ } + $writeCommand = { Write-Host $_ } if ($Terse) { - $WriteCommand = { Write-Terse $_ } + $writeCommand = { Write-Terse $_ } } - Start-NativeExecution -sb $PassThruCommand | ForEach-Object $WriteCommand - Import-Clixml -Path $PassThruFile | Where-Object {$_.TotalCount -is [Int32]} + Start-NativeExecution -sb $passThruCommand | ForEach-Object $writeCommand + Import-Clixml -Path $passThruFile | Where-Object {$_.TotalCount -is [Int32]} } finally { - Remove-Item $PassThruFile -ErrorAction SilentlyContinue + Remove-Item $passThruFile -ErrorAction SilentlyContinue -Force } } else { if ($Terse) { - Start-NativeExecution -sb {& $powershell -noprofile -c $Command} | ForEach-Object { Write-Terse -line $_ } + Start-NativeExecution -sb {& $powershell -noprofile -c $command} | ForEach-Object { Write-Terse -line $_ } } else { - Start-NativeExecution -sb {& $powershell -noprofile -c $Command} + Start-NativeExecution -sb {& $powershell -noprofile -c $command} } } } From 573d91bc60f53ff64de6af980881145f482edc2c Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Tue, 13 Feb 2018 13:52:25 -0800 Subject: [PATCH 09/13] Deleting stale comment. --- .../Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 | 3 --- 1 file changed, 3 deletions(-) diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 index 0614decfd1f..387bea1bfc8 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Set-Date.Tests.ps1 @@ -1,9 +1,6 @@ # Copyright (c) Microsoft Corporation. All rights reserved. # Licensed under the MIT License. Describe "Set-Date for admin" -Tag @('CI', 'RequireAdminOnWindows', 'RequireSudoOnUnix') { - # Currently, CI tests on Linux/macOS are always run as normal user. So we need to skip these tests on non-Windows platform. - # CI tests in root privilege on Linux/macOS is not supported. - # See : https://github.com/PowerShell/PowerShell/issues/5645 It "Set-Date should be able to set the date in an elevated context" { { Get-Date | Set-Date } | Should Not Throw } From a2db0896fbb7d40111bf49a7603cdbb12cede684 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Wed, 14 Feb 2018 12:13:00 -0800 Subject: [PATCH 10/13] Updating test results files in travis. --- .travis.yml | 3 ++- tools/travis.ps1 | 11 ++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 472f23a807d..679a9e5a7c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,7 +16,8 @@ addons: artifacts: paths: - $(ls powershell*{deb,pkg,AppImage,gz} | tr "\n" ":") - - pester-tests.xml + - ./tools/TestResultsSudo.xml + - ./tools/TestResultsNoSudo.xml install: # Default 2.0.0 Ruby is buggy diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 3f882b10261..3da5ce74c96 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -200,12 +200,16 @@ elseif($Stage -eq 'Build') $ProgressPreference = $originalProgressPreference } + $testResultsNoSudo = "$pwd\TestResultsNoSudo.xml" + $testResultsSudo = "$pwd\TestResultsSudo.xml" + $pesterParam = @{ 'binDir' = $output 'PassThru' = $true 'Terse' = $true 'Tag' = @() 'ExcludeTag' = @('RequireSudoOnUnix') + 'OutputFile' = $testResultsNoSudo } if ($isFullBuild) { @@ -228,18 +232,19 @@ elseif($Stage -eq 'Build') } # Running tests which do not require sudo. - $pesterPassThruNoSudoObject = Start-PSPester @pesterParam + Start-PSPester @pesterParam # Running tests, which require sudo. pesterParam['Tag'] = @('RequireSudoOnUnix') pesterParam['ExcludeTag'] = @() pesterParam['Sudo'] = $true - $pesterPassThruSudoObject = Start-PSPester @pesterParam + pesterParam['OutputFile'] = $testResultsSudo + Start-PSPester @pesterParam # Determine whether the build passed try { # this throws if there was an error - @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | ForEach-Object { Test-PSPesterResults -ResultObject $_ } + @($testResultsNoSudo, $testResultsSudo) | ForEach-Object { Test-PSPesterResults -TestResultsFile $_ } $result = "PASS" } catch { From 08736e360307ed0cf1f9743ece85727acfd26d2b Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Wed, 14 Feb 2018 12:52:27 -0800 Subject: [PATCH 11/13] Correcting paths to test results. --- .travis.yml | 4 ++-- tools/travis.ps1 | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 679a9e5a7c6..b84708f21af 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,8 @@ addons: artifacts: paths: - $(ls powershell*{deb,pkg,AppImage,gz} | tr "\n" ":") - - ./tools/TestResultsSudo.xml - - ./tools/TestResultsNoSudo.xml + - TestResultsSudo.xml + - TestResultsNoSudo.xml install: # Default 2.0.0 Ruby is buggy diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 3da5ce74c96..d4027644a94 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -200,8 +200,8 @@ elseif($Stage -eq 'Build') $ProgressPreference = $originalProgressPreference } - $testResultsNoSudo = "$pwd\TestResultsNoSudo.xml" - $testResultsSudo = "$pwd\TestResultsSudo.xml" + $testResultsNoSudo = "$pwd/TestResultsNoSudo.xml" + $testResultsSudo = "$pwd/TestResultsSudo.xml" $pesterParam = @{ 'binDir' = $output From b328b6235b63badfd52d9c22de11aec45dd269c5 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Wed, 14 Feb 2018 14:46:57 -0800 Subject: [PATCH 12/13] Adding the variable mark --- tools/travis.ps1 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index d4027644a94..4718fe3e98e 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -235,10 +235,10 @@ elseif($Stage -eq 'Build') Start-PSPester @pesterParam # Running tests, which require sudo. - pesterParam['Tag'] = @('RequireSudoOnUnix') - pesterParam['ExcludeTag'] = @() - pesterParam['Sudo'] = $true - pesterParam['OutputFile'] = $testResultsSudo + $pesterParam['Tag'] = @('RequireSudoOnUnix') + $pesterParam['ExcludeTag'] = @() + $pesterParam['Sudo'] = $true + $pesterParam['OutputFile'] = $testResultsSudo Start-PSPester @pesterParam # Determine whether the build passed From dc404aa283a8f1d6ca998184d5e833efe78d8171 Mon Sep 17 00:00:00 2001 From: Klaudia Algiz Date: Thu, 15 Feb 2018 15:37:25 -0800 Subject: [PATCH 13/13] Use pass Thru objects in Test-PSPester results instead of output files --- tools/travis.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/travis.ps1 b/tools/travis.ps1 index 4718fe3e98e..d5bbdf52509 100644 --- a/tools/travis.ps1 +++ b/tools/travis.ps1 @@ -232,19 +232,19 @@ elseif($Stage -eq 'Build') } # Running tests which do not require sudo. - Start-PSPester @pesterParam + $pesterPassThruNoSudoObject = Start-PSPester @pesterParam # Running tests, which require sudo. $pesterParam['Tag'] = @('RequireSudoOnUnix') $pesterParam['ExcludeTag'] = @() $pesterParam['Sudo'] = $true $pesterParam['OutputFile'] = $testResultsSudo - Start-PSPester @pesterParam + $pesterPassThruSudoObject = Start-PSPester @pesterParam # Determine whether the build passed try { # this throws if there was an error - @($testResultsNoSudo, $testResultsSudo) | ForEach-Object { Test-PSPesterResults -TestResultsFile $_ } + @($pesterPassThruNoSudoObject, $pesterPassThruSudoObject) | ForEach-Object { Test-PSPesterResults -ResultObject $_ } $result = "PASS" } catch {