OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 """Tests for enum_preprocess.py. | 6 """Tests for enum_preprocess.py. |
7 | 7 |
8 This test suite containss various tests for the C++ -> Java enum generator. | 8 This test suite containss various tests for the C++ -> Java enum generator. |
9 """ | 9 """ |
10 | 10 |
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
411 definition.AppendEntry('B', None) | 411 definition.AppendEntry('B', None) |
412 definition.AppendEntry('NAME_LAST', None) | 412 definition.AppendEntry('NAME_LAST', None) |
413 definition.Finalize() | 413 definition.Finalize() |
414 self.assertEqual(['A', 'B', 'NAME_LAST'], definition.entries.keys()) | 414 self.assertEqual(['A', 'B', 'NAME_LAST'], definition.entries.keys()) |
415 | 415 |
416 def testGenerateThrowsOnEmptyInput(self): | 416 def testGenerateThrowsOnEmptyInput(self): |
417 with self.assertRaises(Exception): | 417 with self.assertRaises(Exception): |
418 original_do_parse = java_cpp_enum.DoParseHeaderFile | 418 original_do_parse = java_cpp_enum.DoParseHeaderFile |
419 try: | 419 try: |
420 java_cpp_enum.DoParseHeaderFile = lambda _: [] | 420 java_cpp_enum.DoParseHeaderFile = lambda _: [] |
421 java_cpp_enum.DoGenerate('dir', ['file']) | 421 for _ in java_cpp_enum.DoGenerate(['file']): |
| 422 pass |
422 finally: | 423 finally: |
423 java_cpp_enum.DoParseHeaderFile = original_do_parse | 424 java_cpp_enum.DoParseHeaderFile = original_do_parse |
424 | 425 |
425 def main(argv): | 426 def main(argv): |
426 parser = optparse.OptionParser() | 427 parser = optparse.OptionParser() |
427 parser.add_option("--stamp", help="File to touch on success.") | 428 parser.add_option("--stamp", help="File to touch on success.") |
428 options, _ = parser.parse_args(argv) | 429 options, _ = parser.parse_args(argv) |
429 | 430 |
430 suite = unittest.TestLoader().loadTestsFromTestCase(TestPreprocess) | 431 suite = unittest.TestLoader().loadTestsFromTestCase(TestPreprocess) |
431 unittest.TextTestRunner(verbosity=0).run(suite) | 432 unittest.TextTestRunner(verbosity=0).run(suite) |
432 | 433 |
433 if options.stamp: | 434 if options.stamp: |
434 build_utils.Touch(options.stamp) | 435 build_utils.Touch(options.stamp) |
435 | 436 |
436 if __name__ == '__main__': | 437 if __name__ == '__main__': |
437 main(sys.argv[1:]) | 438 main(sys.argv[1:]) |
OLD | NEW |