Add a test to protect against syntax errors in main(). Also

test some main()-invariant logic while I'm at it.

DELTA=19  (16 added, 0 deleted, 3 changed)


Revision created by MOE tool push_codebase.
MOE_MIGRATION=1409
This commit is contained in:
csilvers+iwyu 2011-04-13 03:11:35 +00:00
parent d81dcede97
commit ed381497a3
146 changed files with 19 additions and 3 deletions

0
CMakeLists.txt Executable file → Normal file
View File

0
LICENSE.TXT Executable file → Normal file
View File

0
Makefile Executable file → Normal file
View File

0
README.txt Executable file → Normal file
View File

View File

@ -1944,9 +1944,9 @@ def main(argv):
' else min(the number of files that would be'
' modified, 100)'))
parse.add_option('--ignore_re', default=None,
help=('fix_includes.py will skip editing any file whose'
' name matches this regular expression.'))
parser.add_option('--ignore_re', default=None,
help=('fix_includes.py will skip editing any file whose'
' name matches this regular expression.'))
parser.add_option('--checkout_command', default=None,
help=('A command, such as "p4 edit", to run on each'

View File

@ -18,6 +18,7 @@ __author__ = 'csilvers@google.com (Craig Silverstein)'
import cStringIO
import re
import sys
# I use unittest instead of googletest to ease opensourcing. Luckily,
# the only googletest function I have to re-implement is assertListEqual.
import unittest
@ -2432,6 +2433,21 @@ namespace util { class Status; }
{'structuredsearch/common/internal/query_field_xlate.h': infile})
self.ProcessAndTest(iwyu_output)
def testMain(self):
"""Make sure calling main doesn't crash. Inspired by a syntax-error bug."""
# Give an empty stdin so we don't actually try to parse anything.
old_stdin = sys.stdin
try:
sys.stdin = cStringIO.StringIO()
fix_includes.main(['fix_includes.py']) # argv[0] doesn't really matter
finally:
sys.stdin = old_stdin
def testFilenamesForSortingInMain(self):
"""Make sure if we use s, we have a filename specified, in main()."""
# -s without any files to sort.
self.assertRaises(SystemExit, fix_includes.main,
['fix_includes.py', '-s'])
if __name__ == '__main__':
unittest.main()

0
iwyu.cc Executable file → Normal file
View File

0
iwyu_ast_util.cc Executable file → Normal file
View File

0
iwyu_ast_util.h Executable file → Normal file
View File

0
iwyu_cache.cc Executable file → Normal file
View File

0
iwyu_cache.h Executable file → Normal file
View File

0
iwyu_driver.cc Executable file → Normal file
View File

0
iwyu_driver.h Executable file → Normal file
View File

0
iwyu_globals.cc Executable file → Normal file
View File

0
iwyu_globals.h Executable file → Normal file
View File

0
iwyu_include_picker.cc Executable file → Normal file
View File

0
iwyu_include_picker.h Executable file → Normal file
View File

0
iwyu_lexer_utils.cc Executable file → Normal file
View File

0
iwyu_lexer_utils.h Executable file → Normal file
View File

0
iwyu_location_util.cc Executable file → Normal file
View File

0
iwyu_location_util.h Executable file → Normal file
View File

0
iwyu_output.cc Executable file → Normal file
View File

0
iwyu_output.h Executable file → Normal file
View File

0
iwyu_path_util.h Executable file → Normal file
View File

0
iwyu_preprocessor.cc Executable file → Normal file
View File

0
iwyu_preprocessor.h Executable file → Normal file
View File

0
iwyu_stl_util.h Executable file → Normal file
View File

0
iwyu_string_util.h Executable file → Normal file
View File

0
more_tests/iwyu_lexer_utils_test.cc Executable file → Normal file
View File

0
more_tests/iwyu_output_test.cc Executable file → Normal file
View File

0
more_tests/iwyu_string_util_test.cc Executable file → Normal file
View File

0
more_tests/iwyu_test.cc Executable file → Normal file
View File

0
port.h Executable file → Normal file
View File

0
tests/avoids_double_specialization.cc Executable file → Normal file
View File

0
tests/badinc-d1.h Executable file → Normal file
View File

0
tests/badinc-d2.h Executable file → Normal file
View File

0
tests/badinc-d3.h Executable file → Normal file
View File

0
tests/badinc-d4.h Executable file → Normal file
View File

0
tests/badinc-extradef.cc Executable file → Normal file
View File

0
tests/badinc-i1.h Executable file → Normal file
View File

0
tests/badinc-i2-inl.h Executable file → Normal file
View File

0
tests/badinc-i2.h Executable file → Normal file
View File

0
tests/badinc-i3.h Executable file → Normal file
View File

0
tests/badinc-i4.h Executable file → Normal file
View File

0
tests/badinc-i5.h Executable file → Normal file
View File

0
tests/badinc-i6.h Executable file → Normal file
View File

0
tests/badinc-inl.h Executable file → Normal file
View File

0
tests/badinc-private.h Executable file → Normal file
View File

0
tests/badinc-private2.h Executable file → Normal file
View File

0
tests/badinc.cc Executable file → Normal file
View File

0
tests/badinc.h Executable file → Normal file
View File

0
tests/badinc2.c Executable file → Normal file
View File

0
tests/built_ins_new_included.cc Executable file → Normal file
View File

0
tests/built_ins_no_includes.cc Executable file → Normal file
View File

0
tests/check_also-d1.h Executable file → Normal file
View File

0
tests/check_also-i1.h Executable file → Normal file
View File

0
tests/check_also-n1.h Executable file → Normal file
View File

0
tests/check_also.cc Executable file → Normal file
View File

0
tests/comment_pragmas-d1.h Executable file → Normal file
View File

0
tests/comment_pragmas-d10.h Executable file → Normal file
View File

0
tests/comment_pragmas-d2.h Executable file → Normal file
View File

0
tests/comment_pragmas-d3.h Executable file → Normal file
View File

0
tests/comment_pragmas-d4.h Executable file → Normal file
View File

0
tests/comment_pragmas-d5.h Executable file → Normal file
View File

0
tests/comment_pragmas-d6.h Executable file → Normal file
View File

0
tests/comment_pragmas-d7.h Executable file → Normal file
View File

0
tests/comment_pragmas-d8.h Executable file → Normal file
View File

0
tests/comment_pragmas-d9.h Executable file → Normal file
View File

0
tests/comment_pragmas-i1.h Executable file → Normal file
View File

0
tests/comment_pragmas-i2.h Executable file → Normal file
View File

0
tests/comment_pragmas-i3.h Executable file → Normal file
View File

0
tests/comment_pragmas-i4.h Executable file → Normal file
View File

0
tests/comment_pragmas-i5.h Executable file → Normal file
View File

0
tests/comment_pragmas-i6.h Executable file → Normal file
View File

0
tests/comment_pragmas-i7.h Executable file → Normal file
View File

0
tests/comment_pragmas-i8.h Executable file → Normal file
View File

0
tests/comment_pragmas-i9.h Executable file → Normal file
View File

0
tests/comment_pragmas.cc Executable file → Normal file
View File

0
tests/default_template_arg_other_file-d1.h Executable file → Normal file
View File

0
tests/default_template_arg_other_file-d2.h Executable file → Normal file
View File

0
tests/default_template_arg_other_file-i2.h Executable file → Normal file
View File

0
tests/default_template_arg_other_file-o1.h Executable file → Normal file
View File

0
tests/default_template_arg_other_file.cc Executable file → Normal file
View File

0
tests/depopulated_h_file-i1.h Executable file → Normal file
View File

0
tests/depopulated_h_file.cc Executable file → Normal file
View File

0
tests/depopulated_h_file.h Executable file → Normal file
View File

0
tests/derived_function_tpl_args-d1.h Executable file → Normal file
View File

0
tests/derived_function_tpl_args-i1.h Executable file → Normal file
View File

0
tests/derived_function_tpl_args.cc Executable file → Normal file
View File

0
tests/direct.h Executable file → Normal file
View File

0
tests/fwd_decl_class_template-i1.h Executable file → Normal file
View File

0
tests/fwd_decl_class_template.cc Executable file → Normal file
View File

0
tests/fwd_decl_class_template.h Executable file → Normal file
View File

0
tests/fwd_decl_nested_class.cc Executable file → Normal file
View File

0
tests/fwd_decl_then_dfn.cc Executable file → Normal file
View File

0
tests/fwd_decl_with_instantiation-d1.h Executable file → Normal file
View File

0
tests/fwd_decl_with_instantiation.cc Executable file → Normal file
View File

0
tests/fwd_decl_with_instantiation.h Executable file → Normal file
View File

0
tests/implicit_ctor-d1.h Executable file → Normal file
View File

0
tests/implicit_ctor-i1.h Executable file → Normal file
View File

Some files were not shown because too many files have changed in this diff Show More