Skip to content

Fix irept printing in failed unit tests #6584

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,5 @@ endif()
if(NOT WIN32)
add_subdirectory(crangler)
endif()

add_subdirectory(catch-framework)
1 change: 1 addition & 0 deletions regression/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ DIRS = cbmc \
goto-interpreter \
cbmc-sequentialization \
cpp-linter \
catch-framework \
# Empty last line

ifeq ($(OS),Windows_NT)
Expand Down
4 changes: 4 additions & 0 deletions regression/catch-framework/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

add_test_pl_tests(
"$<TARGET_FILE:unit>"
)
9 changes: 9 additions & 0 deletions regression/catch-framework/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
default: test

test:
@../test.pl -e -p -c "../../../unit/unit_tests"

tests.log: ../test.pl test

clean:
$(RM) tests*.log
12 changes: 12 additions & 0 deletions regression/catch-framework/irep-printing/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CORE
[irep_error_printing]

REQUIRE\( foo == bar \)
key: value
^EXIT=0$
^SIGNAL=0$
--
\{\?\}
--
Test that when unit tests fail on mismatching ireps, the ireps are
pretty-printed and not printed as catch's default of {?}.
3 changes: 3 additions & 0 deletions unit/testing-utils/use_catch.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,7 @@ Author: Michael Tautschnig
/// Add to the end of test tags to mark a test that is expected to fail
#define XFAIL "[.][!shouldfail]"

class irept;
std::ostream &operator<<(std::ostream &os, const irept &value);

#endif // CPROVER_TESTING_UTILS_USE_CATCH_H
13 changes: 13 additions & 0 deletions unit/util/irep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,16 @@ SCENARIO("irept_memory", "[core][utils][irept]")
}
}
}

// This test is expected to fail so that we can test the error printing of the
// unit test framework for regressions. It is not included in the [core] or
// default set of tests, so that the usual output is not polluted with
// irrelevant error messages.
TEST_CASE(
"Catch2 printing of `irept` for test failures.",
"[irep_error_printing]" XFAIL)
{
const irept foo{"foo", irept::named_subt{{"key", irept{"value"}}}, {}};
const irept bar{"bar"};
REQUIRE(foo == bar);
}