1. Aaron Jensen
  2. Carbon

Commits

Aaron Jensen  committed 2672494

Fixing Invoke-PowerShell test to run under CCNet.

  • Participants
  • Parent commits 4563f9b
  • Branches default

Comments (0)

Files changed (2)

File Carbon/PowerShell/Invoke-PowerShell.ps1

View file
  • Ignore whitespace
                 $powerShellArgs += '-ExecutionPolicy'
                 $powerShellArgs += $ExecutionPolicy
             }
+            Write-Verbose ('{0} {1} -Command {2} {3}' -f $psPath,($powerShellArgs -join " "),$FilePath,($ArgumentList -join ' '))
             & $psPath $powerShellArgs -Command $FilePath $ArgumentList
+            Write-Verbose ('LASTEXITCODE: {0}' -f $LASTEXITCODE)
         }
     }
     finally

File Test/PowerShell/Test-InvokePowerShell.ps1

View file
  • Ignore whitespace
 function Test-ShouldUseExecutionPolicy
 {
     $Error.Clear()
-    $result = Invoke-PowerShell -FilePath (Join-Path $TestDir Get-PsVersionTable.ps1) -ExecutionPolicy Restricted -ErrorAction SilentlyContinue
-    if( $Host.Name -eq 'ConsoleHost' )
+    $result = Invoke-PowerShell -FilePath (Join-Path $TestDir Get-PsVersionTable.ps1) -ExecutionPolicy Restricted -OutputFormat XML -ErrorAction SilentlyContinue
+    Assert-LastProcessFailed
+    if( $result )
     {
-        Assert-NotNull $result
-        Assert-Like $result[0] '*running scripts is disabled*'
+        Assert-Like $result[0] '*disabled*'
     }
-    else
+    # For some reason, when run under CCNet, $Error doesn't get populated.
+    if( $Error )
     {
-        Assert-Null $result
-        Assert-GreaterThan $Error.Count 0
         Assert-ContainsLike $Error '*disabled*'
     }
 }