<commit_before>package io.kotlintest.runner.junit5

import io.kotlintest.TestCase
import io.kotlintest.TestCaseConfig
import io.kotlintest.TestResult
import io.kotlintest.TestStatus
import org.junit.runners.model.TestTimedOutException
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

/**
 * Runs a [TestCase] returning a [TestResult] describing
 * the outcome of the test.
 *
 * Will run the test multiple times on one or more thread,
 * as controlled by the [TestCaseConfig]
 */
object TestCaseRunner {

  fun runTest(testCase: TestCase): TestResult {

    val executor = Executors.newFixedThreadPool(testCase.config.threads)

    return if (testCase.isActive()) {

      val context = TestCaseContext(testCase)

      val errors = mutableListOf<Throwable>()
      for (j in 1..testCase.config.invocations) {
        executor.execute {
          try {
            testCase.test(context)
            val result = context.future().get()
            if (result != null)
              errors.add(result)
          } catch (t: Throwable) {
            errors.add(t)
          }
        }
      }

      executor.shutdown()
      val timeout = testCase.config.timeout
      val terminated = executor.awaitTermination(timeout.seconds, TimeUnit.SECONDS)

      if (!terminated) {
        TestResult(TestStatus.Error, TestTimedOutException(timeout.seconds, TimeUnit.SECONDS), context.metaData())
      } else if (errors.isEmpty()) {
        TestResult(TestStatus.Success, null, context.metaData())
      } else {
        TestResult(TestStatus.Failure, errors.firstOrNull(), context.metaData())
      }

    } else {
      TestResult(TestStatus.Ignored, null)
    }
  }
}<commit_msg>Updated test runner to handle error vs failure<commit_after>package io.kotlintest.runner.junit5

import io.kotlintest.TestCase
import io.kotlintest.TestCaseConfig
import io.kotlintest.TestResult
import io.kotlintest.TestStatus
import org.junit.runners.model.TestTimedOutException
import java.util.concurrent.Executors
import java.util.concurrent.TimeUnit

/**
 * Runs a [TestCase] returning a [TestResult] describing
 * the outcome of the test.
 *
 * Will run the test multiple times on one or more thread,
 * as controlled by the [TestCaseConfig]
 */
object TestCaseRunner {

  fun runTest(testCase: TestCase): TestResult {

    val executor = Executors.newFixedThreadPool(testCase.config.threads)

    return if (testCase.isActive()) {

      val context = TestCaseContext(testCase)

      val errors = mutableListOf<Throwable>()
      for (j in 1..testCase.config.invocations) {
        executor.execute {
          try {
            testCase.test(context)
            val result = context.future().get()
            if (result != null)
              errors.add(result)
          } catch (t: Throwable) {
            errors.add(t)
          }
        }
      }

      executor.shutdown()
      val timeout = testCase.config.timeout
      val terminated = executor.awaitTermination(timeout.seconds, TimeUnit.SECONDS)

      if (!terminated) {
        TestResult(TestStatus.Error, TestTimedOutException(timeout.seconds, TimeUnit.SECONDS), context.metaData())
      } else {
        val first = errors.firstOrNull()
        when (first) {
          null -> TestResult(TestStatus.Success, null, context.metaData())
          is AssertionError -> TestResult(TestStatus.Failure, first, context.metaData())
          else -> TestResult(TestStatus.Error, first, context.metaData())
        }
      }
    } else {
      TestResult(TestStatus.Ignored, null)
    }
  }
}
{'fraction_non_alphanumeric': 0.10103845074375527, 'fraction_numerical': 0.001122649452708392, 'mean_word_length': 2.832258064516129, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3639454', 'n_tokens_mistral': 1041, 'n_tokens_neox': 1010, 'n_words': 230}