<commit_before>package au.com.ps4impact.madcow.report

import groovy.text.GStringTemplateEngine
import au.com.ps4impact.madcow.util.ResourceFinder
import au.com.ps4impact.madcow.MadcowProject
import org.apache.commons.lang3.StringUtils
import au.com.ps4impact.madcow.MadcowTestCase

/**
 * JUnit specific Test Case Report
 */
class JUnitTestCaseReport extends MadcowTestCaseReport {

    protected static final String JUNIT_RESULTS_DIRECTORY = MadcowProject.RESULTS_DIRECTORY + "/junit-results";

    public static void prepareResultsDirectory() {

        if (new File(JUNIT_RESULTS_DIRECTORY).exists())
            new File(JUNIT_RESULTS_DIRECTORY).delete();

        new File(JUNIT_RESULTS_DIRECTORY).mkdir();
    }

    /**
     * Create the result files.
     */
    public static void createTestCaseResult(MadcowTestCase testCase) {

        def binding = [ 'errorCount'   : '0',
                        'failureCount' : testCase.lastExecutedStep.result.failed() ? '1' : '0',
                        'hostname'     : InetAddress.localHost.hostName,
                        'testName'     : testCase.name,
                        'time'         : (testCase.endTime.time - testCase.startTime.time) / (1000 * 60 * 60),
                        'timestamp'    : testCase.endTime.format("yyyy-MM-dd'T'HH:mm:ss"),
        ];

        def engine = new GStringTemplateEngine();
        def template = engine.createTemplate(ResourceFinder.locateResourceOnClasspath(testCase.class.classLoader, 'result-junit.gtemplate').URL).make(binding);

        String templateContents = template.toString();
        def result = new File(JUNIT_RESULTS_DIRECTORY + "/TEST-${StringUtils.replace(testCase.name, '/', '_')}.xml");
        result << templateContents;
    }
}<commit_msg>Time in seconds…<commit_after>package au.com.ps4impact.madcow.report

import groovy.text.GStringTemplateEngine
import au.com.ps4impact.madcow.util.ResourceFinder
import au.com.ps4impact.madcow.MadcowProject
import org.apache.commons.lang3.StringUtils
import au.com.ps4impact.madcow.MadcowTestCase
import java.text.DecimalFormat

/**
 * JUnit specific Test Case Report
 */
class JUnitTestCaseReport extends MadcowTestCaseReport {

    protected static final String JUNIT_RESULTS_DIRECTORY = MadcowProject.RESULTS_DIRECTORY + "/junit-results";
    protected static final DecimalFormat TIME_SECONDS_FORMAT = new DecimalFormat("#.###");

    public static void prepareResultsDirectory() {

        if (new File(JUNIT_RESULTS_DIRECTORY).exists())
            new File(JUNIT_RESULTS_DIRECTORY).delete();

        new File(JUNIT_RESULTS_DIRECTORY).mkdir();
    }

    /**
     * Create the result files.
     */
    public static void createTestCaseResult(MadcowTestCase testCase) {

        def binding = [ 'errorCount'   : '0',
                        'failureCount' : testCase.lastExecutedStep.result.failed() ? '1' : '0',
                        'hostname'     : InetAddress.localHost.hostName,
                        'testName'     : testCase.name,
                        'time'         : TIME_SECONDS_FORMAT.format((testCase.endTime.time - testCase.startTime.time) / (1000 * 60)),
                        'timestamp'    : testCase.endTime.format("yyyy-MM-dd'T'HH:mm:ss"),
        ];

        def engine = new GStringTemplateEngine();
        def template = engine.createTemplate(ResourceFinder.locateResourceOnClasspath(testCase.class.classLoader, 'result-junit.gtemplate').URL).make(binding);

        String templateContents = template.toString();
        def result = new File(JUNIT_RESULTS_DIRECTORY + "/TEST-${StringUtils.replace(testCase.name, '/', '_')}.xml");
        result << templateContents;
    }
}
{'fraction_non_alphanumeric': 0.11262241566920565, 'fraction_numerical': 0.008161044613710556, 'mean_word_length': 2.932620320855615, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '3024838', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1041, 'n_words': 184}