def expect_cpp_code_compile_error_helper(check_error_fun, tmppy_source, module_ir2, module_ir1, cxx_source):
    source_file_name = _create_temporary_file(cxx_source, file_name_suffix='.cpp')
    try:
        compiler.compile_discarding_output(source=source_file_name, include_dirs=[config.MPYL_INCLUDE_DIR], args=[])
        pytest.fail(textwrap.dedent('            The test should have failed to compile, but it compiled successfully.\n            \n            TMPPy source:\n            {tmppy_source}\n\n            TMPPy IR2:\n            {tmppy_ir2}\n            \n            TMPPy IR1:\n            {tmppy_ir1}\n            \n            C++ source code:\n            {cxx_source}\n            ').format(tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1), cxx_source=add_line_numbers(cxx_source)), pytrace=False)
    except CompilationFailedException as e1:
        e = e1
    error_message = e.error_message
    error_message_lines = error_message.splitlines()
    normalized_error_message = error_message.replace(' ', '').replace('std::__1::', 'std::')
    normalized_error_message_lines = normalized_error_message.splitlines()
    error_message_head = _cap_to_lines(error_message, 40)
    check_error_fun(e, error_message_lines, error_message_head, normalized_error_message_lines)
    try_remove_temporary_file(source_file_name)
def expect_cpp_code_compile_error_helper(check_error_fun, tmppy_source, module_ir2, module_ir1, cxx_source):
    source_file_name = _create_temporary_file(cxx_source, file_name_suffix='.cpp')
    try:
        compiler.compile_discarding_output(source=source_file_name, include_dirs=[config.MPYL_INCLUDE_DIR], args=[])
        pytest.fail(textwrap.dedent('            The test should have failed to compile, but it compiled successfully.\n            \n            TMPPy source:\n            {tmppy_source}\n\n            TMPPy IR2:\n            {tmppy_ir2}\n            \n            TMPPy IR1:\n            {tmppy_ir1}\n            \n            C++ source code:\n            {cxx_source}\n            ').format(tmppy_source=add_line_numbers(tmppy_source), tmppy_ir2=str(module_ir2), tmppy_ir1=str(module_ir1), cxx_source=add_line_numbers(cxx_source)), pytrace=False)
    except CompilationFailedException as e1:
        e = e1
    error_message = e.error_message
    error_message_lines = error_message.splitlines()
    normalized_error_message = error_message.replace(' ', ).replace('std::__1::', 'std::')
    normalized_error_message_lines = normalized_error_message.splitlines()
    error_message_head = _cap_to_lines(error_message, 40)
    check_error_fun(e, error_message_lines, error_message_head, normalized_error_message_lines)
    try_remove_temporary_file(source_file_name)