Skip to content

Misleading error reporting when a CHECK calls a REQUIRE #1292

@brevzin

Description

@brevzin

Description

If a CHECK() assertion internally calls a function that does a REQUIRE() assertion that fails, we get a very misleading message.

Steps to reproduce

Here is the complete test:

#define CATCH_CONFIG_MAIN
#include "catch.hpp"

int foo(int i) {
    REQUIRE(i > 10);
    return 42;
}

TEST_CASE("a", "[a]") {
    CHECK(foo(2) == 2);
}

Compiled with -std=c++11 and no other flags, run with no arguments. This emits:

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a is a Catch v2.2.2 host application.
Run with -? for options

-------------------------------------------------------------------------------
a
-------------------------------------------------------------------------------
test.cxx:9
...............................................................................

test.cxx:5: FAILED:
  REQUIRE( i > 10 )
with expansion:
  2 > 10

test.cxx:10: FAILED:
  CHECK( foo(2) == 2 )
due to unexpected exception with message:
  Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE

===============================================================================
test cases: 1 | 1 failed
assertions: 2 | 2 failed

Note the message about CATCH_CONFIG_FAST_COMPILE - which isn't actually defined here. This is super confusing.

Extra information

  • Catch version: v2.2.2, Generated: 2018-04-06 12:05:03.186665
  • Operating System: Cygwin on Windows
  • Compiler+version: gcc 6.4.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions