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

Test failures still running subsequent build steps #80

Open
slaneyrw opened this issue May 26, 2016 · 4 comments
Open

Test failures still running subsequent build steps #80

slaneyrw opened this issue May 26, 2016 · 4 comments

Comments

@slaneyrw
Copy link

slaneyrw commented May 26, 2016

When an xunit test fails the step is still reported as failed ( ie in red ) but subsequent tasks still execute even though the execute step are all set to "If all previous steps finished successfully"

The xUnit.net console running is returning exit code '1'

TeamCity server version is 9.1.6 (build 37459)

[Step 1/1] dotCoverArgs: cover coverage_settings.xml /LogFile=dotCoverXunitLog.txt /ReturnTargetExitCode
[Step 1/1] JetBrains dotCover Console Runner 10.0.2. Build 104.0.20151218.125453
[Step 1/1] xUnit.net Console Runner (64-bit .NET 4.0.30319.42000)

...

[Step 1/1] [JetBrains dotCover] Analysed application exited with code '1'

@slaneyrw slaneyrw changed the title Test failures not failing build step Test failures still running subsequent build steps May 26, 2016
@wwwlicious
Copy link
Contributor

wwwlicious commented May 27, 2016

Odd, the fact it returns an non-zero error code (1 in this case) should tell TC that the step failed.

Can you confirm what version of Powershell is running on the agent?
Reason I ask is:

There is an issue with PowerShell 2.0 not returning the correct exit code when the script contains explicitly defined parameters. As a workaround, either upgrade your PowerShell or to use
[[Environment]]::Exit(code)

Could you try and change the return code to [Environment]::Exit(code) to see if it fixes your issue?

@slaneyrw
Copy link
Author

slaneyrw commented May 30, 2016

The devops guy says it's running version 4.0

> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1 

@brettveenstra
Copy link

brettveenstra commented Apr 28, 2017

Was able to modify script to refer to $LASTEXITCODE so errors are reported and stop build

workaround snippet

  iex $command
  ## Evaulate Win32 exit code to pickup xunit runner failures (otherwise invoke-expression always is successful)
  Write-Host "##teamcity[message text='xunit runner exit code (Win32): $LASTEXITCODE']"
  if ($LASTEXITCODE -ne 0)
  {
    Write-Host "##teamcity[buildStatus text='$_' status='FAILURE']"
    Write-Host "##teamcity[message text='xunit runner reported exitcode: $LASTEXITCODE' status='ERROR']"

    exit $LASTEXITCODE
  }

@zlamma
Copy link

zlamma commented Mar 22, 2018

@brettveenstra definitely useful. Just one note that above should be applied to every usage of iex in that file.

We just had failures on the nuget command in the beginning of the file and that produced a false positive for all tests.

As there are quite a few iex usages in there, would be best to make it a subroutine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants