<commit_before>package org.orbeon.junit

import java.io.OutputStream
import java.io.PrintStream
import junit.framework.AssertionFailedError
import junit.framework.Test
import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

class LiveResultFormatter extends JUnitResultFormatter {

    private var out = System.out

    def addError(test: Test, error: Throwable): Unit = {
        logResult(test, "ERR")
        out.println(error.getMessage)
    }

    def addFailure(test: Test, failure: AssertionFailedError): Unit = {
        logResult(test, "FAIL")
        out.println(failure.getMessage)
    }

    def endTest(test: Test): Unit = {
        logResult(test, "PASS")
    }

    def startTest(test: Test) = ()
    def endTestSuite(testSuite: JUnitTest) = ()
    def setOutput(out: OutputStream): Unit = this.out = new PrintStream(out)
    def setSystemError(text: String) = ()
    def setSystemOutput(text: String) = ()
    def startTestSuite(testSuite: JUnitTest) = ()

    private def logResult(test: Test, result: String): Unit = {
        out.println("[" + result + "] " + test)
        out.flush()
    }
}
<commit_msg>JUnit to log exception in case of error/failure<commit_after>/**
 * Copyright (C) 2014 Orbeon, Inc.
 *
 * This program is free software; you can redistribute it and/or modify it under the terms of the
 * GNU Lesser General Public License as published by the Free Software Foundation; either version
 * 2.1 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
 * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU Lesser General Public License for more details.
 *
 * The full text of the license is available at http://www.gnu.org/copyleft/lesser.html
 */
package org.orbeon.junit

import java.io.OutputStream
import java.io.PrintStream
import junit.framework.AssertionFailedError
import junit.framework.Test
import org.apache.tools.ant.taskdefs.optional.junit.JUnitResultFormatter
import org.apache.tools.ant.taskdefs.optional.junit.JUnitTest

class LiveResultFormatter extends JUnitResultFormatter {

    private var out = System.out

    def addError(test: Test, error: Throwable): Unit = {
        logResult(test, "FAIL")
        error.printStackTrace(out)
    }

    def addFailure(test: Test, failure: AssertionFailedError): Unit = {
        addError(test, failure)
    }

    def endTest(test: Test): Unit = {
        logResult(test, "PASS")
    }

    def startTest(test: Test) = ()
    def endTestSuite(testSuite: JUnitTest) = ()
    def setOutput(out: OutputStream): Unit = this.out = new PrintStream(out)
    def setSystemError(text: String) = ()
    def setSystemOutput(text: String) = ()
    def startTestSuite(testSuite: JUnitTest) = ()

    private def logResult(test: Test, result: String): Unit = {
        out.println("[" + result + "] " + test)
        out.flush()
    }
}

{'fraction_non_alphanumeric': 0.104296490652673, 'fraction_numerical': 0.0019678583142013774, 'mean_word_length': 3.572713643178411, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '674950', 'n_tokens_mistral': 900, 'n_tokens_neox': 883, 'n_words': 261}