<commit_before>include(junit.cmake)

set(JUNIT_VERSION "4.12")
set(HAMCREST_VERSION "1.3")

set(OMNICX2X_JAR1 ${PROJECT_BINARY_DIR}/build/${OMNI_CX2X_CLAW_NAME}.jar)
set(OMNICX2X_JAR2 ${PROJECT_BINARY_DIR}/build/${OMNI_CX2X_XCODEML_NAME}.jar)
# TODO detect jar and do not build if not present (use find_jar)
set(JUNIT_JAR /usr/local/lib/junit-${JUNIT_VERSION}.jar)
set(HAMCREST_JAR /usr/local/lib/hamcrest-core-${HAMCREST_VERSION}.jar)

if(NOT EXISTS ${JUNIT_JAR})
  message( FATAL_ERROR "JUnit jar is not present (${JUNIT_JAR}). CMake will exit." )
endif()

if(NOT EXISTS ${HAMCREST_JAR})
  message( FATAL_ERROR "Hamcrest jar is not present (${HAMCREST_JAR}). CMake will exit." )
endif()

set(CMAKE_JAVA_INCLUDE_PATH
  ${OMNICX2X_JAR1}
  ${OMNICX2X_JAR2}
  ${JUNIT_JAR}
  ${HAMCREST_JAR}
)

add_jar(omni-cx2x-unittest

  helper/XmlHelper.java
  pragma/ClawPragmaTest.java
  xelement/XcodeProgTest.java
  xelement/XbasicTypeTest.java
  xelement/XexprModelTest.java
  xelement/XidTest.java
  xelement/XsymbolsTest.java
  xelement/XfctTypeTest.java
  xelement/XvarRefTest.java
  xelement/XvarTest.java

  OUTPUT_DIR ${PROJECT_BINARY_DIR}/build
)

get_target_property(UNITTEST_JAR omni-cx2x-unittest JAR_FILE)

# Add unit test classes

add_junit_test(xelement
   CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} ${UNITTEST_JAR}
   TESTS
   xelement.XidTest xelement.XvarTest xelement.XcodeProgTest
   xelement.XexprModelTest xelement.XvarRefTest xelement.XbasicTypeTest
   xelement.XfctTypeTest xelement.XsymbolsTest
)

add_junit_test(pragma
   CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} ${UNITTEST_JAR}
   TESTS pragma.ClawPragmaTest
)<commit_msg>Do not compile unit tests if Junit or hamcrest not present<commit_after>include(junit.cmake)

set(JUNIT_VERSION "4.12")
set(HAMCREST_VERSION "1.3")

set(OMNICX2X_JAR1 ${PROJECT_BINARY_DIR}/build/${OMNI_CX2X_CLAW_NAME}.jar)
set(OMNICX2X_JAR2 ${PROJECT_BINARY_DIR}/build/${OMNI_CX2X_XCODEML_NAME}.jar)
# TODO detect jar and do not build if not present (use find_jar)
set(JUNIT_JAR /usr/local/lib/junit-${JUNIT_VERSION}.jar)
set(HAMCREST_JAR /usr/local/lib/hamcrest-core-${HAMCREST_VERSION}.jar)



if(NOT EXISTS ${JUNIT_JAR} OR NOT EXISTS ${HAMCREST_JAR})
  message( FATAL_ERROR "JUnit jar or Hamcrest is not present. Unit test will not be build." )
else()

  set(CMAKE_JAVA_INCLUDE_PATH
    ${OMNICX2X_JAR1}
    ${OMNICX2X_JAR2}
    ${JUNIT_JAR}
    ${HAMCREST_JAR}
  )

  add_jar(omni-cx2x-unittest

    helper/XmlHelper.java
    pragma/ClawPragmaTest.java
    xelement/XcodeProgTest.java
    xelement/XbasicTypeTest.java
    xelement/XexprModelTest.java
    xelement/XidTest.java
    xelement/XsymbolsTest.java
    xelement/XfctTypeTest.java
    xelement/XvarRefTest.java
    xelement/XvarTest.java

    OUTPUT_DIR ${PROJECT_BINARY_DIR}/build
  )

  get_target_property(UNITTEST_JAR omni-cx2x-unittest JAR_FILE)

  # Add unit test classes

  add_junit_test(xelement
     CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} ${UNITTEST_JAR}
     TESTS
     xelement.XidTest xelement.XvarTest xelement.XcodeProgTest
     xelement.XexprModelTest xelement.XvarRefTest xelement.XbasicTypeTest
     xelement.XfctTypeTest xelement.XsymbolsTest
  )

  add_junit_test(pragma
     CLASSPATH ${CMAKE_JAVA_INCLUDE_PATH} ${UNITTEST_JAR}
     TESTS pragma.ClawPragmaTest
  )

endif()
{'fraction_non_alphanumeric': 0.09935995123437977, 'fraction_numerical': 0.010362694300518135, 'mean_word_length': 5.169172932330827, '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': '502173', 'n_tokens_mistral': 1389, 'n_tokens_neox': 1329, 'n_words': 202}