function(add_autopybind11_test name)
  add_test(NAME ${name} COMMAND "${CMAKE_CTEST_COMMAND}"
    --build-and-test
    ${CMAKE_CURRENT_SOURCE_DIR}/${name}
    ${CMAKE_CURRENT_BINARY_DIR}/${name}
    --build-two-config
    --build-run-dir ${CMAKE_CURRENT_BINARY_DIR}/${name}
    --build-generator ${CMAKE_GENERATOR}
    --build-project ${name}
    --build-options "-DPYBIND11_SRC_DIR=${pybind11_SOURCE_DIR}"
    "-DAutoPyBind11_DIR=${AutoPyBind11_DIR}"
    "-DCastXML_EXECUTABLE=${CastXML_EXECUTABLE}"
    "-DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}"
    --test-command ${PYTHON_EXECUTABLE}
    ${CMAKE_CURRENT_SOURCE_DIR}/${name}/${name}.py
    )
  set_tests_properties(${name} PROPERTIES
    ENVIRONMENT PYTHONPATH=${CMAKE_CURRENT_BINARY_DIR}/${name})

endfunction()

function(add_autopybind11_failing_test name)
  add_autopybind11_test(${name})
  set_tests_properties(${name} PROPERTIES WILL_FAIL TRUE)
endfunction(add_autopybind11_failing_test)

add_autopybind11_test(simple)
add_autopybind11_test(missing_classes)
add_autopybind11_test(complex_trampoline)
add_autopybind11_test(interface_library)
add_autopybind11_test(gen_only)
add_autopybind11_test(multi_module)
add_autopybind11_test(multi_namespace)
add_autopybind11_test(multi_target)
add_autopybind11_test(inheritance_features)
add_autopybind11_test(operators)
add_autopybind11_test(custom_names)
add_autopybind11_test(skip_structure)
add_autopybind11_test(nested_enum)
add_autopybind11_test(argument_casting)
add_autopybind11_test(deleted_constructor)
add_autopybind11_test(module_local)
add_autopybind11_test(blacklist)
add_autopybind11_test(custom_namespaces)
add_autopybind11_test(extra_includes)
add_autopybind11_failing_test(extra_includes/expect_failure)
add_subdirectory(code_generation_regression)
