Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updating functionaltest.ps1 so it works in VSTS. #1896

Merged
merged 1 commit into from
Feb 2, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Copy link
Contributor Author

@pradipd pradipd Feb 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bbowman just be able to take this and add it to his pull request so we can have the UT's running TAEF as well.

}
}

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

ExecTest($argList)

exit
exit $script:exitCode