JetBrains / meta-runner-power-pack

A set of Meta-runners for TeamCity
Apache License 2.0
257 stars 125 forks source link

Test failures still running subsequent build steps #80

Open slaneyrw opened 8 years ago

slaneyrw commented 8 years ago

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'

wwwlicious commented 8 years ago

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

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

slaneyrw commented 8 years ago

The devops guy says it's running version 4.0

> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
4      0      -1     -1 
brettveenstra commented 7 years ago

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 commented 6 years ago

@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.