Skip to content

Commit

Permalink
Updating functionaltest.ps1 so it works in VSTS. (#1896)
Browse files Browse the repository at this point in the history
  • Loading branch information
pradipd authored Feb 2, 2017
1 parent a60098d commit 26c6891
Showing 1 changed file with 33 additions and 3 deletions.
36 changes: 33 additions & 3 deletions tests/Run-FunctionalTests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
.PARAMETER PackageRootPath
Path to build share where the TAEF package can be found
.PARAMETER RedirectTAEFErrors
Redirect TAEF errors/failures to stderr. This is used to integrate with VSTS powershell task.
.EXAMPLE
Run-FunctionalTests.ps1 -TAEFDirectory D:\TAEF
Expand Down Expand Up @@ -59,9 +61,13 @@ param(

[string]$TestWorkingDirectory = "",

[string]$PackageRootPath = $null
[string]$PackageRootPath = $null,

[switch]$RedirectTAEFErrors
)

$script:exitCode = 0

if ($NoCopy)
{
if ($TestWorkingDirectory -eq "")
Expand Down Expand Up @@ -176,7 +182,31 @@ function ExecTest($argList)
else
{
$arguments = "$testPath" + "$argList"
Invoke-Expression "$taefPath $arguments"
if ($RedirectTAEFErrors) {
$output = Invoke-Expression "$taefPath $arguments"
$script:exitCode = $LASTEXITCODE
foreach ($o in $output) {

if ($o.StartsWith("Error:") -or $o.Contains("[Failed]")) {

#TAEF does not report exceptions/crashes/failures during test cleanup as test failures.
#However, it will log a message like: "Error: TAEF: [HRESULT 0x8000FFFF] ...."
#We want to detect and mark these as test failures.
$script:exitCode = 1

#Note: Adding ##[error]: is just to make the errors show up as red in VSTS output
#Unfortunately, writing the output to stderr (write-error) creates a lot of noise in powershell.
#And attempting to use Console.WriteError or $host.ui.WriteErrorLine results in lines be displayed out of order.
write-host "##[error]: $o" -foregroundcolor red

} else {
write-host $o
}
}
} else {
Invoke-Expression "$taefPath $arguments"
$script:exitCode = $LASTEXITCODE
}
}
}

Expand Down Expand Up @@ -250,4 +280,4 @@ if($TestFilter -ne [string]$null)

ExecTest($argList)

exit
exit $script:exitCode

0 comments on commit 26c6891

Please sign in to comment.