Skip to content

Commit

Permalink
update r860
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix committed May 28, 2015
1 parent 94f6add commit 1f50da9
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 12 deletions.
2 changes: 1 addition & 1 deletion doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = iutest
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 1.11.99.19
PROJECT_NUMBER = 1.11.99.20

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
7 changes: 6 additions & 1 deletion include/internal/iutest_internal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,11 @@
/**
* @brief コンパイルエラーチェックタグ
*/
#define IUTEST_TEST_COMPILEERROR(e) IUTEST_PRAGMA_MESSAGE("IUTEST_TEST_COMPILEERROR( " #e " )")
#if defined(_MSC_VER)
# define IUTEST_TEST_COMPILEERROR(e) IUTEST_PRAGMA_MESSAGE( \
__FILE__ "(" IUTEST_PP_TOSTRING(__LINE__) "): note : " "IUTEST_TEST_COMPILEERROR( " #e " )")
#else
# define IUTEST_TEST_COMPILEERROR(e) IUTEST_PRAGMA_MESSAGE("IUTEST_TEST_COMPILEERROR( " #e " )")
#endif

#endif // INCG_IRIS_IUTEST_INTERNAL_HPP_A5BD9FBB_B57A_4C1D_B205_0ADB7798DBF9_
4 changes: 2 additions & 2 deletions include/iutest_ver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@

//======================================================================
// define
#define IUTEST_VER 0x01119919u //!< iutest version 1.11.99.19
#define IUTEST_VER 0x01119920u //!< iutest version 1.11.99.20
#define IUTEST_MAJORVER 0x01u //!< Major Version
#define IUTEST_MINORVER 0x11u //!< Minor Version
#define IUTEST_BUILD 0x99u //!< Build
#define IUTEST_REVISION 0x19u //!< Revision
#define IUTEST_REVISION 0x20u //!< Revision

/**
* @mainpage
Expand Down
6 changes: 5 additions & 1 deletion test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ CXXFLAGS =$(CXXFLAGS) -DOUTPUTXML
!include <CommonMakefile.in>

RUN_TARGETS = $(ALLTESTS_TARGET) $(TARGETS1) $(TARGETS2) $(TARGETS_IUTEST_ONLY)
BUILD_TARGETS = $(RUN_TARGETS) $(BUILD_ONLY)
BUILD_TARGETS = $(RUN_TARGETS) $(BUILD_ONLY) $(COMPILEERROR_TARGETS)
TARGETS = $(BUILD_TARGETS)

SRCS = $(BUILD_TARGETS:_tests=_tests.cpp)
Expand Down Expand Up @@ -77,3 +77,7 @@ $(ALLTESTS_TARGET) : $(ALLTESTS_SRCS) $(IUTEST_HEADERS) Makefile
$(TARGETS_EXCLUDE_ALLTESTS) : $(SRCS) $(IUTEST_HEADERS) Makefile
$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) /Fe$@ $@.cpp $(LDFLAGS)

$(COMPILEERROR_TARGETS) : $(SRCS) $(IUTEST_HEADERS) Makefile
# -$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) /Fe$@ $@.cpp $(LDFLAGS)
$(CXX) $(IUTEST_INCLUDE) $(CXXFLAGS) /Fe$@ $@.cpp $(LDFLAGS) | python ../tools/python/iutest_compile_error_test.py -c $(CXX)

72 changes: 65 additions & 7 deletions tools/python/iutest_compile_error_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# see LICENSE
#

import os
import sys
import argparse
import re
Expand Down Expand Up @@ -74,6 +75,9 @@ def get_error(self):
return self.parent.get_error()
return None

format_gcc=True
color_prompt=False

#
# command line option
def parse_command_line():
Expand Down Expand Up @@ -149,10 +153,44 @@ def parse_gcc(options, f):
def parse_clang(options, f):
return parse_gcc_clang(options, f, r'expanded from macro', True)

#
# parse_vc
def parse_vc(options, f):
re_file = re.compile(r'(\S+)\((\d+)\):')
re_message = re.compile(r'.*\(\d+\): (\S*) (\S*: .*)')
msg_list = []
msg = None
prev = None
for line in f:
m = re_file.match(line)

if m:
if msg:
msg_list.append(msg)
prev = msg
msg = ErrorMessage()
msg.file = m.group(1)
msg.line = int(m.group(2))
msg.type = ""
n = re_message.match(line)
if n:
msg.set_type(n.group(1))
msg.message += n.group(2)
else:
if msg:
msg.message += '\n'
msg.message += line
msg_list.append(msg)
return msg_list

#
# dump
def dump_msg(m):
print "%s:%d: %s: %s" % (m.file, m.line, m.type, m.message)
if format_gcc:
print "%s:%d: %s: %s" % (m.file, m.line, m.type, m.message)
else:
print "%s(%d): %s %s" % (m.file, m.line, m.type, m.message)


def dump_msgs(m):
if m.parent:
Expand All @@ -178,9 +216,15 @@ def test_result(result, str):
ENDC = '\033[0m'

if result:
print OKGREEN + '[OK] ' + ENDC + str
if color_prompt:
print OKGREEN + '[OK] ' + ENDC + str
else:
print '[OK] ' + str
else:
print FAIL + '[NG] ' + ENDC + str
if color_prompt:
print FAIL + '[NG] ' + ENDC + str
else:
print '[NG] ' + str

#
# iutest
Expand Down Expand Up @@ -209,7 +253,7 @@ def iutest(l):
if check and msg.file in check.file and msg.line == check.line+1:
actual = msg.get_error()
expect = re_m.group(1).strip('"')
if actual.message.find(expect):
if actual.message.find(expect) != -1:
check = None
e = None
msg.checked = True
Expand All @@ -227,24 +271,38 @@ def iutest(l):
#
# parse_output
def parse_output(options):
global format_gcc
l = None
if not options.infile:
raise Exception("infile null")

if options.compiler == 'gcc' or options.compiler == 'g++':
l = parse_gcc(options, options.infile)
elif options.compiler == 'clang' or options.compiler == 'clang++':
if any(options.compiler.find(s) != -1 for s in ('clang', 'clang++')):
l = parse_clang(options, options.infile)
elif any(options.compiler.find(s) != -1 for s in ('gcc', 'g++')):
l = parse_gcc(options, options.infile)
elif options.compiler == 'cl':
format_gcc = False
l = parse_vc(options, options.infile)
else:
raise Exception("sorry, %s compiler is not supported", (options.compiler))

#return dump_list(l)
return iutest(l)

#
# setup
def setup():
global color_prompt
term = os.environ.get('TERM')
if term:
if any( term.find(s) for s in ('xterm', 'screen', 'rxvt', 'linux', 'cygwin' ) ):
color_prompt = True

#
# main
def main():
options = parse_command_line()
setup()
if not parse_output(options):
sys.exit(1)

Expand Down

0 comments on commit 1f50da9

Please sign in to comment.