# This is a list of test XML files.
# When you add an entry **be sure to describe the actions a user
# must perform to reproduce the test** as it can be painful to
# read the XML when a test needs to be re-recorded.
# **It is also useful to tersely describe what functionality is
# being tested if not clear from the procedural description and
# test name.**
set(xml_tests_with_baselines
)

set(xml_tests_no_baselines
)

if (aeva_data_dir AND EXISTS "${aeva_data_dir}")
  list(APPEND xml_tests_with_baselines
    # Just impoort a MED file and ensure it renders properly.
    OpenModelFile
    # Run the normal-vector feature operation and convert the
    # selection into a surface cell.
    NormalFeature
  )
endif()

set(_image_fail_regex "(\n|^)ERROR: The following event FAILED")

set(test_images ${aeva_SOURCE_DIR}/data/baselines/aeva)
if (aeva_data_dir AND aeva_test_data_dir)
  foreach(test ${xml_tests_with_baselines})
    #get_image_threshold_arg(THRESHOLD_CMD ${test})
    set(tname "${test}")
    add_test(
      NAME ${tname}
      COMMAND aeva
        -dr
        --data-directory=${aeva_test_data_dir}
        --test-script=${CMAKE_CURRENT_SOURCE_DIR}/${test}.xml
        --test-directory=${aeva_test_dir}
        --test-baseline=${test_images}/${test}.png
        --exit
    )
    set(tlabels aeva aeva ${${test}-labels})
    set_tests_properties(${tname}
      PROPERTIES
        LABELS "${tlabels}"
    )
    # if a plugins file was created, use it
    if (${plugins_file})
      set_tests_properties(${tname}
        PROPERTIES
          ENVIRONMENT "PV_PLUGIN_CONFIG_FILE=${plugins_file}"
      )
    endif()
  endforeach()
  foreach(test ${xml_tests_no_baselines})
    #get_image_threshold_arg(THRESHOLD_CMD ${test})
    set(tname "${test}")
    add_test(
      NAME ${tname}
      COMMAND aeva
        -dr
        --data-directory=${cmb_test_data_dir}
        --test-script=${CMAKE_CURRENT_SOURCE_DIR}/${test}.xml
        --test-directory=${cmb_test_dir}
        --exit
    )
    set(tlabels aeva ${${test}-labels})
    set(plug_cfg "")
    # if a plugins file was created, use it
    if (${plugins_file})
      set(plug_cfg "PV_PLUGIN_CONFIG_FILE=${plugins_file}")
    endif()
    set_tests_properties(${tname}
      PROPERTIES
        LABELS "${tlabels}"
        FAIL_REGULAR_EXPRESSION "${_image_fail_regex}"
        ENVIRONMENT
          "PARAVIEW_TEST_BASELINE_DIR=${test_images} ${plug_cfg}"
    )
  endforeach()
endif()
