<commit_before>package com.wixpress.guineapig.drivers

import java.util.concurrent.atomic.AtomicBoolean
import com.wixpress.guineapig.embeddedjetty.WebUiServer
import com.wixpress.guineapig.util.ITEmbeddedMysql
import com.wixpress.petri.experiments.jackson.ObjectMapperFactory
import org.specs2.mutable.{Before, SpecificationWithJUnit}

import scala.sys.ShutdownHookThread

trait SpecificationWithEnvSupport extends SpecificationWithJUnit with Before {

  final val httpDriver = new HttpDriver
  final val om = ObjectMapperFactory.makeObjectMapper

  override def before: Any = {
    GlobalEnv.ensureStarted()

    ShutdownHookThread({
      GlobalEnv.ensureStop()
    })
  }
}

object GlobalEnv {
  private final val started = new AtomicBoolean(false)
  private final val embeddedMySql: ITEmbeddedMysql = new ITEmbeddedMysql(3316)
  private final val server = WebUiServer()

  def ensureStarted() = {
    if (!started.get()) {
      started.compareAndSet(false, true)

      embeddedMySql.start()
      server.start()
    }
  }

  def ensureStop(): Unit = {
    if (started.get()) {
      embeddedMySql.stop()
      server.stop()

      started.compareAndSet(true, false)
    }

  }
}

object MainTest {
  def main(args: Array[String]) {
    GlobalEnv.ensureStarted()
  }
}<commit_msg>Remove MainTest object<commit_after>package com.wixpress.guineapig.drivers

import java.util.concurrent.atomic.AtomicBoolean
import com.wixpress.guineapig.embeddedjetty.WebUiServer
import com.wixpress.guineapig.util.ITEmbeddedMysql
import com.wixpress.petri.experiments.jackson.ObjectMapperFactory
import org.specs2.mutable.{Before, SpecificationWithJUnit}

import scala.sys.ShutdownHookThread

trait SpecificationWithEnvSupport extends SpecificationWithJUnit with Before {

  final val httpDriver = new HttpDriver
  final val om = ObjectMapperFactory.makeObjectMapper

  override def before: Any = {
    GlobalEnv.ensureStarted()

    ShutdownHookThread({
      GlobalEnv.ensureStop()
    })
  }
}

object GlobalEnv {
  private final val started = new AtomicBoolean(false)
  private final val embeddedMySql: ITEmbeddedMysql = new ITEmbeddedMysql(3316)
  private final val server = WebUiServer()

  def ensureStarted() = {
    if (!started.get()) {
      started.compareAndSet(false, true)

      embeddedMySql.start()
      server.start()
    }
  }

  def ensureStop(): Unit = {
    if (started.get()) {
      embeddedMySql.stop()
      server.stop()

      started.compareAndSet(true, false)
    }

  }
}
{'fraction_non_alphanumeric': 0.09149277688603531, 'fraction_numerical': 0.0040128410914927765, 'mean_word_length': 4.036363636363636, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3321548', 'n_tokens_mistral': 812, 'n_tokens_neox': 782, 'n_words': 156}