Commits

Aaron Jensen committed 2672494

Fixing Invoke-PowerShell test to run under CCNet.

Comments (0)

Files changed (2)

Carbon/PowerShell/Invoke-PowerShell.ps1

                 $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

Test/PowerShell/Test-InvokePowerShell.ps1

 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*'
     }
 }