#!/bin/bash

set -e

declare -a DISABLED_TESTS
DISABLED_TESTS=(
  # test_vmtkbifurcationsections.py: these tests segfault on amd64
  "test_expected_cell_data_keys_present"
  "test_number_expected_cell_data_keys"
  "test_number_expected_point_data_keys"
  "test_expected_number_points_with_one_sphere"
  "test_expected_number_points_with_two_spheres"
  "test_bifurcation_section_group_ids_correct"
  "test_bifurcation_section_bifurcation_group_ids_correct"
  "test_bifurcation_section_point_correct"
  "test_bifurcation_section_normal_correct"
  "test_bifurcation_section_area_correct"
  "test_bifurcation_section_min_size_correct"
  "test_bifurcation_section_max_size_correct"
  "test_bifurcation_section_shape_correct"
  "test_bifurcation_section_closed_correct"
  "test_bifurcation_section_orientation_correct"
  "test_bifurcation_section_distance_to_spheres_correct"
  "test_number_of_points_per_cell"
  "test_cell_data_pointId_start_indices"
  "test_cell_data_pointId_end_indices"
  "test_cell_data_point_start_and_end_xyz_locations"

  # test_vmtkbranchgeometry.py: these tests fail due to precision issues on amd64
  "test_point_data_is_correct"

  # test_vmtkbranchsections.py: these tests segfault on amd64
  "test_number_of_cells_one_sphere"
  "test_number_of_cells_two_sphere"
  "test_branch_section_group_ids_correct"
  "test_branch_section_area_correct"
  "test_branch_section_min_size_correct"
  "test_branch_section_max_size_correct"
  "test_branch_section_shape_correct"
  "test_branch_section_closed_correct"
  "test_branch_section_distance_to_spheres_correct"
  "test_cell_data_pointId_start_indices_one_sphere"
  "test_cell_data_pointId_start_indices_two_sphere"
  "test_cell_data_pointId_end_indices_one_sphere"
  "test_cell_data_pointId_end_indices_two_spheres"
  "test_cell_data_point_start_and_end_xyz_locations_one_sphere"
  "test_cell_data_point_start_and_end_xyz_locations_two_spheres"

  # test_vmtkcenterlines.py: these tests fail due to precision issues on amd64
  "test_idlist_centerlines"

  # test_vmtkcenterlinesnetwork.py: these tests fail due to TypeError: PolyData.__init__() takes 1 positional argument but 2 were given
  "test_centerline_extraction_surface_with_no_hole"

  # test_vmtkimagesmoother.py: these tests segfault on amd64
  "test_anisotropic_smoothing_default_params"
  "test_anisotropic_smoother_varied_params"

  # test_vmtksurfacebooleanoperation.py: these tests fail due to precision issues on amd64
  "test_operations_default_tolerance_regression"

  # test_vmtksurfacenormals.py: these tests fail due to precision issues on amd64
  "test_default_params"
  "test_no_autoorient_normals"
  "test_no_consistency"

  # test_vmtksurfacesmoothing.py: these tests fail due to precision issues on amd64
  "test_taubin"
  "test_taubin_change_passband"

  # test_vmtksurfaceremeshing.py: these tests segfault on amd64
  "test_size_modes_with_default_params"
  "test_change_target_area"
  "test_change_target_area_factor"
  "test_change_triangle_split_factor"
  "test_change_max_area"
  "test_change_min_area"
  "test_change_number_connectivity_iterations"
  "test_change_relaxation_factor"
  "test_change_min_area_factor"
  "test_change_aspect_ratio_threshold"
)

DISABLED_TESTS_SEPARATOR=" or "
DISABLED_TESTS_STRING=$(printf "${DISABLED_TESTS_SEPARATOR}%s" "${DISABLED_TESTS[@]}")
DISABLED_TESTS_STRING=${DISABLED_TESTS_STRING:${#DISABLED_TESTS_SEPARATOR}}

pytest -vv -k "not (${DISABLED_TESTS_STRING})" tests
