diff options
author | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-10-22 01:22:29 (GMT) |
---|---|---|
committer | vladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925> | 2009-10-22 01:22:29 (GMT) |
commit | 6bfc4b2bd378940fa006bd32b9667ad4137d8f15 (patch) | |
tree | b4a2c212be4354c69b6a87e66295bebacda1a7bf /test/gtest_help_test.py | |
parent | bad778caa39a88b7c11b159e20730aeec4fd711e (diff) | |
download | googletest-6bfc4b2bd378940fa006bd32b9667ad4137d8f15.zip googletest-6bfc4b2bd378940fa006bd32b9667ad4137d8f15.tar.gz googletest-6bfc4b2bd378940fa006bd32b9667ad4137d8f15.tar.bz2 |
Prints help when encountering unrecognized Google Test flags.
Diffstat (limited to 'test/gtest_help_test.py')
-rwxr-xr-x | test/gtest_help_test.py | 46 |
1 files changed, 41 insertions, 5 deletions
diff --git a/test/gtest_help_test.py b/test/gtest_help_test.py index 91081ad..7883c1c 100755 --- a/test/gtest_help_test.py +++ b/test/gtest_help_test.py @@ -50,6 +50,11 @@ PROGRAM_PATH = gtest_test_utils.GetTestExecutablePath('gtest_help_test_') FLAG_PREFIX = '--gtest_' CATCH_EXCEPTIONS_FLAG = FLAG_PREFIX + 'catch_exceptions' DEATH_TEST_STYLE_FLAG = FLAG_PREFIX + 'death_test_style' +UNKNOWN_FLAG = FLAG_PREFIX + 'unknown_flag_for_testing' +INCORRECT_FLAG_VARIANTS = [re.sub('^--', '-', DEATH_TEST_STYLE_FLAG), + re.sub('^--', '/', DEATH_TEST_STYLE_FLAG), + re.sub('_', '-', DEATH_TEST_STYLE_FLAG)] +INTERNAL_FLAG_FOR_TESTING = FLAG_PREFIX + 'internal_flag_for_testing' # The help message must match this regex. HELP_REGEX = re.compile( @@ -88,8 +93,14 @@ class GTestHelpTest(gtest_test_utils.TestCase): """Tests the --help flag and its equivalent forms.""" def TestHelpFlag(self, flag): - """Verifies that the right message is printed and the tests are - skipped when the given flag is specified.""" + """Verifies correct behavior when help flag is specified. + + The right message must be printed and the tests must + skipped when the given flag is specified. + + Args: + flag: A flag to pass to the binary or None. + """ exit_code, output = RunWithFlag(flag) self.assertEquals(0, exit_code) @@ -101,6 +112,20 @@ class GTestHelpTest(gtest_test_utils.TestCase): self.assert_(CATCH_EXCEPTIONS_FLAG not in output, output) self.assert_(DEATH_TEST_STYLE_FLAG in output, output) + def TestNonHelpFlag(self, flag): + """Verifies correct behavior when no help flag is specified. + + Verifies that when no help flag is specified, the tests are run + and the help message is not printed. + + Args: + flag: A flag to pass to the binary or None. + """ + + exit_code, output = RunWithFlag(flag) + self.assert_(exit_code != 0) + self.assert_(not HELP_REGEX.search(output), output) + def testPrintsHelpWithFullFlag(self): self.TestHelpFlag('--help') @@ -113,13 +138,24 @@ class GTestHelpTest(gtest_test_utils.TestCase): def testPrintsHelpWithWindowsStyleQuestionFlag(self): self.TestHelpFlag('/?') + def testPrintsHelpWithUnrecognizedGoogleTestFlag(self): + self.TestHelpFlag(UNKNOWN_FLAG) + + def testPrintsHelpWithIncorrectFlagStyle(self): + for incorrect_flag in INCORRECT_FLAG_VARIANTS: + self.TestHelpFlag(incorrect_flag) + def testRunsTestsWithoutHelpFlag(self): """Verifies that when no help flag is specified, the tests are run and the help message is not printed.""" - exit_code, output = RunWithFlag(None) - self.assert_(exit_code != 0) - self.assert_(not HELP_REGEX.search(output), output) + self.TestNonHelpFlag(None) + + def testRunsTestsWithGtestInternalFlag(self): + """Verifies that the tests are run and no help message is printed when + a flag starting with Google Test prefix and 'internal_' is supplied.""" + + self.TestNonHelpFlag(INTERNAL_FLAG_FOR_TESTING) if __name__ == '__main__': |