JetBrains / sbt-tc-logger

SBT plugin generates TeamCity service messages to be used by SBT runner
Apache License 2.0
10 stars 12 forks source link

Failed tests in sbt return a success #9

Open rich-nguyen opened 8 years ago

rich-nguyen commented 8 years ago

I wrote a small sbt task that takes the result of the test task and checks for incomplete, something like this:

myTask := Def.task( {
    (test in Test).result.value match {
        case Inc(inc) =>{
            println("Tests Failed")
            throw inc
        }
        case Value(v) => {
            println("Tests Passed.")
        }
    }
} ).value

In team city, if I ssh on to an agent and run this sbt task manually, the result is "Tests Failed". But if i run the same task through the team city runner, I get "Tests Passed".

jamespamplin commented 8 years ago

Generally for this, we need the test task to fail (with an exception), which should correct @rich-nguyen's problem above, and a related of problem of mine, which is we need the sbt test command to fail with a exit code of 1, to fail the build in teamcity (we run it as part of a shell script).

I've found that the plugin explicitly disables failing the test task with an exception by overwriting the testResultLogger in the test task in 6c39634d256b681fea03bbd1ab3fe0dad34da0b2. Why is this explicitly disabled? /cc @shkate

As a workaround, I've found that setting the testResultLogger back to the default, causes the test task to fail as expected:

testResultLogger in (Test, test) := TestResultLogger.Default