<commit_before>
MITK_CREATE_MODULE_TESTS(LABELS MITK-Core)


include(mitkFunctionAddTestLabel)

# verify minimum expectations:
#   files are recognized as DICOM
#   loading files results in a given number of images
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_NoFiles mitkDICOMTestingSanityTest 0)
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_CTImage mitkDICOMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-ct.dcm)
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_MRImage mitkDICOMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-mr.dcm)
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_SCImage mitkDICOMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-sc.dcm)

set(VERIFY_DUMP_CMD  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/VerifyDICOMMitkImageDump)

set(CT_ABDOMEN_DIR ${MITK_DATA_DIR}/TinyCTAbdomen)

# these variables could be passed as parameters to a generic test creation function
set(CURRENT_DATASET_DIR ${CT_ABDOMEN_DIR})
set(TESTS_DIR Tests)
set(INPUT_LISTNAME input)
set(EXPECTED_DUMP expected.dump)

file(GLOB_RECURSE allInputs ${CURRENT_DATASET_DIR}/${TESTS_DIR}/*/${INPUT_LISTNAME})

function(expectFileExists filename)
  if (NOT EXISTS ${filename})
    message(SEND_ERROR "Test case expected file ${filename} which does not exist! Please fix your CMake code or file layout.")
  endif (NOT EXISTS ${filename})
endfunction(expectFileExists)

foreach(input ${allInputs})
  string(REGEX REPLACE ".*${TESTS_DIR}/([^/]+)/.*" "\\1" input ${input})
  set(inputfilelist "${CURRENT_DATASET_DIR}/${TESTS_DIR}/${input}/${INPUT_LISTNAME}")
  set(expecteddump "${CURRENT_DATASET_DIR}/${TESTS_DIR}/${input}/${EXPECTED_DUMP}")
  set(testname "DICOM_Load_${input}")

  message(STATUS "DICOM loading test case '${input}'")
  expectFileExists(${inputfilelist})
  expectFileExists(${expecteddump})

  # TODO provide error messages if input not valid

  set(dicomFiles) # clear list
  file(STRINGS ${inputfilelist} rawDicomFiles)
  foreach(raw ${rawDicomFiles})
    set(fileWithFullPath ${CURRENT_DATASET_DIR}/${raw})
    list(APPEND dicomFiles ${fileWithFullPath})
  endforeach(raw ${rawDicomFiles})

  #message(STATUS "  Load ${dicomFiles}")

  add_test(NAME ${testname}
           COMMAND ${VERIFY_DUMP_CMD} ${expecteddump} ${dicomFiles})
  mitkFunctionAddTestLabel(${testname}) #not yet in branch

endforeach(input allInputs)


<commit_msg>Use differnt add_test syntax (other one would not work with Windows immediately)<commit_after>
MITK_CREATE_MODULE_TESTS(LABELS MITK-Core)


include(mitkFunctionAddTestLabel)

# verify minimum expectations:
#   files are recognized as DICOM
#   loading files results in a given number of images
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_NoFiles mitkDICOMTestingSanityTest 0)
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_CTImage mitkDICOMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-ct.dcm)
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_MRImage mitkDICOMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-mr.dcm)
mitkAddCustomModuleTest(mitkDICOMTestingSanityTest_SCImage mitkDICOMTestingSanityTest 1 ${MITK_DATA_DIR}/spacing-ok-sc.dcm)

set(VERIFY_DUMP_CMD  ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/VerifyDICOMMitkImageDump)

set(CT_ABDOMEN_DIR ${MITK_DATA_DIR}/TinyCTAbdomen)

# these variables could be passed as parameters to a generic test creation function
set(CURRENT_DATASET_DIR ${CT_ABDOMEN_DIR})
set(TESTS_DIR Tests)
set(INPUT_LISTNAME input)
set(EXPECTED_DUMP expected.dump)

file(GLOB_RECURSE allInputs ${CURRENT_DATASET_DIR}/${TESTS_DIR}/*/${INPUT_LISTNAME})

function(expectFileExists filename)
  if (NOT EXISTS ${filename})
    message(SEND_ERROR "Test case expected file ${filename} which does not exist! Please fix your CMake code or file layout.")
  endif (NOT EXISTS ${filename})
endfunction(expectFileExists)

foreach(input ${allInputs})
  string(REGEX REPLACE ".*${TESTS_DIR}/([^/]+)/.*" "\\1" input ${input})
  set(inputfilelist "${CURRENT_DATASET_DIR}/${TESTS_DIR}/${input}/${INPUT_LISTNAME}")
  set(expecteddump "${CURRENT_DATASET_DIR}/${TESTS_DIR}/${input}/${EXPECTED_DUMP}")
  set(testname "DICOM_Load_${input}")

  message(STATUS "DICOM loading test case '${input}'")
  expectFileExists(${inputfilelist})
  expectFileExists(${expecteddump})

  # TODO provide error messages if input not valid

  set(dicomFiles) # clear list
  file(STRINGS ${inputfilelist} rawDicomFiles)
  foreach(raw ${rawDicomFiles})
    set(fileWithFullPath ${CURRENT_DATASET_DIR}/${raw})
    list(APPEND dicomFiles ${fileWithFullPath})
  endforeach(raw ${rawDicomFiles})

  #message(STATUS "  Load ${dicomFiles}")
  add_test(${testname}
           ${VERIFY_DUMP_CMD} ${expecteddump} ${dicomFiles})
  mitkFunctionAddTestLabel(${testname})

endforeach(input allInputs)



{'fraction_non_alphanumeric': 0.1115580016934801, 'fraction_numerical': 0.0021168501270110076, 'mean_word_length': 7.513513513513513, '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': '1786116', 'n_tokens_mistral': 1637, 'n_tokens_neox': 1626, 'n_words': 313}