Skip to content

Commit

Permalink
test: Log error message for spectests expecting a failure
Browse files Browse the repository at this point in the history
  • Loading branch information
gumb0 committed Dec 11, 2020
1 parent d7caaf5 commit 45a0c29
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
10 changes: 10 additions & 0 deletions test/smoketests/spectests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,16 @@ set_tests_properties(
PASS_REGULAR_EXPRESSION "PASSED 32, FAILED 0, SKIPPED 3"
)

add_test(
NAME fizzy/smoketests/spectests/showpassed-error-message
COMMAND fizzy-spectests ${CMAKE_CURRENT_LIST_DIR}/default --show-passed
)
set_tests_properties(
fizzy/smoketests/spectests/showpassed-error-message
PROPERTIES
PASS_REGULAR_EXPRESSION "assert_malformed PASSED invalid wasm module prefix"
)

add_test(
NAME fizzy/smoketests/spectests/showskipped
COMMAND fizzy-spectests ${CMAKE_CURRENT_LIST_DIR}/default --show-skipped
Expand Down
14 changes: 7 additions & 7 deletions test/spectests/spectests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ class test_runner
catch (fizzy::parser_error const& ex)
{
if (type == "assert_malformed")
pass();
pass(ex.what());
else
fail(std::string{"Unexpected parser error: "} + ex.what());
continue;
}
catch (fizzy::validation_error const& ex)
{
if (type == "assert_invalid")
pass();
pass(ex.what());
else
fail(std::string{"Unexpected validation error: "} + ex.what());
continue;
Expand Down Expand Up @@ -332,7 +332,7 @@ class test_runner
if (!error.empty())
{
if (type == "assert_unlinkable")
pass();
pass(error);
else
fail(error);
continue;
Expand All @@ -357,7 +357,7 @@ class test_runner
if (ex.what() == std::string{"start function failed to execute"})
{
if (type == "assert_uninstantiable")
pass();
pass(ex.what());
else
fail(std::string{"Instantiation failed with error: "} + ex.what());
}
Expand All @@ -366,7 +366,7 @@ class test_runner
if (type == "assert_uninstantiable")
fail(std::string{"Instantiation failed with error: "} + ex.what());
else
pass();
pass(ex.what());
}
continue;
}
Expand Down Expand Up @@ -622,11 +622,11 @@ class test_runner
return {result, ""};
}

void pass()
void pass(std::string_view message = {})
{
++m_results.passed;
if (m_settings.show_passed)
add_to_result_details("PASSED");
add_to_result_details("PASSED " + std::string{message});
log_no_newline(".");
}

Expand Down

0 comments on commit 45a0c29

Please sign in to comment.