OLD | NEW |
1 # Copyright (C) 2012 Google, Inc. | 1 # Copyright (C) 2012 Google, Inc. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions | 4 # modification, are permitted provided that the following conditions |
5 # are met: | 5 # are met: |
6 # 1. Redistributions of source code must retain the above copyright | 6 # 1. Redistributions of source code must retain the above copyright |
7 # notice, this list of conditions and the following disclaimer. | 7 # notice, this list of conditions and the following disclaimer. |
8 # 2. Redistributions in binary form must reproduce the above copyright | 8 # 2. Redistributions in binary form must reproduce the above copyright |
9 # notice, this list of conditions and the following disclaimer in the | 9 # notice, this list of conditions and the following disclaimer in the |
10 # documentation and/or other materials provided with the distribution. | 10 # documentation and/or other materials provided with the distribution. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
98 self.assertEqual(parallel_tests, [ | 98 self.assertEqual(parallel_tests, [ |
99 STUBS_CLASS + '.integration_test_empty', | 99 STUBS_CLASS + '.integration_test_empty', |
100 STUBS_CLASS + '.test_empty', | 100 STUBS_CLASS + '.test_empty', |
101 ]) | 101 ]) |
102 self.assertEqual(serial_tests, [ | 102 self.assertEqual(serial_tests, [ |
103 STUBS_CLASS + '.serial_integration_test_empty', | 103 STUBS_CLASS + '.serial_integration_test_empty', |
104 STUBS_CLASS + '.serial_test_empty', | 104 STUBS_CLASS + '.serial_test_empty', |
105 ]) | 105 ]) |
106 | 106 |
107 def test_coverage_works(self): | 107 def test_coverage_works(self): |
| 108 # This is awkward; by design, running test-webkitpy -c will |
| 109 # create a .coverage file in Tools/Scripts, so we need to be |
| 110 # careful not to clobber an existing one, and to clean up. |
| 111 # FIXME: This design needs to change since it means we can't actually |
| 112 # run this method itself under coverage properly. |
108 filesystem = FileSystem() | 113 filesystem = FileSystem() |
109 executive = Executive() | 114 executive = Executive() |
110 module_path = filesystem.path_to_module(self.__module__) | 115 module_path = filesystem.path_to_module(self.__module__) |
111 script_dir = module_path[0:module_path.find('webkitpy') - 1] | 116 script_dir = module_path[0:module_path.find('webkitpy') - 1] |
112 proc = executive.popen([sys.executable, filesystem.join(script_dir, 'tes
t-webkitpy'), '-c', STUBS_CLASS + '.test_empty'], | 117 coverage_file = filesystem.join(script_dir, '.coverage') |
113 stdout=executive.PIPE, stderr=executive.PIPE) | 118 coverage_file_orig = None |
114 out, _ = proc.communicate() | 119 if filesystem.exists(coverage_file): |
115 retcode = proc.returncode | 120 coverage_file_orig = coverage_file + '.orig' |
116 self.assertEqual(retcode, 0) | 121 filesystem.move(coverage_file, coverage_file_orig) |
117 self.assertIn('Cover', out) | 122 |
| 123 try: |
| 124 proc = executive.popen([sys.executable, filesystem.join(script_dir,
'test-webkitpy'), '-c', STUBS_CLASS + '.test_empty'], |
| 125 stdout=executive.PIPE, stderr=executive.PIPE) |
| 126 out, _ = proc.communicate() |
| 127 retcode = proc.returncode |
| 128 self.assertEqual(retcode, 0) |
| 129 self.assertIn('Cover', out) |
| 130 finally: |
| 131 if coverage_file_orig: |
| 132 filesystem.move(coverage_file_orig, coverage_file) |
| 133 elif filesystem.exists(coverage_file): |
| 134 filesystem.remove(coverage_file) |
OLD | NEW |