Skip to content

Commit

Permalink
regex message check
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed Aug 20, 2020
1 parent 00ba0cd commit 4ef6998
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions include/internal/iutest_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -615,6 +615,7 @@

/**
* @brief コンパイルエラーチェックタグ
* @param e = error message regexp
*/
#if defined(_MSC_VER) && !defined(__clang__)
# define IUTEST_TEST_COMPILEERROR(e) \
Expand All @@ -625,16 +626,17 @@
#endif

/**
* @brief static_assert チェックタグ
* @{
* @brief static_assert チェックタグ
* @param e = error message regexp
* @{
*/
#if IUTEST_HAS_STATIC_ASSERT
# define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR(e)
#else
# define IUTEST_TEST_STATICASSERT(e) IUTEST_TEST_COMPILEERROR("static_assert")
#endif
/**
* @}
* @}
*/

#endif // INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_
4 changes: 2 additions & 2 deletions test/static_assertion_failure_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ IUTEST(StaticAssertTypeEqTest, Fail)

IUTEST(StaticAssertTypeEqTest, Fail2)
{
IUTEST_TEST_STATICASSERT("static_assert")
IUTEST_TEST_STATICASSERT("(static_assert|static assertion failed)")
IUTEST_STATIC_ASSERT(false);
}

IUTEST(StaticAssertTypeEqTest, Fail3)
{
IUTEST_TEST_STATICASSERT("static_assert")
IUTEST_TEST_STATICASSERT("(static_assert|static assertion failed)")
IUTEST_STATIC_ASSERT(test_struct<false, false>::value);
}

Expand Down
8 changes: 6 additions & 2 deletions tools/python/iutest_compile_error_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import os
import sys
import re
import copy

from argparse import ArgumentParser
from argparse import FileType
Expand Down Expand Up @@ -283,9 +284,11 @@ def message(self):
re_message = re.compile(r'.*:\d+:\s*(\S*):\s*(.*)')
re_expansion = re.compile(r_expansion)
re_declaration = re.compile(r'.*declaration of\s*(.*)')
re_required_from = re.compile(r'.*required from here')
msg_list = []
msg = None
prev = None
is_prev_required_from = False
for line in f:
if options.verbose:
print(line.rstrip())
Expand Down Expand Up @@ -320,9 +323,10 @@ def message(self):
is_expansion = re_expansion.search(msg.message)
msg.expansion = is_expansion
# print('%s - %d: %s %s %s %s' % (msg.file, msg.line, is_child, is_type_none, is_declaration, is_expansion))
if is_child or is_type_none or is_declaration or is_expansion:
if is_child or is_type_none or is_declaration or is_expansion or is_prev_required_from:
prev.child = msg
msg.parent = prev
is_prev_required_from = re_required_from.search(msg.message)
else:
if msg:
msg.message += '\n'
Expand Down Expand Up @@ -463,7 +467,7 @@ def iutest(l):
actual = msg.get_error()
#print(actual.message)
msg.checked = True
if not check.expect or actual.message.find(check.expect) != -1:
if not check.expect or re.search(check.expect, actual.message):
check.msg.checked = True
break
if msg.is_tail() and not msg.is_checked():
Expand Down

0 comments on commit 4ef6998

Please sign in to comment.